GroupsController.cs 1.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using EyeSoft.Runtime.InteropServices;
  7. using Google.Protobuf.WellKnownTypes;
  8. using Microsoft.AspNetCore.SignalR;
  9. using Microsoft.IdentityModel.Tokens;
  10. using Microsoft.VisualBasic;
  11. using MySqlX.XDevAPI.Relational;
  12. using NetTaste;
  13. using NPOI.HSSF.UserModel;
  14. using NPOI.SS.Formula.Functions;
  15. using NPOI.SS.UserModel;
  16. using NPOI.SS.Util;
  17. using NPOI.XSSF.UserModel;
  18. using OASystem.API.Middlewares;
  19. using OASystem.API.OAMethodLib;
  20. using OASystem.API.OAMethodLib.APNs;
  21. using OASystem.API.OAMethodLib.File;
  22. using OASystem.API.OAMethodLib.Hub.HubClients;
  23. using OASystem.API.OAMethodLib.Hub.Hubs;
  24. using OASystem.API.OAMethodLib.JuHeAPI;
  25. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  26. using OASystem.Domain.AesEncryption;
  27. using OASystem.Domain.Attributes;
  28. using OASystem.Domain.Dtos.CRM;
  29. using OASystem.Domain.Dtos.FileDto;
  30. using OASystem.Domain.Dtos.Financial;
  31. using OASystem.Domain.Dtos.Groups;
  32. using OASystem.Domain.Entities.Customer;
  33. using OASystem.Domain.Entities.Financial;
  34. using OASystem.Domain.Entities.Groups;
  35. using OASystem.Domain.ViewModels.Financial;
  36. using OASystem.Domain.ViewModels.Groups;
  37. using OASystem.Domain.ViewModels.QiYeWeChat;
  38. using OASystem.Domain.ViewModels.Statistics;
  39. using OASystem.Infrastructure.Repositories.CRM;
  40. using OASystem.Infrastructure.Repositories.Financial;
  41. using OASystem.Infrastructure.Repositories.Groups;
  42. using OASystem.Infrastructure.Tools;
  43. using Org.BouncyCastle.Crypto;
  44. using Org.BouncyCastle.Utilities;
  45. using Quartz.Util;
  46. using SqlSugar.Extensions;
  47. using System.Collections;
  48. using System.Data;
  49. using System.Diagnostics;
  50. using System.Globalization;
  51. using System.IO.Compression;
  52. using System.Text.Json;
  53. using System.Web;
  54. using System.Xml.Linq;
  55. using TencentCloud.Ocr.V20181119.Models;
  56. using static OASystem.API.OAMethodLib.JWTHelper;
  57. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  58. using Bookmark = Aspose.Words.Bookmark;
  59. using Cell = Aspose.Words.Tables.Cell;
  60. using Table = Aspose.Words.Tables.Table;
  61. namespace OASystem.API.Controllers
  62. {
  63. /// <summary>
  64. /// 团组相关
  65. /// </summary>
  66. //[Authorize]
  67. [Route("api/[controller]/[action]")]
  68. public class GroupsController : ControllerBase
  69. {
  70. private readonly ILogger<GroupsController> _logger;
  71. private readonly GrpScheduleRepository _grpScheduleRep;
  72. private readonly IMapper _mapper;
  73. private readonly DelegationInfoRepository _groupRepository;
  74. private readonly TaskAssignmentRepository _taskAssignmentRep;
  75. private readonly AirTicketResRepository _airTicketResRep;
  76. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  77. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  78. private readonly DelegationEnDataRepository _delegationEnDataRep;
  79. private readonly DelegationVisaRepository _delegationVisaRep;
  80. private readonly VisaPriceRepository _visaPriceRep;
  81. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  82. private readonly HotelPriceRepository _hotelPriceRep;
  83. private readonly CustomersRepository _customersRep;
  84. private readonly MessageRepository _message;
  85. private readonly SqlSugarClient _sqlSugar;
  86. private readonly TourClientListRepository _tourClientListRep;
  87. private readonly TeamRateRepository _teamRateRep;
  88. #region 成本相关
  89. private readonly CheckBoxsRepository _checkBoxs;
  90. private readonly GroupCostRepository _GroupCostRepository;
  91. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  92. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  93. #endregion
  94. private readonly SetDataRepository _setDataRep;
  95. private string url;
  96. private string path;
  97. private readonly EnterExitCostRepository _enterExitCostRep;
  98. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  99. private readonly UsersRepository _usersRep;
  100. private readonly IJuHeApiService _juHeApi;
  101. private readonly InvertedListRepository _invertedListRep;
  102. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  103. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  104. private readonly ThreeCodeRepository _threeCodeRepository;
  105. private readonly HotelInquiryRepository _hotelInquiryRep;
  106. private readonly FeeAuditRepository _feeAuditRep;
  107. private readonly VisaCommissionRepository _visaCommissionRep;
  108. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  109. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  110. private readonly List<CurrencyInfo> _currencyInit;
  111. private readonly List<int> _portTypeData;
  112. private readonly TableOperationRecordRepository _tableorRep;
  113. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  114. private readonly RestaurantRepository _restaurantRep;
  115. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  116. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  117. /// <summary>
  118. /// 构造函数
  119. /// </summary>
  120. /// <param name="logger"></param>
  121. /// <param name="mapper"></param>
  122. /// <param name="hubContext"></param>
  123. /// <param name="sqlSugar"></param>
  124. /// <param name="grpScheduleRep"></param>
  125. /// <param name="groupRepository"></param>
  126. /// <param name="taskAssignmentRep"></param>
  127. /// <param name="airTicketResRep"></param>
  128. /// <param name="decreasePaymentsRep"></param>
  129. /// <param name="InvitationOfficialActivitiesRep"></param>
  130. /// <param name="delegationEnDataRep"></param>
  131. /// <param name="enterExitCostRep"></param>
  132. /// <param name="delegationVisaRep"></param>
  133. /// <param name="message"></param>
  134. /// <param name="visaPriceRep"></param>
  135. /// <param name="carTouristGuideGroundRep"></param>
  136. /// <param name="checkBoxs"></param>
  137. /// <param name="GroupCostRepository"></param>
  138. /// <param name="CostTypeHotelNumberRepository"></param>
  139. /// <param name="GroupCostParameterRepository"></param>
  140. /// <param name="hotelPriceRep"></param>
  141. /// <param name="customersRep"></param>
  142. /// <param name="setDataRep"></param>
  143. /// <param name="tourClientListRep"></param>
  144. /// <param name="teamRateRep"></param>
  145. /// <param name="usersRep"></param>
  146. /// <param name="juHeApi"></param>
  147. /// <param name="invertedListRep"></param>
  148. /// <param name="visaFeeInfoRep"></param>
  149. /// <param name="ticketBlackCodeRep"></param>
  150. /// <param name="hotelInquiryRep"></param>
  151. /// <param name="threeCodeRepository"></param>
  152. /// <param name="feeAuditRep"></param>
  153. /// <param name="visaCommissionRep"></param>
  154. /// <param name="ffrRep"></param>
  155. /// <param name="opinionaireRep"></param>
  156. /// <param name="tableorRep"></param>
  157. /// <param name="enterExitCostDraftRep"></param>
  158. /// <param name="restaurantRep"></param>
  159. /// <param name="enterExitCostQuoteRep"></param>
  160. /// <param name="grpOrderPreInfoRep"></param>
  161. public GroupsController(
  162. ILogger<GroupsController> logger,
  163. IMapper mapper,
  164. IHubContext<ChatHub, IChatClient> hubContext,
  165. SqlSugarClient sqlSugar,
  166. GrpScheduleRepository grpScheduleRep,
  167. DelegationInfoRepository groupRepository,
  168. TaskAssignmentRepository taskAssignmentRep,
  169. AirTicketResRepository airTicketResRep,
  170. DecreasePaymentsRepository decreasePaymentsRep,
  171. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  172. DelegationEnDataRepository delegationEnDataRep,
  173. EnterExitCostRepository enterExitCostRep,
  174. DelegationVisaRepository delegationVisaRep,
  175. MessageRepository message,
  176. VisaPriceRepository visaPriceRep,
  177. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  178. CheckBoxsRepository checkBoxs,
  179. GroupCostRepository GroupCostRepository,
  180. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  181. GroupCostParameterRepository GroupCostParameterRepository,
  182. HotelPriceRepository hotelPriceRep,
  183. CustomersRepository customersRep,
  184. SetDataRepository setDataRep,
  185. TourClientListRepository tourClientListRep,
  186. TeamRateRepository teamRateRep,
  187. UsersRepository usersRep, IJuHeApiService juHeApi,
  188. InvertedListRepository invertedListRep,
  189. VisaFeeInfoRepository visaFeeInfoRep,
  190. TicketBlackCodeRepository ticketBlackCodeRep,
  191. HotelInquiryRepository hotelInquiryRep,
  192. ThreeCodeRepository threeCodeRepository,
  193. FeeAuditRepository feeAuditRep,
  194. VisaCommissionRepository visaCommissionRep,
  195. ForeignReceivablesRepository ffrRep,
  196. OpinionaireRepository opinionaireRep,
  197. TableOperationRecordRepository tableorRep,
  198. EnterExitCostDraftRepository enterExitCostDraftRep,
  199. RestaurantRepository restaurantRep,
  200. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  201. GroupOrderPreInfoRepository grpOrderPreInfoRep
  202. )
  203. {
  204. _logger = logger;
  205. _mapper = mapper;
  206. _grpScheduleRep = grpScheduleRep;
  207. _groupRepository = groupRepository;
  208. _taskAssignmentRep = taskAssignmentRep;
  209. _airTicketResRep = airTicketResRep;
  210. _sqlSugar = sqlSugar;
  211. url = AppSettingsHelper.Get("ExcelBaseUrl");
  212. path = AppSettingsHelper.Get("ExcelBasePath");
  213. if (!System.IO.Directory.Exists(path))
  214. {
  215. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  216. }
  217. _decreasePaymentsRep = decreasePaymentsRep;
  218. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  219. _delegationEnDataRep = delegationEnDataRep;
  220. _enterExitCostRep = enterExitCostRep;
  221. _delegationVisaRep = delegationVisaRep;
  222. _message = message;
  223. _visaPriceRep = visaPriceRep;
  224. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  225. _checkBoxs = checkBoxs;
  226. _GroupCostRepository = GroupCostRepository;
  227. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  228. _GroupCostParameterRepository = GroupCostParameterRepository;
  229. _hotelPriceRep = hotelPriceRep;
  230. _customersRep = customersRep;
  231. _setDataRep = setDataRep;
  232. _tourClientListRep = tourClientListRep;
  233. _teamRateRep = teamRateRep;
  234. _hubContext = hubContext;
  235. _usersRep = usersRep;
  236. _juHeApi = juHeApi;
  237. _invertedListRep = invertedListRep;
  238. _visaFeeInfoRep = visaFeeInfoRep;
  239. _ticketBlackCodeRep = ticketBlackCodeRep;
  240. _hotelInquiryRep = hotelInquiryRep;
  241. _threeCodeRepository = threeCodeRepository;
  242. _feeAuditRep = feeAuditRep;
  243. _visaCommissionRep = visaCommissionRep;
  244. _ffrRep = ffrRep;
  245. _opinionaireRep = opinionaireRep;
  246. _currencyInit = new List<CurrencyInfo>()
  247. {
  248. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  249. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  250. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  251. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  252. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  253. };
  254. _portTypeData = new List<int>() { 2, 3 };
  255. _tableorRep = tableorRep;
  256. _enterExitCostDraftRep = enterExitCostDraftRep;
  257. _restaurantRep = restaurantRep;
  258. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  259. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  260. }
  261. #region 流程管控
  262. /// <summary>
  263. /// 获取团组流程管控信息
  264. /// </summary>
  265. /// <param name="_jsonDto"></param>
  266. /// <returns></returns>
  267. [HttpPost]
  268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  269. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  270. {
  271. if (string.IsNullOrEmpty(_jsonDto.Paras))
  272. {
  273. return Ok(JsonView(false, "参数为空"));
  274. }
  275. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  276. if (_ScheduleDto != null)
  277. {
  278. if (_ScheduleDto.SearchType == 2)//获取列表
  279. {
  280. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  281. return Ok(JsonView(_grpScheduleViewList));
  282. }
  283. else//获取对象
  284. {
  285. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  286. if (_grpScheduleView != null)
  287. {
  288. return Ok(JsonView(_grpScheduleView));
  289. }
  290. }
  291. }
  292. else
  293. {
  294. return Ok(JsonView(false, "参数反序列化失败"));
  295. }
  296. return Ok(JsonView(false, "暂无数据!"));
  297. }
  298. /// <summary>
  299. /// 修改团组流程管控详细表数据
  300. /// </summary>
  301. /// <param name="dto"></param>
  302. /// <returns></returns>
  303. [HttpPost]
  304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  305. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  306. {
  307. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  308. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  309. .SetColumns(it => it.Duty == _detail.Duty)
  310. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  311. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  312. .SetColumns(it => it.JobContent == _detail.JobContent)
  313. .SetColumns(it => it.Remark == _detail.Remark)
  314. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  315. .Where(s => s.Id == dto.Id)
  316. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  317. .ExecuteCommandAsync();
  318. if (result > 0)
  319. {
  320. return Ok(JsonView(true, "保存成功!"));
  321. }
  322. return Ok(JsonView(false, "保存失败!"));
  323. }
  324. /// <summary>
  325. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  326. /// </summary>
  327. /// <param name="dto"></param>
  328. /// <returns></returns>
  329. [HttpPost]
  330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  331. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  332. {
  333. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  334. _detail.IsDel = 1;
  335. _detail.DeleteUserId = dto.Duty;
  336. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  337. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  338. .SetColumns(it => it.IsDel == _detail.IsDel)
  339. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  340. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  341. .Where(it => it.Id == dto.Id)
  342. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  343. //.WhereColumns(s => s.Id == dto.Id)
  344. .ExecuteCommandAsync();
  345. if (result > 0)
  346. {
  347. return Ok(JsonView(true, "删除成功!"));
  348. }
  349. return Ok(JsonView(false, "删除失败!"));
  350. }
  351. /// <summary>
  352. /// 增加团组流程管控详细表数据
  353. /// </summary>
  354. /// <param name="dto"></param>
  355. /// <returns></returns>
  356. [HttpPost]
  357. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  358. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  359. {
  360. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  361. if (DateTime.Now < _detail.ExpectBeginDt)
  362. {
  363. _detail.StepStatus = 0;
  364. }
  365. else
  366. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  367. _detail.StepStatus = 1;
  368. }
  369. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  370. if (result > 0)
  371. {
  372. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  373. return Ok(JsonView(true, "添加成功!", _result));
  374. }
  375. return Ok(JsonView(false, "添加失败!"));
  376. }
  377. #endregion
  378. #region 团组前期信息
  379. /// <summary>
  380. /// 团组前期信息 List
  381. /// </summary>
  382. /// <returns></returns>
  383. [HttpPost]
  384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  385. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  386. {
  387. var search = dto.Search;
  388. RefAsync<int> total = 0;
  389. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  390. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  391. .Where((opi, u) => opi.IsDel == 0)
  392. .OrderByDescending((opi, u) => opi.CreateTime)
  393. .Select((opi, u) => new GroupOrderPreInfoListView()
  394. {
  395. Id = opi.Id,
  396. Name = opi.Name,
  397. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && x.FormTempId == 1).Select(x => x.Value),
  398. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && x.FormTempId == 2).Select(x => x.Value),
  399. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && x.FormTempId == 4).Select(x => x.Value),
  400. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && x.FormTempId == 6).Select(x => x.Value),
  401. Operator = u.CnName,
  402. OperationTime = opi.CreateTime
  403. })
  404. .WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  405. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  406. var infoIds = list.Select(x => x.Id).ToList();
  407. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  408. .Where(x => x.IsDel == 0 && x.STid == 109)
  409. .ToArrayAsync();
  410. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  411. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  412. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  413. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  414. .ToListAsync();
  415. foreach (var item in list)
  416. {
  417. var typeDatas1 = typeDatas.Select(x => new
  418. {
  419. Id = x.Id,
  420. Name = x.Name,
  421. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  422. }).ToArray();
  423. item.VersionDetails = typeDatas1;
  424. }
  425. return Ok(JsonView(list, total));
  426. }
  427. /// <summary>
  428. /// 团组前期信息 Init
  429. /// </summary>
  430. /// <returns></returns>
  431. [HttpGet("{userId}")]
  432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  433. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  434. {
  435. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  436. }
  437. /// <summary>
  438. /// 国家数据源
  439. /// </summary>
  440. /// <returns></returns>
  441. [HttpGet]
  442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  443. public async Task<IActionResult> CountryInit()
  444. {
  445. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  446. return Ok(JsonView(countrys));
  447. }
  448. /// <summary>
  449. /// 城市数据源
  450. /// </summary>
  451. /// <returns></returns>
  452. [HttpGet("{countryLabel}")]
  453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  454. public async Task<IActionResult> CityByCountry(string countryLabel)
  455. {
  456. countryLabel=HttpUtility.UrlDecode(countryLabel);
  457. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  458. var citys = Array.Empty<string?>();
  459. if (countryList.Any())
  460. {
  461. var cityDatas = await _sqlSugar
  462. .Queryable<Grp_NationalTravelFee>()
  463. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  464. .ToArrayAsync();
  465. foreach (var item in cityDatas)
  466. {
  467. if (item.City.Contains("城市"))
  468. {
  469. item.City = item.Country + "-所有城市";
  470. }
  471. }
  472. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  473. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  474. }
  475. return Ok(JsonView(citys));
  476. }
  477. /// <summary>
  478. /// 团组前期信息 Info
  479. /// </summary>
  480. /// <param name="id">Id</param>
  481. /// <param name="tempId">Id</param>
  482. /// <returns></returns>
  483. [HttpGet("{id}/{tempId}")]
  484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  485. public async Task<IActionResult> GroupOrderPreInfo(int id,int tempId = 1404)
  486. {
  487. return Ok(await _grpOrderPreInfoRep.InfoAsync(id, tempId));
  488. }
  489. /// <summary>
  490. /// 团组前期信息 Save
  491. /// </summary>
  492. /// <param name="dto">Id</param>
  493. /// <returns></returns>
  494. [HttpPost]
  495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  496. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  497. {
  498. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  499. }
  500. /// <summary>
  501. /// 团组前期信息 文件下载
  502. /// </summary>
  503. /// <param name="id">Id</param>
  504. /// <param name="tempId">Id</param>
  505. /// <returns></returns>
  506. [HttpGet("{id}/{tempId}")]
  507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  508. public async Task<IActionResult> GroupOrderPreInfoFileDownload(int id, int tempId = 1404)
  509. {
  510. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  511. var data = view.Data as GrpOrderPreInfoView;
  512. #region Excel
  513. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  514. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  515. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  516. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  517. var fileNamePrefix = string.Empty;
  518. if (tempId == 1405)
  519. {
  520. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  521. fileNamePrefix = $"{data.Name}_无商邀版";
  522. }
  523. else if (tempId == 1406)
  524. {
  525. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  526. fileNamePrefix = $"{data.Name}_有商邀版";
  527. }
  528. else
  529. {
  530. //tempId == 1404 默认下载
  531. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  532. fileNamePrefix = $"{data.Name}_单接送机";
  533. }
  534. foreach (var item in data.Items)
  535. {
  536. var obj = item.NewValue;
  537. if (obj == null) item.OriginVal = "";
  538. else if (obj.Equals("有") || obj.Equals("无"))
  539. {
  540. item.OriginVal = obj.ToString();
  541. }
  542. else if (obj is object[] objArray)
  543. {
  544. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  545. item.OriginVal = string.Join("、", stringArray);
  546. }
  547. else if (obj is string[] stringArray)
  548. {
  549. item.OriginVal = string.Join("、", stringArray);
  550. } else if (obj.Equals("-"))
  551. {
  552. item.OriginVal = "";
  553. }
  554. }
  555. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  556. fileName = CommonFun.ValidFileName(fileName);
  557. //载入模板
  558. WorkbookDesigner designer = new WorkbookDesigner();
  559. designer.Workbook = new Workbook(tempPath);
  560. if (tempId == 1406)
  561. {
  562. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  563. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  564. for (int i = 1; i <= view2.Length; i++)
  565. {
  566. view2[i - 1].Index = i;
  567. }
  568. designer.SetDataSource("View1", view1);
  569. designer.SetDataSource("View2", view2);
  570. }
  571. else
  572. {
  573. designer.SetDataSource("View", data.Items);
  574. }
  575. designer.Process();
  576. if (!Directory.Exists(savePath))
  577. {
  578. Directory.CreateDirectory(savePath);
  579. }
  580. string serverPath = $"{savePath}{fileName}";
  581. designer.Workbook.Save(serverPath);
  582. string rst = $"{servicePath}{ftpPath}{fileName}";
  583. #endregion
  584. return Ok(JsonView(new { url = rst }));
  585. }
  586. #endregion
  587. #region 团组基本信息
  588. /// <summary>
  589. /// 接团信息列表
  590. /// </summary>
  591. /// <param name="dto">团组列表请求dto</param>
  592. /// <returns></returns>
  593. [HttpPost]
  594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  595. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  596. {
  597. var groupData = await _groupRepository.GetGroupList(dto);
  598. if (groupData.Code != 0)
  599. {
  600. return Ok(JsonView(false, groupData.Msg));
  601. }
  602. return Ok(JsonView(groupData.Data));
  603. }
  604. /// <summary>
  605. /// 分页查询团组列表
  606. /// </summary>
  607. /// <param name="dto"></param>
  608. /// <returns></returns>
  609. [HttpPost]
  610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  611. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  612. {
  613. var watch = new Stopwatch();
  614. watch.Start();
  615. RefAsync<int> total = 0;
  616. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  617. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  618. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  619. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  620. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  621. .Distinct()
  622. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  623. watch.Stop();
  624. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  625. }
  626. /// <summary>
  627. /// 接团信息列表 Page Init
  628. /// </summary>
  629. /// <returns></returns>
  630. [HttpPost]
  631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  632. public async Task<IActionResult> PostGroupPageListInit()
  633. {
  634. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  635. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  636. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  637. var _view = new
  638. {
  639. depData = depDatas,
  640. rankData = rankDatas
  641. };
  642. return Ok(JsonView(true, "查询成功!", _view));
  643. }
  644. /// <summary>
  645. /// 接团信息列表 Page
  646. /// </summary>
  647. /// <param name="dto">团组列表请求dto</param>
  648. /// <returns></returns>
  649. [HttpPost]
  650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  651. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  652. {
  653. #region 参数验证
  654. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  655. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  656. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  657. #region 页面操作权限验证
  658. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  659. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  660. #endregion
  661. #endregion
  662. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  663. {
  664. string sqlWhere = string.Empty;
  665. if (dto.IsSure == 0) //未完成
  666. {
  667. sqlWhere += string.Format(@" And IsSure = 0");
  668. }
  669. else if (dto.IsSure == 1) //已完成
  670. {
  671. sqlWhere += string.Format(@" And IsSure = 1");
  672. }
  673. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  674. {
  675. string tj = dto.SearchCriteria;
  676. 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}%')",
  677. tj, tj, tj, tj, tj);
  678. }
  679. if (int.TryParse(dto.Rank, out int rankId))
  680. {
  681. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  682. }
  683. string sqlWhere1 = string.Empty;
  684. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  685. {
  686. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  687. }
  688. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  689. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  690. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  691. JietuanOperator,IsSure,CreateTime,IsBid
  692. From (
  693. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  694. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  695. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  696. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  697. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  698. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  699. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  700. From Grp_DelegationInfo gdi
  701. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  702. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  703. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  704. Where gdi.IsDel = 0 {0}
  705. ) temp {1}", sqlWhere, sqlWhere1);
  706. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  707. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  708. var _view = new
  709. {
  710. PageFuncAuth = pageFunAuthView,
  711. Data = _DelegationList
  712. };
  713. return Ok(JsonView(true, "查询成功!", _view, total));
  714. }
  715. else
  716. {
  717. return Ok(JsonView(false, "查询失败"));
  718. }
  719. }
  720. /// <summary>
  721. /// 团组列表
  722. /// </summary>
  723. /// <returns></returns>
  724. [HttpPost]
  725. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  726. {
  727. #region 参数验证
  728. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  729. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  730. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  731. #region 页面操作权限验证
  732. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  733. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  734. #endregion
  735. #endregion
  736. if (dto.PortType != 1 && dto.PortType != 2)
  737. {
  738. return Ok(JsonView(false, "查询失败!"));
  739. }
  740. string orderbyStr = "order by gdi.CreateTime Desc";
  741. string sqlWhere = string.Empty;
  742. if (dto.IsSure == 0) //未完成
  743. {
  744. sqlWhere += string.Format(@" And IsSure = 0");
  745. }
  746. else if (dto.IsSure == 1) //已完成
  747. {
  748. sqlWhere += string.Format(@" And IsSure = 1");
  749. }
  750. //团组类型
  751. if (dto.TeamDid > 0)
  752. {
  753. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  754. }
  755. //团组名称
  756. if (!string.IsNullOrEmpty(dto.TeamName))
  757. {
  758. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  759. }
  760. //客户名称
  761. if (!string.IsNullOrEmpty(dto.ClientName))
  762. {
  763. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  764. }
  765. //客户单位
  766. if (!string.IsNullOrEmpty(dto.ClientUnit))
  767. {
  768. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  769. }
  770. //出访时间
  771. if (!string.IsNullOrEmpty(dto.visitDataTime))
  772. {
  773. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  774. orderbyStr = "order by gdi.VisitDate";
  775. }
  776. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  777. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  778. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  779. JietuanOperator,IsSure,CreateTime
  780. From (
  781. Select row_number() over({0}) as Row_Number,
  782. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  783. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  784. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  785. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  786. From Grp_DelegationInfo gdi
  787. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  788. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  789. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  790. Where gdi.IsDel = 0 {1}
  791. ) temp ", orderbyStr, sqlWhere);
  792. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  793. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  794. #region 处理所属部门
  795. /*
  796. * 1.sq 和 gyy 等显示 市场部
  797. * 2.王鸽和主管及张总还有管理员号统一国交部
  798. * 2-1. 4 管理员 ,21 张海麟
  799. */
  800. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  801. List<int> userIds1 = new List<int>() { 4, 21 };
  802. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  803. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  804. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  805. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  806. .ToList();
  807. foreach (var item in _DelegationList)
  808. {
  809. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  810. }
  811. #endregion
  812. var _view = new
  813. {
  814. PageFuncAuth = pageFunAuthView,
  815. Data = _DelegationList
  816. };
  817. return Ok(JsonView(true, "查询成功!", _view, total));
  818. }
  819. /// <summary>
  820. /// 接团信息详情
  821. /// </summary>
  822. /// <param name="dto">团组info请求dto</param>
  823. /// <returns></returns>
  824. [HttpPost]
  825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  826. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  827. {
  828. var groupData = await _groupRepository.GetGroupInfo(dto);
  829. if (groupData.Code != 0)
  830. {
  831. return Ok(JsonView(false, groupData.Msg));
  832. }
  833. return Ok(JsonView(groupData.Data));
  834. }
  835. /// <summary>
  836. /// 接团信息 编辑添加
  837. /// 基础信息数据源
  838. /// </summary>
  839. /// <param name="dto"></param>
  840. /// <returns></returns>
  841. [HttpPost]
  842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  843. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  844. {
  845. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  846. if (groupData.Code != 0)
  847. {
  848. return Ok(JsonView(false, groupData.Msg));
  849. }
  850. return Ok(JsonView(groupData.Data));
  851. }
  852. /// <summary>
  853. /// 接团信息 操作(增改)
  854. /// </summary>
  855. /// <param name="dto"></param>
  856. /// <returns></returns>
  857. [HttpPost]
  858. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  859. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  860. {
  861. // 创建 Stopwatch 实例
  862. Stopwatch stopwatch = Stopwatch.StartNew();
  863. decimal ffrPrice = 0.00M;
  864. DateTime? visitDt = null;
  865. if (dto.Status == 2)
  866. {
  867. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  868. if (groupInfo != null)
  869. {
  870. ffrPrice = groupInfo.PaymentMoney;
  871. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  872. }
  873. }
  874. var groupData = await _groupRepository.GroupOperation(dto);
  875. if (groupData.Code != 0)
  876. {
  877. return Ok(JsonView(false, groupData.Msg));
  878. }
  879. int diId = 0;
  880. try
  881. {
  882. //添加时 默认加入团组汇率
  883. if (dto.Status == 1) //添加
  884. {
  885. diId = groupData.Data;
  886. //添加默认币种
  887. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  888. //默认分配权限
  889. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  890. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  891. var _managerIds = new List<int>() { 22, 32, 21 };
  892. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  893. if (userIds.Count > 0)
  894. {
  895. userIds.Add(208);
  896. //创建团组管控
  897. GroupStepForDelegation.CreateWorkStep(diId);
  898. //发送消息
  899. string groupName = dto.TeamName;
  900. string createGroupUser = string.Empty;
  901. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  902. if (userInfo != null) createGroupUser = userInfo.CnName;
  903. string title = $"系统通知";
  904. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  905. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  906. }
  907. //默认创建倒推表
  908. await _invertedListRep._Create(dto.UserId, diId);
  909. }
  910. else if (dto.Status == 2)
  911. {
  912. diId = dto.Id;
  913. }
  914. #region 签证人员团组时间通知
  915. #region 计算出访起止时间
  916. var startTime = new DateTime();
  917. var endTime = new DateTime();
  918. if (DateTime.TryParse(dto.VisitDate, out startTime))
  919. {
  920. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  921. }
  922. #endregion
  923. #endregion
  924. #region 团组操作默认添加/修改收款账单
  925. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  926. {
  927. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  928. .Where(x => x.IsDel == 0 &&
  929. x.Diid == diId &&
  930. x.Remark.Equals("预付款")
  931. )
  932. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  933. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  934. .FirstAsync();
  935. ffrInfo = new Fin_ForeignReceivables()
  936. {
  937. Diid = diId,
  938. PriceName = dto.ClientUnit,
  939. Price = dto.PaymentMoney,
  940. Count = 1,
  941. Unit = $"元",
  942. ItemSumPrice = dto.PaymentMoney,
  943. Rate = 1.0000M,
  944. Currency = 836,
  945. AddingWay = 0,
  946. CreateUserId = dto.UserId,
  947. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  948. Remark = $"预付款"
  949. };
  950. if (ffrInfo == null) //Add
  951. {
  952. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  953. }
  954. else //修改
  955. {
  956. await _sqlSugar.Updateable(ffrInfo)
  957. .UpdateColumns(x => new
  958. {
  959. x.PriceName,
  960. x.Price,
  961. x.ItemSumPrice,
  962. x.CreateTime,
  963. x.CreateUserId
  964. })
  965. .WhereColumns(x => x.Id)
  966. .ExecuteCommandAsync();
  967. }
  968. }
  969. #endregion
  970. if (diId > 0)
  971. {
  972. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  973. }
  974. // 停止计时
  975. stopwatch.Stop();
  976. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  977. }
  978. catch (Exception ex)
  979. {
  980. // 停止计时
  981. stopwatch.Stop();
  982. Logs("[response]" + JsonConvert.SerializeObject(dto));
  983. Logs(ex.Message);
  984. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  985. }
  986. // 停止计时
  987. stopwatch.Stop();
  988. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  989. }
  990. /// <summary>
  991. /// 接团流程操作(增改)
  992. /// 安卓端使用 建团时添加客户名单
  993. /// </summary>
  994. /// <param name="dto"></param>
  995. /// <returns></returns>
  996. [HttpPost]
  997. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  998. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  999. {
  1000. #region 参数验证
  1001. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1002. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1003. #region 页面操作权限验证
  1004. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1005. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1006. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1007. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1008. #endregion
  1009. #endregion
  1010. try
  1011. {
  1012. //_sqlSugar.BeginTran();
  1013. decimal ffrPrice = 0.00M;
  1014. DateTime? visitDt = null;
  1015. if (dto.Status == 2)
  1016. {
  1017. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1018. if (groupInfo != null)
  1019. {
  1020. ffrPrice = groupInfo.PaymentMoney;
  1021. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1022. }
  1023. }
  1024. var _dto = new GroupOperationDto();
  1025. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1026. var groupData = await _groupRepository.GroupOperation(_dto);
  1027. if (groupData.Code != 0)
  1028. {
  1029. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1030. }
  1031. int diId = 0;
  1032. //添加时 默认加入团组汇率
  1033. if (dto.Status == 1) //添加
  1034. {
  1035. diId = groupData.Data;
  1036. //添加默认币种
  1037. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1038. //默认分配权限
  1039. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1040. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1041. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1042. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1043. if (userIds.Count > 0)
  1044. {
  1045. userIds.Add(208);
  1046. //创建团组管控
  1047. GroupStepForDelegation.CreateWorkStep(diId);
  1048. //发送消息
  1049. string groupName = dto.TeamName;
  1050. string createGroupUser = string.Empty;
  1051. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1052. if (userInfo != null) createGroupUser = userInfo.CnName;
  1053. string title = $"系统通知";
  1054. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1055. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1056. }
  1057. #region 应用推送
  1058. try
  1059. {
  1060. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1061. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1062. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1063. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1064. {
  1065. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1066. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1067. }
  1068. }
  1069. catch (Exception ex)
  1070. {
  1071. }
  1072. #endregion
  1073. //默认创建倒推表
  1074. await _invertedListRep._Create(dto.UserId, diId);
  1075. }
  1076. if (dto.Status == 2)
  1077. {
  1078. diId = dto.Id;
  1079. if (diId == 0)
  1080. {
  1081. //_sqlSugar.RollbackTran();
  1082. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1083. }
  1084. }
  1085. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1086. if (viewData.Code != 0)
  1087. {
  1088. //_sqlSugar.RollbackTran();
  1089. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1090. }
  1091. #region 团组操作默认添加/修改收款账单
  1092. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1093. {
  1094. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1095. .Where(x => x.IsDel == 0 &&
  1096. x.Diid == diId &&
  1097. x.Remark.Equals("预付款")
  1098. )
  1099. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1100. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1101. .FirstAsync();
  1102. ffrInfo = new Fin_ForeignReceivables()
  1103. {
  1104. Diid = diId,
  1105. PriceName = dto.ClientUnit,
  1106. Price = dto.PaymentMoney,
  1107. Count = 1,
  1108. Unit = $"元",
  1109. ItemSumPrice = dto.PaymentMoney,
  1110. Rate = 1.0000M,
  1111. Currency = 836,
  1112. AddingWay = 0,
  1113. CreateUserId = dto.UserId,
  1114. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1115. Remark = $"预付款"
  1116. };
  1117. if (ffrInfo == null) //Add
  1118. {
  1119. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1120. }
  1121. else //修改
  1122. {
  1123. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1124. .UpdateColumns(x => new
  1125. {
  1126. x.PriceName,
  1127. x.Price,
  1128. x.ItemSumPrice,
  1129. x.CreateTime,
  1130. x.CreateUserId
  1131. })
  1132. .WhereColumns(x => x.Id)
  1133. .ExecuteCommandAsync();
  1134. }
  1135. }
  1136. #endregion
  1137. #region 签证人员团组时间通知
  1138. #region 计算出访起止时间
  1139. var startTime = new DateTime();
  1140. var endTime = new DateTime();
  1141. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1142. {
  1143. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1144. }
  1145. #endregion
  1146. if (diId > 0)
  1147. {
  1148. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1149. }
  1150. #endregion
  1151. //_sqlSugar.CommitTran();
  1152. return Ok(JsonView(true, "添加成功"));
  1153. }
  1154. catch (Exception ex)
  1155. {
  1156. _sqlSugar.RollbackTran();
  1157. return Ok(JsonView(false, ex.Message));
  1158. }
  1159. }
  1160. /// <summary>
  1161. /// 接团流程操作(增改)
  1162. /// 安卓端使用 建团时添加客户名单
  1163. /// </summary>
  1164. /// <param name="dto"></param>
  1165. /// <returns></returns>
  1166. [HttpPost]
  1167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1168. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1169. {
  1170. #region 参数验证
  1171. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1172. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1173. #region 页面操作权限验证
  1174. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1175. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1176. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1177. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1178. #endregion
  1179. #endregion
  1180. _sqlSugar.BeginTran();
  1181. decimal ffrPrice = 0.00M;
  1182. DateTime? visitDt = null;
  1183. if (dto.Status == 2)
  1184. {
  1185. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1186. if (groupInfo != null)
  1187. {
  1188. ffrPrice = groupInfo.PaymentMoney;
  1189. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1190. }
  1191. }
  1192. var _dto = new GroupOperationDto();
  1193. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1194. var groupData = await _groupRepository.GroupOperation(_dto);
  1195. if (groupData.Code != 0)
  1196. {
  1197. _sqlSugar.RollbackTran();
  1198. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1199. }
  1200. try
  1201. {
  1202. int diId = 0;
  1203. //添加时 默认加入团组汇率
  1204. if (dto.Status == 1) //添加
  1205. {
  1206. diId = groupData.Data;
  1207. //添加默认币种
  1208. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1209. //默认分配权限
  1210. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1211. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1212. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1213. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1214. if (userIds.Count > 0)
  1215. {
  1216. userIds.Add(208);
  1217. //创建团组管控
  1218. GroupStepForDelegation.CreateWorkStep(diId);
  1219. //发送消息
  1220. string groupName = dto.TeamName;
  1221. string createGroupUser = string.Empty;
  1222. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1223. if (userInfo != null) createGroupUser = userInfo.CnName;
  1224. string title = $"系统通知";
  1225. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1226. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1227. }
  1228. #region 应用推送
  1229. try
  1230. {
  1231. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1232. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1233. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1234. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1235. {
  1236. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1237. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1238. }
  1239. }
  1240. catch (Exception ex)
  1241. {
  1242. _sqlSugar.CommitTran();
  1243. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1244. }
  1245. #endregion
  1246. //默认创建倒推表
  1247. await _invertedListRep._Create(dto.UserId, diId);
  1248. }
  1249. else if (dto.Status == 2)
  1250. {
  1251. diId = dto.Id;
  1252. if (diId == 0)
  1253. {
  1254. _sqlSugar.RollbackTran();
  1255. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1256. }
  1257. }
  1258. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1259. if (viewData.Code != 0)
  1260. {
  1261. _sqlSugar.RollbackTran();
  1262. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1263. }
  1264. #region 团组操作默认添加/修改收款账单
  1265. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1266. {
  1267. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1268. .Where(x => x.IsDel == 0 &&
  1269. x.Diid == diId &&
  1270. x.Remark.Equals("预付款")
  1271. )
  1272. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1273. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1274. .FirstAsync();
  1275. ffrInfo = new Fin_ForeignReceivables()
  1276. {
  1277. Diid = diId,
  1278. PriceName = dto.ClientUnit,
  1279. Price = dto.PaymentMoney,
  1280. Count = 1,
  1281. Unit = $"元",
  1282. ItemSumPrice = dto.PaymentMoney,
  1283. Rate = 1.0000M,
  1284. Currency = 836,
  1285. AddingWay = 0,
  1286. CreateUserId = dto.UserId,
  1287. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1288. Remark = $"预付款"
  1289. };
  1290. if (ffrInfo == null) //Add
  1291. {
  1292. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1293. }
  1294. else //修改
  1295. {
  1296. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1297. .UpdateColumns(x => new
  1298. {
  1299. x.PriceName,
  1300. x.Price,
  1301. x.ItemSumPrice,
  1302. x.CreateTime,
  1303. x.CreateUserId
  1304. })
  1305. .WhereColumns(x => x.Id)
  1306. .ExecuteCommandAsync();
  1307. }
  1308. }
  1309. #endregion
  1310. #region 签证人员团组时间通知
  1311. #region 计算出访起止时间
  1312. var startTime = new DateTime();
  1313. var endTime = new DateTime();
  1314. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1315. {
  1316. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1317. }
  1318. #endregion
  1319. if (diId > 0)
  1320. {
  1321. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1322. }
  1323. #endregion
  1324. _sqlSugar.CommitTran();
  1325. return Ok(JsonView(true));
  1326. }
  1327. catch (Exception ex)
  1328. {
  1329. _sqlSugar.RollbackTran();
  1330. return Ok(JsonView(false, ex.Message));
  1331. }
  1332. }
  1333. /// <summary>
  1334. /// 接团信息 操作(删除)
  1335. /// </summary>
  1336. /// <param name="dto"></param>
  1337. /// <returns></returns>
  1338. [HttpPost]
  1339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1340. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1341. {
  1342. var diId = dto.Id;
  1343. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1344. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1345. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1346. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1347. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1348. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1349. #endregion
  1350. var groupData = await _groupRepository.GroupDel(dto);
  1351. if (groupData.Code != 0)
  1352. {
  1353. return Ok(JsonView(false, groupData.Msg));
  1354. }
  1355. return Ok(JsonView(true));
  1356. }
  1357. /// <summary>
  1358. /// 获取团组销售报价号
  1359. /// 团组添加时 使用
  1360. /// </summary>
  1361. /// <returns></returns>
  1362. [HttpPost]
  1363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1364. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1365. {
  1366. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1367. if (groupData.Code != 0)
  1368. {
  1369. return Ok(JsonView(false, groupData.Msg));
  1370. }
  1371. object salesQuoteNo = new
  1372. {
  1373. SalesQuoteNo = groupData.Data
  1374. };
  1375. return Ok(JsonView(salesQuoteNo));
  1376. }
  1377. /// <summary>
  1378. /// 设置确认出团
  1379. /// </summary>
  1380. /// <param name="dto"></param>
  1381. /// <returns></returns>
  1382. [HttpPost]
  1383. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1384. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1385. {
  1386. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1387. if (groupData.Code != 0)
  1388. {
  1389. return Ok(JsonView(false, groupData.Msg));
  1390. }
  1391. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1392. #region OA消息推送
  1393. try
  1394. {
  1395. string groupName = groupInfo.TeamName;
  1396. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1397. string title = $"系统通知";
  1398. string content = $"团组[{groupName}]已确认出团!";
  1399. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1400. }
  1401. catch (Exception ex)
  1402. {
  1403. }
  1404. #endregion
  1405. #region 应用推送
  1406. try
  1407. {
  1408. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1409. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1410. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1411. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1412. {
  1413. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1414. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1415. }
  1416. }
  1417. catch (Exception ex)
  1418. {
  1419. }
  1420. #endregion
  1421. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1422. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1423. }
  1424. /// <summary>
  1425. /// 获取团组名称data And 签证国别Data
  1426. /// </summary>
  1427. /// <param name="dto"></param>
  1428. /// <returns></returns>
  1429. [HttpPost]
  1430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1431. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1432. {
  1433. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1434. if (groupData.Code != 0)
  1435. {
  1436. return Ok(JsonView(false, groupData.Msg));
  1437. }
  1438. return Ok(JsonView(groupData.Data));
  1439. }
  1440. /// <summary>
  1441. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1442. /// </summary>
  1443. /// <returns></returns>
  1444. [HttpPost]
  1445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1446. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1447. {
  1448. try
  1449. {
  1450. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1451. if (groupData.Code != 0)
  1452. {
  1453. return Ok(JsonView(false, groupData.Msg));
  1454. }
  1455. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1456. }
  1457. catch (Exception ex)
  1458. {
  1459. return Ok(JsonView(false, "程序错误!"));
  1460. throw;
  1461. }
  1462. }
  1463. /// <summary>
  1464. /// 团组清单 Excel
  1465. /// </summary>
  1466. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1467. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1468. /// <returns></returns>
  1469. [HttpGet]
  1470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1471. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1472. {
  1473. DateTime _beginDt, _endDt;
  1474. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1475. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1476. if (!beginBool && !endBool)
  1477. {
  1478. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1479. }
  1480. string sql = string.Format(@"
  1481. SELECT
  1482. ROW_NUMBER,
  1483. Id,
  1484. SalesQuoteNo,
  1485. TourCode,
  1486. TeamTypeId,
  1487. TeamType,
  1488. TeamLevId,
  1489. TeamLev,
  1490. TeamName,
  1491. ClientName,
  1492. ClientUnit,
  1493. VisitDate,
  1494. VisitDays,
  1495. VisitPNumber,
  1496. JietuanOperatorId,
  1497. JietuanOperator,
  1498. IsSure,
  1499. CreateUserName,
  1500. IsBid
  1501. FROM
  1502. (
  1503. SELECT
  1504. ROW_NUMBER() OVER(
  1505. ORDER BY
  1506. gdi.CreateTime Desc
  1507. ) AS ROW_NUMBER,
  1508. gdi.Id,
  1509. SalesQuoteNo,
  1510. TourCode,
  1511. ssd.Id TeamTypeId,
  1512. ssd.Name TeamType,
  1513. ssd1.Id TeamLevId,
  1514. ssd1.Name TeamLev,
  1515. TeamName,
  1516. ClientName,
  1517. ClientUnit,
  1518. VisitDate,
  1519. VisitDays,
  1520. VisitPNumber,
  1521. JietuanOperator JietuanOperatorId,
  1522. su.CnName JietuanOperator,
  1523. IsSure,
  1524. gdi.CreateTime,
  1525. su1.CnName As CreateUserName,
  1526. gdi.IsBid
  1527. FROM
  1528. Grp_DelegationInfo gdi
  1529. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1530. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1531. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1532. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1533. WHERE
  1534. gdi.IsDel = 0
  1535. AND gdi.IsBid = 0
  1536. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1537. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1538. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1539. #region 处理所属部门
  1540. /*
  1541. * 1.sq 和 gyy 等显示 市场部
  1542. * 2.王鸽和主管及张总还有管理员号统一国交部
  1543. * 2-1. 4 管理员 ,21 张海麟
  1544. */
  1545. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1546. List<int> userIds1 = new List<int>() { 4, 21 };
  1547. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1548. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1549. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1550. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1551. .ToListAsync();
  1552. var droupIds = groupList.Select(it => it.Id).ToList();
  1553. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1554. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1555. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1556. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1557. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1558. {
  1559. DiId = tcl.DiId,
  1560. LastName = dc.LastName,
  1561. FirstName = dc.FirstName,
  1562. Sex = dc.Sex,
  1563. Birthday = dc.BirthDay,
  1564. Company = cc.CompanyFullName,
  1565. Job = dc.Job,
  1566. CreateTime = tcl.CreateTime,
  1567. })
  1568. .ToList();
  1569. foreach (var item in groupList)
  1570. {
  1571. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1572. string groupFirstName = "";
  1573. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1574. if (currDatas.Any())
  1575. {
  1576. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1577. }
  1578. item.GroupFirst = groupFirstName;
  1579. }
  1580. #endregion
  1581. #region Excel
  1582. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1583. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1584. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1585. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1586. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1587. //载入模板
  1588. WorkbookDesigner designer = new WorkbookDesigner();
  1589. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1590. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1591. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1592. dt.TableName = "GroupList";
  1593. designer.SetDataSource(dt);
  1594. designer.Process();
  1595. if (!Directory.Exists(savePath))
  1596. {
  1597. Directory.CreateDirectory(savePath);
  1598. }
  1599. string serverPath = $"{savePath}{fileName}";
  1600. designer.Workbook.Save(serverPath);
  1601. string rst = $"{servicePath}{ftpPath}{fileName}";
  1602. #endregion
  1603. return Ok(JsonView(true, "操作成功!", rst));
  1604. }
  1605. #endregion
  1606. #region 团组&签证
  1607. /// <summary>
  1608. /// 根据团组Id获取签证客户信息List
  1609. /// </summary>
  1610. /// <param name="dto">请求dto</param>
  1611. /// <returns></returns>
  1612. [HttpPost]
  1613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1614. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1615. {
  1616. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1617. if (groupData.Code != 0)
  1618. {
  1619. return Ok(JsonView(false, groupData.Msg));
  1620. }
  1621. return Ok(JsonView(groupData.Data));
  1622. }
  1623. /// <summary>
  1624. /// IOS获取团组签证拍照上传进度01(团组列表)
  1625. /// </summary>
  1626. /// <param name="dto">请求dto</param>
  1627. /// <returns></returns>
  1628. [HttpPost]
  1629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1630. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1631. {
  1632. if (dto == null)
  1633. {
  1634. return Ok(JsonView(false, "参数为空"));
  1635. }
  1636. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1637. return Ok(JsonView(visaList));
  1638. }
  1639. /// <summary>
  1640. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1641. /// </summary>
  1642. /// <returns></returns>
  1643. [HttpPost]
  1644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1645. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1646. {
  1647. if (dto == null)
  1648. {
  1649. return Ok(JsonView(false, "请求错误:"));
  1650. }
  1651. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1652. return Ok(JsonView(list));
  1653. }
  1654. /// <summary>
  1655. /// IOS获取团组签证拍照上传进度03(相册)
  1656. /// </summary>
  1657. /// <returns></returns>
  1658. [HttpPost]
  1659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1660. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1661. {
  1662. if (dto == null)
  1663. {
  1664. return Ok(JsonView(false, "请求错误:"));
  1665. }
  1666. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1667. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1668. list.ForEach(s => s.url = url);
  1669. return Ok(JsonView(list));
  1670. }
  1671. /// <summary>
  1672. /// IOS获取团组签证拍照上传进度04(图片上传)
  1673. /// </summary>
  1674. /// <param name="dto"></param>
  1675. /// <returns></returns>
  1676. [HttpPost]
  1677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1678. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1679. {
  1680. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1681. //if (!string.IsNullOrEmpty(result))
  1682. //{
  1683. //}
  1684. //else {
  1685. // return Ok(JsonView(false, "上传失败"));
  1686. //}
  1687. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1688. int sucNum = 0;
  1689. try
  1690. {
  1691. foreach (var item in dto.base64DataList)
  1692. {
  1693. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1694. string result = DecodeBase64ToImage(item, imageName);
  1695. if (!string.IsNullOrEmpty(result))
  1696. {
  1697. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1698. pic.CreateUserId = dto.CreateUserId;
  1699. pic.PicName = imageName;
  1700. pic.PicPath = result;
  1701. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1702. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1703. if (insertResult > 0)
  1704. {
  1705. sucNum++;
  1706. }
  1707. }
  1708. }
  1709. }
  1710. catch (Exception ex)
  1711. {
  1712. return Ok(JsonView(false, ex.Message));
  1713. }
  1714. string msg = string.Format(@"成功上传{0}张", sucNum);
  1715. return Ok(JsonView(true, msg));
  1716. }
  1717. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  1718. {
  1719. string filename = "";//声明一个string类型的相对路径
  1720. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1721. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1722. try//会有异常抛出,try,catch一下
  1723. {
  1724. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1725. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1726. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1727. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1728. //文件名称
  1729. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1730. //上传的文件的路径
  1731. string filePath = "";
  1732. if (!Directory.Exists(fileDir))
  1733. {
  1734. Directory.CreateDirectory(fileDir);
  1735. }
  1736. //上传的文件的路径
  1737. filePath = fileDir + filename;
  1738. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1739. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1740. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1741. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1742. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1743. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1744. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1745. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1746. bitmap.Dispose();
  1747. }
  1748. catch (Exception e)
  1749. {
  1750. string massage = e.Message;
  1751. Logs("IOS图片上传Error:" + massage);
  1752. //filename = e.Message;
  1753. }
  1754. return filename;//返回相对路径
  1755. }
  1756. /// <summary>
  1757. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1758. /// </summary>
  1759. /// <param name="dto"></param>
  1760. /// <returns></returns>
  1761. [HttpPost]
  1762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1763. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1764. {
  1765. if (dto == null)
  1766. {
  1767. return Ok(JsonView(false, "请求错误:"));
  1768. }
  1769. string msg = "参数错误";
  1770. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1771. {
  1772. try
  1773. {
  1774. //_delegationVisaRep.BeginTran();
  1775. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1776. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1777. .Where(s => s.Id == dto.visaProgressCustomerId)
  1778. .ExecuteCommandAsync();
  1779. if (updCount > 0 && dto.publishCode == 1)
  1780. {
  1781. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1782. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1783. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1784. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1785. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1786. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1787. if (groupData == null)
  1788. {
  1789. _delegationVisaRep.RollbackTran();
  1790. }
  1791. string title = string.Format(@"[签证进度更新]");
  1792. string content = string.Format(@"测试文本");
  1793. bool rst = await _message.AddMsg(new MessageDto()
  1794. {
  1795. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1796. IssuerId = dto.publisher,
  1797. Title = title,
  1798. Content = content,
  1799. ReleaseTime = DateTime.Now,
  1800. UIdList = new List<int> {
  1801. 234
  1802. }
  1803. });
  1804. if (rst)
  1805. {
  1806. return Ok(JsonView(true, "发送通知成功"));
  1807. }
  1808. }
  1809. //_delegationVisaRep.CommitTran();
  1810. }
  1811. catch (Exception)
  1812. {
  1813. //_delegationVisaRep.RollbackTran();
  1814. }
  1815. }
  1816. return Ok(JsonView(true, msg));
  1817. }
  1818. #endregion
  1819. #region 团组任务分配
  1820. /// <summary>
  1821. /// 团组任务分配初始化
  1822. /// </summary>
  1823. /// <returns></returns>
  1824. [HttpPost]
  1825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1826. public async Task<IActionResult> GetTaskAssignmen()
  1827. {
  1828. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1829. if (groupData.Code != 0)
  1830. {
  1831. return Ok(JsonView(false, groupData.Msg));
  1832. }
  1833. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1834. }
  1835. /// <summary>
  1836. /// 团组任务分配查询
  1837. /// </summary>
  1838. /// <param name="dto"></param>
  1839. /// <returns></returns>
  1840. [HttpPost]
  1841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1842. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1843. {
  1844. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1845. if (groupData.Code != 0)
  1846. {
  1847. return Ok(JsonView(false, groupData.Msg));
  1848. }
  1849. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1850. }
  1851. /// <summary>
  1852. /// 团组任务分配操作
  1853. /// </summary>
  1854. /// <param name="dto"></param>
  1855. /// <returns></returns>
  1856. [HttpPost]
  1857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1858. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1859. {
  1860. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1861. if (groupData.Code != 0)
  1862. {
  1863. return Ok(JsonView(false, groupData.Msg));
  1864. }
  1865. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1866. }
  1867. /// <summary>
  1868. /// 团组任务分配
  1869. /// 批量分配
  1870. /// 查询团组
  1871. /// </summary>
  1872. /// <param name="dto"></param>
  1873. /// <returns></returns>
  1874. [HttpPost]
  1875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1876. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1877. {
  1878. //参数验证
  1879. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1880. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1881. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1882. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1883. }
  1884. /// <summary>
  1885. /// 团组任务分配
  1886. /// 批量分配
  1887. /// </summary>
  1888. /// <param name="dto"></param>
  1889. /// <returns></returns>
  1890. [HttpPost]
  1891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1892. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1893. {
  1894. //参数验证
  1895. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1896. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1897. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1898. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1899. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1900. }
  1901. #endregion
  1902. #region 团组费用审核
  1903. /// <summary>
  1904. /// 费用审核
  1905. /// 团组列表 Page
  1906. /// </summary>
  1907. /// <param name="_dto">团组列表请求dto</param>
  1908. /// <returns></returns>
  1909. [HttpPost]
  1910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1911. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1912. {
  1913. #region 参数验证
  1914. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1915. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1916. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1917. #region 页面操作权限验证
  1918. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1919. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1920. #endregion
  1921. #endregion
  1922. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1923. {
  1924. string sqlWhere = string.Empty;
  1925. if (_dto.IsSure == 0) //未完成
  1926. {
  1927. sqlWhere += string.Format(@" And IsSure = 0");
  1928. }
  1929. else if (_dto.IsSure == 1) //已完成
  1930. {
  1931. sqlWhere += string.Format(@" And IsSure = 1");
  1932. }
  1933. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1934. {
  1935. string tj = _dto.SearchCriteria;
  1936. 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}%')",
  1937. tj, tj, tj, tj, tj);
  1938. }
  1939. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1940. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1941. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1942. From (
  1943. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1944. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1945. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1946. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1947. From Grp_DelegationInfo gdi
  1948. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1949. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1950. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1951. Where gdi.IsDel = 0 {0}
  1952. ) temp ", sqlWhere);
  1953. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1954. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1955. var _view = new
  1956. {
  1957. PageFuncAuth = pageFunAuthView,
  1958. Data = _DelegationList
  1959. };
  1960. return Ok(JsonView(true, "查询成功!", _view, total));
  1961. }
  1962. else
  1963. {
  1964. return Ok(JsonView(false, "查询失败"));
  1965. }
  1966. }
  1967. /// <summary>
  1968. /// 获取团组费用审核
  1969. /// </summary>
  1970. /// <param name="_dto"></param>
  1971. /// <returns></returns>
  1972. [HttpPost]
  1973. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1974. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1975. {
  1976. try
  1977. {
  1978. #region 参数验证
  1979. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1980. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1981. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1982. #region 页面操作权限验证
  1983. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1984. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1985. #endregion
  1986. #endregion
  1987. var _view = new Grp_CreditCardPaymentView();
  1988. var clientNameList = getSimplClientList(_dto.DiId);
  1989. #region 费用清单
  1990. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1991. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1992. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1993. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1994. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1995. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1996. /*
  1997. * 76://酒店预订
  1998. */
  1999. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2000. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2001. /*
  2002. * 79://车/导游地接
  2003. */
  2004. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2005. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2006. /*
  2007. * 80: //签证
  2008. */
  2009. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2010. /*
  2011. *81: //邀请/公务活动
  2012. */
  2013. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2014. /*
  2015. * 82: //团组客户保险
  2016. */
  2017. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2018. /*
  2019. * Lable = 85 机票预订
  2020. */
  2021. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2022. /*
  2023. * 85 机票预定
  2024. */
  2025. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2026. /*
  2027. * 98 其他款项
  2028. */
  2029. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2030. /*
  2031. * 285:收款退还
  2032. */
  2033. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2034. /*
  2035. * 1015: //超支费用
  2036. */
  2037. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2038. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2039. /*
  2040. * 币种信息
  2041. */
  2042. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2043. /*
  2044. * 车/导游地接 费用类型
  2045. */
  2046. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2047. /*
  2048. * 车/导游地接 费用类型
  2049. */
  2050. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2051. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2052. /*
  2053. * 用户信息
  2054. */
  2055. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2056. /*
  2057. * 费用模块
  2058. */
  2059. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2060. string priceModule = string.Empty;
  2061. if (sdPriceName != null)
  2062. {
  2063. priceModule = sdPriceName.Name;
  2064. }
  2065. /*
  2066. * 成本信息
  2067. */
  2068. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2069. decimal _groupRate = 0.0000M;
  2070. string _groupCurrencyCode = "-";
  2071. if (groupCost != null)
  2072. {
  2073. _groupRate = groupCost.Rate;
  2074. if (int.TryParse(groupCost.Currency, out int _currency))
  2075. {
  2076. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2077. }
  2078. else _groupCurrencyCode = groupCost.Currency;
  2079. }
  2080. string costContentSql = $"Select * From Grp_GroupCost";
  2081. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2082. //处理日期为空的天数
  2083. for (int i = 0; i < groupCostDetails.Count; i++)
  2084. if (i != 0)
  2085. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2086. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2087. /*
  2088. * 处理详情数据
  2089. */
  2090. foreach (var entity in entityList)
  2091. {
  2092. var _detail = new Grp_CreditCardPaymentDetailView();
  2093. _detail.Id = entity.Id;
  2094. _detail.PriceName = priceModule;
  2095. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2096. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2097. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2098. //处理金额
  2099. if (entity.CTable == 1015)
  2100. {
  2101. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2102. if (czInfo != null)
  2103. {
  2104. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2105. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2106. }
  2107. }
  2108. /*
  2109. * 应付款金额
  2110. */
  2111. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2112. string PaymentCurrency_WaitPay = "Unknown";
  2113. string hotelCurrncyCode = "Unknown";
  2114. string hotelCurrncyName = "Unknown";
  2115. if (sdPaymentCurrency_WaitPay != null)
  2116. {
  2117. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2118. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2119. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2120. if (hotelCurrncyCode.Equals("CNY"))
  2121. {
  2122. entity.DayRate = 1.0000M;
  2123. }
  2124. }
  2125. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2126. /*
  2127. * 此次付款金额
  2128. */
  2129. decimal CurrPayStr = 0.00M,
  2130. OriginalCurrPay = 0.00M;
  2131. if (entity.PayPercentage == 0)
  2132. {
  2133. if (entity.PayThenMoney != 0)
  2134. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2135. }
  2136. else
  2137. {
  2138. if (entity.PayMoney != 0)
  2139. {
  2140. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2141. }
  2142. }
  2143. //if (_dto.Label == 79)
  2144. //{
  2145. // string original = string.Empty;
  2146. // if (hotelCurrncyCode.Equals("CNY"))
  2147. // {
  2148. // OriginalCurrPay = CurrPayStr;
  2149. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2150. // }
  2151. // else
  2152. // {
  2153. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2154. // //760 EUR(7600.00 CNY)
  2155. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2156. // }
  2157. //}
  2158. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2159. string original = string.Empty;
  2160. if (hotelCurrncyCode.Equals("CNY"))
  2161. {
  2162. OriginalCurrPay = CurrPayStr;
  2163. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2164. }
  2165. else
  2166. {
  2167. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2168. //760 EUR(7600.00 CNY)
  2169. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2170. }
  2171. /*
  2172. * 剩余尾款
  2173. */
  2174. decimal BalanceStr = 0;
  2175. if (CurrPayStr != 0)
  2176. {
  2177. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2178. BalanceStr = 0;
  2179. else
  2180. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2181. }
  2182. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2183. /*
  2184. * Bus名称
  2185. */
  2186. _detail.BusName = "待增加";
  2187. /*
  2188. *费用所属
  2189. */
  2190. switch (entity.CTable)
  2191. {
  2192. case 76://酒店预订
  2193. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2194. if (hotelReservations != null)
  2195. {
  2196. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2197. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2198. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2199. string roomFeeStr = "", roomFeestr1 = "";
  2200. //是否比较房型价格
  2201. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2202. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2203. roomFeeStr += $"<br/>";
  2204. var roomTotal = 0.00M;
  2205. if (hotelReservations.SingleRoomPrice > 0)
  2206. {
  2207. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  2208. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2209. //__isSingle = true;
  2210. roomTotal += fee;
  2211. }
  2212. if (hotelReservations.DoubleRoomPrice > 0)
  2213. {
  2214. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  2215. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2216. // __isDouble = true;
  2217. roomTotal += fee;
  2218. }
  2219. if (hotelReservations.SuiteRoomPrice > 0)
  2220. {
  2221. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2222. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2223. //__isSuite = true;
  2224. roomTotal += fee;
  2225. }
  2226. if (hotelReservations.OtherRoomPrice > 0)
  2227. {
  2228. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2229. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2230. //__isOther = true;
  2231. roomTotal += fee;
  2232. }
  2233. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2234. else roomFeeStr += " 0.00 * 0";
  2235. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2236. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2237. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2238. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2239. /*
  2240. * 费用类型
  2241. * 1:房费
  2242. * 2:早餐
  2243. * 3:地税
  2244. * 4:城市税
  2245. * </summary>
  2246. */
  2247. //地税
  2248. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2249. if (governmentRentData != null)
  2250. {
  2251. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2252. governmentRentFee = governmentRentData.Price;
  2253. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2254. if (governmentRentCurrData != null)
  2255. {
  2256. governmentRentCode = governmentRentCurrData.Name;
  2257. governmentRentName = $"({governmentRentCurrData.Remark})";
  2258. }
  2259. }
  2260. //城市税
  2261. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2262. if (cityTaxData != null)
  2263. {
  2264. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2265. cityTaxFee = cityTaxData.Price;
  2266. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2267. if (cityTaxCurrData != null)
  2268. {
  2269. cityTaxCode = cityTaxCurrData.Name;
  2270. cityTaxName = $"({cityTaxCurrData.Remark})";
  2271. }
  2272. }
  2273. //酒店早餐
  2274. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2275. if (breakfastData != null)
  2276. {
  2277. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2278. breakfastFee = breakfastData.Price;
  2279. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2280. if (breakfastCurrData != null)
  2281. {
  2282. breakfastCode = breakfastCurrData.Name;
  2283. breakfastName = $"({breakfastCurrData.Remark})";
  2284. }
  2285. }
  2286. //房间费用
  2287. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2288. if (roomData != null)
  2289. {
  2290. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2291. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2292. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2293. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2294. roomFee = roomData.Price;
  2295. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2296. if (roomCurrData != null)
  2297. {
  2298. roomCode = roomCurrData.Name;
  2299. roomName = $"({roomCurrData.Remark})";
  2300. }
  2301. }
  2302. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2303. string hotelCostStr = "";
  2304. decimal hotelCsotTotal = 0.00M;
  2305. if (groupCost != null)
  2306. {
  2307. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2308. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2309. }
  2310. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2311. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2312. string hotelCost_day = "";
  2313. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2314. foreach (var item in hotelCostDetails1)
  2315. {
  2316. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2317. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2318. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2319. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2320. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2321. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2322. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2323. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2324. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2325. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2326. hotelCost_day += @$"<br/>";
  2327. }
  2328. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2329. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2330. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2331. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2332. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2333. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2334. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2335. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2336. $"房间说明: {hotelReservations.Remark} <br/>" +
  2337. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2338. $"{hotelBreakfastStr}" +
  2339. $"{hotelGovernmentRentStr}" +
  2340. $"{hotelCityTaxStr}";
  2341. _detail.PriceNameContent = hotelReservations.HotelName;
  2342. }
  2343. break;
  2344. case 79://车/导游地接
  2345. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2346. if (touristGuideGroundReservations != null)
  2347. {
  2348. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2349. {
  2350. _detail.BusName = touristGuideGroundReservations.BusName;
  2351. }
  2352. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2353. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2354. //if (isInt)
  2355. //{
  2356. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2357. // if (cityInfo != null)
  2358. // {
  2359. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2360. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2361. // if (carFeeItem != null)
  2362. // {
  2363. // nameContent += $@"({carFeeItem.Name})";
  2364. // }
  2365. // _detail.PriceNameContent = nameContent;
  2366. // }
  2367. //}
  2368. //else
  2369. //{
  2370. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2371. //}
  2372. var touristGuideGroundReservationsContents =
  2373. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2374. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2375. foreach (var item in touristGuideGroundReservationsContents)
  2376. {
  2377. string typeName = "Unknown";
  2378. string carCurrencyCode = "Unknown";
  2379. string carCurrencyName = "Unknown";
  2380. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2381. if (carTypeData != null) typeName = carTypeData.Name;
  2382. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2383. if (currencyData != null)
  2384. {
  2385. carCurrencyCode = currencyData.Name;
  2386. carCurrencyName = currencyData.Remark;
  2387. }
  2388. //op、成本 币种是否一致
  2389. bool IsCurrencyAgreement = false;
  2390. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2391. string opCostStr = string.Empty;
  2392. decimal opCostTypePrice = 0.00M;
  2393. #region 处理成本各项费用
  2394. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2395. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2396. if (opCost.Count > 0)
  2397. {
  2398. switch (item.SId)
  2399. {
  2400. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2401. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2402. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2403. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2404. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2405. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2406. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2407. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2408. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2409. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2410. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2411. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2412. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2413. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2414. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2415. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2416. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2417. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2418. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2419. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2420. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2421. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2422. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2423. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2424. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2425. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2426. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2427. }
  2428. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2429. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2430. }
  2431. #endregion
  2432. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2433. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2434. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2435. $"{opTypeStr} {opCostStr}<br/>" +
  2436. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2437. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2438. }
  2439. _detail.PriceMsgContent = priceMsg;
  2440. }
  2441. break;
  2442. case 80: //签证
  2443. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2444. if (visaInfo != null)
  2445. {
  2446. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2447. _detail.PriceNameContent = visaInfo.VisaDescription;
  2448. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2449. }
  2450. break;
  2451. case 81: //邀请/公务活动
  2452. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2453. if (_ioa != null)
  2454. {
  2455. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2456. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2457. sendCurrName = "Unknown", //快递费用币种 Name
  2458. sendCurrCode = "Unknown", //快递费用币种 Code
  2459. eventsCurrName = "Unknown", //公务活动费币种 Name
  2460. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2461. translateCurrName = "Unknown", //公务翻译费 Name
  2462. translateCurrCode = "Unknown"; //公务翻译费 Code
  2463. #region 处理费用币种
  2464. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2465. if (inviteCurrData != null)
  2466. {
  2467. inviteCurrName = inviteCurrData.Remark;
  2468. inviteCurrCode = inviteCurrData.Name;
  2469. }
  2470. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2471. if (sendCurrData != null)
  2472. {
  2473. sendCurrName = sendCurrData.Remark;
  2474. sendCurrCode = sendCurrData.Name;
  2475. }
  2476. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2477. if (eventsCurrData != null)
  2478. {
  2479. eventsCurrName = eventsCurrData.Remark;
  2480. eventsCurrCode = eventsCurrData.Name;
  2481. }
  2482. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2483. if (translateCurrData != null)
  2484. {
  2485. translateCurrName = translateCurrData.Remark;
  2486. translateCurrCode = translateCurrData.Name;
  2487. }
  2488. #endregion
  2489. _detail.PriceNameContent = _ioa.InviterArea;
  2490. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2491. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2492. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2493. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2494. $@"备注:" + _ioa.Remark + "<br/>";
  2495. }
  2496. break;
  2497. case 82: //团组客户保险
  2498. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2499. if (customers != null)
  2500. {
  2501. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2502. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2503. }
  2504. break;
  2505. case 85: //机票预订
  2506. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2507. if (jpRes != null)
  2508. {
  2509. string FlightsDescription = jpRes.FlightsDescription;
  2510. string PriceDescription = jpRes.PriceDescription;
  2511. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2512. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2513. }
  2514. break;
  2515. case 98://其他款项
  2516. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2517. if (gdpRes != null)
  2518. {
  2519. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2520. _detail.PriceNameContent = gdpRes.PriceName;
  2521. }
  2522. break;
  2523. case 285://收款退还
  2524. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2525. if (refundAndOtherMoney != null)
  2526. {
  2527. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2528. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2529. }
  2530. break;
  2531. case 751://酒店早餐
  2532. break;
  2533. case 1015://超支费用
  2534. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2535. if (groupExtraCost != null)
  2536. {
  2537. _detail.PriceNameContent = groupExtraCost.PriceName;
  2538. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2539. }
  2540. break;
  2541. default:
  2542. break;
  2543. }
  2544. /*
  2545. * 申请人
  2546. */
  2547. string operatorName = " - ";
  2548. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2549. if (_opUser != null)
  2550. {
  2551. operatorName = _opUser.CnName;
  2552. }
  2553. _detail.OperatorName = operatorName;
  2554. /*
  2555. * 审核人
  2556. */
  2557. string auditOperatorName = "Unknown";
  2558. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2559. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2560. else
  2561. {
  2562. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2563. if (_adUser != null)
  2564. {
  2565. auditOperatorName = _adUser.CnName;
  2566. }
  2567. }
  2568. _detail.AuditOperatorName = auditOperatorName;
  2569. /*
  2570. * 超预算比例
  2571. */
  2572. string overBudgetStr = "";
  2573. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2574. else if (entity.ExceedBudget == 0)
  2575. {
  2576. if (entity.CTable == 76 || entity.CTable == 79)
  2577. {
  2578. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2579. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2580. }
  2581. else
  2582. {
  2583. overBudgetStr = "未超预算";
  2584. }
  2585. }
  2586. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2587. _detail.OverBudget = overBudgetStr;
  2588. decimal auditFee = 0.00M; //已审核金额 人名币
  2589. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2590. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2591. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2592. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2593. {
  2594. auditedFeeOriginal = entity.PayMoney;
  2595. auditFee = CurrPayStr;
  2596. }
  2597. else if (entity.IsAuditGM == 0)
  2598. {
  2599. unAuditFeeCNY = CurrPayStr;
  2600. unAuditFeeOriginal = OriginalCurrPay;
  2601. OriginalCurrPay = 0.00M;
  2602. }
  2603. /*
  2604. * 费用总计
  2605. */
  2606. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2607. {
  2608. CurrencyId = entity.PaymentCurrency,
  2609. CurrencyName = PaymentCurrency_WaitPay,
  2610. AmountPayable = entity.PayMoney,
  2611. ThisPayment = OriginalCurrPay,
  2612. BalancePayment = BalanceStr,
  2613. AuditedFunds = auditFee,
  2614. AuditedFundsOriginal = auditedFeeOriginal,
  2615. UnAuditFundsCNY = unAuditFeeCNY,
  2616. UnAuditFundsOriginal = unAuditFeeOriginal
  2617. });
  2618. _detail.IsAuditGM = entity.IsAuditGM;
  2619. detailList.Add(_detail);
  2620. }
  2621. #endregion
  2622. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2623. /*
  2624. * 下方描述处理
  2625. */
  2626. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2627. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2628. if (ccpCurrencyPrice != null)
  2629. {
  2630. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2631. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2632. }
  2633. else
  2634. {
  2635. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2636. }
  2637. string amountPayableStr = string.Format(@"应付款总金额: ");
  2638. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2639. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2640. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2641. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2642. foreach (var item in nonDuplicat)
  2643. {
  2644. var currencyName = item.CurrencyName;
  2645. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2646. if (strs.Count > 0)
  2647. {
  2648. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2649. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2650. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2651. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2652. //单独处理此次付款金额
  2653. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2654. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2655. //单独处理已审核费用
  2656. //if (item.CurrencyId == 836) //人民币
  2657. //{
  2658. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2659. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2660. //}
  2661. //else
  2662. //{
  2663. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2664. //}
  2665. if (currencyName.Equals("CNY"))
  2666. {
  2667. //已审核费用
  2668. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2669. //未审核费用
  2670. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2671. }
  2672. else
  2673. {
  2674. //已审核费用
  2675. auditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName, strs.Sum(x => x.AuditedFunds).ToString("#0.00"));
  2676. //未审核费用
  2677. unAuditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName, strs.Sum(x => x.UnAuditFundsCNY).ToString("#0.00"));
  2678. }
  2679. }
  2680. }
  2681. _view.TotalStr1 = amountPayableStr[..^1];
  2682. _view.TotalStr2 = thisPaymentStr[..^1];
  2683. _view.TotalStr3 = balancePaymentStr[..^1];
  2684. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  2685. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2686. var _view1 = new
  2687. {
  2688. PageFuncAuth = pageFunAuthView,
  2689. Data = _view
  2690. };
  2691. return Ok(JsonView(_view1));
  2692. }
  2693. catch (Exception ex)
  2694. {
  2695. return Ok(JsonView(false, ex.Message));
  2696. }
  2697. }
  2698. /// <summary>
  2699. /// 费用审核
  2700. /// 修改团组费用审核状态
  2701. /// </summary>
  2702. /// <param name="_dto">参数Json字符串</param>
  2703. /// <returns></returns>
  2704. [HttpPost]
  2705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2706. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2707. {
  2708. #region 参数验证
  2709. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2710. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2711. #endregion
  2712. #region 页面操作权限验证
  2713. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2714. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2715. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2716. #endregion
  2717. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2718. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2719. DateTime dtNow = DateTime.Now;
  2720. _groupRepository.BeginTran();
  2721. int rst = 0;
  2722. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2723. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2724. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2725. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2726. List<dynamic> msgDatas = new List<dynamic>();
  2727. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2728. foreach (var item in idList)
  2729. {
  2730. int CreditId = int.Parse(item);
  2731. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2732. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2733. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2734. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2735. .Where(s => s.Id == CreditId)
  2736. .ExecuteCommandAsync();
  2737. if (result < 1)
  2738. {
  2739. rst = -1;
  2740. _groupRepository.RollbackTran();
  2741. return Ok(JsonView(false, "操作失败并回滚!"));
  2742. }
  2743. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2744. if (creditData != null)
  2745. {
  2746. #region 应用通知配置
  2747. try
  2748. {
  2749. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2750. }
  2751. catch (Exception ex)
  2752. {
  2753. }
  2754. #endregion
  2755. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2756. string groupNameStr = string.Empty;
  2757. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2758. if (groupData != null) groupNameStr = groupData.TeamName;
  2759. string creditTypeStr = string.Empty;
  2760. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2761. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2762. string creditCurrency = string.Empty;
  2763. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2764. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2765. if (creditCurrency.Equals("CNY"))
  2766. {
  2767. creditData.DayRate = 1.0000M;
  2768. }
  2769. if (creditData.PayPercentage == 0.00M)
  2770. {
  2771. creditData.PayPercentage = 100M;
  2772. }
  2773. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2774. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2775. string msgContent = "";
  2776. if (creditCurrency.Equals("CNY"))
  2777. {
  2778. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2779. }
  2780. else
  2781. {
  2782. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2783. }
  2784. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2785. }
  2786. }
  2787. if (rst == 0)
  2788. {
  2789. _groupRepository.CommitTran();
  2790. foreach (var item in msgDatas)
  2791. {
  2792. //发送消息
  2793. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2794. }
  2795. #region 应用推送
  2796. try
  2797. {
  2798. foreach (var ccpId in dic_ccp_user.Keys)
  2799. {
  2800. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2801. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2802. }
  2803. }
  2804. catch (Exception)
  2805. {
  2806. }
  2807. #endregion
  2808. return Ok(JsonView(true, "操作成功!"));
  2809. }
  2810. return Ok(JsonView(false, "操作失败!"));
  2811. }
  2812. #endregion
  2813. #region 机票费用录入
  2814. /// <summary>
  2815. /// 机票录入当前登录人可操作团组
  2816. /// </summary>
  2817. /// <param name="dto"></param>
  2818. /// <returns></returns>
  2819. [HttpPost]
  2820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2821. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2822. {
  2823. try
  2824. {
  2825. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2826. if (groupData.Code != 0)
  2827. {
  2828. return Ok(JsonView(false, groupData.Msg));
  2829. }
  2830. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2831. }
  2832. catch (Exception ex)
  2833. {
  2834. return Ok(JsonView(false, "程序错误!"));
  2835. throw;
  2836. }
  2837. }
  2838. /// <summary>
  2839. /// 机票费用录入列表
  2840. /// </summary>
  2841. /// <param name="dto"></param>
  2842. /// <returns></returns>
  2843. [HttpPost]
  2844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2845. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2846. {
  2847. try
  2848. {
  2849. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2850. if (groupData.Code != 0)
  2851. {
  2852. return Ok(JsonView(false, groupData.Msg));
  2853. }
  2854. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2855. }
  2856. catch (Exception ex)
  2857. {
  2858. return Ok(JsonView(false, ex.Message));
  2859. throw;
  2860. }
  2861. }
  2862. /// <summary>
  2863. /// 根据id查询费用录入信息
  2864. /// </summary>
  2865. /// <param name="dto"></param>
  2866. /// <returns></returns>
  2867. [HttpPost]
  2868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2869. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2870. {
  2871. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2872. if (groupData.Code != 0)
  2873. {
  2874. return Ok(JsonView(false, groupData.Msg));
  2875. }
  2876. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2877. }
  2878. /// <summary>
  2879. /// 机票费用录入操作(Status:1.新增,2.修改)
  2880. /// </summary>
  2881. /// <param name="dto"></param>
  2882. /// <returns></returns>
  2883. [HttpPost]
  2884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2885. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2886. {
  2887. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2888. if (groupData.Code != 0)
  2889. {
  2890. return Ok(JsonView(false, groupData.Msg));
  2891. }
  2892. #region 应用推送
  2893. try
  2894. {
  2895. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2896. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2897. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2898. //2024-10-21 新增LZ UID
  2899. var userIds = new List<int>() { 21 };
  2900. string title = $"系统通知";
  2901. string content = "";
  2902. var diId = dto.AirTicketResOpData.DiId;
  2903. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2904. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2905. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2906. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2907. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2908. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2909. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2910. }
  2911. catch (Exception ex)
  2912. {
  2913. }
  2914. #endregion
  2915. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2916. }
  2917. /// <summary>
  2918. /// 根据舱位类型查询接团客户名单信息
  2919. /// </summary>
  2920. /// <param name="dto"></param>
  2921. /// <returns></returns>
  2922. [HttpPost]
  2923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2924. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2925. {
  2926. try
  2927. {
  2928. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2929. if (crm_Groups.Count != 0)
  2930. {
  2931. List<dynamic> Customer = new List<dynamic>();
  2932. foreach (var item in crm_Groups)
  2933. {
  2934. var data = new
  2935. {
  2936. Id = item.Id,
  2937. Pinyin = item.Pinyin,
  2938. Name = item.LastName + item.FirstName
  2939. };
  2940. Customer.Add(data);
  2941. }
  2942. return Ok(JsonView(true, "查询成功!", Customer));
  2943. }
  2944. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2945. }
  2946. catch (Exception ex)
  2947. {
  2948. return Ok(JsonView(false, "程序错误!"));
  2949. throw;
  2950. }
  2951. }
  2952. /// <summary>
  2953. /// 根据团号获取客户信息
  2954. /// </summary>
  2955. /// <param name="dto"></param>
  2956. /// <returns></returns>
  2957. [HttpPost]
  2958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2959. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2960. {
  2961. var jw = JsonView(false);
  2962. if (dto.DIID < 1)
  2963. {
  2964. jw.Msg += "请输入正确的diid";
  2965. return Ok(jw);
  2966. }
  2967. var arr = getSimplClientList(dto.DIID);
  2968. jw = JsonView(true, "获取成功!", arr);
  2969. return Ok(jw);
  2970. }
  2971. private List<SimplClientInfo> getSimplClientList(int diId)
  2972. {
  2973. 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);
  2974. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2975. foreach (var item in arr)
  2976. {
  2977. EncryptionProcessor.DecryptProperties(item);
  2978. }
  2979. return arr;
  2980. }
  2981. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2982. {
  2983. string result = origin;
  2984. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2985. {
  2986. string[] temparr = origin.Split(',');
  2987. string fistrStr = temparr[0];
  2988. int count = temparr.Count();
  2989. int tempId;
  2990. bool success = int.TryParse(fistrStr, out tempId);
  2991. if (success)
  2992. {
  2993. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2994. if (tempInfo != null)
  2995. {
  2996. if (count > 1)
  2997. {
  2998. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2999. }
  3000. else
  3001. {
  3002. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  3003. }
  3004. }
  3005. }
  3006. }
  3007. return result;
  3008. }
  3009. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  3010. {
  3011. string result = origin;
  3012. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3013. {
  3014. string[] temparr = origin.Split(',');
  3015. result = "";
  3016. foreach (var item in temparr)
  3017. {
  3018. int tempId;
  3019. bool success = int.TryParse(item, out tempId);
  3020. if (success)
  3021. {
  3022. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3023. if (tempInfo != null)
  3024. {
  3025. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  3026. }
  3027. }
  3028. }
  3029. }
  3030. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  3031. return result;
  3032. }
  3033. /// <summary>
  3034. /// 机票费用录入,删除
  3035. /// </summary>
  3036. /// <param name="dto"></param>
  3037. /// <returns></returns>
  3038. [HttpPost]
  3039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3040. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  3041. {
  3042. try
  3043. {
  3044. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3045. if (res)
  3046. {
  3047. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  3048. {
  3049. IsDel = 1,
  3050. DeleteUserId = dto.DeleteUserId,
  3051. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3052. }).ExecuteCommandAsync();
  3053. return Ok(JsonView(true, "删除成功!"));
  3054. }
  3055. return Ok(JsonView(false, "删除失败!"));
  3056. }
  3057. catch (Exception ex)
  3058. {
  3059. return Ok(JsonView(false, "程序错误!"));
  3060. throw;
  3061. }
  3062. }
  3063. /// <summary>
  3064. /// 导出机票录入报表
  3065. /// </summary>
  3066. /// <param name="dto"></param>
  3067. /// <returns></returns>
  3068. [HttpPost]
  3069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3070. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  3071. {
  3072. try
  3073. {
  3074. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  3075. if (groupData.Code != 0)
  3076. {
  3077. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3078. }
  3079. else
  3080. {
  3081. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  3082. if (AirTicketReservations.Count != 0)
  3083. {
  3084. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  3085. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  3086. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  3087. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  3088. WorkbookDesigner designer = new WorkbookDesigner();
  3089. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  3090. decimal countCost = 0;
  3091. foreach (var item in AirTicketReservations)
  3092. {
  3093. #region 处理客人姓名
  3094. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  3095. item.ClientName = clientNames;
  3096. #endregion
  3097. if (item.BankType == "其他")
  3098. {
  3099. item.BankNo = "--";
  3100. }
  3101. else
  3102. {
  3103. if (!string.IsNullOrEmpty(item.BankType))
  3104. {
  3105. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  3106. }
  3107. }
  3108. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  3109. item.Price = System.Decimal.Round(item.Price, 2);
  3110. countCost += Convert.ToDecimal(item.Price);
  3111. }
  3112. designer.SetDataSource("Export", AirTicketReservations);
  3113. designer.SetDataSource("ExportDiCode", diCode);
  3114. designer.SetDataSource("ExportDiName", diName);
  3115. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  3116. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  3117. designer.Process();
  3118. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  3119. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3120. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3121. return Ok(JsonView(true, "成功", url = rst));
  3122. }
  3123. else
  3124. {
  3125. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  3126. }
  3127. }
  3128. }
  3129. catch (Exception ex)
  3130. {
  3131. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  3132. throw;
  3133. }
  3134. }
  3135. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3136. /// <summary>
  3137. /// 行程单导出
  3138. /// </summary>
  3139. /// <param name="dto"></param>
  3140. /// <returns></returns>
  3141. [HttpPost]
  3142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3143. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  3144. {
  3145. try
  3146. {
  3147. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  3148. if (groupData.Code != 0)
  3149. {
  3150. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3151. }
  3152. else
  3153. {
  3154. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3155. if (dto.Language == "CN")
  3156. {
  3157. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3158. DocumentBuilder builder = new DocumentBuilder(doc);
  3159. int tableIndex = 0;//表格索引
  3160. //得到文档中的第一个表格
  3161. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3162. foreach (var item in _AirTicketReservations)
  3163. {
  3164. #region 处理固定数据
  3165. string[] FlightsCode = item.FlightsCode.Split('/');
  3166. if (FlightsCode.Length != 0)
  3167. {
  3168. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3169. if (_AirCompany != null)
  3170. {
  3171. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3172. }
  3173. else
  3174. {
  3175. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3176. }
  3177. }
  3178. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3179. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3180. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3181. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3182. string name = "";
  3183. foreach (string clientName in nameArray)
  3184. {
  3185. if (!name.Contains(clientName))
  3186. {
  3187. name += clientName + ",";
  3188. }
  3189. }
  3190. if (!string.IsNullOrWhiteSpace(name))
  3191. {
  3192. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3193. }
  3194. else
  3195. {
  3196. table.Range.Bookmarks["ClientName"].Text = "--";
  3197. }
  3198. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3199. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3200. table.Range.Bookmarks["JointTicket"].Text = "--";
  3201. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3202. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3203. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3204. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3205. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3206. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3207. #endregion
  3208. #region 循环数据处理
  3209. List<AirInfo> airs = new List<AirInfo>();
  3210. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3211. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3212. for (int i = 0; i < FlightsCode.Length; i++)
  3213. {
  3214. AirInfo air = new AirInfo();
  3215. string[] tempstr = DayArray[i]
  3216. .Replace("\r\n", string.Empty)
  3217. .Replace("\\r\\n", string.Empty)
  3218. .TrimStart().TrimEnd()
  3219. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3220. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3221. string starCity = "";
  3222. if (star_Three != null)
  3223. {
  3224. starCity = star_Three.AirPort;
  3225. }
  3226. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3227. string EndCity = "";
  3228. if (End_Three != null)
  3229. {
  3230. EndCity = End_Three.AirPort;
  3231. }
  3232. air.Destination = starCity + "/" + EndCity;
  3233. air.Flight = FlightsCode[i];
  3234. air.SeatingClass = item.CTypeName;
  3235. string dateTime = tempstr[2];
  3236. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3237. air.FlightDate = DateTemp;
  3238. air.DepartureTime = tempstr[5];
  3239. air.LandingTime = tempstr[6];
  3240. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3241. air.TicketStatus = "--";
  3242. air.Luggage = "--";
  3243. air.DepartureTerminal = "--";
  3244. air.LandingTerminal = "--";
  3245. airs.Add(air);
  3246. }
  3247. int row = 13;
  3248. for (int i = 0; i < airs.Count; i++)
  3249. {
  3250. if (airs.Count > 2)
  3251. {
  3252. for (int j = 0; j < airs.Count - 2; j++)
  3253. {
  3254. var CopyRow = table.Rows[12].Clone(true);
  3255. table.Rows.Add(CopyRow);
  3256. }
  3257. }
  3258. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3259. int index = 0;
  3260. foreach (PropertyInfo property in properties)
  3261. {
  3262. string value = property.GetValue(airs[i]).ToString();
  3263. Cell ishcel0 = table.Rows[row].Cells[index];
  3264. Paragraph p = new Paragraph(doc);
  3265. string s = value;
  3266. p.AppendChild(new Run(doc, s));
  3267. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3268. ishcel0.AppendChild(p);
  3269. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3270. index++;
  3271. }
  3272. row++;
  3273. }
  3274. #endregion
  3275. Paragraph lastParagraph = new Paragraph(doc);
  3276. //第一个表格末尾加段落
  3277. table.ParentNode.InsertAfter(lastParagraph, table);
  3278. //复制第一个表格
  3279. Table cloneTable = (Table)table.Clone(true);
  3280. //在文档末尾段落后面加入复制的表格
  3281. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3282. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3283. {
  3284. int rownewsIndex = 13;
  3285. for (int i = 0; i < 2; i++)
  3286. {
  3287. var CopyRow = table.Rows[12].Clone(true);
  3288. table.Rows.RemoveAt(13);
  3289. table.Rows.Add(CopyRow);
  3290. rownewsIndex++;
  3291. }
  3292. }
  3293. else
  3294. {
  3295. table.Rows.RemoveAt(12);
  3296. }
  3297. cloneTable.Rows.RemoveAt(12);
  3298. }
  3299. if (_AirTicketReservations.Count != 0)
  3300. {
  3301. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3302. if (FlightsCode.Length != 0)
  3303. {
  3304. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3305. if (_AirCompany != null)
  3306. {
  3307. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3308. }
  3309. else
  3310. {
  3311. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3312. }
  3313. }
  3314. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3315. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3316. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3317. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3318. string name = "";
  3319. foreach (string clientName in nameArray)
  3320. {
  3321. if (!name.Contains(clientName))
  3322. {
  3323. name += clientName + ",";
  3324. }
  3325. }
  3326. if (!string.IsNullOrWhiteSpace(name))
  3327. {
  3328. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3329. }
  3330. else
  3331. {
  3332. table.Range.Bookmarks["ClientName"].Text = "--";
  3333. }
  3334. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3335. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3336. table.Range.Bookmarks["JointTicket"].Text = "--";
  3337. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3338. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3339. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3340. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3341. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3342. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3343. }
  3344. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3345. //保存合并后的文档
  3346. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3347. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3348. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3349. return Ok(JsonView(true, "成功!", rst));
  3350. }
  3351. else
  3352. {
  3353. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3354. DocumentBuilder builder = new DocumentBuilder(doc);
  3355. int tableIndex = 0;//表格索引
  3356. //得到文档中的第一个表格
  3357. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3358. List<string> texts = new List<string>();
  3359. foreach (var item in _AirTicketReservations)
  3360. {
  3361. string[] FlightsCode = item.FlightsCode.Split('/');
  3362. if (FlightsCode.Length != 0)
  3363. {
  3364. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3365. if (_AirCompany != null)
  3366. {
  3367. if (!transDic.ContainsKey(_AirCompany.CnName))
  3368. {
  3369. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3370. }
  3371. }
  3372. else
  3373. {
  3374. if (!transDic.ContainsKey("--"))
  3375. {
  3376. transDic.Add("--", "--");
  3377. }
  3378. }
  3379. }
  3380. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3381. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3382. string name = "";
  3383. foreach (string clientName in nameArray)
  3384. {
  3385. name += clientName + ",";
  3386. }
  3387. if (!texts.Contains(name))
  3388. {
  3389. texts.Add(name);
  3390. }
  3391. List<AirInfo> airs = new List<AirInfo>();
  3392. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3393. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3394. for (int i = 0; i < FlightsCode.Length; i++)
  3395. {
  3396. AirInfo air = new AirInfo();
  3397. string[] tempstr = DayArray[i]
  3398. .Replace("\r\n", string.Empty)
  3399. .Replace("\\r\\n", string.Empty)
  3400. .TrimStart().TrimEnd()
  3401. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3402. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3403. if (star_Three != null)
  3404. {
  3405. if (!transDic.ContainsKey(star_Three.AirPort))
  3406. {
  3407. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3408. }
  3409. }
  3410. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3411. if (End_Three != null)
  3412. {
  3413. if (!transDic.ContainsKey(End_Three.AirPort))
  3414. {
  3415. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3416. }
  3417. }
  3418. if (!texts.Contains(item.CTypeName))
  3419. {
  3420. texts.Add(item.CTypeName);
  3421. }
  3422. }
  3423. }
  3424. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  3425. if (transData.Count > 0)
  3426. {
  3427. foreach (TranslateResult item in transData)
  3428. {
  3429. if (!transDic.ContainsKey(item.Query))
  3430. {
  3431. transDic.Add(item.Query, item.Translation);
  3432. }
  3433. }
  3434. }
  3435. foreach (var item in _AirTicketReservations)
  3436. {
  3437. #region 处理固定数据
  3438. string[] FlightsCode = item.FlightsCode.Split('/');
  3439. if (FlightsCode.Length != 0)
  3440. {
  3441. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3442. if (_AirCompany != null)
  3443. {
  3444. string str = "--";
  3445. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3446. if (!string.IsNullOrEmpty(translateResult))
  3447. {
  3448. str = translateResult;
  3449. str = _airTicketResRep.Processing(str);
  3450. }
  3451. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3452. }
  3453. else
  3454. {
  3455. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3456. }
  3457. }
  3458. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3459. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3460. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3461. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3462. string names = "";
  3463. foreach (string clientName in nameArray)
  3464. {
  3465. names += clientName + ",";
  3466. }
  3467. if (!string.IsNullOrWhiteSpace(names))
  3468. {
  3469. string str = "--";
  3470. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3471. if (!string.IsNullOrEmpty(translateResult))
  3472. {
  3473. str = translateResult;
  3474. str = _airTicketResRep.Processing(str);
  3475. }
  3476. table.Range.Bookmarks["ClientName"].Text = str;
  3477. }
  3478. else
  3479. {
  3480. table.Range.Bookmarks["ClientName"].Text = "--";
  3481. }
  3482. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3483. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3484. table.Range.Bookmarks["JointTicket"].Text = "--";
  3485. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3486. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3487. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3488. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3489. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3490. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3491. #endregion
  3492. #region 循环数据处理
  3493. List<AirInfo> airs = new List<AirInfo>();
  3494. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3495. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3496. for (int i = 0; i < FlightsCode.Length; i++)
  3497. {
  3498. AirInfo air = new AirInfo();
  3499. string[] tempstr = DayArray[i]
  3500. .Replace("\r\n", string.Empty)
  3501. .Replace("\\r\\n", string.Empty)
  3502. .TrimStart().TrimEnd()
  3503. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3504. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3505. string starCity = "";
  3506. if (star_Three != null)
  3507. {
  3508. string str2 = "--";
  3509. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3510. if (!string.IsNullOrEmpty(translateResult2))
  3511. {
  3512. str2 = translateResult2;
  3513. str2 = _airTicketResRep.Processing(str2);
  3514. }
  3515. starCity = str2;
  3516. }
  3517. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3518. string EndCity = "";
  3519. if (End_Three != null)
  3520. {
  3521. string str1 = "--";
  3522. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3523. if (!string.IsNullOrEmpty(translateResult1))
  3524. {
  3525. str1 = translateResult1;
  3526. str1 = _airTicketResRep.Processing(str1);
  3527. }
  3528. EndCity = str1;
  3529. }
  3530. air.Destination = starCity + "/" + EndCity;
  3531. air.Flight = FlightsCode[i];
  3532. string str = "--";
  3533. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3534. if (!string.IsNullOrEmpty(translateResult))
  3535. {
  3536. str = translateResult;
  3537. str = _airTicketResRep.Processing(str);
  3538. }
  3539. air.SeatingClass = str;
  3540. string dateTime = tempstr[2];
  3541. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3542. air.FlightDate = DateTemp;
  3543. air.DepartureTime = tempstr[5];
  3544. air.LandingTime = tempstr[6];
  3545. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3546. air.TicketStatus = "--";
  3547. air.Luggage = "--";
  3548. air.DepartureTerminal = "--";
  3549. air.LandingTerminal = "--";
  3550. airs.Add(air);
  3551. }
  3552. int row = 13;
  3553. for (int i = 0; i < airs.Count; i++)
  3554. {
  3555. if (airs.Count > 2)
  3556. {
  3557. for (int j = 0; j < airs.Count - 2; j++)
  3558. {
  3559. var CopyRow = table.Rows[12].Clone(true);
  3560. table.Rows.Add(CopyRow);
  3561. }
  3562. }
  3563. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3564. int index = 0;
  3565. foreach (PropertyInfo property in properties)
  3566. {
  3567. string value = property.GetValue(airs[i]).ToString();
  3568. Cell ishcel0 = table.Rows[row].Cells[index];
  3569. Paragraph p = new Paragraph(doc);
  3570. string s = value;
  3571. p.AppendChild(new Run(doc, s));
  3572. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3573. ishcel0.AppendChild(p);
  3574. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3575. //ishcel0.CellFormat.VerticalAlignment=
  3576. index++;
  3577. }
  3578. row++;
  3579. }
  3580. #endregion
  3581. Paragraph lastParagraph = new Paragraph(doc);
  3582. //第一个表格末尾加段落
  3583. table.ParentNode.InsertAfter(lastParagraph, table);
  3584. //复制第一个表格
  3585. Table cloneTable = (Table)table.Clone(true);
  3586. //在文档末尾段落后面加入复制的表格
  3587. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3588. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3589. {
  3590. int rownewsIndex = 13;
  3591. for (int i = 0; i < 2; i++)
  3592. {
  3593. var CopyRow = table.Rows[12].Clone(true);
  3594. table.Rows.RemoveAt(13);
  3595. table.Rows.Add(CopyRow);
  3596. rownewsIndex++;
  3597. }
  3598. }
  3599. else
  3600. {
  3601. table.Rows.RemoveAt(12);
  3602. }
  3603. cloneTable.Rows.RemoveAt(12);
  3604. }
  3605. if (_AirTicketReservations.Count != 0)
  3606. {
  3607. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3608. if (FlightsCode.Length != 0)
  3609. {
  3610. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3611. if (_AirCompany != null)
  3612. {
  3613. string str = "--";
  3614. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3615. if (!string.IsNullOrEmpty(translateResult))
  3616. {
  3617. str = translateResult;
  3618. str = _airTicketResRep.Processing(str);
  3619. }
  3620. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3621. }
  3622. else
  3623. {
  3624. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3625. }
  3626. }
  3627. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3628. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3629. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3630. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3631. string names = "";
  3632. foreach (string clientName in nameArray)
  3633. {
  3634. names += clientName + ",";
  3635. }
  3636. if (!string.IsNullOrWhiteSpace(names))
  3637. {
  3638. string str = "--";
  3639. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3640. if (!string.IsNullOrEmpty(translateResult))
  3641. {
  3642. str = translateResult;
  3643. str = _airTicketResRep.Processing(str);
  3644. }
  3645. table.Range.Bookmarks["ClientName"].Text = str;
  3646. }
  3647. else
  3648. {
  3649. table.Range.Bookmarks["ClientName"].Text = "--";
  3650. }
  3651. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3652. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3653. table.Range.Bookmarks["JointTicket"].Text = "--";
  3654. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3655. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3656. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3657. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3658. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3659. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3660. }
  3661. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3662. //保存合并后的文档
  3663. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3664. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3665. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3666. return Ok(JsonView(true, "成功!", rst));
  3667. }
  3668. }
  3669. }
  3670. catch (Exception ex)
  3671. {
  3672. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3673. throw;
  3674. }
  3675. }
  3676. #endregion
  3677. #region 团组增减款项 --> 其他款项
  3678. /// <summary>
  3679. /// 团组增减款项下拉框绑定
  3680. /// </summary>
  3681. /// <param name="dto"></param>
  3682. /// <returns></returns>
  3683. [HttpPost]
  3684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3685. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3686. {
  3687. #region 参数验证
  3688. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3689. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3690. #endregion
  3691. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3692. }
  3693. /// <summary>
  3694. /// 根据团组Id查询团组增减款项
  3695. /// </summary>
  3696. /// <param name="dto"></param>
  3697. /// <returns></returns>
  3698. [HttpPost]
  3699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3700. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3701. {
  3702. #region 参数验证
  3703. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3704. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3705. #endregion
  3706. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3707. }
  3708. /// <summary>
  3709. /// 团组增减款项操作(Status:1.新增,2.修改)
  3710. /// </summary>
  3711. /// <param name="dto"></param>
  3712. /// <returns></returns>
  3713. [HttpPost]
  3714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3715. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3716. {
  3717. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3718. if (groupData.Code != 200)
  3719. {
  3720. return Ok(JsonView(false, groupData.Msg));
  3721. }
  3722. #region 应用推送
  3723. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3724. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3725. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3726. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  3727. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  3728. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  3729. //自动审核
  3730. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3731. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3732. //2024-10-21 新增LZ UID
  3733. var userIds = new List<int>() { 21 };
  3734. string title = $"系统通知";
  3735. string content = "";
  3736. var diId = dto.DiId;
  3737. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3738. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3739. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3740. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3741. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3742. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3743. #endregion
  3744. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3745. }
  3746. /// <summary>
  3747. /// 团组增减款项操作 删除
  3748. /// </summary>
  3749. /// <param name="dto"></param>
  3750. /// <returns></returns>
  3751. [HttpPost]
  3752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3753. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3754. {
  3755. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3756. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3757. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3758. if (res.Code == 0)
  3759. {
  3760. return Ok(JsonView(true, "删除成功!"));
  3761. }
  3762. return Ok(JsonView(false, "删除失败!"));
  3763. }
  3764. /// <summary>
  3765. /// 根据团组增减款项Id查询
  3766. /// </summary>
  3767. /// <param name="dto"></param>
  3768. /// <returns></returns>
  3769. [HttpPost]
  3770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3771. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3772. {
  3773. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3774. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3775. }
  3776. /// <summary>
  3777. /// 查询供应商名称
  3778. /// </summary>
  3779. /// <param name="dto"></param>
  3780. /// <returns></returns>
  3781. [HttpPost]
  3782. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3783. {
  3784. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3785. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3786. ?? new List<Grp_DecreasePayments>();
  3787. dbResult = dbResult.Distinct(new
  3788. ProductComparer()).ToList();
  3789. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3790. {
  3791. x.Id,
  3792. x.SupplierAddress,
  3793. x.SupplierArea,
  3794. x.SupplierContact,
  3795. x.SupplierContactNumber,
  3796. x.SupplierEmail,
  3797. x.SupplierName,
  3798. x.SupplierSocialAccount,
  3799. x.SupplierTypeId,
  3800. }).ToList());
  3801. return Ok(jw);
  3802. }
  3803. /// <summary>
  3804. /// 团组增减款项 OTA匹配
  3805. /// </summary>
  3806. /// <param name="file"></param>
  3807. /// <returns></returns>
  3808. [HttpPost]
  3809. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3810. {
  3811. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3812. string fileName = file.FileName;
  3813. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3814. {
  3815. return Ok(JsonView(false, "请上传Excel文件!"));
  3816. }
  3817. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3818. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3819. if (!Directory.Exists(path))
  3820. {
  3821. Directory.CreateDirectory(path);
  3822. }
  3823. var filePath = @$"{path}/{fileName}";
  3824. //保存文件
  3825. using (FileStream fs = System.IO.File.Create(filePath))
  3826. {
  3827. file.CopyTo(fs);
  3828. fs.Flush();
  3829. }
  3830. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3831. //读取ExcelFile
  3832. DataTable dt = ConvertExcelToDataTable(filePath);
  3833. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3834. dt.TableName = "TB";
  3835. //修改table列名
  3836. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3837. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3838. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3839. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3840. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3841. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3842. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3843. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3844. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3845. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3846. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3847. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3848. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3849. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3850. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3851. var otaOrderNos = new List<string>();
  3852. foreach (DataRow item in dt.Rows)
  3853. {
  3854. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3855. }
  3856. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3857. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3858. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3859. .Select((dp, di) => new
  3860. {
  3861. dp.PriceName,
  3862. dp.OTAOrderNo,
  3863. dp.FeeTotal,
  3864. di.TeamName,
  3865. })
  3866. .ToListAsync();
  3867. foreach (DataRow item in dt.Rows)
  3868. {
  3869. var otaOrderNo = item["OTAOrderNo"].ToString();
  3870. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3871. if (oaData == null) continue;
  3872. item["GroupName"] = oaData.TeamName;
  3873. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3874. }
  3875. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3876. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3877. List<DataTable> datas = new List<DataTable>();
  3878. datas.Add(dt);
  3879. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3880. return Ok(JsonView(true, "操作成功", new { url = url }));
  3881. }
  3882. #region
  3883. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3884. {
  3885. // 创建Workbook对象
  3886. Workbook workbook = new Workbook(excelFilePath);
  3887. // 获取第一个工作表
  3888. Worksheet worksheet = workbook.Worksheets[0];
  3889. // 将工作表转换为DataTable
  3890. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3891. return dataTable;
  3892. }
  3893. #endregion
  3894. #endregion
  3895. #region 文件上传、删除
  3896. /// <summary>
  3897. /// region 文件上传 可以带参数
  3898. /// </summary>
  3899. /// <param name="file"></param>
  3900. /// <returns></returns>
  3901. [HttpPost]
  3902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3903. public async Task<IActionResult> UploadProject(IFormFile file)
  3904. {
  3905. //var TypeName = Request.Headers["TypeName"].ToString();
  3906. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3907. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3908. ////文件名称
  3909. //string projectFileName = file.FileName;
  3910. ////上传的文件的路径
  3911. //string filePath = $"{fileDir}/{projectFileName}";
  3912. //if (TypeName == "A")//A代表团组增减款项
  3913. //{
  3914. // filePath = fileDir + $@"\团组增减款项相关文件";
  3915. // if (!Directory.Exists(filePath))
  3916. // {
  3917. // Directory.CreateDirectory(filePath);
  3918. // }
  3919. // //上传的文件的路径
  3920. // filePath += $@"\{projectFileName}";
  3921. //}
  3922. //else if (TypeName == "B")//B代表商邀相关文件
  3923. //{
  3924. // //上传的文件的路径
  3925. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3926. // if (!Directory.Exists(filePath))
  3927. // {
  3928. // Directory.CreateDirectory(filePath);
  3929. // }
  3930. // //上传的文件的路径
  3931. // filePath = $@"\{projectFileName}";
  3932. //}
  3933. //try
  3934. //{
  3935. // using (FileStream fs = System.IO.File.Create(filePath))
  3936. // {
  3937. // file.CopyTo(fs);
  3938. // fs.Flush();
  3939. // }
  3940. //}
  3941. //catch (Exception ex)
  3942. //{
  3943. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3944. //}
  3945. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3946. try
  3947. {
  3948. var TypeName = Request.Headers["TypeName"].ToString();
  3949. if (file != null)
  3950. {
  3951. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3952. //文件名称
  3953. string projectFileName = file.FileName;
  3954. //上传的文件的路径
  3955. string filePath = $"{fileDir}/{projectFileName}";
  3956. if (TypeName == "A")//A代表团组增减款项
  3957. {
  3958. if (!Directory.Exists(fileDir))
  3959. {
  3960. Directory.CreateDirectory(fileDir);
  3961. }
  3962. //上传的文件的路径
  3963. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3964. }
  3965. else if (TypeName == "B")//B代表商邀相关文件
  3966. {
  3967. if (!Directory.Exists(fileDir))
  3968. {
  3969. Directory.CreateDirectory(fileDir);
  3970. }
  3971. //上传的文件的路径
  3972. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3973. }
  3974. using (FileStream fs = System.IO.File.Create(filePath))
  3975. {
  3976. file.CopyTo(fs);
  3977. fs.Flush();
  3978. }
  3979. return Ok(JsonView(true, "上传成功!", projectFileName));
  3980. }
  3981. else
  3982. {
  3983. return Ok(JsonView(false, "上传失败!"));
  3984. }
  3985. }
  3986. catch (Exception ex)
  3987. {
  3988. return Ok(JsonView(false, "程序错误!"));
  3989. }
  3990. }
  3991. /// <summary>
  3992. /// 删除指定文件
  3993. /// </summary>
  3994. /// <param name="dto"></param>
  3995. /// <returns></returns>
  3996. [HttpPost]
  3997. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3998. public async Task<IActionResult> DelFile(DelFileDto dto)
  3999. {
  4000. try
  4001. {
  4002. var TypeName = Request.Headers["TypeName"].ToString();
  4003. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4004. string filePath = "";
  4005. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4006. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4007. int id = 0;
  4008. if (TypeName == "A")
  4009. {
  4010. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  4011. // 删除该文件
  4012. System.IO.File.Delete(filePath);
  4013. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  4014. .Where(a => a.Id == dto.Id)
  4015. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  4016. .ExecuteCommandAsync();
  4017. }
  4018. else if (TypeName == "B")
  4019. {
  4020. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  4021. // 删除该文件
  4022. System.IO.File.Delete(filePath);
  4023. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  4024. if (info != null)
  4025. {
  4026. string[] files = new string[] { };
  4027. if (!string.IsNullOrEmpty(info.Attachment))
  4028. {
  4029. try
  4030. {
  4031. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  4032. }
  4033. catch (Exception)
  4034. {
  4035. files = new List<string>() { info.Attachment }.ToArray();
  4036. }
  4037. }
  4038. if (files.Length > 0)
  4039. {
  4040. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  4041. string filePath2 = string.Empty;
  4042. if (files1.Length > 0)
  4043. {
  4044. filePath2 = JsonConvert.SerializeObject(files1);
  4045. }
  4046. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4047. .Where(a => a.Id == dto.Id)
  4048. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  4049. .ExecuteCommandAsync();
  4050. }
  4051. }
  4052. }
  4053. if (id != 0)
  4054. {
  4055. return Ok(JsonView(true, "成功!"));
  4056. }
  4057. else
  4058. {
  4059. return Ok(JsonView(false, "失败!"));
  4060. }
  4061. }
  4062. catch (Exception ex)
  4063. {
  4064. return Ok(JsonView(false, "程序错误!"));
  4065. throw;
  4066. }
  4067. }
  4068. /// <summary>
  4069. /// 文件上传多个文件 可以带参数
  4070. /// </summary>
  4071. /// <param name="files"></param>
  4072. /// <returns></returns>
  4073. [HttpPost]
  4074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4075. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  4076. {
  4077. try
  4078. {
  4079. var TypeName = Request.Headers["TypeName"].ToString();
  4080. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4081. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  4082. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4083. var filePahts = new List<string>();
  4084. foreach (var file in files)
  4085. {
  4086. //文件名称
  4087. string projectFileName = file.FileName;
  4088. //上传的文件的路径
  4089. string filePath = $"{fileDir}/{projectFileName}";
  4090. if (TypeName == "A")//A代表团组增减款项
  4091. {
  4092. if (!Directory.Exists(fileDir))
  4093. {
  4094. Directory.CreateDirectory(fileDir);
  4095. }
  4096. //上传的文件的路径
  4097. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4098. }
  4099. else if (TypeName == "B")//B代表商邀相关文件
  4100. {
  4101. if (!Directory.Exists(fileDir))
  4102. {
  4103. Directory.CreateDirectory(fileDir);
  4104. }
  4105. //上传的文件的路径
  4106. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4107. }
  4108. using (FileStream fs = System.IO.File.Create(filePath))
  4109. {
  4110. file.CopyTo(fs);
  4111. fs.Flush();
  4112. }
  4113. filePahts.Add(projectFileName);
  4114. }
  4115. return Ok(JsonView(true, "上传成功!", filePahts));
  4116. }
  4117. catch (Exception ex)
  4118. {
  4119. return Ok(JsonView(false, "程序错误!"));
  4120. }
  4121. }
  4122. #endregion
  4123. #region 商邀费用录入
  4124. /// <summary>
  4125. /// 根据团组Id查询商邀费用列表
  4126. /// </summary>
  4127. /// <param name="dto"></param>
  4128. /// <returns></returns>
  4129. [HttpPost]
  4130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4131. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  4132. {
  4133. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  4134. if (groupData.Code != 0)
  4135. {
  4136. return Ok(JsonView(false, groupData.Msg));
  4137. }
  4138. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4139. }
  4140. /// <summary>
  4141. /// 商邀费用列表
  4142. /// 下载文件
  4143. /// </summary>
  4144. /// <param name="id"></param>
  4145. /// <returns></returns>
  4146. [HttpGet("{id}")]
  4147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4148. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  4149. {
  4150. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4151. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4152. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4153. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4154. var filePaths = new List<string>();
  4155. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4156. try
  4157. {
  4158. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4159. }
  4160. catch (Exception ex)
  4161. {
  4162. filePaths.Add(info.Attachment);
  4163. }
  4164. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4165. for (int i = 0; i < filePaths.Count; i++)
  4166. {
  4167. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4168. }
  4169. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4170. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4171. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4172. {
  4173. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4174. {
  4175. foreach (string filePath in filePaths)
  4176. {
  4177. if (System.IO.File.Exists(filePath))
  4178. {
  4179. // 获取文件名
  4180. string fileName = Path.GetFileName(filePath);
  4181. // 将文件添加到ZIP归档中
  4182. zipArchive.CreateEntryFromFile(filePath, fileName);
  4183. }
  4184. }
  4185. }
  4186. }
  4187. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4188. }
  4189. /// <summary>
  4190. /// 商邀费用 Info Page 基础数据源
  4191. /// </summary>
  4192. /// <returns></returns>
  4193. [HttpPost]
  4194. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4195. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4196. {
  4197. try
  4198. {
  4199. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4200. if (groupData.Code != 0)
  4201. {
  4202. return Ok(JsonView(false, groupData.Msg));
  4203. }
  4204. return Ok(JsonView(true, "操作成功", groupData.Data));
  4205. }
  4206. catch (Exception ex)
  4207. {
  4208. return Ok(JsonView(false, ex.Message));
  4209. throw;
  4210. }
  4211. }
  4212. /// <summary>
  4213. /// 根据商邀费用ID查询C表和商邀费用数据
  4214. /// </summary>
  4215. /// <param name="dto"></param>
  4216. /// <returns></returns>
  4217. [HttpPost]
  4218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4219. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4220. {
  4221. try
  4222. {
  4223. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4224. if (groupData.Code != 0)
  4225. {
  4226. return Ok(JsonView(false, groupData.Msg));
  4227. }
  4228. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4229. }
  4230. catch (Exception ex)
  4231. {
  4232. return Ok(JsonView(false, ex.Message));
  4233. throw;
  4234. }
  4235. }
  4236. /// <summary>
  4237. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4238. /// </summary>
  4239. /// <param name="dto"></param>
  4240. /// <returns></returns>
  4241. [HttpPost]
  4242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4243. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4244. {
  4245. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4246. if (groupData.Code != 0)
  4247. {
  4248. return Ok(JsonView(false, groupData.Msg));
  4249. }
  4250. #region 应用推送
  4251. try
  4252. {
  4253. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4254. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4255. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4256. //2024-10-21 新增LZ UID
  4257. var userIds = new List<int>() { 21 };
  4258. string title = $"系统通知";
  4259. string content = "";
  4260. var diId = dto.DiId;
  4261. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4262. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4263. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4264. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4265. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4266. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4267. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4268. }
  4269. catch (Exception ex)
  4270. {
  4271. }
  4272. #endregion
  4273. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4274. }
  4275. /// <summary>
  4276. /// 商邀删除
  4277. /// </summary>
  4278. /// <param name="dto"></param>
  4279. /// <returns></returns>
  4280. [HttpPost]
  4281. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4282. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4283. {
  4284. try
  4285. {
  4286. _sqlSugar.BeginTran();
  4287. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4288. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4289. {
  4290. IsDel = 1,
  4291. DeleteUserId = dto.DeleteUserId,
  4292. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4293. })
  4294. .Where(it => it.Id == dto.Id)
  4295. .ExecuteCommand();
  4296. if (res1 > 0)
  4297. {
  4298. int _diId = 0;
  4299. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4300. if (_ioaInfo != null)
  4301. {
  4302. _diId = _ioaInfo.DiId;
  4303. }
  4304. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4305. .SetColumns(a => new Grp_CreditCardPayment()
  4306. {
  4307. IsDel = 1,
  4308. DeleteUserId = dto.DeleteUserId,
  4309. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4310. })
  4311. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4312. .ExecuteCommand();
  4313. if (res2 > 0)
  4314. {
  4315. _sqlSugar.CommitTran();
  4316. return Ok(JsonView(true, "删除成功!"));
  4317. }
  4318. }
  4319. _sqlSugar.RollbackTran();
  4320. return Ok(JsonView(false, "删除失败"));
  4321. }
  4322. catch (Exception ex)
  4323. {
  4324. _sqlSugar.RollbackTran();
  4325. return Ok(JsonView(false, ex.Message));
  4326. }
  4327. }
  4328. /// <summary>
  4329. /// 团组模块文件上传
  4330. /// </summary>
  4331. /// <param name="dto"></param>
  4332. /// <returns></returns>
  4333. [HttpPost]
  4334. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4335. {
  4336. var jw = JsonView(false);
  4337. long M = 1024 * 1024;
  4338. if (dto.Files == null || dto.Files.Count == 0)
  4339. {
  4340. jw.Msg = "无文件信息!";
  4341. return Ok(jw);
  4342. }
  4343. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4344. {
  4345. jw.Msg = "文件大小超过20M!";
  4346. return Ok(jw);
  4347. }
  4348. //var nameSp = dto.File.FileName.Split(".");
  4349. //if (nameSp.Length < 2)
  4350. //{
  4351. // jw.Msg = "拓展名称有误!";
  4352. // return Ok(jw);
  4353. //}
  4354. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4355. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4356. //{
  4357. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4358. // return Ok(jw);
  4359. //}
  4360. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4361. if (Ctable == null)
  4362. {
  4363. jw.Msg = "Ctable指向有误!";
  4364. return Ok(jw);
  4365. }
  4366. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4367. if (groupInfo == null)
  4368. {
  4369. jw.Msg = "团组信息不存在!";
  4370. return Ok(jw);
  4371. }
  4372. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4373. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4374. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4375. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4376. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4377. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4378. try
  4379. {
  4380. if (!Directory.Exists(fileBase))
  4381. {
  4382. Directory.CreateDirectory(fileBase);
  4383. }
  4384. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4385. foreach (var fileStream in dto.Files)
  4386. {
  4387. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4388. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4389. {
  4390. Cid = dto.Cid,
  4391. CreateTime = DateTime.Now,
  4392. CreateUserId = dto.Userid,
  4393. Ctable = dto.Ctable,
  4394. Diid = dto.Diid,
  4395. IsDel = 0,
  4396. FilePath = saveFilePath,
  4397. FileName = fileStream.FileName
  4398. };
  4399. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4400. {
  4401. fileStream.CopyTo(fs);
  4402. fs.Flush();
  4403. }
  4404. saveArr.Add(file);
  4405. }
  4406. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4407. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4408. jw = JsonView(true, "保存成功!", new
  4409. {
  4410. count = addResult,
  4411. filesName = saveArr.Select(x => x.FileName)
  4412. });
  4413. }
  4414. catch (Exception ex)
  4415. {
  4416. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4417. {
  4418. count = 0,
  4419. filesName = new string[0],
  4420. });
  4421. }
  4422. return Ok(jw);
  4423. }
  4424. /// <summary>
  4425. /// 查询各模块已保存文件
  4426. /// </summary>
  4427. /// <param name="dto"></param>
  4428. /// <returns></returns>
  4429. [HttpPost]
  4430. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4431. {
  4432. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4433. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4434. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4435. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4436. {
  4437. expression = Expressionable.Create<Grp_GroupModelFile>()
  4438. .And(x => visaIds.Contains(x.CreateUserId));
  4439. }
  4440. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4441. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4442. .Where(expression.ToExpression())
  4443. .ToList();
  4444. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4445. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4446. {
  4447. x.FileName,
  4448. x.Id,
  4449. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4450. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4451. })));
  4452. }
  4453. /// <summary>
  4454. /// 下载该团组下的所有文件
  4455. /// </summary>
  4456. /// <param name="dto"></param>
  4457. /// <returns></returns>
  4458. [HttpPost]
  4459. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4460. {
  4461. var jw = JsonView(false);
  4462. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4463. if (groupInfo == null)
  4464. {
  4465. jw.Msg = "团组信息不存在!";
  4466. return Ok(jw);
  4467. }
  4468. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4469. var isModule = Convert.ToBoolean(dto.isModule);
  4470. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4471. IOOperatorHelper io = new IOOperatorHelper();
  4472. if (isModule)
  4473. {
  4474. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4475. foreach (var moduleArr in moduleGroup)
  4476. {
  4477. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4478. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4479. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4480. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4481. foreach (var item in moduleArr)
  4482. {
  4483. if (System.IO.File.Exists(item.FilePath))
  4484. {
  4485. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4486. {
  4487. byte[] bytes = new byte[fileStream.Length];
  4488. fileStream.Read(bytes, 0, bytes.Length);
  4489. fileStream.Close();
  4490. Stream stream = new MemoryStream(bytes);
  4491. chiZips.Add(item.FileName, stream);
  4492. }
  4493. }
  4494. }
  4495. if (chiZips.Count > 0)
  4496. {
  4497. var byts = io.ConvertZipStream(chiZips);
  4498. Stream stream = new MemoryStream(byts);
  4499. Zips.Add(key.Name + "_.zip", stream);
  4500. }
  4501. }
  4502. }
  4503. else
  4504. {
  4505. foreach (var item in dbQuery)
  4506. {
  4507. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4508. {
  4509. byte[] bytes = new byte[fileStream.Length];
  4510. fileStream.Read(bytes, 0, bytes.Length);
  4511. fileStream.Close();
  4512. Stream stream = new MemoryStream(bytes);
  4513. while (Zips.Keys.Contains(item.FileName))
  4514. {
  4515. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4516. }
  4517. Zips.Add(item.FileName, stream);
  4518. }
  4519. }
  4520. }
  4521. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4522. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4523. if (Zips.Count > 0)
  4524. {
  4525. var byts = io.ConvertZipStream(Zips);
  4526. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4527. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4528. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4529. }
  4530. else
  4531. {
  4532. jw.Msg = "暂无生成文件!";
  4533. }
  4534. return Ok(jw);
  4535. }
  4536. /// <summary>
  4537. /// 下载该团组下此模块的所有文件
  4538. /// </summary>
  4539. /// <param name="dto"></param>
  4540. /// <returns></returns>
  4541. [HttpPost]
  4542. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4543. {
  4544. var jw = JsonView(false);
  4545. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4546. if (groupInfo == null)
  4547. {
  4548. jw.Msg = "团组信息不存在!";
  4549. return Ok(jw);
  4550. }
  4551. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4552. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4553. && x.IsDel == 0);
  4554. if (key == null)
  4555. {
  4556. jw.Msg = "Ctable指向错误!";
  4557. return Ok(jw);
  4558. }
  4559. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4560. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4561. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4562. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4563. IOOperatorHelper io = new IOOperatorHelper();
  4564. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4565. foreach (var item in dbQuery)
  4566. {
  4567. if (System.IO.File.Exists(item.FilePath))
  4568. {
  4569. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4570. {
  4571. byte[] bytes = new byte[fileStream.Length];
  4572. fileStream.Read(bytes, 0, bytes.Length);
  4573. fileStream.Close();
  4574. Stream stream = new MemoryStream(bytes);
  4575. while (Zips.Keys.Contains(item.FileName))
  4576. {
  4577. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4578. }
  4579. Zips.Add(item.FileName, stream);
  4580. }
  4581. }
  4582. }
  4583. if (Zips.Count > 0)
  4584. {
  4585. var byts = io.ConvertZipStream(Zips);
  4586. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4587. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4588. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4589. }
  4590. else
  4591. {
  4592. jw.Msg = "暂无生成文件!";
  4593. }
  4594. return Ok(jw);
  4595. }
  4596. /// <summary>
  4597. /// 删除该团组下的指定文件
  4598. /// </summary>
  4599. /// <param name="dto"></param>
  4600. /// <returns></returns>
  4601. [HttpPost]
  4602. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4603. {
  4604. var jw = JsonView(false);
  4605. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4606. if (sing == null)
  4607. {
  4608. jw.Msg = "暂无";
  4609. return Ok(jw);
  4610. }
  4611. if (System.IO.File.Exists(sing.FilePath))
  4612. {
  4613. try
  4614. {
  4615. System.IO.File.Delete(sing.FilePath);
  4616. }
  4617. catch (Exception ex)
  4618. {
  4619. jw.Msg = "删除失败!" + ex.Message;
  4620. return Ok(jw);
  4621. }
  4622. }
  4623. sing.IsDel = 1;
  4624. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4625. sing.DeleteUserId = dto.UserId;
  4626. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4627. jw = JsonView(true, "删除成功!");
  4628. return Ok(jw);
  4629. }
  4630. #endregion
  4631. #region 团组英文资料
  4632. /// <summary>
  4633. /// 查询团组英文所有资料
  4634. /// </summary>
  4635. /// <param name="dto"></param>
  4636. /// <returns></returns>
  4637. [HttpPost]
  4638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4639. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4640. {
  4641. try
  4642. {
  4643. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4644. if (groupData.Code != 0)
  4645. {
  4646. return Ok(JsonView(false, groupData.Msg));
  4647. }
  4648. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4649. }
  4650. catch (Exception ex)
  4651. {
  4652. return Ok(JsonView(false, "程序错误!"));
  4653. throw;
  4654. }
  4655. }
  4656. /// <summary>
  4657. /// 团组英文资料操作(Status:1.新增,2.修改)
  4658. /// </summary>
  4659. /// <param name="dto"></param>
  4660. /// <returns></returns>
  4661. [HttpPost]
  4662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4663. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4664. {
  4665. try
  4666. {
  4667. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4668. if (groupData.Code != 0)
  4669. {
  4670. return Ok(JsonView(false, groupData.Msg));
  4671. }
  4672. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4673. }
  4674. catch (Exception ex)
  4675. {
  4676. return Ok(JsonView(false, "程序错误!"));
  4677. throw;
  4678. }
  4679. }
  4680. /// <summary>
  4681. /// 团组英文资料Id查询数据
  4682. /// </summary>
  4683. /// <param name="dto"></param>
  4684. /// <returns></returns>
  4685. [HttpPost]
  4686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4687. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4688. {
  4689. try
  4690. {
  4691. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4692. if (_DelegationEnData != null)
  4693. {
  4694. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4695. }
  4696. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4697. }
  4698. catch (Exception ex)
  4699. {
  4700. return Ok(JsonView(false, "程序错误!"));
  4701. throw;
  4702. }
  4703. }
  4704. /// <summary>
  4705. /// 团组英文资料删除
  4706. /// </summary>
  4707. /// <param name="dto"></param>
  4708. /// <returns></returns>
  4709. [HttpPost]
  4710. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4711. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4712. {
  4713. try
  4714. {
  4715. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4716. if (!res)
  4717. {
  4718. return Ok(JsonView(false, "删除失败"));
  4719. }
  4720. return Ok(JsonView(true, "删除成功!"));
  4721. }
  4722. catch (Exception ex)
  4723. {
  4724. return Ok(JsonView(false, "程序错误!"));
  4725. throw;
  4726. }
  4727. }
  4728. #endregion
  4729. #region 导出邀请函
  4730. /// <summary>
  4731. /// 导出邀请函页面初始化
  4732. /// </summary>
  4733. /// <param name="dto"></param>
  4734. /// <returns></returns>
  4735. [HttpPost]
  4736. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4737. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4738. {
  4739. try
  4740. {
  4741. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  4742. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4743. if (dto.DiId == 0)
  4744. {
  4745. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4746. }
  4747. else
  4748. {
  4749. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4750. }
  4751. return Ok(JsonView(true, "查询成功!", new
  4752. {
  4753. deleClient = crm_Deles,
  4754. delegations = grp_Delegations
  4755. }));
  4756. }
  4757. catch (Exception ex)
  4758. {
  4759. return Ok(JsonView(false, "程序错误!"));
  4760. throw;
  4761. }
  4762. }
  4763. /// <summary>
  4764. /// 导出邀请函
  4765. /// </summary>
  4766. /// <param name="dto"></param>
  4767. /// <returns></returns>
  4768. [HttpPost]
  4769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4770. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4771. {
  4772. #region 参数验证
  4773. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4774. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4775. #endregion
  4776. try
  4777. {
  4778. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4779. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4780. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4781. From Grp_TourClientList tcl
  4782. Left Join
  4783. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4784. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4785. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4786. From Crm_DeleClient dc
  4787. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4788. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4789. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4790. Where dc.IsDel = 0) temp
  4791. On temp.DcId =tcl.ClientId
  4792. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4793. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4794. List<string> texts = new List<string>();
  4795. if (datas.Count != 0)
  4796. {
  4797. foreach (TourClientListDetailsView item in datas)
  4798. {
  4799. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4800. {
  4801. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4802. }
  4803. else
  4804. {
  4805. string name = item.LastName + item.FirstName;
  4806. texts.Add(name);
  4807. }
  4808. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4809. {
  4810. if (!transDic.ContainsKey(item.Job))
  4811. {
  4812. texts.Add(item.Job);
  4813. }
  4814. }
  4815. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4816. {
  4817. texts.Add(item.CompanyFullName);
  4818. }
  4819. }
  4820. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4821. if (transData.Count > 0)
  4822. {
  4823. foreach (TranslateResult item in transData)
  4824. {
  4825. if (!transDic.ContainsKey(item.Query))
  4826. {
  4827. transDic.Add(item.Query, item.Translation);
  4828. }
  4829. }
  4830. }
  4831. List<GuestList> list = new List<GuestList>();
  4832. foreach (TourClientListDetailsView dele in datas)
  4833. {
  4834. GuestList guestList = new GuestList();
  4835. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4836. {
  4837. guestList.Name = dele.Pinyin;
  4838. }
  4839. else
  4840. {
  4841. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4842. guestList.Name = Name;
  4843. }
  4844. if (dele.Sex == 0)
  4845. {
  4846. guestList.Sex = "Male";
  4847. }
  4848. else if (dele.Sex == 1)
  4849. {
  4850. guestList.Sex = "Female";
  4851. }
  4852. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4853. if (!string.IsNullOrEmpty(dele.Job))
  4854. {
  4855. guestList.Job = dele.Job;
  4856. }
  4857. list.Add(guestList);
  4858. }
  4859. //载入模板
  4860. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4861. DocumentBuilder builder = new DocumentBuilder(doc);
  4862. //获取word里所有表格
  4863. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4864. //获取所填表格的序数
  4865. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4866. var rowStart = tableOne.Rows[0]; //获取第1行
  4867. //循环赋值
  4868. for (int i = 0; i < list.Count; i++)
  4869. {
  4870. builder.MoveToCell(0, i + 1, 0, 0);
  4871. builder.Write(list[i].Name.ToString());
  4872. builder.MoveToCell(0, i + 1, 1, 0);
  4873. builder.Write(list[i].Sex.ToString());
  4874. builder.MoveToCell(0, i + 1, 2, 0);
  4875. builder.Write(list[i].DOB.ToString());
  4876. builder.MoveToCell(0, i + 1, 3, 0);
  4877. builder.Write(list[i].Job.ToString());
  4878. }
  4879. //删除多余行
  4880. while (tableOne.Rows.Count > list.Count + 1)
  4881. {
  4882. tableOne.Rows.RemoveAt(list.Count + 1);
  4883. }
  4884. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4885. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4886. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4887. doc.Save(filePath);
  4888. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4889. return Ok(JsonView(true, "操作成功!", Url));
  4890. }
  4891. else
  4892. {
  4893. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4894. }
  4895. }
  4896. catch (Exception ex)
  4897. {
  4898. return Ok(JsonView(false, ex.Message));
  4899. throw;
  4900. }
  4901. }
  4902. #endregion
  4903. #region 团组经理模块 出入境费用
  4904. /// <summary>
  4905. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4906. /// </summary>
  4907. /// <returns></returns>
  4908. [HttpPost]
  4909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4910. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4911. {
  4912. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4913. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4914. //SetDataInfoView
  4915. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4916. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4917. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4918. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4919. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4920. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4921. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4922. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  4923. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4924. return Ok(JsonView(true, "查询成功!", new
  4925. {
  4926. GroupNameData = groupNameData.Data,
  4927. CurrencyData = _CurrencyData,
  4928. WordTypeData = _WordTypeData,
  4929. ExcelTypeData = _ExcelTypeData,
  4930. CurrencyInit = _currencyInfos,
  4931. ViewPermissionData = viewPermissionData
  4932. }));
  4933. }
  4934. /// <summary>
  4935. /// 团组模块 - 出入境费用
  4936. /// 实时汇率 tips
  4937. /// 签证费用 tips
  4938. /// 机票费用 tips
  4939. /// </summary>
  4940. /// <returns></returns>
  4941. [HttpPost]
  4942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4943. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4944. {
  4945. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4946. //默认币种显示
  4947. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  4948. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  4949. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4950. return Ok(JsonView(true, "查询成功!", new
  4951. {
  4952. //GroupNameData = groupNameData.Data,
  4953. visaData = visaData.Data,
  4954. airData = airData.Data,
  4955. reteInfos = reteInfos
  4956. }));
  4957. }
  4958. /// <summary>
  4959. /// 团组模块 - 出入境费用 - Info
  4960. /// </summary>
  4961. /// <returns></returns>
  4962. [HttpPost]
  4963. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  4964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4965. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4966. {
  4967. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4968. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4969. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4970. }
  4971. /// <summary>
  4972. /// 团组模块 - 出入境费用 - 设置view权限
  4973. /// </summary>
  4974. /// <returns></returns>
  4975. [HttpPost]
  4976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4977. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4978. {
  4979. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4980. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4981. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4982. var permissions = new List<Grp_EnterExitCostPermission>();
  4983. foreach (var userId in dto.UserIds)
  4984. {
  4985. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4986. }
  4987. if (permissions.Any())
  4988. {
  4989. _sqlSugar.BeginTran();
  4990. try
  4991. {
  4992. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4993. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4994. if (result < 1)
  4995. {
  4996. _sqlSugar.RollbackTran();
  4997. return Ok(JsonView(false));
  4998. }
  4999. }
  5000. catch (Exception ex)
  5001. {
  5002. _sqlSugar.RollbackTran();
  5003. return Ok(JsonView(false, ex.Message));
  5004. }
  5005. _sqlSugar.CommitTran();
  5006. return Ok(JsonView(true));
  5007. }
  5008. return Ok(JsonView(false));
  5009. }
  5010. /// <summary>
  5011. /// 团组模块 - 出入境费用 - Add And Update
  5012. /// </summary>
  5013. /// <returns></returns>
  5014. [HttpPost]
  5015. [ApiLog("Grp_EnterExitCost",OperationEnum.Add)]
  5016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5017. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  5018. {
  5019. try
  5020. {
  5021. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5022. if (dto.DayOtherPriceData.Any())
  5023. {
  5024. var inserList = dto.DayOtherPriceData
  5025. .Where(x => x.Id == 0)
  5026. .Select(x => new Grp_DayOtherPrice
  5027. {
  5028. Cost = x.Cost,
  5029. Id = x.Id,
  5030. CreateTime = DateTime.Now,
  5031. CreateUserId = dto.UserId,
  5032. Currency = x.Currency,
  5033. Diid = x.DiId,
  5034. Index = x.Index,
  5035. IsDel = 0,
  5036. SetDataId = x.SetDataId,
  5037. SubTotal = x.SubTotal,
  5038. Remark = x.Remark
  5039. })
  5040. .ToList();
  5041. var updateList = dto.DayOtherPriceData
  5042. .Where(x => x.Id != 0)
  5043. .Select(x => new Grp_DayOtherPrice
  5044. {
  5045. Cost = x.Cost,
  5046. Id = x.Id,
  5047. CreateTime = DateTime.Now,
  5048. CreateUserId = dto.UserId,
  5049. Currency = x.Currency,
  5050. Diid = x.DiId,
  5051. Index = x.Index,
  5052. IsDel = 0,
  5053. SetDataId = x.SetDataId,
  5054. SubTotal = x.SubTotal,
  5055. Remark = x.Remark
  5056. })
  5057. .ToList();
  5058. //添加
  5059. _sqlSugar.BeginTran();
  5060. if (inserList.Any())
  5061. {
  5062. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  5063. }
  5064. if (updateList.Any())
  5065. {
  5066. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  5067. }
  5068. _sqlSugar.CommitTran();
  5069. }
  5070. if (data.Code != 0)
  5071. {
  5072. return Ok(JsonView(false, data.Msg));
  5073. }
  5074. //生成默认文件pdf并且通知人员
  5075. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  5076. {
  5077. DiId = dto.DiId,
  5078. ExportType = 1,
  5079. SubTypeId = 1005
  5080. }, "pdf");
  5081. //发送通知
  5082. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  5083. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  5084. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  5085. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  5086. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  5087. //汇率信息记录
  5088. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  5089. return Ok(JsonView(true, data.Msg, data.Data));
  5090. }
  5091. catch (Exception ex)
  5092. {
  5093. return Ok(JsonView(false, ex.Message));
  5094. }
  5095. }
  5096. /// <summary>
  5097. /// 团组模块 - 出入境费用 - Confirm 费用
  5098. /// </summary>
  5099. /// <returns></returns>
  5100. [HttpPost]
  5101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5102. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  5103. {
  5104. //TODO:测试完毕需把对应的用户ID更改
  5105. //1、数据表添加字段
  5106. //2、更改字段接口()
  5107. var _view = await _enterExitCostRep.ConfirmCost(dto);
  5108. //3、确认成功 给财务发送消息
  5109. if (_view.Code == 200)
  5110. {
  5111. if (dto.Type == 1)
  5112. {
  5113. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  5114. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  5115. }
  5116. }
  5117. return Ok(_view);
  5118. }
  5119. /// <summary>
  5120. /// 团组模块 - 出入境费用 - File download
  5121. /// </summary>
  5122. /// <param name="dto"></param>
  5123. /// <returns></returns>
  5124. [HttpPost]
  5125. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  5126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5127. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  5128. {
  5129. try
  5130. {
  5131. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  5132. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  5133. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  5134. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  5135. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  5136. 3 团组成员名单 1 团组成员名单", ""));
  5137. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  5138. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  5139. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  5140. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  5141. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  5142. //数据源
  5143. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  5144. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  5145. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  5146. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  5147. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  5148. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  5149. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  5150. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  5151. .Select((x, a, b) => new
  5152. {
  5153. x.Index,
  5154. itemName = a.Name,
  5155. CurrencyStr = b.Name,
  5156. x.Cost,
  5157. x.SubTotal,
  5158. x.Remark
  5159. })
  5160. .OrderBy((x) => x.Index)
  5161. .ToList(); //其他款项费用
  5162. var peiceItemCurrencys = new List<string>();
  5163. if (_DayAndCosts.Any())
  5164. {
  5165. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  5166. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  5167. }
  5168. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  5169. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  5170. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  5171. {
  5172. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  5173. }
  5174. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5175. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5176. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5177. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5178. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5179. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5180. .Select((tcl, dc, cc) => new ClientInfo
  5181. {
  5182. LastName = dc.LastName,
  5183. FirstName = dc.FirstName,
  5184. Sex = dc.Sex,
  5185. Birthday = dc.BirthDay,
  5186. Company = cc.CompanyFullName,
  5187. Job = dc.Job
  5188. })
  5189. .ToList();
  5190. foreach (var item in DeleClientList)
  5191. {
  5192. EncryptionProcessor.DecryptProperties(item);
  5193. }
  5194. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5195. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5196. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5197. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5198. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5199. if (dto.ExportType == 1) //明细表
  5200. {
  5201. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5202. {
  5203. //获取模板
  5204. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5205. //载入模板
  5206. Document doc = new Document(tempPath);
  5207. DocumentBuilder builder = new DocumentBuilder(doc);
  5208. //利用键值对存放数据
  5209. Dictionary<string, string> dic = new Dictionary<string, string>();
  5210. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5211. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5212. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5213. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5214. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5215. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5216. //境内费用(其他费用)
  5217. if (_EnterExitCosts.ChoiceOne == 1)
  5218. {
  5219. string row1_1 = "";
  5220. if (_EnterExitCosts.Visa > 0)
  5221. {
  5222. //insidePayTotal += _EnterExitCosts.Visa;
  5223. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5224. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5225. {
  5226. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5227. }
  5228. }
  5229. string row1_2 = "";
  5230. if (_EnterExitCosts.YiMiao > 0)
  5231. {
  5232. //insidePayTotal += _EnterExitCosts.YiMiao;
  5233. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5234. }
  5235. if (_EnterExitCosts.HeSuan > 0)
  5236. {
  5237. //insidePayTotal += _EnterExitCosts.HeSuan;
  5238. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5239. }
  5240. if (_EnterExitCosts.Service > 0)
  5241. {
  5242. //insidePayTotal += _EnterExitCosts.Service;
  5243. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5244. }
  5245. string row1_3 = "";
  5246. if (_EnterExitCosts.Safe > 0)
  5247. {
  5248. //insidePayTotal += _EnterExitCosts.Safe;
  5249. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5250. }
  5251. if (_EnterExitCosts.Ticket > 0)
  5252. {
  5253. //insidePayTotal += _EnterExitCosts.Ticket;
  5254. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5255. }
  5256. string row1 = "";
  5257. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5258. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5259. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5260. row1 += $"备注:{_EnterExitCosts.Remark}";
  5261. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5262. dic.Add("Row1Str", row1);
  5263. }
  5264. string airTotalStr = string.Empty,
  5265. airPriceStr = string.Empty;
  5266. //经济舱
  5267. if (_EnterExitCosts.SumJJC == 1)
  5268. {
  5269. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5270. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5271. }
  5272. //公务舱
  5273. if (_EnterExitCosts.SumGWC == 1)
  5274. {
  5275. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5276. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5277. }
  5278. //头等舱
  5279. if (_EnterExitCosts.SumTDC == 1)
  5280. {
  5281. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5282. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5283. }
  5284. //汇率描述
  5285. string rateStr = "";
  5286. if (peiceItemCurrencyInfos.Any())
  5287. {
  5288. rateStr = "\r\n汇率描述:";
  5289. foreach (var item in peiceItemCurrencyInfos)
  5290. {
  5291. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  5292. }
  5293. }
  5294. string twoItemRemark = "备注:";
  5295. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  5296. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  5297. dic.Add("AirTotalStr", airTotalStr);
  5298. dic.Add("AirPriceStr", airPriceStr);
  5299. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5300. dic.Add("TwoItemRemark", twoItemRemark);
  5301. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5302. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5303. int table1Row = 0,
  5304. table2Row = 0,
  5305. table3Row = 0,
  5306. table4Row = 0,
  5307. table5Row = 0;
  5308. //住宿费
  5309. if (_EnterExitCosts.ChoiceThree == 1)
  5310. {
  5311. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5312. table1Row = dac1.Count;
  5313. #region 填充word表格内容
  5314. for (int i = 0; i < dac1.Count; i++)
  5315. {
  5316. Grp_DayAndCost dac = dac1[i];
  5317. if (dac == null) continue;
  5318. builder.MoveToCell(0, i, 0, 0);
  5319. builder.Write("第" + dac.Days.ToString() + "晚:");
  5320. builder.MoveToCell(0, i, 1, 0);
  5321. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5322. //builder.Write(dac.Place == null ? "" : dac.Place);
  5323. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5324. builder.MoveToCell(0, i, 2, 0);
  5325. builder.Write("费用标准:");
  5326. string curr = "";
  5327. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5328. if (currData != null)
  5329. {
  5330. curr = currData.Name;
  5331. }
  5332. builder.MoveToCell(0, i, 3, 0);
  5333. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5334. builder.MoveToCell(0, i, 4, 0);
  5335. builder.Write("费用小计:");
  5336. builder.MoveToCell(0, i, 5, 0);
  5337. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5338. }
  5339. #endregion
  5340. }
  5341. else dic.Add("SubZS", "0.00");
  5342. //删除多余行
  5343. while (table1.Rows.Count > table1Row)
  5344. {
  5345. table1.Rows.RemoveAt(table1Row);
  5346. }
  5347. //伙食费
  5348. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5349. if (_EnterExitCosts.ChoiceFour == 1)
  5350. {
  5351. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5352. table2Row = dac2.Count;
  5353. #region 填充word表格内容
  5354. for (int i = 0; i < dac2.Count; i++)
  5355. {
  5356. Grp_DayAndCost dac = dac2[i];
  5357. if (dac == null) continue;
  5358. builder.MoveToCell(1, i, 0, 0);
  5359. builder.Write("第" + dac.Days.ToString() + "天:");
  5360. builder.MoveToCell(1, i, 1, 0);
  5361. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5362. builder.MoveToCell(1, i, 2, 0);
  5363. builder.Write("费用标准:");
  5364. string curr = "";
  5365. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5366. if (currData != null)
  5367. {
  5368. curr = currData.Name;
  5369. }
  5370. builder.MoveToCell(1, i, 3, 0);
  5371. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5372. builder.MoveToCell(1, i, 4, 0);
  5373. builder.Write("费用小计:");
  5374. builder.MoveToCell(1, i, 5, 0);
  5375. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5376. }
  5377. #endregion
  5378. }
  5379. else dic.Add("SubHS", "0.00");
  5380. //删除多余行
  5381. while (table2.Rows.Count > table2Row)
  5382. {
  5383. table2.Rows.RemoveAt(table2Row);
  5384. }
  5385. //公杂费
  5386. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5387. if (_EnterExitCosts.ChoiceFive == 1)
  5388. {
  5389. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5390. table3Row = dac3.Count;
  5391. #region 填充word表格内容
  5392. for (int i = 0; i < dac3.Count; i++)
  5393. {
  5394. Grp_DayAndCost dac = dac3[i];
  5395. if (dac == null) continue;
  5396. builder.MoveToCell(2, i, 0, 0);
  5397. builder.Write("第" + dac.Days.ToString() + "天:");
  5398. builder.MoveToCell(2, i, 1, 0);
  5399. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5400. builder.MoveToCell(2, i, 2, 0);
  5401. builder.Write("费用标准:");
  5402. string curr = "";
  5403. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5404. if (currData != null)
  5405. {
  5406. curr = currData.Name;
  5407. }
  5408. builder.MoveToCell(2, i, 3, 0);
  5409. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5410. builder.MoveToCell(2, i, 4, 0);
  5411. builder.Write("费用小计:");
  5412. builder.MoveToCell(2, i, 5, 0);
  5413. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5414. }
  5415. //删除多余行
  5416. while (table3.Rows.Count > table3Row)
  5417. {
  5418. table3.Rows.RemoveAt(table3Row);
  5419. }
  5420. #endregion
  5421. }
  5422. else dic.Add("SubGZF", "0.00");
  5423. //删除多余行
  5424. while (table3.Rows.Count > table3Row)
  5425. {
  5426. table3.Rows.RemoveAt(table3Row);
  5427. }
  5428. //培训费
  5429. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5430. if (_EnterExitCosts.ChoiceSix == 1)
  5431. {
  5432. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5433. dic.Add("SubPX", pxStr);
  5434. table4Row = dac4.Count;
  5435. #region 填充word表格内容
  5436. for (int i = 0; i < dac4.Count; i++)
  5437. {
  5438. Grp_DayAndCost dac = dac4[i];
  5439. if (dac == null) continue;
  5440. builder.MoveToCell(3, i, 0, 0);
  5441. builder.Write("第" + dac.Days.ToString() + "天:");
  5442. builder.MoveToCell(3, i, 1, 0);
  5443. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5444. builder.MoveToCell(3, i, 2, 0);
  5445. builder.Write("费用标准:");
  5446. string curr = "";
  5447. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5448. if (currData != null)
  5449. {
  5450. curr = currData.Name;
  5451. }
  5452. builder.MoveToCell(3, i, 3, 0);
  5453. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5454. builder.MoveToCell(3, i, 4, 0);
  5455. builder.Write("费用小计:");
  5456. builder.MoveToCell(3, i, 5, 0);
  5457. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5458. }
  5459. #endregion
  5460. }
  5461. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  5462. //删除多余行
  5463. while (table4.Rows.Count > table4Row)
  5464. {
  5465. table4.Rows.RemoveAt(table4Row);
  5466. }
  5467. //其他费用
  5468. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5469. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5470. {
  5471. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5472. dic.Add("titleQi", qtStr);
  5473. table5Row = dac5.Count;
  5474. #region 填充word表格内容
  5475. for (int i = 0; i < dac5.Count; i++)
  5476. {
  5477. var dac = dac5[i];
  5478. if (dac == null) continue;
  5479. builder.MoveToCell(4, i, 0, 0);
  5480. builder.Write("第" + dac.Index.ToString() + "项:");
  5481. builder.MoveToCell(4, i, 1, 0);
  5482. builder.Write(dac.itemName);
  5483. builder.MoveToCell(4, i, 2, 0);
  5484. builder.Write("费用标准:");
  5485. builder.MoveToCell(4, i, 3, 0);
  5486. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5487. builder.MoveToCell(4, i, 4, 0);
  5488. builder.Write("费用小计:");
  5489. builder.MoveToCell(4, i, 5, 0);
  5490. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5491. builder.MoveToCell(4, i, 6, 0);
  5492. builder.Write("备注:");
  5493. builder.MoveToCell(4, i, 7, 0);
  5494. builder.Write(dac.Remark);
  5495. }
  5496. #endregion
  5497. }
  5498. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5499. //删除多余行
  5500. while (table5.Rows.Count > table5Row)
  5501. {
  5502. table5.Rows.RemoveAt(table5Row);
  5503. }
  5504. //加上其他费用
  5505. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5506. decimal subJJC = 0.00M,
  5507. subGWC = 0.00M,
  5508. subTDC = 0.00M;
  5509. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  5510. string totalLabel = string.Format("全部费用总计:");
  5511. //经济舱
  5512. if (_EnterExitCosts.SumJJC == 1)
  5513. {
  5514. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5515. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  5516. }
  5517. //公务舱
  5518. if (_EnterExitCosts.SumGWC == 1) {
  5519. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5520. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  5521. }
  5522. //头等舱
  5523. if (_EnterExitCosts.SumTDC == 1)
  5524. {
  5525. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5526. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  5527. }
  5528. //TotalLabel
  5529. dic.Add("TotalLabel", totalLabel);
  5530. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5531. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5532. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5533. #region 填充word模板书签内容
  5534. foreach (var key in dic.Keys)
  5535. {
  5536. Bookmark bookmark = doc.Range.Bookmarks[key];
  5537. if (bookmark != null)
  5538. {
  5539. builder.MoveToBookmark(key);
  5540. builder.Write(dic[key]);
  5541. }
  5542. }
  5543. #endregion
  5544. #region 设置页眉
  5545. string userLabel = string.Empty;
  5546. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5547. if (currUserInfo != null)
  5548. {
  5549. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5550. if (userInfo != null)
  5551. {
  5552. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5553. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5554. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5555. }
  5556. }
  5557. //设置页脚
  5558. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5559. #endregion
  5560. //文件名
  5561. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5562. AsposeHelper.removewatermark_v2180();
  5563. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5564. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5565. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5566. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5567. }
  5568. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5569. {
  5570. //获取模板
  5571. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5572. //载入模板
  5573. Document doc = new Document(tempPath);
  5574. DocumentBuilder builder = new DocumentBuilder(doc);
  5575. Dictionary<string, string> dic = new Dictionary<string, string>();
  5576. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5577. {
  5578. List<string> list = new List<string>();
  5579. try
  5580. {
  5581. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5582. foreach (var item in spilitArr)
  5583. {
  5584. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5585. var depCode = spDotandEmpty[2].Substring(0, 3);
  5586. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5587. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5588. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5589. list.Add(depName);
  5590. list.Add(arrName);
  5591. }
  5592. list = list.Distinct().ToList();
  5593. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5594. }
  5595. catch (Exception)
  5596. {
  5597. dic.Add("ReturnCode", "行程录入不正确!");
  5598. }
  5599. }
  5600. else
  5601. {
  5602. dic.Add("ReturnCode", "未录入行程!");
  5603. }
  5604. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5605. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5606. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5607. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5608. {
  5609. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5610. dic.Add("Day", sp.Days.ToString());
  5611. }
  5612. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5613. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5614. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5615. //dic.Add("Names", Names);
  5616. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5617. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5618. decimal dac1totalPrice = 0.00M;
  5619. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5620. foreach (var dac in dac1)
  5621. {
  5622. if (dac.SubTotal == 0.00M)
  5623. {
  5624. continue;
  5625. }
  5626. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5627. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5628. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5629. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5630. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5631. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5632. builder.Write(currency);//币种
  5633. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5634. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5635. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5636. builder.Write("");//人数
  5637. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5638. builder.Write("");//天数
  5639. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5640. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5641. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5642. decimal rate = 0.00M;
  5643. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5644. builder.Write(rate.ToString("#0.0000"));//汇率
  5645. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5646. decimal rbmPrice = dac.SubTotal;
  5647. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5648. accommodationStartIndex++;
  5649. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5650. }
  5651. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5652. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5653. {
  5654. table1.Rows.RemoveAt(i - 1);
  5655. foodandotherStartIndex--;
  5656. }
  5657. if (dac2.Count == dac3.Count)//国家 币种 金额
  5658. {
  5659. for (int i = 0; i < dac2.Count; i++)
  5660. {
  5661. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5662. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5663. }
  5664. }
  5665. decimal dac2totalPrice = 0.00M;
  5666. foreach (var dac in dac2)
  5667. {
  5668. if (dac.SubTotal == 0)
  5669. {
  5670. continue;
  5671. }
  5672. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5673. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5674. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5675. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5676. builder.Write(currency);//币种
  5677. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5678. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5679. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5680. builder.Write("");//人数
  5681. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5682. builder.Write("");//天数
  5683. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5684. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5685. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5686. decimal rate = 0.00M;
  5687. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5688. builder.Write(rate.ToString("#0.0000"));//汇率
  5689. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5690. decimal rbmPrice = dac.SubTotal;
  5691. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5692. foodandotherStartIndex++;
  5693. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5694. }
  5695. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5696. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5697. {
  5698. table1.Rows.RemoveAt(i - 1);
  5699. }
  5700. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5701. string otherFeeStr = "";
  5702. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5703. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5704. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5705. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5706. foreach (var otherInfo in dac5)
  5707. {
  5708. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5709. }
  5710. #endregion
  5711. if (otherFeeStr.Length > 0)
  5712. {
  5713. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5714. otherFeeStr = $"({otherFeeStr})";
  5715. dic.Add("OtherFeeStr", otherFeeStr);
  5716. }
  5717. //总计
  5718. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5719. //国际旅费
  5720. string outsideAir = string.Empty;
  5721. string allPriceAir = string.Empty;
  5722. if (_EnterExitCosts.SumJJC == 1)
  5723. {
  5724. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5725. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5726. }
  5727. if (_EnterExitCosts.SumGWC == 1)
  5728. {
  5729. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5730. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5731. }
  5732. if (_EnterExitCosts.SumTDC == 1)
  5733. {
  5734. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5735. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5736. }
  5737. dic.Add("InTravelPrice", $"({outsideAir})");
  5738. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5739. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5740. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5741. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5742. foreach (var key in dic.Keys)
  5743. {
  5744. builder.MoveToBookmark(key);
  5745. builder.Write(dic[key]);
  5746. }
  5747. //模板文件名
  5748. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5749. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5750. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5751. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5752. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5753. }
  5754. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5755. {
  5756. //获取模板
  5757. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5758. //载入模板
  5759. WorkbookDesigner designer = new WorkbookDesigner();
  5760. designer.Workbook = new Workbook(tempPath);
  5761. Dictionary<string, string> dic = new Dictionary<string, string>();
  5762. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5763. {
  5764. List<string> list = new List<string>();
  5765. try
  5766. {
  5767. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5768. foreach (var item in spilitArr)
  5769. {
  5770. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5771. var depCode = spDotandEmpty[2].Substring(0, 3);
  5772. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5773. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5774. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5775. list.Add(depName);
  5776. list.Add(arrName);
  5777. }
  5778. list = list.Distinct().ToList();
  5779. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5780. }
  5781. catch (Exception)
  5782. {
  5783. dic.Add("ReturnCode", "行程录入不正确!");
  5784. }
  5785. }
  5786. else
  5787. {
  5788. dic.Add("ReturnCode", "未录入行程!");
  5789. }
  5790. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5791. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5792. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5793. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5794. {
  5795. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5796. dic.Add("Day", sp.Days.ToString());
  5797. }
  5798. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5799. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5800. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5801. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5802. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5803. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5804. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5805. designer.SetDataSource("Name", Names);
  5806. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5807. designer.SetDataSource("Day", dic["Day"] + "天");
  5808. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5809. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5810. int startIndex = 10;
  5811. const int startIndexcopy = 10;
  5812. if (dac2.Count == dac3.Count)//国家 币种 金额
  5813. {
  5814. for (int i = 0; i < dac2.Count; i++)
  5815. {
  5816. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5817. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5818. }
  5819. }
  5820. DataTable dtdac1 = new DataTable();
  5821. List<string> place = new List<string>();
  5822. dtdac1.Columns.AddRange(new DataColumn[] {
  5823. new DataColumn(){ ColumnName = "city"},
  5824. new DataColumn(){ ColumnName = "curr"},
  5825. new DataColumn(){ ColumnName = "criterion"},
  5826. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5827. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5828. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5829. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5830. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5831. });
  5832. DataTable dtdac2 = new DataTable();
  5833. dtdac2.Columns.AddRange(new DataColumn[] {
  5834. new DataColumn(){ ColumnName = "city"},
  5835. new DataColumn(){ ColumnName = "curr"},
  5836. new DataColumn(){ ColumnName = "criterion"},
  5837. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5838. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5839. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5840. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5841. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5842. });
  5843. dtdac1.TableName = "tb1";
  5844. dtdac2.TableName = "tb2";
  5845. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5846. foreach (var item in dac1)
  5847. {
  5848. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5849. if (place.Contains(item.Place))
  5850. {
  5851. continue;
  5852. }
  5853. DataRow row = dtdac1.NewRow();
  5854. row["city"] = item.Place;
  5855. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5856. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5857. row["curr"] = currency;
  5858. row["rate"] = rate.ToString("#0.0000");
  5859. row["criterion"] = item.Cost.ToString("#0.00");
  5860. row["number"] = 1;
  5861. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5862. //row["costRMB"] = rbmPrice;
  5863. dtdac1.Rows.Add(row);
  5864. place.Add(item.Place);
  5865. }
  5866. place = new List<string>();
  5867. foreach (var item in dac2)
  5868. {
  5869. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5870. if (place.Contains(item.Place))
  5871. {
  5872. continue;
  5873. }
  5874. DataRow row = dtdac2.NewRow();
  5875. row["city"] = item.Place;
  5876. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5877. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5878. row["curr"] = currency;
  5879. row["rate"] = rate.ToString("#0.0000");
  5880. row["criterion"] = item.Cost.ToString("#0.00");
  5881. row["number"] = 1;
  5882. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5883. //row["cost"] = item.SubTotal;
  5884. //row["costRMB"] = rbmPrice;
  5885. dtdac2.Rows.Add(row);
  5886. place.Add(item.Place);
  5887. //dac2totalPrice += rbmPrice;
  5888. }
  5889. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5890. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5891. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5892. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5893. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5894. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5895. string cell4Str1 = string.Empty;
  5896. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5897. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5898. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5899. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5900. string cellStr = $" 5.其他费用(";
  5901. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5902. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5903. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5904. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5905. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5906. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5907. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5908. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5909. foreach (var otherInfo in dac5)
  5910. {
  5911. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5912. }
  5913. #endregion
  5914. if (cellStr.Length > 8)
  5915. {
  5916. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5917. }
  5918. cellStr += ")";
  5919. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5920. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5921. decimal pxFee = dac4.Sum(it => it.Cost);
  5922. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5923. string celllastStr1 = "";
  5924. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5925. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5926. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5927. celllastStr1 += $",国际旅费 元";
  5928. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5929. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5930. designer.SetDataSource("cell4Str", cell4Str);
  5931. designer.SetDataSource("cellStr", cellStr);
  5932. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5933. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5934. designer.SetDataSource("celllastStr", celllastStr);
  5935. Workbook wb = designer.Workbook;
  5936. var sheet = wb.Worksheets[0];
  5937. //绑定datatable数据集
  5938. designer.SetDataSource(dtdac1);
  5939. designer.SetDataSource(dtdac2);
  5940. designer.Process();
  5941. var rowStart = dtdac1.Rows.Count;
  5942. while (rowStart > 0)
  5943. {
  5944. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5945. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5946. startIndex++;
  5947. rowStart--;
  5948. }
  5949. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5950. startIndex += 1; //总计行
  5951. rowStart = dtdac2.Rows.Count;
  5952. while (rowStart > 0)
  5953. {
  5954. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5955. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5956. startIndex++;
  5957. rowStart--;
  5958. }
  5959. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5960. wb.CalculateFormula(true);
  5961. //模板文件名
  5962. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5963. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5964. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5965. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5966. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5967. }
  5968. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5969. {
  5970. //获取模板
  5971. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5972. //载入模板
  5973. Document doc = new Document(tempPath);
  5974. DocumentBuilder builder = new DocumentBuilder(doc);
  5975. Dictionary<string, string> dic = new Dictionary<string, string>();
  5976. dic.Add("GroupName", _DelegationInfo.TeamName);
  5977. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5978. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5979. string missionLeaderJob = "";//负责人job
  5980. //int groupNumber = 0; //团人数
  5981. if (DeleClientList.Count > 0)
  5982. {
  5983. missionLeader = DeleClientList[0]?.Name ?? "";
  5984. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5985. }
  5986. dic.Add("MissionLeader", missionLeader); //团负责人
  5987. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5988. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5989. #region MyRegion
  5990. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5991. //{
  5992. // List<string> list = new List<string>();
  5993. // try
  5994. // {
  5995. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5996. // foreach (var item in spilitArr)
  5997. // {
  5998. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5999. // var depCode = spDotandEmpty[2].Substring(0, 3);
  6000. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  6001. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6002. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6003. // list.Add(depName);
  6004. // list.Add(arrName);
  6005. // }
  6006. // list = list.Distinct().ToList();
  6007. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6008. // }
  6009. // catch (Exception)
  6010. // {
  6011. // dic.Add("ReturnCode", "行程录入不正确!");
  6012. // }
  6013. //}
  6014. //else
  6015. //{
  6016. // dic.Add("ReturnCode", "未录入行程!");
  6017. //}
  6018. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  6019. dic.Add("ReturnCode", string.Join("、", countrys));
  6020. #endregion
  6021. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6022. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6023. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6024. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6025. //{
  6026. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6027. // dic.Add("Day", sp.Days.ToString());
  6028. //}
  6029. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  6030. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  6031. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6032. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6033. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6034. //培训人员名单
  6035. int cultivateRowIndex = 7;
  6036. foreach (var item in DeleClientList)
  6037. {
  6038. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  6039. builder.Write(item.Name);
  6040. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  6041. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  6042. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  6043. string birthDay = "";
  6044. if (item.Birthday != null)
  6045. {
  6046. DateTime dt = Convert.ToDateTime(item.Birthday);
  6047. birthDay = $"{dt.Year}.{dt.Month}";
  6048. }
  6049. builder.Write(birthDay);
  6050. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  6051. builder.Write(item.Company);
  6052. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  6053. builder.Write(item.Job);
  6054. cultivateRowIndex++;
  6055. }
  6056. //删除多余行
  6057. //cultivateRowIndex -= 2;
  6058. int delRows = 10 + 7 - cultivateRowIndex;
  6059. if (delRows > 0)
  6060. {
  6061. for (int i = 0; i < delRows; i++)
  6062. {
  6063. table1.Rows.RemoveAt(cultivateRowIndex);
  6064. //cultivateRowIndex++;
  6065. }
  6066. }
  6067. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  6068. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  6069. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  6070. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  6071. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  6072. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  6073. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  6074. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  6075. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  6076. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  6077. //其他费用
  6078. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  6079. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  6080. //其他费用合计
  6081. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  6082. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  6083. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  6084. //公务舱合计
  6085. //国际旅费
  6086. //string outsideJJ = "";
  6087. //string allPriceJJ = "";
  6088. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  6089. {
  6090. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6091. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  6092. }
  6093. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  6094. {
  6095. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  6096. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  6097. }
  6098. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  6099. {
  6100. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  6101. dic.Add("AirFeeTotal", airFeeTotalStr);
  6102. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  6103. dic.Add("FeeTotal", feeTotalStr);
  6104. }
  6105. foreach (var key in dic.Keys)
  6106. {
  6107. builder.MoveToBookmark(key);
  6108. builder.Write(dic[key]);
  6109. }
  6110. //模板文件名
  6111. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  6112. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6113. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6114. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6115. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6116. }
  6117. }
  6118. else if (dto.ExportType == 2) //表格
  6119. {
  6120. //利用键值对存放数据
  6121. Dictionary<string, string> dic = new Dictionary<string, string>();
  6122. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6123. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6124. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6125. dic.Add("Day", sp.Days.ToString());
  6126. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6127. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  6128. {
  6129. //获取模板
  6130. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  6131. //载入模板
  6132. Document doc = new Document(tempPath);
  6133. DocumentBuilder builder = new DocumentBuilder(doc);
  6134. dic.Add("TeamName", _DelegationInfo.TeamName);
  6135. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6136. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  6137. string missionLeaderName = "",
  6138. missionLeaderJob = "";
  6139. if (DeleClientList.Count > 0)
  6140. {
  6141. missionLeaderName = DeleClientList[0].Name;
  6142. missionLeaderJob = DeleClientList[0].Job;
  6143. }
  6144. dic.Add("MissionLeaderName", missionLeaderName);
  6145. dic.Add("MissionLeaderJob", missionLeaderJob);
  6146. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  6147. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  6148. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6149. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6150. int rowCount = 10;//总人数行
  6151. int startRowIndex = 7; //起始行
  6152. for (int i = 0; i < DeleClientList.Count; i++)
  6153. {
  6154. builder.MoveToCell(0, startRowIndex, 0, 0);
  6155. builder.Write(DeleClientList[i].Name); //出国人员姓名
  6156. builder.MoveToCell(0, startRowIndex, 1, 0);
  6157. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6158. builder.Write(sex);//性别
  6159. builder.MoveToCell(0, startRowIndex, 2, 0);
  6160. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  6161. builder.MoveToCell(0, startRowIndex, 3, 0);
  6162. builder.Write(DeleClientList[i].Company);//工作单位
  6163. builder.MoveToCell(0, startRowIndex, 4, 0);
  6164. builder.Write(DeleClientList[i].Job);//职务及级别
  6165. builder.MoveToCell(0, startRowIndex, 5, 0);
  6166. builder.Write("");//人员属性
  6167. builder.MoveToCell(0, startRowIndex, 6, 0);
  6168. builder.Write("");//上次出国时间
  6169. startRowIndex++;
  6170. }
  6171. int nullRow = rowCount - DeleClientList.Count;//空行
  6172. for (int i = 0; i < nullRow; i++)
  6173. {
  6174. table1.Rows.Remove(table1.Rows[startRowIndex]);
  6175. }
  6176. foreach (var key in dic.Keys)
  6177. {
  6178. builder.MoveToBookmark(key);
  6179. builder.Write(dic[key]);
  6180. }
  6181. //模板文件名
  6182. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  6183. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6184. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6185. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  6186. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  6187. }
  6188. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  6189. {
  6190. //获取模板
  6191. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  6192. //载入模板
  6193. Document doc = new Document(tempPath);
  6194. DocumentBuilder builder = new DocumentBuilder(doc);
  6195. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6196. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6197. dic.Add("Names", Names);
  6198. int accommodationRows = 12;
  6199. //int foodandotherRows = 12;
  6200. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6201. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6202. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6203. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6204. int accommodationStartIndex = 6;
  6205. decimal dac1totalPrice = 0.00M;
  6206. foreach (var dac in dac1)
  6207. {
  6208. if (dac.SubTotal == 0)
  6209. {
  6210. continue;
  6211. }
  6212. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6213. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6214. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6215. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6216. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6217. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6218. builder.Write(currency);//币种
  6219. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6220. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6221. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6222. builder.Write("");//人数
  6223. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6224. builder.Write("");//天数
  6225. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6226. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6227. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6228. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6229. builder.Write(rate.ToString("#0.0000"));//汇率
  6230. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6231. decimal rbmPrice = rate * dac.SubTotal;
  6232. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6233. accommodationStartIndex++;
  6234. dac1totalPrice += rbmPrice;
  6235. }
  6236. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6237. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6238. builder.Write("小计");
  6239. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6240. builder.Write(dac1totalPrice.ToString("#0.00"));
  6241. accommodationStartIndex++;
  6242. int nullRow = accommodationRows - dac1.Count;
  6243. //删除空行
  6244. //if (nullRow > 0)
  6245. //{
  6246. // int rowIndex = accommodationStartIndex;
  6247. // for (int i = 0; i < nullRow; i++)
  6248. // {
  6249. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6250. // row.Remove();
  6251. // rowIndex++;
  6252. // }
  6253. //}
  6254. if (dac2.Count == dac3.Count)//国家 币种 金额
  6255. {
  6256. for (int i = 0; i < dac2.Count; i++)
  6257. {
  6258. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6259. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6260. }
  6261. }
  6262. int foodandotherStartIndex = 19;//
  6263. decimal dac2totalPrice = 0.00M;
  6264. foreach (var dac in dac2)
  6265. {
  6266. if (dac.SubTotal == 0)
  6267. {
  6268. continue;
  6269. }
  6270. //foodandotherStartIndex = 12;
  6271. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6272. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6273. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6274. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6275. builder.Write(currency);//币种
  6276. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6277. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6278. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6279. builder.Write("");//人数
  6280. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6281. builder.Write("");//天数
  6282. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6283. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6284. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6285. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6286. builder.Write(rate.ToString("#0.0000"));//汇率
  6287. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6288. decimal rbmPrice = rate * dac.SubTotal;
  6289. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6290. foodandotherStartIndex++;
  6291. dac2totalPrice += rbmPrice;
  6292. }
  6293. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6294. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6295. //删除空行
  6296. //if (dac2.Count < foodandotherRows)
  6297. //{
  6298. // while (table2.Rows.Count > dac2.Count)
  6299. // {
  6300. // table2.Rows.RemoveAt(dac2.Count);
  6301. // }
  6302. //}
  6303. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6304. string otherFeeStr = "";
  6305. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6306. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6307. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6308. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6309. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6310. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6311. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6312. foreach (var otherInfo in dac5)
  6313. {
  6314. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6315. }
  6316. #endregion
  6317. if (otherFeeStr.Length > 0)
  6318. {
  6319. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6320. otherFeeStr = $"({otherFeeStr})";
  6321. dic.Add("OtherFeeStr", otherFeeStr);
  6322. }
  6323. foreach (var key in dic.Keys)
  6324. {
  6325. builder.MoveToBookmark(key);
  6326. builder.Write(dic[key]);
  6327. }
  6328. //模板文件名
  6329. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6330. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6331. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6332. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6333. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6334. }
  6335. }
  6336. else if (dto.ExportType == 3)
  6337. {
  6338. if (dto.SubTypeId == 1) //团组成员名单
  6339. {
  6340. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6341. //获取模板
  6342. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6343. //载入模板
  6344. Document doc = new Document(tempPath);
  6345. DocumentBuilder builder = new DocumentBuilder(doc);
  6346. //获取word里所有表格
  6347. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6348. //获取所填表格的序数
  6349. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6350. var rowStart = tableOne.Rows[0]; //获取第1行
  6351. //循环赋值
  6352. for (int i = 0; i < DeleClientList.Count; i++)
  6353. {
  6354. builder.MoveToCell(0, i + 1, 0, 0);
  6355. builder.Write(DeleClientList[i].Name);
  6356. builder.MoveToCell(0, i + 1, 1, 0);
  6357. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6358. builder.Write(sex);
  6359. builder.MoveToCell(0, i + 1, 2, 0);
  6360. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6361. builder.MoveToCell(0, i + 1, 3, 0);
  6362. builder.Write(DeleClientList[i].Company);
  6363. builder.MoveToCell(0, i + 1, 4, 0);
  6364. builder.Write(DeleClientList[i].Job);
  6365. }
  6366. //删除多余行
  6367. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6368. {
  6369. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6370. }
  6371. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6372. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6373. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6374. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6375. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6376. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6377. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6378. }
  6379. }
  6380. return Ok(JsonView(400, "操作失败!", ""));
  6381. }
  6382. catch (Exception ex)
  6383. {
  6384. return Ok(JsonView(400, ex.Message, ""));
  6385. }
  6386. }
  6387. /// <summary>
  6388. /// 获取三公费用标准city
  6389. /// </summary>
  6390. /// <param name="placeData"></param>
  6391. /// <param name="nationalTravelFeeId"></param>
  6392. /// <returns></returns>
  6393. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6394. {
  6395. string _city = string.Empty;
  6396. if (placeData.Count < 1) return _city;
  6397. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6398. if (data == null) return _city;
  6399. string country = data.Country;
  6400. string city = data.City;
  6401. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6402. else _city = city;
  6403. return _city;
  6404. }
  6405. /// <summary>
  6406. /// 团组模块 - 出入境费用 - 明细表导出
  6407. /// </summary>
  6408. /// <returns></returns>
  6409. [HttpPost]
  6410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6411. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6412. {
  6413. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6414. if (data.Code != 0)
  6415. {
  6416. return Ok(JsonView(false, data.Msg));
  6417. }
  6418. return Ok(JsonView(true, data.Msg, data.Data));
  6419. }
  6420. /// <summary>
  6421. /// 团组模块 - 出入境费用 - 一键清空
  6422. /// </summary>
  6423. /// <returns></returns>
  6424. [HttpPost]
  6425. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6427. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6428. {
  6429. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6430. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6431. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6432. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6433. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6434. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6435. .SetColumns(x => new Grp_DayOtherPrice
  6436. {
  6437. IsDel = 1,
  6438. DeleteUserId = dto.UserId,
  6439. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6440. })
  6441. .ExecuteCommandAsync();
  6442. if (_view.Code == 0)
  6443. {
  6444. return Ok(JsonView(true, "操作成功"));
  6445. }
  6446. return Ok(JsonView(false, "操作失败"));
  6447. }
  6448. /// <summary>
  6449. /// 团组模块 - 出入境费用 - 子项删除
  6450. /// </summary>
  6451. /// <returns></returns>
  6452. [HttpPost]
  6453. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6455. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6456. {
  6457. try
  6458. {
  6459. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6460. if (data.Code != 0)
  6461. {
  6462. return Ok(JsonView(false, data.Msg));
  6463. }
  6464. return Ok(JsonView(true, "操作成功!", data.Data));
  6465. }
  6466. catch (Exception ex)
  6467. {
  6468. return Ok(JsonView(false, ex.Message));
  6469. }
  6470. }
  6471. /// <summary>
  6472. /// 删除三公其他费用
  6473. /// </summary>
  6474. /// <param name="dto"></param>
  6475. /// <returns></returns>
  6476. [HttpPost]
  6477. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6478. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6479. {
  6480. var jw = JsonView(false, "删除失败!");
  6481. var data = new Grp_DayOtherPrice()
  6482. {
  6483. Id = dto.Id,
  6484. IsDel = 1,
  6485. DeleteUserId = dto.DeleteUserId,
  6486. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6487. };
  6488. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6489. if (del > 0)
  6490. {
  6491. jw.Code = 200;
  6492. jw.Msg = "删除成功!";
  6493. }
  6494. return Ok(jw);
  6495. }
  6496. /// <summary>
  6497. /// 团组模块 - 出入境国家费用标准 List
  6498. /// </summary>
  6499. /// <returns></returns>
  6500. [HttpPost]
  6501. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6502. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6503. {
  6504. try
  6505. {
  6506. Stopwatch sw = new Stopwatch();
  6507. sw.Start();
  6508. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6509. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6510. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6511. Where gntf.Isdel = 0");
  6512. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6513. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6514. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6515. //foreach (var item in nationalTravel)
  6516. //{
  6517. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6518. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6519. // if (otherData != null)
  6520. // {
  6521. // cityData.Remove(otherData);
  6522. // cityData.Add(otherData);
  6523. // }
  6524. // nationalTravelFeeData1.Add(new
  6525. // {
  6526. // Country = item.Country,
  6527. // CityData = cityData
  6528. // });
  6529. //}
  6530. sw.Stop();
  6531. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6532. }
  6533. catch (Exception ex)
  6534. {
  6535. return Ok(JsonView(false, ex.Message));
  6536. throw;
  6537. }
  6538. }
  6539. /// <summary>
  6540. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6541. /// </summary>
  6542. /// <returns></returns>
  6543. [HttpPost]
  6544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6545. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6546. {
  6547. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6548. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6549. List<string> countryData = new List<string>();
  6550. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  6551. countryData = countryData.Distinct().ToList();
  6552. List<dynamic> dataSource = new List<dynamic>();
  6553. foreach (var item in countryData)
  6554. {
  6555. var cityData1 = new List<string>();
  6556. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  6557. var countryData2 = new
  6558. {
  6559. CountryName = item,
  6560. CityData = cityData1
  6561. };
  6562. dataSource.Add(countryData2);
  6563. }
  6564. return Ok(JsonView(true, "查询成功!", dataSource));
  6565. }
  6566. /// <summary>
  6567. /// 团组模块 - 出入境国家费用标准 Page List
  6568. /// </summary>
  6569. /// <returns></returns>
  6570. [HttpPost]
  6571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6572. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6573. {
  6574. int portId = dto.PortType;
  6575. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6576. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6577. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6578. string whereSql = string.Empty;
  6579. if (!string.IsNullOrEmpty(dto.Country))
  6580. {
  6581. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6582. }
  6583. if (!string.IsNullOrEmpty(dto.City))
  6584. {
  6585. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6586. }
  6587. string pageSql = string.Format(@"Select * From (
  6588. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6589. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6590. From Grp_NationalTravelFee gntf
  6591. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6592. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6593. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6594. RefAsync<int> total = 0;
  6595. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6596. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6597. }
  6598. /// <summary>
  6599. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6600. /// </summary>
  6601. /// <returns></returns>
  6602. [HttpPost]
  6603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6604. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6605. {
  6606. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6607. int portId = dto.PortType;
  6608. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6609. string whereSql = string.Empty;
  6610. if (!string.IsNullOrEmpty(dto.Country))
  6611. {
  6612. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6613. }
  6614. if (!string.IsNullOrEmpty(dto.City))
  6615. {
  6616. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6617. }
  6618. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6619. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6620. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6621. From Grp_NationalTravelFee gntf
  6622. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6623. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6624. Where gntf.Isdel = 0 {0} ", whereSql);
  6625. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6626. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6627. }
  6628. /// <summary>
  6629. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6630. /// </summary>
  6631. /// <returns></returns>
  6632. [HttpPost]
  6633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6634. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6635. {
  6636. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6637. if (data.Code != 0)
  6638. {
  6639. return Ok(JsonView(false, data.Msg));
  6640. }
  6641. return Ok(JsonView(true, "操作成功!", data.Data));
  6642. }
  6643. /// <summary>
  6644. /// 团组模块 - 出入境国家费用标准 - Del
  6645. /// </summary>
  6646. /// <returns></returns>
  6647. [HttpPost]
  6648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6649. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6650. {
  6651. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6652. {
  6653. Id = dto.Id,
  6654. DeleteUserId = dto.DeleteUserId,
  6655. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6656. IsDel = 1
  6657. };
  6658. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6659. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6660. .WhereColumns(it => new { it.Id })
  6661. .ExecuteCommandAsync();
  6662. if (delStatus <= 0)
  6663. {
  6664. return Ok(JsonView(false, "删除失败!"));
  6665. }
  6666. return Ok(JsonView(true, "操作成功!"));
  6667. }
  6668. /// <summary>
  6669. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6670. /// 注:Get 请求Headers 加 Token
  6671. /// </summary>
  6672. /// <param name="groupId"></param>
  6673. /// <returns></returns>
  6674. [HttpGet("{groupId}")]
  6675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6676. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6677. {
  6678. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6679. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6680. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6681. data.ForEach(x =>
  6682. {
  6683. x.CreateUserId = _currUserInfo.UserId;
  6684. });
  6685. if (data.Any())
  6686. {
  6687. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6688. if (add > 0)
  6689. {
  6690. return Ok(JsonView(true, "操作成功!"));
  6691. }
  6692. }
  6693. return Ok(JsonView(false, "未操作!"));
  6694. }
  6695. #endregion
  6696. #region 团组经理模块 出入境费用-草稿
  6697. /// <summary>
  6698. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6699. /// </summary>
  6700. /// <returns></returns>
  6701. [HttpPost]
  6702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6703. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6704. {
  6705. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6706. .Where(x => x.IsDel == 0)
  6707. .OrderByDescending(x => x.CreateTime)
  6708. .Select(x => new { x.Id, x.DraftName })
  6709. .ToListAsync();
  6710. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6711. //SetDataInfoView
  6712. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6713. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6714. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6715. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6716. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6717. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6718. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6719. //默认币种显示
  6720. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6721. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6722. return Ok(JsonView(true, "查询成功!", new
  6723. {
  6724. DraftNameDatas = draftNameDatas,
  6725. CurrencyData = _CurrencyData,
  6726. WordTypeData = _WordTypeData,
  6727. ExcelTypeData = _ExcelTypeData,
  6728. CurrencyInit = _currencyInfos,
  6729. ViewPermissionData = viewPermissionData
  6730. }));
  6731. }
  6732. /// <summary>
  6733. /// 团组模块 - 出入境费用-草稿
  6734. /// 实时汇率 tips
  6735. /// 机票费用 tips
  6736. /// </summary>
  6737. /// <returns></returns>
  6738. [HttpPost]
  6739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6740. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6741. {
  6742. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6743. return Ok(JsonView(true, "查询成功!", new
  6744. {
  6745. //GroupNameData = groupNameData.Data,
  6746. //visaData = visaData.Data,
  6747. //airData = airData.Data,
  6748. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  6749. }));
  6750. }
  6751. /// <summary>
  6752. /// 团组模块 - 出入境费用-草稿
  6753. /// 签证费用 tips
  6754. /// </summary>
  6755. /// <returns></returns>
  6756. [HttpPost]
  6757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6758. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  6759. {
  6760. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  6761. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  6762. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  6763. .Select(x => x.NationalTravelFeeId)
  6764. .Distinct()
  6765. .ToListAsync();
  6766. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6767. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6768. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  6769. .Select(x => x.Country)
  6770. .Distinct()
  6771. .ToArrayAsync();
  6772. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6773. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  6774. return Ok(JsonView(true, "查询成功!", new
  6775. {
  6776. totalAmt = totalAmt,
  6777. remark = remark
  6778. }));
  6779. }
  6780. /// <summary>
  6781. /// 团组模块 - 出入境费用-草稿 - Info
  6782. /// </summary>
  6783. /// <returns></returns>
  6784. [HttpPost]
  6785. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  6786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6787. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6788. {
  6789. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6790. }
  6791. /// <summary>
  6792. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6793. /// </summary>
  6794. /// <returns></returns>
  6795. [HttpPost]
  6796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6797. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6798. {
  6799. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6800. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6801. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6802. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6803. foreach (var userId in dto.UserIds)
  6804. {
  6805. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6806. }
  6807. if (permissions.Any())
  6808. {
  6809. _sqlSugar.BeginTran();
  6810. try
  6811. {
  6812. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6813. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6814. if (result < 1)
  6815. {
  6816. _sqlSugar.RollbackTran();
  6817. return Ok(JsonView(false));
  6818. }
  6819. }
  6820. catch (Exception ex)
  6821. {
  6822. _sqlSugar.RollbackTran();
  6823. return Ok(JsonView(false, ex.Message));
  6824. }
  6825. _sqlSugar.CommitTran();
  6826. return Ok(JsonView(true));
  6827. }
  6828. return Ok(JsonView(false));
  6829. }
  6830. /// <summary>
  6831. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6832. /// </summary>
  6833. /// <returns></returns>
  6834. [HttpPost]
  6835. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  6836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6837. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6838. {
  6839. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6840. if (data.Code != 0)
  6841. {
  6842. return Ok(JsonView(false, data.Msg));
  6843. }
  6844. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6845. //汇率信息记录
  6846. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6847. return Ok(JsonView(true, data.Msg, data.Data));
  6848. }
  6849. /// <summary>
  6850. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6851. /// </summary>
  6852. /// <param name="dto"></param>
  6853. /// <returns></returns>
  6854. [HttpPost]
  6855. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  6856. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6857. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6858. {
  6859. try
  6860. {
  6861. var id = dto.Id;
  6862. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6863. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6864. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6865. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6866. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6867. 3 团组成员名单 1 团组成员名单", ""));
  6868. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6869. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6870. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6871. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6872. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6873. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6874. //数据源
  6875. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6876. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6877. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6878. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6879. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6880. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6881. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6882. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6883. .Select((x, a, b) => new
  6884. {
  6885. x.Index,
  6886. itemName = a.Name,
  6887. CurrencyStr = b.Name,
  6888. x.Cost,
  6889. x.SubTotal,
  6890. x.Remark
  6891. })
  6892. .OrderBy((x) => x.Index)
  6893. .ToList(); //其他款项费用
  6894. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6895. var peiceItemCurrencys = new List<string>();
  6896. if (_DayAndCosts.Any())
  6897. {
  6898. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6899. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6900. }
  6901. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6902. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6903. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6904. {
  6905. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6906. }
  6907. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6908. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6909. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6910. if (dto.ExportType == 1) //明细表
  6911. {
  6912. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6913. {
  6914. //获取模板
  6915. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6916. //载入模板
  6917. Document doc = new Document(tempPath);
  6918. DocumentBuilder builder = new DocumentBuilder(doc);
  6919. //利用键值对存放数据
  6920. Dictionary<string, string> dic = new Dictionary<string, string>();
  6921. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6922. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6923. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6924. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6925. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6926. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6927. //境内费用(其他费用)
  6928. if (_EnterExitCosts.ChoiceOne == 1)
  6929. {
  6930. string row1_1 = "";
  6931. if (_EnterExitCosts.Visa > 0)
  6932. {
  6933. //insidePayTotal += _EnterExitCosts.Visa;
  6934. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6935. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6936. {
  6937. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6938. }
  6939. }
  6940. string row1_2 = "";
  6941. if (_EnterExitCosts.YiMiao > 0)
  6942. {
  6943. //insidePayTotal += _EnterExitCosts.YiMiao;
  6944. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6945. }
  6946. if (_EnterExitCosts.HeSuan > 0)
  6947. {
  6948. //insidePayTotal += _EnterExitCosts.HeSuan;
  6949. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6950. }
  6951. if (_EnterExitCosts.Service > 0)
  6952. {
  6953. //insidePayTotal += _EnterExitCosts.Service;
  6954. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6955. }
  6956. string row1_3 = "";
  6957. if (_EnterExitCosts.Safe > 0)
  6958. {
  6959. //insidePayTotal += _EnterExitCosts.Safe;
  6960. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6961. }
  6962. if (_EnterExitCosts.Ticket > 0)
  6963. {
  6964. //insidePayTotal += _EnterExitCosts.Ticket;
  6965. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6966. }
  6967. string row1 = "";
  6968. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6969. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6970. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6971. row1 += $"备注:{_EnterExitCosts.Remark}";
  6972. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6973. dic.Add("Row1Str", row1);
  6974. }
  6975. string airTotalStr = string.Empty,
  6976. airPriceStr = string.Empty;
  6977. //经济舱
  6978. if (_EnterExitCosts.SumJJC == 1)
  6979. {
  6980. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6981. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6982. }
  6983. //公务舱
  6984. if (_EnterExitCosts.SumGWC == 1)
  6985. {
  6986. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6987. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6988. }
  6989. //头等舱
  6990. if (_EnterExitCosts.SumTDC == 1)
  6991. {
  6992. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6993. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6994. }
  6995. //汇率描述
  6996. string rateStr = "";
  6997. if (peiceItemCurrencyInfos.Any())
  6998. {
  6999. rateStr = "\r\n汇率描述:";
  7000. foreach (var item in peiceItemCurrencyInfos)
  7001. {
  7002. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  7003. }
  7004. }
  7005. string twoItemRemark = "备注:";
  7006. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7007. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7008. dic.Add("AirTotalStr", airTotalStr);
  7009. dic.Add("AirPriceStr", airPriceStr);
  7010. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7011. dic.Add("TwoItemRemark", twoItemRemark);
  7012. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7013. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7014. int table1Row = 0,
  7015. table2Row = 0,
  7016. table3Row = 0,
  7017. table4Row = 0,
  7018. table5Row = 0;
  7019. //住宿费
  7020. if (_EnterExitCosts.ChoiceThree == 1)
  7021. {
  7022. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  7023. table1Row = dac1.Count;
  7024. #region 填充word表格内容
  7025. for (int i = 0; i < dac1.Count; i++)
  7026. {
  7027. var dac = dac1[i];
  7028. if (dac == null) continue;
  7029. builder.MoveToCell(0, i, 0, 0);
  7030. builder.Write("第" + dac.Days.ToString() + "晚:");
  7031. builder.MoveToCell(0, i, 1, 0);
  7032. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  7033. //builder.Write(dac.Place == null ? "" : dac.Place);
  7034. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7035. builder.MoveToCell(0, i, 2, 0);
  7036. builder.Write("费用标准:");
  7037. string curr = "";
  7038. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7039. if (currData != null)
  7040. {
  7041. curr = currData.Name;
  7042. }
  7043. builder.MoveToCell(0, i, 3, 0);
  7044. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7045. builder.MoveToCell(0, i, 4, 0);
  7046. builder.Write("费用小计:");
  7047. builder.MoveToCell(0, i, 5, 0);
  7048. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7049. }
  7050. #endregion
  7051. }
  7052. else dic.Add("SubZS", "0.00");
  7053. //删除多余行
  7054. while (table1.Rows.Count > table1Row)
  7055. {
  7056. table1.Rows.RemoveAt(table1Row);
  7057. }
  7058. //伙食费
  7059. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7060. if (_EnterExitCosts.ChoiceFour == 1)
  7061. {
  7062. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7063. table2Row = dac2.Count;
  7064. #region 填充word表格内容
  7065. for (int i = 0; i < dac2.Count; i++)
  7066. {
  7067. var dac = dac2[i];
  7068. if (dac == null) continue;
  7069. builder.MoveToCell(1, i, 0, 0);
  7070. builder.Write("第" + dac.Days.ToString() + "天:");
  7071. builder.MoveToCell(1, i, 1, 0);
  7072. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7073. builder.MoveToCell(1, i, 2, 0);
  7074. builder.Write("费用标准:");
  7075. string curr = "";
  7076. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7077. if (currData != null)
  7078. {
  7079. curr = currData.Name;
  7080. }
  7081. builder.MoveToCell(1, i, 3, 0);
  7082. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7083. builder.MoveToCell(1, i, 4, 0);
  7084. builder.Write("费用小计:");
  7085. builder.MoveToCell(1, i, 5, 0);
  7086. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7087. }
  7088. #endregion
  7089. }
  7090. else dic.Add("SubHS", "0.00");
  7091. //删除多余行
  7092. while (table2.Rows.Count > table2Row)
  7093. {
  7094. table2.Rows.RemoveAt(table2Row);
  7095. }
  7096. //公杂费
  7097. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7098. if (_EnterExitCosts.ChoiceFive == 1)
  7099. {
  7100. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7101. table3Row = dac3.Count;
  7102. #region 填充word表格内容
  7103. for (int i = 0; i < dac3.Count; i++)
  7104. {
  7105. var dac = dac3[i];
  7106. if (dac == null) continue;
  7107. builder.MoveToCell(2, i, 0, 0);
  7108. builder.Write("第" + dac.Days.ToString() + "天:");
  7109. builder.MoveToCell(2, i, 1, 0);
  7110. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7111. builder.MoveToCell(2, i, 2, 0);
  7112. builder.Write("费用标准:");
  7113. string curr = "";
  7114. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7115. if (currData != null)
  7116. {
  7117. curr = currData.Name;
  7118. }
  7119. builder.MoveToCell(2, i, 3, 0);
  7120. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7121. builder.MoveToCell(2, i, 4, 0);
  7122. builder.Write("费用小计:");
  7123. builder.MoveToCell(2, i, 5, 0);
  7124. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7125. }
  7126. //删除多余行
  7127. while (table3.Rows.Count > table3Row)
  7128. {
  7129. table3.Rows.RemoveAt(table3Row);
  7130. }
  7131. #endregion
  7132. }
  7133. else dic.Add("SubGZF", "0.00");
  7134. //删除多余行
  7135. while (table3.Rows.Count > table3Row)
  7136. {
  7137. table3.Rows.RemoveAt(table3Row);
  7138. }
  7139. //培训费
  7140. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7141. if (_EnterExitCosts.ChoiceSix == 1)
  7142. {
  7143. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  7144. dic.Add("SubPX", pxStr);
  7145. table4Row = dac4.Count;
  7146. #region 填充word表格内容
  7147. for (int i = 0; i < dac4.Count; i++)
  7148. {
  7149. var dac = dac4[i];
  7150. if (dac == null) continue;
  7151. builder.MoveToCell(3, i, 0, 0);
  7152. builder.Write("第" + dac.Days.ToString() + "天:");
  7153. builder.MoveToCell(3, i, 1, 0);
  7154. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7155. builder.MoveToCell(3, i, 2, 0);
  7156. builder.Write("费用标准:");
  7157. string curr = "";
  7158. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7159. if (currData != null)
  7160. {
  7161. curr = currData.Name;
  7162. }
  7163. builder.MoveToCell(3, i, 3, 0);
  7164. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7165. builder.MoveToCell(3, i, 4, 0);
  7166. builder.Write("费用小计:");
  7167. builder.MoveToCell(3, i, 5, 0);
  7168. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7169. }
  7170. #endregion
  7171. }
  7172. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  7173. //删除多余行
  7174. while (table4.Rows.Count > table4Row)
  7175. {
  7176. table4.Rows.RemoveAt(table4Row);
  7177. }
  7178. //其他费用
  7179. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7180. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7181. {
  7182. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  7183. dic.Add("titleQi", qtStr);
  7184. table5Row = dac5.Count;
  7185. #region 填充word表格内容
  7186. for (int i = 0; i < dac5.Count; i++)
  7187. {
  7188. var dac = dac5[i];
  7189. if (dac == null) continue;
  7190. builder.MoveToCell(4, i, 0, 0);
  7191. builder.Write("第" + dac.Index.ToString() + "项:");
  7192. builder.MoveToCell(4, i, 1, 0);
  7193. builder.Write(dac.itemName);
  7194. builder.MoveToCell(4, i, 2, 0);
  7195. builder.Write("费用标准:");
  7196. builder.MoveToCell(4, i, 3, 0);
  7197. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7198. builder.MoveToCell(4, i, 4, 0);
  7199. builder.Write("费用小计:");
  7200. builder.MoveToCell(4, i, 5, 0);
  7201. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7202. builder.MoveToCell(4, i, 6, 0);
  7203. builder.Write("备注:");
  7204. builder.MoveToCell(4, i, 7, 0);
  7205. builder.Write(dac.Remark);
  7206. }
  7207. #endregion
  7208. }
  7209. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7210. //删除多余行
  7211. while (table5.Rows.Count > table5Row)
  7212. {
  7213. table5.Rows.RemoveAt(table5Row);
  7214. }
  7215. //加上其他费用
  7216. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7217. decimal subJJC = 0.00M,
  7218. subGWC = 0.00M,
  7219. subTDC = 0.00M;
  7220. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7221. string totalLabel = string.Format("全部费用总计:");
  7222. //经济舱
  7223. if (_EnterExitCosts.SumJJC == 1)
  7224. {
  7225. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7226. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  7227. }
  7228. //公务舱
  7229. if (_EnterExitCosts.SumGWC == 1)
  7230. {
  7231. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7232. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  7233. }
  7234. //头等舱
  7235. if (_EnterExitCosts.SumTDC == 1)
  7236. {
  7237. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7238. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  7239. }
  7240. //TotalLabel
  7241. dic.Add("TotalLabel", totalLabel);
  7242. #region 填充word模板书签内容
  7243. foreach (var key in dic.Keys)
  7244. {
  7245. Bookmark bookmark = doc.Range.Bookmarks[key];
  7246. if (bookmark != null)
  7247. {
  7248. builder.MoveToBookmark(key);
  7249. builder.Write(dic[key]);
  7250. }
  7251. }
  7252. #endregion
  7253. //文件名
  7254. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7255. strFileName = CommonFun.ValidFileName(strFileName);
  7256. AsposeHelper.removewatermark_v2180();
  7257. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7258. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7259. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7260. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7261. }
  7262. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7263. {
  7264. //获取模板
  7265. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7266. //载入模板
  7267. Document doc = new Document(tempPath);
  7268. DocumentBuilder builder = new DocumentBuilder(doc);
  7269. Dictionary<string, string> dic = new Dictionary<string, string>();
  7270. string returnCodeLabel = string.Empty;
  7271. if (nationalTravelFeeData.Any())
  7272. {
  7273. List<string> list = new List<string>();
  7274. foreach (var item in nationalTravelFeeData)
  7275. {
  7276. list.Add($"{item.Country}({item.City})");
  7277. }
  7278. list = list.Distinct().ToList();
  7279. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7280. }
  7281. var countryLabel = string.Empty;
  7282. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7283. if (countryData.Any())
  7284. {
  7285. countryLabel = string.Join("、", countryData);
  7286. }
  7287. dic.Add("ReturnCodeAir", returnCodeLabel);
  7288. dic.Add("VisitStartDate", "-");
  7289. dic.Add("VisitEndDate", "-");
  7290. dic.Add("Day", "-");
  7291. dic.Add("VisitCountry", countryLabel);
  7292. dic.Add("ClientUnit", "-");
  7293. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7294. //dic.Add("Names", Names);
  7295. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7296. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7297. decimal dac1totalPrice = 0.00M;
  7298. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7299. foreach (var dac in dac1)
  7300. {
  7301. if (dac.SubTotal == 0.00M)
  7302. {
  7303. continue;
  7304. }
  7305. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7306. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7307. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7308. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7309. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7310. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7311. builder.Write(currency);//币种
  7312. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7313. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7314. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7315. builder.Write("");//人数
  7316. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7317. builder.Write("");//天数
  7318. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7319. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7320. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7321. decimal rate = 0.00M;
  7322. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7323. builder.Write(rate.ToString("#0.0000"));//汇率
  7324. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7325. decimal rbmPrice = dac.SubTotal;
  7326. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7327. accommodationStartIndex++;
  7328. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7329. }
  7330. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7331. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7332. {
  7333. table1.Rows.RemoveAt(i - 1);
  7334. foodandotherStartIndex--;
  7335. }
  7336. if (dac2.Count == dac3.Count)//国家 币种 金额
  7337. {
  7338. for (int i = 0; i < dac2.Count; i++)
  7339. {
  7340. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7341. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7342. }
  7343. }
  7344. decimal dac2totalPrice = 0.00M;
  7345. foreach (var dac in dac2)
  7346. {
  7347. if (dac.SubTotal == 0)
  7348. {
  7349. continue;
  7350. }
  7351. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7352. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7353. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7354. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7355. builder.Write(currency);//币种
  7356. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7357. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7358. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7359. builder.Write("");//人数
  7360. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7361. builder.Write("");//天数
  7362. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7363. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7364. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7365. decimal rate = 0.00M;
  7366. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7367. builder.Write(rate.ToString("#0.0000"));//汇率
  7368. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7369. decimal rbmPrice = dac.SubTotal;
  7370. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7371. foodandotherStartIndex++;
  7372. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7373. }
  7374. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7375. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7376. {
  7377. table1.Rows.RemoveAt(i - 1);
  7378. }
  7379. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7380. string otherFeeStr = "";
  7381. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7382. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7383. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7384. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7385. foreach (var otherInfo in dac5)
  7386. {
  7387. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7388. }
  7389. #endregion
  7390. if (otherFeeStr.Length > 0)
  7391. {
  7392. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7393. otherFeeStr = $"({otherFeeStr})";
  7394. dic.Add("OtherFeeStr", otherFeeStr);
  7395. }
  7396. //总计
  7397. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7398. //国际旅费
  7399. string outsideAir = string.Empty;
  7400. string allPriceAir = string.Empty;
  7401. if (_EnterExitCosts.SumJJC == 1)
  7402. {
  7403. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7404. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7405. }
  7406. if (_EnterExitCosts.SumGWC == 1)
  7407. {
  7408. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7409. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7410. }
  7411. if (_EnterExitCosts.SumTDC == 1)
  7412. {
  7413. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7414. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7415. }
  7416. dic.Add("InTravelPrice", $"({outsideAir})");
  7417. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7418. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7419. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7420. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7421. foreach (var key in dic.Keys)
  7422. {
  7423. builder.MoveToBookmark(key);
  7424. builder.Write(dic[key]);
  7425. }
  7426. //模板文件名
  7427. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7428. strFileName = CommonFun.ValidFileName(strFileName);
  7429. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7430. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7431. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7432. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7433. }
  7434. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7435. {
  7436. //获取模板
  7437. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7438. //载入模板
  7439. WorkbookDesigner designer = new WorkbookDesigner();
  7440. designer.Workbook = new Workbook(tempPath);
  7441. Dictionary<string, string> dic = new Dictionary<string, string>();
  7442. string returnCodeLabel = string.Empty;
  7443. if (nationalTravelFeeData.Any())
  7444. {
  7445. List<string> list = new List<string>();
  7446. foreach (var item in nationalTravelFeeData)
  7447. {
  7448. list.Add($"{item.Country}({item.City})");
  7449. }
  7450. list = list.Distinct().ToList();
  7451. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7452. }
  7453. var countryLabel = string.Empty;
  7454. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7455. if (countryData.Any())
  7456. {
  7457. countryLabel = string.Join("、", countryData);
  7458. }
  7459. dic.Add("ReturnCodeAir", returnCodeLabel);
  7460. dic.Add("VisitStartDate", "-");
  7461. dic.Add("VisitEndDate", "-");
  7462. dic.Add("Day", "0");
  7463. dic.Add("VisitCountry", countryLabel);
  7464. dic.Add("ClientUnit", "-");
  7465. designer.SetDataSource("ClientUnit", "-");
  7466. designer.SetDataSource("VisitCountry", countryLabel);
  7467. designer.SetDataSource("Group", "-");
  7468. designer.SetDataSource("ClientUnitTitle", "-");
  7469. designer.SetDataSource("Name", "-");
  7470. designer.SetDataSource("VisitStartDate", "-");
  7471. designer.SetDataSource("Day", "0");
  7472. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7473. designer.SetDataSource("ReturnCodeAir", "-");
  7474. int startIndex = 10;
  7475. const int startIndexcopy = 10;
  7476. if (dac2.Count == dac3.Count)//国家 币种 金额
  7477. {
  7478. for (int i = 0; i < dac2.Count; i++)
  7479. {
  7480. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7481. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7482. }
  7483. }
  7484. DataTable dtdac1 = new DataTable();
  7485. List<string> place = new List<string>();
  7486. dtdac1.Columns.AddRange(new DataColumn[] {
  7487. new DataColumn(){ ColumnName = "city"},
  7488. new DataColumn(){ ColumnName = "curr"},
  7489. new DataColumn(){ ColumnName = "criterion"},
  7490. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7491. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7492. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7493. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7494. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7495. });
  7496. DataTable dtdac2 = new DataTable();
  7497. dtdac2.Columns.AddRange(new DataColumn[] {
  7498. new DataColumn(){ ColumnName = "city"},
  7499. new DataColumn(){ ColumnName = "curr"},
  7500. new DataColumn(){ ColumnName = "criterion"},
  7501. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7502. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7503. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7504. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7505. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7506. });
  7507. dtdac1.TableName = "tb1";
  7508. dtdac2.TableName = "tb2";
  7509. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7510. foreach (var item in dac1)
  7511. {
  7512. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7513. if (place.Contains(item.Place))
  7514. {
  7515. continue;
  7516. }
  7517. DataRow row = dtdac1.NewRow();
  7518. row["city"] = item.Place;
  7519. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7520. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7521. row["curr"] = currency;
  7522. row["rate"] = rate.ToString("#0.0000");
  7523. row["criterion"] = item.Cost.ToString("#0.00");
  7524. row["number"] = 1;
  7525. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7526. //row["costRMB"] = rbmPrice;
  7527. dtdac1.Rows.Add(row);
  7528. place.Add(item.Place);
  7529. }
  7530. place = new List<string>();
  7531. foreach (var item in dac2)
  7532. {
  7533. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7534. if (place.Contains(item.Place))
  7535. {
  7536. continue;
  7537. }
  7538. DataRow row = dtdac2.NewRow();
  7539. row["city"] = item.Place;
  7540. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7541. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7542. row["curr"] = currency;
  7543. row["rate"] = rate.ToString("#0.0000");
  7544. row["criterion"] = item.Cost.ToString("#0.00");
  7545. row["number"] = 1;
  7546. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7547. //row["cost"] = item.SubTotal;
  7548. //row["costRMB"] = rbmPrice;
  7549. dtdac2.Rows.Add(row);
  7550. place.Add(item.Place);
  7551. //dac2totalPrice += rbmPrice;
  7552. }
  7553. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7554. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7555. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7556. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7557. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7558. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7559. string cell4Str1 = string.Empty;
  7560. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7561. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7562. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7563. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7564. string cellStr = $" 5.其他费用(";
  7565. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7566. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7567. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7568. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7569. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7570. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7571. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7572. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7573. foreach (var otherInfo in dac5)
  7574. {
  7575. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7576. }
  7577. #endregion
  7578. if (cellStr.Length > 8)
  7579. {
  7580. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7581. }
  7582. cellStr += ")";
  7583. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7584. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7585. decimal pxFee = dac4.Sum(it => it.Cost);
  7586. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7587. string celllastStr1 = "";
  7588. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7589. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7590. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7591. celllastStr1 += $",国际旅费 元";
  7592. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7593. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7594. designer.SetDataSource("cell4Str", cell4Str);
  7595. designer.SetDataSource("cellStr", cellStr);
  7596. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7597. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7598. designer.SetDataSource("celllastStr", celllastStr);
  7599. Workbook wb = designer.Workbook;
  7600. var sheet = wb.Worksheets[0];
  7601. //绑定datatable数据集
  7602. designer.SetDataSource(dtdac1);
  7603. designer.SetDataSource(dtdac2);
  7604. designer.Process();
  7605. var rowStart = dtdac1.Rows.Count;
  7606. while (rowStart > 0)
  7607. {
  7608. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7609. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7610. startIndex++;
  7611. rowStart--;
  7612. }
  7613. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7614. startIndex += 1; //总计行
  7615. rowStart = dtdac2.Rows.Count;
  7616. while (rowStart > 0)
  7617. {
  7618. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7619. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7620. startIndex++;
  7621. rowStart--;
  7622. }
  7623. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7624. wb.CalculateFormula(true);
  7625. //模板文件名
  7626. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7627. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7628. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7629. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7630. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7631. }
  7632. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7633. {
  7634. //获取模板
  7635. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7636. //载入模板
  7637. Document doc = new Document(tempPath);
  7638. DocumentBuilder builder = new DocumentBuilder(doc);
  7639. Dictionary<string, string> dic = new Dictionary<string, string>();
  7640. dic.Add("GroupName", "-");
  7641. dic.Add("ClientUnit", "-");
  7642. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7643. //string missionLeaderJob = "";//负责人job
  7644. //int groupNumber = 0; //团人数
  7645. dic.Add("MissionLeader", "-"); //团负责人
  7646. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7647. dic.Add("GroupNumber", "0"); //团人数
  7648. dic.Add("Day", "0");
  7649. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7650. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7651. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7652. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7653. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7654. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7655. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7656. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7657. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7658. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7659. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7660. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7661. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7662. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7663. //其他费用
  7664. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7665. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7666. //其他费用合计
  7667. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7668. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7669. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7670. //公务舱合计
  7671. //国际旅费
  7672. //string outsideJJ = "";
  7673. //string allPriceJJ = "";
  7674. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7675. {
  7676. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7677. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7678. }
  7679. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7680. {
  7681. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7682. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7683. }
  7684. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7685. {
  7686. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7687. dic.Add("AirFeeTotal", airFeeTotalStr);
  7688. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7689. dic.Add("FeeTotal", feeTotalStr);
  7690. }
  7691. foreach (var key in dic.Keys)
  7692. {
  7693. builder.MoveToBookmark(key);
  7694. builder.Write(dic[key]);
  7695. }
  7696. //模板文件名
  7697. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7698. strFileName = CommonFun.ValidFileName(strFileName);
  7699. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7700. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7701. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7702. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7703. }
  7704. }
  7705. else if (dto.ExportType == 2) //表格
  7706. {
  7707. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7708. }
  7709. else if (dto.ExportType == 3)
  7710. {
  7711. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7712. }
  7713. return Ok(JsonView(400, "只可导出明细表!", ""));
  7714. }
  7715. catch (Exception ex)
  7716. {
  7717. return Ok(JsonView(400, ex.Message, ""));
  7718. }
  7719. }
  7720. /// <summary>
  7721. /// 获取三公费用标准city
  7722. /// </summary>
  7723. /// <param name="placeData"></param>
  7724. /// <param name="nationalTravelFeeId"></param>
  7725. /// <returns></returns>
  7726. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7727. {
  7728. string _city = string.Empty;
  7729. if (!placeData.Any()) return _city;
  7730. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7731. if (data == null) return _city;
  7732. string country = data.Country;
  7733. string city = data.City;
  7734. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7735. else _city = city;
  7736. return _city;
  7737. }
  7738. /// <summary>
  7739. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7740. /// </summary>
  7741. /// <returns></returns>
  7742. [HttpPost]
  7743. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7745. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7746. {
  7747. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7748. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7749. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7750. if (_view.Code == 0)
  7751. {
  7752. return Ok(JsonView(true, "操作成功"));
  7753. }
  7754. return Ok(JsonView(false, "操作失败"));
  7755. }
  7756. /// <summary>
  7757. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7758. /// </summary>
  7759. /// <returns></returns>
  7760. [HttpPost]
  7761. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7763. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7764. {
  7765. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7766. if (data.Code != 0)
  7767. {
  7768. return Ok(JsonView(false, data.Msg));
  7769. }
  7770. return Ok(JsonView(true, "操作成功!", data.Data));
  7771. }
  7772. /// <summary>
  7773. /// 三公其他费用草稿 删除
  7774. /// </summary>
  7775. /// <param name="dto"></param>
  7776. /// <returns></returns>
  7777. [HttpPost]
  7778. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7779. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7780. {
  7781. var jw = JsonView(false, "删除失败!");
  7782. var data = new Grp_DayOtherPriceDraft()
  7783. {
  7784. Id = dto.Id,
  7785. IsDel = 1,
  7786. DeleteUserId = dto.DeleteUserId,
  7787. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7788. };
  7789. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7790. if (del > 0)
  7791. {
  7792. jw.Code = 200;
  7793. jw.Msg = "删除成功!";
  7794. }
  7795. return Ok(jw);
  7796. }
  7797. /// <summary>
  7798. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7799. /// </summary>
  7800. /// <returns></returns>
  7801. [HttpPost]
  7802. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7803. {
  7804. var jw = JsonView(false);
  7805. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7806. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  7807. jw.Code = StatusCodes.Status200OK;
  7808. jw.Msg = "操作成功!";
  7809. jw.Data = new { groupNameDatas = groupNameDatas.Data, draftNames = draftDatas };
  7810. return Ok(jw);
  7811. }
  7812. /// <summary>
  7813. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7814. /// </summary>
  7815. /// <param name="dto"></param>
  7816. /// <returns></returns>
  7817. [HttpPost]
  7818. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7819. {
  7820. int userId = dto.UserId,
  7821. portId = dto.PortType,
  7822. groupId = dto.GroupId,
  7823. draftId = dto.DraftId;
  7824. _portTypeData.Add(1);
  7825. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7826. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7827. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7828. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7829. _sqlSugar.BeginTran();
  7830. try
  7831. {
  7832. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7833. if (draftDatas == null)
  7834. {
  7835. _sqlSugar.RollbackTran();
  7836. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7837. }
  7838. //验证可覆盖已有数据 两边创建人需为同一人;
  7839. int draftCreateUserId = draftDatas.CreateUserId,
  7840. formalCreateUserId = 0;
  7841. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7842. if (formalData != null)
  7843. {
  7844. formalCreateUserId = formalData.CreateUserId;
  7845. if (draftCreateUserId != formalCreateUserId)
  7846. {
  7847. _sqlSugar.RollbackTran();
  7848. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7849. }
  7850. }
  7851. //默认添加查看、编辑权限(创建人、自己)
  7852. await _enterExitCostRep.InitPerm(dto.GroupId,dto.UserId);
  7853. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7854. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7855. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7856. newExterData.DiId = groupId;
  7857. newExterData.CreateUserId = userId;
  7858. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7859. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7860. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7861. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7862. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7863. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7864. //数据如果存在执行删除
  7865. if (enterExitCostInfo != null)
  7866. {
  7867. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7868. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7869. .Where(x => x.Id == enterExitCostInfo.Id)
  7870. .ExecuteCommand();
  7871. _sqlSugar.Updateable<Grp_DayAndCost>()
  7872. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7873. .Where(x => x.DiId == groupId)
  7874. .ExecuteCommand();
  7875. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7876. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7877. .Where(x => x.Diid == groupId)
  7878. .ExecuteCommand();
  7879. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7880. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7881. .Where(x => x.GroupId == groupId)
  7882. .ExecuteCommand();
  7883. }
  7884. //执行insert
  7885. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7886. if (insertId < 1)
  7887. {
  7888. _sqlSugar.RollbackTran();
  7889. return Ok(JsonView(false, "草稿数据导入失败!"));
  7890. }
  7891. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7892. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7893. #region 默认添加权限
  7894. #endregion
  7895. _sqlSugar.CommitTran();
  7896. //执行操作之后
  7897. //生成默认文件pdf并且通知人员
  7898. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7899. {
  7900. DiId = groupId,
  7901. ExportType = 1,
  7902. SubTypeId = 1005
  7903. }, "pdf");
  7904. //发送通知
  7905. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7906. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7907. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7908. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7909. //汇率信息记录
  7910. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7911. return Ok(JsonView(true));
  7912. }
  7913. catch (Exception ex)
  7914. {
  7915. _sqlSugar.RollbackTran();
  7916. return Ok(JsonView(false, ex.Message));
  7917. }
  7918. }
  7919. #endregion
  7920. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7921. /// <summary>
  7922. /// 获取币种基础数据(含逻辑处理)
  7923. /// </summary>
  7924. /// <returns></returns>
  7925. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7926. {
  7927. return await GeneralMethod.EnterExitCostInitRate();
  7928. }
  7929. /// <summary>
  7930. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7931. /// </summary>
  7932. /// <returns></returns>
  7933. [HttpPost]
  7934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7935. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7936. {
  7937. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7938. //SetDataInfoView
  7939. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7940. var fileTypes = new List<EecSetDataInfoView>();
  7941. var wordTypeData = dataSource.Where(it => it.STid == 72).Select(x => new EecSetDataInfoView() {
  7942. ParentId = 1,
  7943. Id = x.Id,
  7944. Name = x.Name
  7945. }) .ToList(); //三公费用-Word明细类型
  7946. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  7947. var excelTypeData = dataSource.Where(it => it.STid == 73)
  7948. .Select(x => new EecSetDataInfoView()
  7949. {
  7950. ParentId = 2,
  7951. Id = x.Id,
  7952. Name = x.Name
  7953. }).ToList(); //三公费用-Excel明细类型
  7954. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  7955. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  7956. fileTypes.Add(groupNameList);
  7957. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  7958. //默认币种显示
  7959. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7960. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7961. return Ok(JsonView(true, "查询成功!", new
  7962. {
  7963. FileTypeData = fileTypes,
  7964. CurrencyInit = _currencyInfos,
  7965. viewPermissionData = viewPermissionData
  7966. }));
  7967. }
  7968. /// <summary>
  7969. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7970. /// </summary>
  7971. /// <returns></returns>
  7972. [HttpPost]
  7973. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7974. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7975. {
  7976. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7977. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7978. RefAsync<int> total = 0;
  7979. int diId = 0;
  7980. var status = int.TryParse(dto.GroupName, out diId);
  7981. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  7982. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  7983. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  7984. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7985. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  7986. .OrderByDescending(x => x.VisitStartDate)
  7987. .Select(x => new EnterExitCostMobileGroupView()
  7988. {
  7989. Id = x.Id,
  7990. GroupName = x.TeamName,
  7991. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  7992. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  7993. })
  7994. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7995. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  7996. {
  7997. foreach (var item in data)
  7998. {
  7999. item.IsView = true;
  8000. }
  8001. }
  8002. return Ok(JsonView(true, "查询成功!", data, total));
  8003. }
  8004. /// <summary>
  8005. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  8006. /// </summary>
  8007. /// <returns></returns>
  8008. [HttpPost]
  8009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8010. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  8011. {
  8012. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8013. RefAsync<int> total = 0;
  8014. var data = await _sqlSugar.Queryable<Sys_SetData>()
  8015. .Where(x => x.IsDel == 0 && x.STid == 66)
  8016. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  8017. .Select(x => new
  8018. {
  8019. id = x.Id,
  8020. name = x.Name,
  8021. remark = x.Remark,
  8022. })
  8023. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8024. return Ok(JsonView(true, "查询成功!", data, total));
  8025. }
  8026. /// <summary>
  8027. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  8028. /// </summary>
  8029. /// <returns></returns>
  8030. [HttpPost]
  8031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8032. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  8033. {
  8034. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8035. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8036. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  8037. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  8038. var groupOtherRateData = groupRateData.TeamRates;
  8039. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8040. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  8041. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  8042. groupOtherRateData = groupOtherRateData
  8043. .Select(x => new TeamRateDescAddCurrencyIdView
  8044. {
  8045. CurrencyId = x.CurrencyId,
  8046. CurrencyName = x.CurrencyName,
  8047. CurrencyCode = x.CurrencyCode,
  8048. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  8049. }).ToList();
  8050. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  8051. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  8052. }
  8053. /// <summary>
  8054. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  8055. /// </summary>
  8056. /// <returns></returns>
  8057. [HttpPost]
  8058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8059. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  8060. {
  8061. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8062. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8063. var tipsData = new List<int>() { 1, 2, 3 };
  8064. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  8065. if (dto.TipsType == 1)
  8066. {
  8067. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  8068. }
  8069. else if (dto.TipsType == 2)
  8070. {
  8071. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  8072. return Ok(JsonView(true, "查询成功!", visaData.Data));
  8073. }
  8074. else if (dto.TipsType == 3)
  8075. {
  8076. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  8077. return Ok(JsonView(true, "查询成功!", airData.Data));
  8078. }
  8079. return Ok(JsonView(false));
  8080. }
  8081. /// <summary>
  8082. /// 团组模块 - 出入境国家费用标准-移动端 List
  8083. /// </summary>
  8084. /// <returns></returns>
  8085. [HttpPost]
  8086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8087. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  8088. {
  8089. Stopwatch sw = new Stopwatch();
  8090. sw.Start();
  8091. RefAsync<int> total = 0;
  8092. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8093. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  8094. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  8095. .Where((ntf, sd, u) => ntf.IsDel == 0)
  8096. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  8097. .Select((ntf, sd, u) => new
  8098. {
  8099. Id = ntf.Id,
  8100. Area = $"{ntf.Country}-{ntf.City}",
  8101. Currency = ntf.Currency,
  8102. CurrencyCode = sd.Name,
  8103. CurrencyName = sd.Remark,
  8104. RoomCost = ntf.RoomCost,
  8105. FoodCost = ntf.FoodCost,
  8106. PublicCost = ntf.PublicCost,
  8107. LastUpdateUserId = ntf.LastUpdateUserId,
  8108. LastUpdateUserName = u.CnName,
  8109. LastUpdateTime = ntf.LastUpdateTime,
  8110. })
  8111. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8112. sw.Stop();
  8113. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  8114. }
  8115. /// <summary>
  8116. /// 团组模块 - 出入境费用-移动端 - Info
  8117. /// </summary>
  8118. /// <returns></returns>
  8119. [HttpPost]
  8120. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8121. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  8122. {
  8123. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8124. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8125. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  8126. return Ok(data);
  8127. }
  8128. /// <summary>
  8129. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  8130. /// </summary>
  8131. /// <returns></returns>
  8132. [HttpPost]
  8133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8134. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8135. {
  8136. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8137. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8138. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8139. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8140. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8141. mobileInfo.DiId = dto.DiId;
  8142. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8143. if (eecInfo == null) return Ok(mobileInfo);
  8144. //验证查看权限
  8145. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  8146. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  8147. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8148. mobileInfo.IsAssignPerm = isSet;
  8149. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8150. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8151. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8152. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8153. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8154. {
  8155. SubId = dac.Id,
  8156. DiId = dac.DiId,
  8157. Type = dac.Type,
  8158. Days = dac.Days,
  8159. NationalTravelFeeId = dac.NationalTravelFeeId,
  8160. Arae = $"{ntf.Country}-{ntf.City}",
  8161. Cost = dac.Cost,
  8162. Currency = dac.Currency,
  8163. CurrencyName = sd.Name,
  8164. SubTotal = dac.SubTotal,
  8165. })
  8166. .ToList();
  8167. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8168. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8169. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8170. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8171. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8172. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8173. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8174. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8175. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8176. //其他款项
  8177. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8178. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8179. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8180. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8181. .OrderBy((dop, sd1, sd2) => dop.Index)
  8182. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8183. {
  8184. SubId = dop.Id,
  8185. DiId = dop.Diid,
  8186. Index = dop.Index,
  8187. SetDataId = dop.SetDataId,
  8188. SetDataName = sd1.Name,
  8189. Cost = dop.Cost,
  8190. Currency = dop.Currency,
  8191. CurrencyName = sd2.Remark,
  8192. SubTotal = dop.SubTotal,
  8193. Remark = dop.Remark,
  8194. })
  8195. .ToArray();
  8196. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8197. return Ok(mobileInfo);
  8198. }
  8199. /// <summary>
  8200. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8201. /// </summary>
  8202. /// <returns></returns>
  8203. [HttpPost]
  8204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8205. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8206. {
  8207. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8208. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8209. //验证查看权限
  8210. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  8211. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  8212. var userIds = await _sqlSugar
  8213. .Queryable<Grp_EnterExitCostPermission>()
  8214. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8215. .Select(x => x.UserId)
  8216. .ToArrayAsync();
  8217. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  8218. var perUsersView = new List<dynamic>();
  8219. foreach (var item in perUsers)
  8220. {
  8221. bool isView1 = false;
  8222. if (userIds.Any(x => x == item.Id)) isView1 = true;
  8223. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  8224. }
  8225. return Ok(JsonView(perUsersView));
  8226. }
  8227. /// <summary>
  8228. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8229. /// </summary>
  8230. /// <returns></returns>
  8231. [HttpPost]
  8232. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8233. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8234. {
  8235. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8236. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8237. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8238. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8239. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8240. //验证查看权限
  8241. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8242. //if (!isView) return Ok(JsonView(false, msg));
  8243. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8244. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8245. var subType = dto.SubType;
  8246. if (subType == 1) //1:境内费用
  8247. {
  8248. var oneData = new ChoiceOneMobileSubInfoView()
  8249. {
  8250. Id = eecInfo.Id,
  8251. ChoiceOne = eecInfo.ChoiceOne,
  8252. ChoiceOneTotalCost = eecInfo.InsidePay,
  8253. Visa = eecInfo.Visa,
  8254. VisaRemark = eecInfo.VisaRemark,
  8255. YiMiao = eecInfo.YiMiao,
  8256. HeSuan = eecInfo.HeSuan,
  8257. Service = eecInfo.Service,
  8258. Ticket = eecInfo.Ticket,
  8259. Safe = eecInfo.Safe,
  8260. FirstItemRemark = eecInfo.FirstItemRemark
  8261. };
  8262. return Ok(JsonView(oneData));
  8263. }
  8264. else if (subType == 2) //2:国际旅费
  8265. {
  8266. var twoData = new ChoiceTwoMobileSubInfoView()
  8267. {
  8268. Id = eecInfo.Id,
  8269. ChoiceTwoJJ = eecInfo.SumJJC,
  8270. OutsideJJPay = eecInfo.OutsideJJPay,
  8271. ChoiceTwoGW = eecInfo.SumGWC,
  8272. OutsideGWPay = eecInfo.OutsideGWPay,
  8273. ChoiceTwoTD = eecInfo.SumTDC,
  8274. OutsideTDPay = eecInfo.OutsideTDPay,
  8275. AirJJ = eecInfo.AirJJ,
  8276. AirGW = eecInfo.AirGW,
  8277. AirTD = eecInfo.AirTD,
  8278. CityTranffic = eecInfo.CityTranffic,
  8279. TwoItemRemark = eecInfo.TwoItemRemark
  8280. };
  8281. return Ok(JsonView(twoData));
  8282. }
  8283. else if (subType == 3) //3:住宿费
  8284. {
  8285. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8286. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8287. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8288. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8289. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8290. {
  8291. SubId = dac.Id,
  8292. DiId = dac.DiId,
  8293. Type = dac.Type,
  8294. Days = dac.Days,
  8295. NationalTravelFeeId = dac.NationalTravelFeeId,
  8296. Arae = $"{ntf.Country}-{ntf.City}",
  8297. Cost = dac.Cost,
  8298. Currency = dac.Currency,
  8299. CurrencyName = sd.Name,
  8300. SubTotal = dac.SubTotal,
  8301. })
  8302. .ToArray();
  8303. var data = new ChoiceMobileSubInfo3To6View()
  8304. {
  8305. ParentId = eecInfo.Id,
  8306. Choice = eecInfo.ChoiceThree,
  8307. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8308. Details = dayAndCostDatas
  8309. };
  8310. return Ok(JsonView(data));
  8311. }
  8312. else if (subType == 4) //4:伙食费
  8313. {
  8314. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8315. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8316. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8317. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8318. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8319. {
  8320. SubId = dac.Id,
  8321. DiId = dac.DiId,
  8322. Type = dac.Type,
  8323. Days = dac.Days,
  8324. NationalTravelFeeId = dac.NationalTravelFeeId,
  8325. Arae = $"{ntf.Country}-{ntf.City}",
  8326. Cost = dac.Cost,
  8327. Currency = dac.Currency,
  8328. CurrencyName = sd.Name,
  8329. SubTotal = dac.SubTotal,
  8330. })
  8331. .ToArray();
  8332. var data = new ChoiceMobileSubInfo3To6View()
  8333. {
  8334. ParentId = eecInfo.Id,
  8335. Choice = eecInfo.ChoiceFour,
  8336. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8337. Details = dayAndCostDatas
  8338. };
  8339. return Ok(JsonView(data));
  8340. }
  8341. else if (subType == 5) //5:公杂费
  8342. {
  8343. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8344. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8345. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8346. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8347. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8348. {
  8349. SubId = dac.Id,
  8350. DiId = dac.DiId,
  8351. Type = dac.Type,
  8352. Days = dac.Days,
  8353. NationalTravelFeeId = dac.NationalTravelFeeId,
  8354. Arae = $"{ntf.Country}-{ntf.City}",
  8355. Cost = dac.Cost,
  8356. Currency = dac.Currency,
  8357. CurrencyName = sd.Name,
  8358. SubTotal = dac.SubTotal,
  8359. })
  8360. .ToArray();
  8361. var data = new ChoiceMobileSubInfo3To6View()
  8362. {
  8363. ParentId = eecInfo.Id,
  8364. Choice = eecInfo.ChoiceFive,
  8365. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8366. Details = dayAndCostDatas
  8367. };
  8368. return Ok(JsonView(data));
  8369. }
  8370. else if (subType == 6) //6:培训费
  8371. {
  8372. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8373. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8374. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8375. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8376. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8377. {
  8378. SubId = dac.Id,
  8379. DiId = dac.DiId,
  8380. Type = dac.Type,
  8381. Days = dac.Days,
  8382. NationalTravelFeeId = dac.NationalTravelFeeId,
  8383. Arae = $"{ntf.Country}-{ntf.City}",
  8384. Cost = dac.Cost,
  8385. Currency = dac.Currency,
  8386. CurrencyName = sd.Name,
  8387. SubTotal = dac.SubTotal,
  8388. })
  8389. .ToArray();
  8390. var data = new ChoiceMobileSubInfo3To6View()
  8391. {
  8392. ParentId = eecInfo.Id,
  8393. Choice = eecInfo.ChoiceSix,
  8394. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8395. Details = dayAndCostDatas
  8396. };
  8397. return Ok(JsonView(data));
  8398. }
  8399. else if (subType == 7) //7:其他
  8400. {
  8401. //其他款项
  8402. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8403. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8404. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8405. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8406. .OrderBy((dop, sd1, sd2) => dop.Index)
  8407. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8408. {
  8409. SubId = dop.Id,
  8410. DiId = dop.Diid,
  8411. Index = dop.Index,
  8412. SetDataId = dop.SetDataId,
  8413. SetDataName = sd1.Name,
  8414. Cost = dop.Cost,
  8415. Currency = dop.Currency,
  8416. CurrencyName = sd2.Name,
  8417. SubTotal = dop.SubTotal,
  8418. Remark = dop.Remark,
  8419. })
  8420. .ToArray();
  8421. var data = new ChoiceSevenMobileSubInfoView()
  8422. {
  8423. ParentId = eecInfo.Id,
  8424. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8425. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8426. Details = otherData
  8427. };
  8428. return Ok(JsonView(data));
  8429. }
  8430. return Ok(JsonView(false));
  8431. }
  8432. #region op
  8433. /// <summary>
  8434. /// 移动端更新费用消息通知
  8435. /// </summary>
  8436. /// <param name="diid"></param>
  8437. /// <param name="id"></param>
  8438. /// <param name="currUserId"></param>
  8439. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8440. {
  8441. try
  8442. {
  8443. ////生成默认文件pdf并且通知人员
  8444. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8445. //{
  8446. // DiId = diid,
  8447. // ExportType = 1,
  8448. // SubTypeId = 1005
  8449. //}, "pdf");
  8450. ////发送通知
  8451. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8452. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8453. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8454. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8455. ////汇率信息记录
  8456. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8457. }
  8458. catch (Exception ex)
  8459. {
  8460. //记录日志
  8461. throw;
  8462. }
  8463. }
  8464. /// <summary>
  8465. /// 验证出入境费用数据是否存在
  8466. /// 不存在添加
  8467. /// </summary>
  8468. /// <param name="diId"></param>
  8469. /// <param name="currUserId"></param>
  8470. /// <returns></returns>
  8471. /// <exception cref="CustomException"></exception>
  8472. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8473. {
  8474. var parentId = 0;
  8475. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8476. if (info != null)
  8477. {
  8478. parentId = info.Id;
  8479. }
  8480. else
  8481. {
  8482. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8483. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8484. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8485. parentId = addId;
  8486. }
  8487. return parentId;
  8488. }
  8489. /// <summary>
  8490. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8491. /// </summary>
  8492. /// <returns></returns>
  8493. [HttpPost]
  8494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8495. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8496. {
  8497. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8498. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8499. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8500. //验证编辑权限
  8501. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8502. //if (!isEdit) return Ok(JsonView(false, msg));
  8503. var permissions = new List<Grp_EnterExitCostPermission>();
  8504. foreach (var userId in dto.UserIds)
  8505. {
  8506. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8507. }
  8508. if (permissions.Any())
  8509. {
  8510. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  8511. {
  8512. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  8513. }
  8514. _sqlSugar.BeginTran();
  8515. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8516. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8517. if (result < 1)
  8518. {
  8519. _sqlSugar.RollbackTran();
  8520. return Ok(JsonView(false));
  8521. }
  8522. _sqlSugar.CommitTran();
  8523. return Ok(JsonView(true));
  8524. }
  8525. return Ok(JsonView(false));
  8526. }
  8527. /// <summary>
  8528. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8529. /// </summary>
  8530. /// <returns></returns>
  8531. [HttpPost]
  8532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8533. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8534. {
  8535. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8536. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8537. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8538. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8539. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8540. int id = dto.Id;
  8541. if (id <= 0) //add
  8542. {
  8543. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8544. if (add < 1) return Ok(JsonView(false));
  8545. id = add;
  8546. }
  8547. else //update
  8548. {
  8549. ////验证编辑权限
  8550. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8551. //if (!isEdit) return Ok(JsonView(false, msg));
  8552. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8553. if (upd < 1) return Ok(JsonView(false));
  8554. }
  8555. #region 汇率变更时更改币种相关费用
  8556. var opDayCosts = new List<Grp_DayAndCost>();
  8557. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8558. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8559. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8560. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  8561. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8562. .Select((dac, sd) => new
  8563. {
  8564. dac.Id,
  8565. dac.DiId,
  8566. CurrencyCode = sd.Name,
  8567. dac.Cost
  8568. })
  8569. .ToList();
  8570. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8571. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8572. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8573. .Select((dop, sd) => new
  8574. {
  8575. dop.Id,
  8576. dop.Diid,
  8577. CurrencyCode = sd.Name,
  8578. dop.Cost
  8579. })
  8580. .ToList();
  8581. if (dayCosts.Count > 0)
  8582. {
  8583. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8584. foreach (var dc in new_dayCosts)
  8585. {
  8586. var thisCurrency = dc.Key.ToUpper();
  8587. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8588. if (thisRate == 0.00M) continue;
  8589. foreach (var dcSub in dc)
  8590. {
  8591. opDayCosts.Add(new Grp_DayAndCost()
  8592. {
  8593. Id = dcSub.Id,
  8594. DiId = dcSub.DiId,
  8595. Cost = dcSub.Cost,
  8596. SubTotal = dcSub.Cost * thisRate,
  8597. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8598. });
  8599. }
  8600. }
  8601. if (opDayCosts.Count > 0)
  8602. {
  8603. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8604. }
  8605. }
  8606. if (dayOtherCosts.Count > 0)
  8607. {
  8608. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8609. foreach (var dc in new_dayOtherCosts)
  8610. {
  8611. var thisCurrency = dc.Key.ToUpper();
  8612. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8613. if (thisRate == 0.00M) continue;
  8614. foreach (var dcSub in dc)
  8615. {
  8616. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8617. {
  8618. Id = dcSub.Id,
  8619. Diid = dcSub.Diid,
  8620. Cost = dcSub.Cost,
  8621. SubTotal = dcSub.Cost * thisRate,
  8622. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8623. });
  8624. }
  8625. }
  8626. if (opDayOtherCosts.Count > 0)
  8627. {
  8628. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8629. }
  8630. }
  8631. #endregion
  8632. //消息通知
  8633. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8634. //汇率信息记录
  8635. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8636. return Ok(JsonView(new { parentId = id }));
  8637. }
  8638. /// <summary>
  8639. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8640. /// </summary>
  8641. /// <returns></returns>
  8642. [HttpPost]
  8643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8644. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8645. {
  8646. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8647. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8648. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8649. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8650. int id = dto.Id;
  8651. if (id <= 0) //add
  8652. {
  8653. checkboxInfo.CreateUserId = dto.CurrUserId;
  8654. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8655. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8656. if (add < 1) return Ok(JsonView(false));
  8657. }
  8658. else //update
  8659. {
  8660. ////验证编辑权限
  8661. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8662. //if (!isEdit) return Ok(JsonView(false, msg));
  8663. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8664. .UpdateColumns(x => new
  8665. {
  8666. x.ChoiceOne,
  8667. x.ChoiceTwo,
  8668. x.SumJJC,
  8669. x.SumGWC,
  8670. x.SumTDC,
  8671. x.ChoiceThree,
  8672. x.ChoiceFour,
  8673. x.ChoiceFive,
  8674. x.ChoiceSix,
  8675. x.OtherExpenses_Checked
  8676. })
  8677. .Where(x => x.Id == id)
  8678. .ExecuteCommandAsync();
  8679. if (upd < 1) return Ok(JsonView(false));
  8680. }
  8681. return Ok(JsonView(new { parentId = id }));
  8682. }
  8683. /// <summary>
  8684. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8685. /// </summary>
  8686. /// <returns></returns>
  8687. [HttpPost]
  8688. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8689. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8690. {
  8691. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  8692. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8693. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8694. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8695. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8696. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8697. var checkboxInfo = new Grp_EnterExitCost()
  8698. {
  8699. Id = id,
  8700. DiId = diId,
  8701. CreateUserId = currUserId
  8702. };
  8703. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8704. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8705. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8706. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8707. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8708. if (id <= 0) //add
  8709. {
  8710. checkboxInfo.CreateUserId = dto.CurrUserId;
  8711. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8712. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8713. if (add < 1) return Ok(JsonView(false));
  8714. }
  8715. else //update
  8716. {
  8717. ////验证编辑权限
  8718. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8719. //if (!isEdit) return Ok(JsonView(false, msg));
  8720. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8721. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8722. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8723. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8724. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8725. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8726. .Where(x => x.Id == id)
  8727. .ExecuteCommandAsync();
  8728. if (upd < 1) return Ok(JsonView(false));
  8729. }
  8730. return Ok(JsonView(new { parentId = id }));
  8731. }
  8732. /// <summary>
  8733. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8734. /// </summary>
  8735. /// <returns></returns>
  8736. [HttpPost]
  8737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8738. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8739. {
  8740. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8741. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8742. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8743. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8744. info.FirstItemRemark = dto.FirstItemRemark;
  8745. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8746. int id = dto.Id;
  8747. if (id <= 0) //add
  8748. {
  8749. info.CreateUserId = dto.CurrUserId;
  8750. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8751. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8752. if (add < 1) return Ok(JsonView(false));
  8753. id = add;
  8754. }
  8755. else //update
  8756. {
  8757. ////验证编辑权限
  8758. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8759. //if (!isEdit) return Ok(JsonView(false, msg));
  8760. var upd = await _sqlSugar.Updateable(info)
  8761. .UpdateColumns(x => new
  8762. {
  8763. x.ChoiceOne,
  8764. x.InsidePay,
  8765. x.VisaRemark,
  8766. x.Visa,
  8767. x.Service,
  8768. x.Safe,
  8769. x.Ticket,
  8770. x.HeSuan,
  8771. x.YiMiao,
  8772. x.FirstItemRemark
  8773. })
  8774. .Where(x => x.Id == id)
  8775. .ExecuteCommandAsync();
  8776. if (upd < 1) return Ok(JsonView(false));
  8777. }
  8778. //消息通知
  8779. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8780. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8781. }
  8782. /// <summary>
  8783. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8784. /// </summary>
  8785. /// <returns></returns>
  8786. [HttpPost]
  8787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8788. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8789. {
  8790. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8791. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8792. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8793. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8794. info.OutsideJJPay = dto.OutsideJJPay;
  8795. info.OutsideGWPay = dto.OutsideGWPay;
  8796. info.OutsideTDPay = dto.OutsideTDPay;
  8797. info.AirJJ = dto.AirJJ;
  8798. info.AirGW = dto.AirGW;
  8799. info.AirTD = dto.AirTD;
  8800. info.CityTranffic = dto.CityTranffic;
  8801. info.TwoItemRemark = dto.TwoItemRemark;
  8802. info.SumJJC = dto.ChoiceTwoJJ;
  8803. info.SumGWC = dto.ChoiceTwoGW;
  8804. info.SumTDC = dto.ChoiceTwoTD;
  8805. int id = dto.Id;
  8806. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8807. if (id <= 0) //add
  8808. {
  8809. info.CreateUserId = dto.CurrUserId;
  8810. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8811. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8812. if (addId <= 0) return Ok(JsonView(false));
  8813. id = addId;
  8814. }
  8815. else //update
  8816. {
  8817. ////验证编辑权限
  8818. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8819. //if (!isEdit) return Ok(JsonView(false, msg));
  8820. var upd = await _sqlSugar.Updateable(info)
  8821. .UpdateColumns(x => new
  8822. {
  8823. x.SumJJC,
  8824. x.OutsideJJPay,
  8825. x.SumGWC,
  8826. x.OutsideGWPay,
  8827. x.SumTDC,
  8828. x.OutsideTDPay,
  8829. x.AirJJ,
  8830. x.AirGW,
  8831. x.AirTD,
  8832. x.CityTranffic,
  8833. x.TwoItemRemark
  8834. })
  8835. .Where(x => x.Id == id)
  8836. .ExecuteCommandAsync();
  8837. if (upd < 1) return Ok(JsonView(false));
  8838. }
  8839. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8840. gwcItemTotal = info.AirGW + info.CityTranffic;
  8841. tdcItemTotal = info.AirTD + info.CityTranffic;
  8842. //消息通知
  8843. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8844. return Ok(JsonView(new
  8845. {
  8846. parentId = id,
  8847. choiceTwoJJ = dto.ChoiceTwoJJ,
  8848. jjcItemTotal = jjcItemTotal,
  8849. choiceTwoGW = dto.ChoiceTwoGW,
  8850. gwcItemTotal = gwcItemTotal,
  8851. choiceTwoTD = dto.ChoiceTwoTD,
  8852. tdcItemTotal = tdcItemTotal
  8853. }));
  8854. }
  8855. /// <summary>
  8856. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8857. /// </summary>
  8858. /// <returns></returns>
  8859. [HttpPost]
  8860. [ApiExplorerSettings(IgnoreApi = true)]
  8861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8862. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8863. {
  8864. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8865. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8866. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8867. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8868. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8869. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8870. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8871. var infos = infos1.Select(x => new Grp_DayAndCost
  8872. {
  8873. Id = x.Id,
  8874. DiId = dto.DiId,
  8875. Type = dto.FeeType,
  8876. Days = x.Days,
  8877. NationalTravelFeeId = x.NationalTravelFeeId,
  8878. Cost = x.Cost,
  8879. Currency = x.Currency,
  8880. SubTotal = x.SubTotal,
  8881. CreateUserId = dto.CurrUserId
  8882. })
  8883. .ToList();
  8884. var adds = infos.Where(x => x.Id <= 0).ToList();
  8885. var upds = infos.Where(x => x.Id > 0).ToList();
  8886. if (adds.Count > 0)
  8887. {
  8888. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8889. if (add < 1) return Ok(JsonView(false));
  8890. }
  8891. if (upds.Count > 0)
  8892. {
  8893. var upd = await _sqlSugar.Updateable(adds)
  8894. .UpdateColumns(x => new
  8895. {
  8896. x.Days,
  8897. x.NationalTravelFeeId,
  8898. x.Cost,
  8899. x.Currency,
  8900. x.SubTotal
  8901. })
  8902. .WhereColumns(x => new { x.Id })
  8903. .ExecuteCommandAsync();
  8904. if (upd < 1) return Ok(JsonView(false));
  8905. }
  8906. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8907. //消息通知
  8908. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8909. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8910. return Ok(JsonView(new { itemTotal = itemTotal }));
  8911. }
  8912. /// <summary>
  8913. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8914. /// </summary>
  8915. /// <returns></returns>
  8916. [HttpPost]
  8917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8918. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8919. {
  8920. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8921. int subId = dto.SubId, feeType = dto.FeeType;
  8922. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8923. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8924. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8925. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8926. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8927. subInfo.Id = subId;
  8928. subInfo.DiId = dto.DiId;
  8929. if (feeType == 3) subInfo.Type = 1;
  8930. else if (feeType == 4) subInfo.Type = 2;
  8931. else if (feeType == 5) subInfo.Type = 3;
  8932. else if (feeType == 6) subInfo.Type = 4;
  8933. subInfo.CreateUserId = dto.CurrUserId;
  8934. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8935. if (parentId < 1) return Ok(JsonView(false));
  8936. //子表op
  8937. if (subId < 1)
  8938. {
  8939. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8940. if (subAdd < 1) return Ok(JsonView(false));
  8941. }
  8942. else
  8943. {
  8944. ////验证编辑权限
  8945. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8946. //if (!isEdit) return Ok(JsonView(false, msg));
  8947. var subUpd = await _sqlSugar.Updateable(subInfo)
  8948. .UpdateColumns(x => new
  8949. {
  8950. x.Days,
  8951. x.NationalTravelFeeId,
  8952. x.Cost,
  8953. x.Currency,
  8954. x.SubTotal
  8955. })
  8956. .WhereColumns(x => new { x.Id })
  8957. .ExecuteCommandAsync();
  8958. if (subUpd < 1) return Ok(JsonView(false));
  8959. }
  8960. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8961. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8962. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8963. }
  8964. /// <summary>
  8965. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8966. /// </summary>
  8967. /// <returns></returns>
  8968. [HttpPost]
  8969. [ApiExplorerSettings(IgnoreApi = true)]
  8970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8971. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8972. {
  8973. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8974. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8975. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8976. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8977. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8978. {
  8979. Id = x.Id,
  8980. Diid = dto.DiId,
  8981. SetDataId = x.SetDataId,
  8982. Index = x.Index,
  8983. Cost = x.Cost,
  8984. Currency = x.Currency,
  8985. SubTotal = x.SubTotal,
  8986. CreateUserId = dto.CurrUserId,
  8987. Remark = x.Remark
  8988. }).ToList();
  8989. var adds = infos.Where(x => x.Id <= 0).ToList();
  8990. var upds = infos.Where(x => x.Id > 0).ToList();
  8991. if (adds.Count > 0)
  8992. {
  8993. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8994. if (add < 1) return Ok(JsonView(false));
  8995. }
  8996. if (upds.Count > 0)
  8997. {
  8998. var upd = await _sqlSugar.Updateable(adds)
  8999. .UpdateColumns(x => new
  9000. {
  9001. x.Index,
  9002. x.SetDataId,
  9003. x.Cost,
  9004. x.Currency,
  9005. x.SubTotal,
  9006. x.Remark
  9007. })
  9008. .WhereColumns(x => new { x.Id })
  9009. .ExecuteCommandAsync();
  9010. if (upd < 1) return Ok(JsonView(false));
  9011. }
  9012. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  9013. //消息通知
  9014. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  9015. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9016. return Ok(JsonView(new { itemTotal = itemTotal }));
  9017. }
  9018. /// <summary>
  9019. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  9020. /// </summary>
  9021. /// <returns></returns>
  9022. [HttpPost]
  9023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9024. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  9025. {
  9026. int subId = dto.SubId;
  9027. int diId = dto.Diid;
  9028. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9029. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9030. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9031. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  9032. subInfo.Id = subId;
  9033. subInfo.Diid = dto.Diid;
  9034. subInfo.CreateUserId = dto.CurrUserId;
  9035. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  9036. if (parentId < 1) return Ok(JsonView(false));
  9037. #region 子表op
  9038. if (subId < 1)//add
  9039. {
  9040. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9041. if (subAdd < 1) return Ok(JsonView(false));
  9042. }
  9043. else //upd
  9044. {
  9045. ////验证编辑权限
  9046. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  9047. //if (!isEdit) return Ok(JsonView(false, msg));
  9048. var subUpd = await _sqlSugar.Updateable(subInfo)
  9049. .UpdateColumns(x => new
  9050. {
  9051. x.Index,
  9052. x.SetDataId,
  9053. x.Cost,
  9054. x.Currency,
  9055. x.SubTotal,
  9056. x.Remark
  9057. })
  9058. .WhereColumns(x => new { x.Id })
  9059. .ExecuteCommandAsync();
  9060. if (subUpd < 1) return Ok(JsonView(false));
  9061. }
  9062. #endregion
  9063. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  9064. //消息通知
  9065. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  9066. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9067. }
  9068. /// <summary>
  9069. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  9070. /// </summary>
  9071. /// <returns></returns>
  9072. [HttpPost]
  9073. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9074. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  9075. {
  9076. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  9077. if (data.Code != 0)
  9078. {
  9079. return Ok(JsonView(false, data.Msg));
  9080. }
  9081. return Ok(JsonView(true, "操作成功!", data.Data));
  9082. }
  9083. /// <summary>
  9084. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  9085. /// </summary>
  9086. /// <param name="dto"></param>
  9087. /// <returns></returns>
  9088. [HttpPost]
  9089. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  9090. {
  9091. var data = new Grp_DayOtherPrice()
  9092. {
  9093. Id = dto.Id,
  9094. IsDel = 1,
  9095. DeleteUserId = dto.DeleteUserId,
  9096. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9097. };
  9098. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9099. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  9100. return Ok(JsonView(false, "删除失败!"));
  9101. }
  9102. #endregion
  9103. #endregion
  9104. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  9105. /// <summary>
  9106. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  9107. /// </summary>
  9108. /// <returns></returns>
  9109. [HttpPost]
  9110. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9111. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  9112. {
  9113. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9114. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9115. RefAsync<int> total = 0;
  9116. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  9117. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  9118. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  9119. .Select(x => new
  9120. {
  9121. Id = x.Id,
  9122. DraftName = x.DraftName,
  9123. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  9124. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  9125. .Any()
  9126. })
  9127. .OrderByDescending(x => x.Id)
  9128. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9129. return Ok(JsonView(true, "查询成功!", data, total));
  9130. }
  9131. /// <summary>
  9132. /// 出入境费用-草稿 移动端
  9133. /// 获取币种基础数据(含逻辑处理)
  9134. /// </summary>
  9135. /// <returns></returns>
  9136. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  9137. {
  9138. return await GeneralMethod.EnterExitCostInitRate();
  9139. }
  9140. /// <summary>
  9141. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9142. /// </summary>
  9143. /// <returns></returns>
  9144. [HttpPost]
  9145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9146. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  9147. {
  9148. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9149. //SetDataInfoView
  9150. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  9151. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  9152. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  9153. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  9154. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  9155. //默认币种显示
  9156. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9157. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9158. return Ok(JsonView(true, "查询成功!", new
  9159. {
  9160. WordTypeData = _WordTypeData,
  9161. ExcelTypeData = _ExcelTypeData,
  9162. CurrencyInit = _currencyInfos,
  9163. viewPermissionData = viewPermissionData
  9164. }));
  9165. }
  9166. /// <summary>
  9167. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9168. /// </summary>
  9169. /// <returns></returns>
  9170. [HttpPost]
  9171. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9172. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9173. {
  9174. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9175. RefAsync<int> total = 0;
  9176. int diId = 0;
  9177. var status = int.TryParse(dto.GroupName, out diId);
  9178. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9179. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9180. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9181. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9182. .OrderByDescending(x => x.VisitStartDate)
  9183. .Select(x => new
  9184. {
  9185. Id = x.Id,
  9186. GroupName = x.TeamName
  9187. })
  9188. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9189. return Ok(JsonView(true, "查询成功!", data, total));
  9190. }
  9191. /// <summary>
  9192. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9193. /// </summary>
  9194. /// <returns></returns>
  9195. [HttpPost]
  9196. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9197. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9198. {
  9199. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9200. RefAsync<int> total = 0;
  9201. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9202. .Where(x => x.IsDel == 0 && x.STid == 66)
  9203. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9204. .Select(x => new
  9205. {
  9206. id = x.Id,
  9207. name = x.Name,
  9208. remark = x.Remark,
  9209. })
  9210. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9211. return Ok(JsonView(true, "查询成功!", data, total));
  9212. }
  9213. /// <summary>
  9214. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9215. /// </summary>
  9216. /// <returns></returns>
  9217. [HttpPost]
  9218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9219. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9220. {
  9221. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9222. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9223. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  9224. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9225. var groupOtherRateData = groupRateData.TeamRates;
  9226. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9227. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9228. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9229. groupOtherRateData = groupOtherRateData
  9230. .Select(x => new TeamRateDescAddCurrencyIdView
  9231. {
  9232. CurrencyId = x.CurrencyId,
  9233. CurrencyName = x.CurrencyName,
  9234. CurrencyCode = x.CurrencyCode,
  9235. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9236. }).ToList();
  9237. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9238. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9239. }
  9240. /// <summary>
  9241. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9242. /// </summary>
  9243. /// <returns></returns>
  9244. [HttpPost]
  9245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9246. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9247. {
  9248. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9249. var tipsData = new List<int>() { 1, 2, 3 };
  9250. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9251. if (dto.TipsType == 1)
  9252. {
  9253. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9254. }
  9255. else if (dto.TipsType == 2)
  9256. {
  9257. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  9258. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9259. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9260. .Select(x => x.NationalTravelFeeId)
  9261. .Distinct()
  9262. .ToListAsync();
  9263. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9264. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9265. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9266. .Select(x => x.Country)
  9267. .Distinct()
  9268. .ToArrayAsync();
  9269. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9270. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9271. return Ok(JsonView(true, "查询成功!", new
  9272. {
  9273. totalAmt = totalAmt,
  9274. remark = remark
  9275. }));
  9276. }
  9277. else if (dto.TipsType == 3)
  9278. {
  9279. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  9280. }
  9281. return Ok(JsonView(false));
  9282. }
  9283. /// <summary>
  9284. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  9285. /// </summary>
  9286. /// <returns></returns>
  9287. [HttpPost]
  9288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9289. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  9290. {
  9291. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  9292. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9293. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  9294. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  9295. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  9296. var info = new Grp_EnterExitCostDraft() {
  9297. DraftName = dto.DraftName,
  9298. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  9299. CreateUserId = dto.CurrUserId
  9300. };
  9301. _sqlSugar.BeginTran();
  9302. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9303. if (draftId < 1) {
  9304. _sqlSugar.RollbackTran();
  9305. return Ok(JsonView(false, "草稿创建失败!"));
  9306. }
  9307. //添加默认权限
  9308. await _enterExitCostDraftRep.InitPerm(draftId,dto.CurrUserId);
  9309. _sqlSugar.CommitTran();
  9310. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  9311. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9312. mobileInfo.Id = draftId;
  9313. mobileInfo.DraftName = dto.DraftName;
  9314. mobileInfo.Currencys = rateInfos;
  9315. mobileInfo.IsAssignPerm = assignPerm;
  9316. return Ok(JsonView(mobileInfo));
  9317. }
  9318. /// <summary>
  9319. /// 出入境费用-草稿-移动端 查看编辑提示消息
  9320. /// </summary>
  9321. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  9322. /// <summary>
  9323. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9324. /// </summary>
  9325. /// <returns></returns>
  9326. [HttpPost]
  9327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9328. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9329. {
  9330. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9331. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9332. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9333. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9334. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9335. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  9336. //验证查看编辑权限
  9337. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9338. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9339. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9340. mobileInfo.IsAssignPerm = assignPerm;
  9341. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9342. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9343. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9344. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9345. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9346. {
  9347. ParentId = dac.ParentId,
  9348. SubId = dac.Id,
  9349. Type = dac.Type,
  9350. Days = dac.Days,
  9351. NationalTravelFeeId = dac.NationalTravelFeeId,
  9352. Arae = $"{ntf.Country}-{ntf.City}",
  9353. Cost = dac.Cost,
  9354. Currency = dac.Currency,
  9355. CurrencyName = sd.Name,
  9356. SubTotal = dac.SubTotal,
  9357. })
  9358. .ToList();
  9359. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9360. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9361. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9362. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9363. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9364. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9365. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9366. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9367. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9368. //其他款项
  9369. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9370. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9371. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9372. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9373. .OrderBy((dop, sd1, sd2) => dop.Index)
  9374. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9375. {
  9376. ParentId = dop.ParentId,
  9377. SubId = dop.Id,
  9378. Index = dop.Index,
  9379. SetDataId = dop.SetDataId,
  9380. SetDataName = sd1.Name,
  9381. Cost = dop.Cost,
  9382. Currency = dop.Currency,
  9383. CurrencyName = sd2.Remark,
  9384. SubTotal = dop.SubTotal,
  9385. Remark = dop.Remark,
  9386. })
  9387. .ToArray();
  9388. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9389. return Ok(mobileInfo);
  9390. }
  9391. /// <summary>
  9392. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9393. /// </summary>
  9394. /// <returns></returns>
  9395. [HttpPost]
  9396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9397. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9398. {
  9399. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9400. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9401. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9402. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9403. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9404. //验证查看编辑权限
  9405. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9406. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9407. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9408. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9409. var subType = dto.SubType;
  9410. if (subType == 1) //1:境内费用
  9411. {
  9412. var oneData = new ChoiceOneMobileSubInfoView()
  9413. {
  9414. Id = eecInfo.Id,
  9415. ChoiceOne = eecInfo.ChoiceOne,
  9416. ChoiceOneTotalCost = eecInfo.InsidePay,
  9417. Visa = eecInfo.Visa,
  9418. VisaRemark = eecInfo.VisaRemark,
  9419. YiMiao = eecInfo.YiMiao,
  9420. HeSuan = eecInfo.HeSuan,
  9421. Service = eecInfo.Service,
  9422. Ticket = eecInfo.Ticket,
  9423. Safe = eecInfo.Safe,
  9424. FirstItemRemark = eecInfo.FirstItemRemark
  9425. };
  9426. return Ok(JsonView(oneData));
  9427. }
  9428. else if (subType == 2) //2:国际旅费
  9429. {
  9430. var twoData = new ChoiceTwoMobileSubInfoView()
  9431. {
  9432. Id = eecInfo.Id,
  9433. ChoiceTwoJJ = eecInfo.SumJJC,
  9434. OutsideJJPay = eecInfo.OutsideJJPay,
  9435. ChoiceTwoGW = eecInfo.SumGWC,
  9436. OutsideGWPay = eecInfo.OutsideGWPay,
  9437. ChoiceTwoTD = eecInfo.SumTDC,
  9438. OutsideTDPay = eecInfo.OutsideTDPay,
  9439. AirJJ = eecInfo.AirJJ,
  9440. AirGW = eecInfo.AirGW,
  9441. AirTD = eecInfo.AirTD,
  9442. CityTranffic = eecInfo.CityTranffic,
  9443. TwoItemRemark = eecInfo.TwoItemRemark
  9444. };
  9445. return Ok(JsonView(twoData));
  9446. }
  9447. else if (subType == 3) //3:住宿费
  9448. {
  9449. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9450. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9451. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9452. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9453. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9454. {
  9455. ParentId = dac.ParentId,
  9456. SubId = dac.Id,
  9457. Type = dac.Type,
  9458. Days = dac.Days,
  9459. NationalTravelFeeId = dac.NationalTravelFeeId,
  9460. Arae = $"{ntf.Country}-{ntf.City}",
  9461. Cost = dac.Cost,
  9462. Currency = dac.Currency,
  9463. CurrencyName = sd.Name,
  9464. SubTotal = dac.SubTotal,
  9465. })
  9466. .ToArray();
  9467. var data = new ChoiceDraftMobileSubInfo3To6View()
  9468. {
  9469. ParentId = eecInfo.Id,
  9470. Choice = eecInfo.ChoiceThree,
  9471. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9472. Details = dayAndCostDatas
  9473. };
  9474. return Ok(JsonView(data));
  9475. }
  9476. else if (subType == 4) //4:伙食费
  9477. {
  9478. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9479. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9480. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9481. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9482. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9483. {
  9484. ParentId = dac.ParentId,
  9485. SubId = dac.Id,
  9486. Type = dac.Type,
  9487. Days = dac.Days,
  9488. NationalTravelFeeId = dac.NationalTravelFeeId,
  9489. Arae = $"{ntf.Country}-{ntf.City}",
  9490. Cost = dac.Cost,
  9491. Currency = dac.Currency,
  9492. CurrencyName = sd.Name,
  9493. SubTotal = dac.SubTotal,
  9494. })
  9495. .ToArray();
  9496. var data = new ChoiceDraftMobileSubInfo3To6View()
  9497. {
  9498. ParentId = eecInfo.Id,
  9499. Choice = eecInfo.ChoiceFour,
  9500. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9501. Details = dayAndCostDatas
  9502. };
  9503. return Ok(JsonView(data));
  9504. }
  9505. else if (subType == 5) //5:公杂费
  9506. {
  9507. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9508. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9509. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9510. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9511. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9512. {
  9513. ParentId = dac.ParentId,
  9514. SubId = dac.Id,
  9515. Type = dac.Type,
  9516. Days = dac.Days,
  9517. NationalTravelFeeId = dac.NationalTravelFeeId,
  9518. Arae = $"{ntf.Country}-{ntf.City}",
  9519. Cost = dac.Cost,
  9520. Currency = dac.Currency,
  9521. CurrencyName = sd.Name,
  9522. SubTotal = dac.SubTotal,
  9523. })
  9524. .ToArray();
  9525. var data = new ChoiceDraftMobileSubInfo3To6View()
  9526. {
  9527. ParentId = eecInfo.Id,
  9528. Choice = eecInfo.ChoiceFive,
  9529. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9530. Details = dayAndCostDatas
  9531. };
  9532. return Ok(JsonView(data));
  9533. }
  9534. else if (subType == 6) //6:培训费
  9535. {
  9536. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9537. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9538. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9539. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9540. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9541. {
  9542. ParentId = dac.ParentId,
  9543. SubId = dac.Id,
  9544. Type = dac.Type,
  9545. Days = dac.Days,
  9546. NationalTravelFeeId = dac.NationalTravelFeeId,
  9547. Arae = $"{ntf.Country}-{ntf.City}",
  9548. Cost = dac.Cost,
  9549. Currency = dac.Currency,
  9550. CurrencyName = sd.Name,
  9551. SubTotal = dac.SubTotal,
  9552. })
  9553. .ToArray();
  9554. var data = new ChoiceDraftMobileSubInfo3To6View()
  9555. {
  9556. ParentId = eecInfo.Id,
  9557. Choice = eecInfo.ChoiceSix,
  9558. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9559. Details = dayAndCostDatas
  9560. };
  9561. return Ok(JsonView(data));
  9562. }
  9563. else if (subType == 7) //7:其他
  9564. {
  9565. //其他款项
  9566. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9567. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9568. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9569. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9570. .OrderBy((dop, sd1, sd2) => dop.Index)
  9571. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9572. {
  9573. ParentId = dop.ParentId,
  9574. SubId = dop.Id,
  9575. Index = dop.Index,
  9576. SetDataId = dop.SetDataId,
  9577. SetDataName = sd1.Name,
  9578. Cost = dop.Cost,
  9579. Currency = dop.Currency,
  9580. CurrencyName = sd2.Name,
  9581. SubTotal = dop.SubTotal,
  9582. Remark = dop.Remark,
  9583. })
  9584. .ToArray();
  9585. var data = new ChoiceSevenDraftMobileSubInfoView()
  9586. {
  9587. ParentId = eecInfo.Id,
  9588. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9589. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9590. Details = otherData
  9591. };
  9592. return Ok(JsonView(data));
  9593. }
  9594. return Ok(JsonView(false));
  9595. }
  9596. #region op
  9597. /// <summary>
  9598. /// 移动端更新费用消息通知
  9599. /// </summary>
  9600. /// <param name="draftId"></param>
  9601. /// <param name="id"></param>
  9602. /// <param name="currUserId"></param>
  9603. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9604. {
  9605. try
  9606. {
  9607. ////生成默认文件pdf并且通知人员
  9608. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9609. //{
  9610. // DiId = draftId,
  9611. // ExportType = 1,
  9612. // SubTypeId = 1005
  9613. //}, "pdf");
  9614. ////发送通知
  9615. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9616. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9617. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9618. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9619. ////汇率信息记录
  9620. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9621. }
  9622. catch (Exception ex)
  9623. {
  9624. //记录日志
  9625. throw;
  9626. }
  9627. }
  9628. /// <summary>
  9629. /// 验证出入境费用数据是否存在
  9630. /// 不存在添加
  9631. /// </summary>
  9632. /// <param name="draftId"></param>
  9633. /// <param name="currUserId"></param>
  9634. /// <returns></returns>
  9635. /// <exception cref="CustomException"></exception>
  9636. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9637. {
  9638. var parentId = 0;
  9639. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9640. if (info != null) parentId = info.Id;
  9641. else
  9642. {
  9643. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9644. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9645. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9646. parentId = addId;
  9647. }
  9648. return parentId;
  9649. }
  9650. /// <summary>
  9651. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  9652. /// </summary>
  9653. /// <returns></returns>
  9654. [HttpPost]
  9655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9656. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  9657. {
  9658. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9659. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9660. //验证查看权限
  9661. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9662. if (!isView) return Ok(JsonView(false, _viewPermStr));
  9663. var userIds = await _sqlSugar
  9664. .Queryable<Grp_EnterExitCostDraftPermission>()
  9665. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  9666. .Select(x => x.UserId)
  9667. .ToArrayAsync();
  9668. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  9669. var perUsersView = new List<dynamic>();
  9670. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  9671. var viewPermissionData = new List<PermissionViewUserview>();
  9672. if (feeBasePerm.Any())
  9673. {
  9674. foreach (var item in feeBasePerm)
  9675. {
  9676. if (item.Users.Any())
  9677. {
  9678. viewPermissionData.AddRange(item.Users);
  9679. }
  9680. }
  9681. }
  9682. foreach (var item in perUsers)
  9683. {
  9684. bool isView1 = false;
  9685. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9686. else if (viewPermissionData.Any(x => x.Id ==dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  9687. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9688. }
  9689. return Ok(JsonView(perUsersView));
  9690. }
  9691. /// <summary>
  9692. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9693. /// </summary>
  9694. /// <returns></returns>
  9695. [HttpPost]
  9696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9697. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9698. {
  9699. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9700. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9701. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9702. //验证查看编辑权限
  9703. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9704. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9705. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  9706. foreach (var userId in dto.UserIds)
  9707. {
  9708. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9709. }
  9710. if (permissions.Any())
  9711. {
  9712. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9713. {
  9714. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9715. }
  9716. _sqlSugar.BeginTran();
  9717. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9718. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9719. if (result < 1)
  9720. {
  9721. _sqlSugar.RollbackTran();
  9722. return Ok(JsonView(false));
  9723. }
  9724. _sqlSugar.CommitTran();
  9725. return Ok(JsonView(true));
  9726. }
  9727. return Ok(JsonView(false));
  9728. }
  9729. /// <summary>
  9730. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9731. /// </summary>
  9732. /// <returns></returns>
  9733. [HttpPost]
  9734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9735. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9736. {
  9737. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9738. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9739. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9740. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9741. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9742. int id = dto.DraftId;
  9743. if (id <= 0) //add
  9744. {
  9745. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9746. if (add < 1) return Ok(JsonView(false));
  9747. id = add;
  9748. }
  9749. else //update
  9750. {
  9751. //验证查看编辑权限
  9752. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9753. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9754. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9755. if (upd < 1) return Ok(JsonView(false));
  9756. }
  9757. #region 汇率变更时更改币种相关费用
  9758. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9759. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9760. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9761. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9762. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9763. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9764. .Select((dac, sd) => new
  9765. {
  9766. dac.Id,
  9767. dac.ParentId,
  9768. CurrencyCode = sd.Name,
  9769. dac.Cost
  9770. })
  9771. .ToList();
  9772. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9773. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9774. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9775. .Select((dop, sd) => new
  9776. {
  9777. dop.Id,
  9778. dop.ParentId,
  9779. CurrencyCode = sd.Name,
  9780. dop.Cost
  9781. })
  9782. .ToList();
  9783. if (dayCosts.Count > 0)
  9784. {
  9785. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9786. foreach (var dc in new_dayCosts)
  9787. {
  9788. var thisCurrency = dc.Key.ToUpper();
  9789. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9790. if (thisRate == 0.00M) continue;
  9791. foreach (var dcSub in dc)
  9792. {
  9793. opDayCosts.Add(new Grp_DayAndCostDraft()
  9794. {
  9795. Id = dcSub.Id,
  9796. ParentId = dcSub.ParentId,
  9797. Cost = dcSub.Cost,
  9798. SubTotal = dcSub.Cost * thisRate,
  9799. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  9800. });
  9801. }
  9802. }
  9803. if (opDayCosts.Count > 0)
  9804. {
  9805. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9806. }
  9807. }
  9808. if (dayOtherCosts.Count > 0)
  9809. {
  9810. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9811. foreach (var dc in new_dayOtherCosts)
  9812. {
  9813. var thisCurrency = dc.Key.ToUpper();
  9814. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9815. if (thisRate == 0.00M) continue;
  9816. foreach (var dcSub in dc)
  9817. {
  9818. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  9819. {
  9820. Id = dcSub.Id,
  9821. ParentId = dcSub.ParentId,
  9822. Cost = dcSub.Cost,
  9823. SubTotal = dcSub.Cost * thisRate,
  9824. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9825. });
  9826. }
  9827. }
  9828. if (opDayOtherCosts.Count > 0)
  9829. {
  9830. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9831. }
  9832. }
  9833. #endregion
  9834. ////消息通知
  9835. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9836. ////汇率信息记录
  9837. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9838. return Ok(JsonView(new { parentId = id }));
  9839. }
  9840. /// <summary>
  9841. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9842. /// </summary>
  9843. /// <returns></returns>
  9844. [HttpPost]
  9845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9846. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9847. {
  9848. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9849. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9850. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9851. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9852. int id = dto.DraftId;
  9853. if (id <= 0) //add
  9854. {
  9855. checkboxInfo.CreateUserId = dto.CurrUserId;
  9856. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9857. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9858. if (add < 1) return Ok(JsonView(false));
  9859. }
  9860. else //update
  9861. {
  9862. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9863. .UpdateColumns(x => new
  9864. {
  9865. x.ChoiceOne,
  9866. x.ChoiceTwo,
  9867. x.SumJJC,
  9868. x.SumGWC,
  9869. x.SumTDC,
  9870. x.ChoiceThree,
  9871. x.ChoiceFour,
  9872. x.ChoiceFive,
  9873. x.ChoiceSix,
  9874. x.OtherExpenses_Checked
  9875. })
  9876. .Where(x => x.Id == id)
  9877. .ExecuteCommandAsync();
  9878. if (upd < 1) return Ok(JsonView(false));
  9879. }
  9880. return Ok(JsonView(new { parentId = id }));
  9881. }
  9882. /// <summary>
  9883. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9884. /// </summary>
  9885. /// <returns></returns>
  9886. [HttpPost]
  9887. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9888. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9889. {
  9890. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9891. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9892. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9893. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9894. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9895. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9896. var checkboxInfo = new Grp_EnterExitCostDraft()
  9897. {
  9898. Id = draftId,
  9899. CreateUserId = currUserId
  9900. };
  9901. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9902. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9903. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9904. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9905. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9906. if (draftId <= 0) //add
  9907. {
  9908. checkboxInfo.CreateUserId = dto.CurrUserId;
  9909. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9910. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9911. if (add < 1) return Ok(JsonView(false));
  9912. }
  9913. else //update
  9914. {
  9915. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9916. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9917. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9918. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9919. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9920. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9921. .Where(x => x.Id == draftId)
  9922. .ExecuteCommandAsync();
  9923. if (upd < 1) return Ok(JsonView(false));
  9924. }
  9925. return Ok(JsonView(new { parentId = draftId }));
  9926. }
  9927. /// <summary>
  9928. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9929. /// </summary>
  9930. /// <returns></returns>
  9931. [HttpPost]
  9932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9933. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9934. {
  9935. int id = dto.DraftId, currUserId = dto.CurrUserId;
  9936. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9937. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9938. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9939. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9940. info.FirstItemRemark = dto.FirstItemRemark;
  9941. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9942. if (id <= 0) //add
  9943. {
  9944. info.CreateUserId = dto.CurrUserId;
  9945. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9946. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9947. if (add < 1) return Ok(JsonView(false));
  9948. id = add;
  9949. }
  9950. else //update
  9951. {
  9952. var upd = await _sqlSugar.Updateable(info)
  9953. .UpdateColumns(x => new
  9954. {
  9955. x.ChoiceOne,
  9956. x.InsidePay,
  9957. x.VisaRemark,
  9958. x.Visa,
  9959. x.Service,
  9960. x.Safe,
  9961. x.Ticket,
  9962. x.HeSuan,
  9963. x.YiMiao,
  9964. x.FirstItemRemark
  9965. })
  9966. .Where(x => x.Id == id)
  9967. .ExecuteCommandAsync();
  9968. if (upd < 1) return Ok(JsonView(false));
  9969. }
  9970. ////消息通知
  9971. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9972. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9973. }
  9974. /// <summary>
  9975. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9976. /// </summary>
  9977. /// <returns></returns>
  9978. [HttpPost]
  9979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9980. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9981. {
  9982. int id = dto.DraftId;
  9983. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9984. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9985. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9986. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9987. info.OutsideJJPay = dto.OutsideJJPay;
  9988. info.OutsideGWPay = dto.OutsideGWPay;
  9989. info.OutsideTDPay = dto.OutsideTDPay;
  9990. info.AirJJ = dto.AirJJ;
  9991. info.AirGW = dto.AirGW;
  9992. info.AirTD = dto.AirTD;
  9993. info.CityTranffic = dto.CityTranffic;
  9994. info.TwoItemRemark = dto.TwoItemRemark;
  9995. info.SumJJC = dto.ChoiceTwoJJ;
  9996. info.SumGWC = dto.ChoiceTwoGW;
  9997. info.SumTDC = dto.ChoiceTwoTD;
  9998. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9999. if (id <= 0) //add
  10000. {
  10001. info.CreateUserId = dto.CurrUserId;
  10002. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10003. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10004. if (addId <= 0) return Ok(JsonView(false));
  10005. id = addId;
  10006. }
  10007. else //update
  10008. {
  10009. var upd = await _sqlSugar.Updateable(info)
  10010. .UpdateColumns(x => new
  10011. {
  10012. x.SumJJC,
  10013. x.OutsideJJPay,
  10014. x.SumGWC,
  10015. x.OutsideGWPay,
  10016. x.SumTDC,
  10017. x.OutsideTDPay,
  10018. x.AirJJ,
  10019. x.AirGW,
  10020. x.AirTD,
  10021. x.CityTranffic,
  10022. x.TwoItemRemark
  10023. })
  10024. .Where(x => x.Id == id)
  10025. .ExecuteCommandAsync();
  10026. if (upd < 1) return Ok(JsonView(false));
  10027. }
  10028. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10029. gwcItemTotal = info.AirGW + info.CityTranffic;
  10030. tdcItemTotal = info.AirTD + info.CityTranffic;
  10031. ////消息通知
  10032. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10033. return Ok(JsonView(new
  10034. {
  10035. parentId = id,
  10036. choiceTwoJJ = dto.ChoiceTwoJJ,
  10037. jjcItemTotal = jjcItemTotal,
  10038. choiceTwoGW = dto.ChoiceTwoGW,
  10039. gwcItemTotal = gwcItemTotal,
  10040. choiceTwoTD = dto.ChoiceTwoTD,
  10041. tdcItemTotal = tdcItemTotal
  10042. }));
  10043. }
  10044. /// <summary>
  10045. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10046. /// </summary>
  10047. /// <returns></returns>
  10048. [HttpPost]
  10049. [ApiExplorerSettings(IgnoreApi = true)]
  10050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10051. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  10052. {
  10053. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10054. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10055. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10056. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10057. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10058. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10059. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  10060. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  10061. {
  10062. Id = x.Id,
  10063. ParentId = dto.DraftId,
  10064. Type = dto.FeeType,
  10065. Days = x.Days,
  10066. NationalTravelFeeId = x.NationalTravelFeeId,
  10067. Cost = x.Cost,
  10068. Currency = x.Currency,
  10069. SubTotal = x.SubTotal,
  10070. CreateUserId = dto.CurrUserId
  10071. })
  10072. .ToList();
  10073. var adds = infos.Where(x => x.Id <= 0).ToList();
  10074. var upds = infos.Where(x => x.Id > 0).ToList();
  10075. if (adds.Count > 0)
  10076. {
  10077. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10078. if (add < 1) return Ok(JsonView(false));
  10079. }
  10080. if (upds.Count > 0)
  10081. {
  10082. var upd = await _sqlSugar.Updateable(adds)
  10083. .UpdateColumns(x => new
  10084. {
  10085. x.Days,
  10086. x.NationalTravelFeeId,
  10087. x.Cost,
  10088. x.Currency,
  10089. x.SubTotal
  10090. })
  10091. .WhereColumns(x => new { x.Id })
  10092. .ExecuteCommandAsync();
  10093. if (upd < 1) return Ok(JsonView(false));
  10094. }
  10095. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10096. ////消息通知
  10097. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  10098. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10099. return Ok(JsonView(new { itemTotal = itemTotal }));
  10100. }
  10101. /// <summary>
  10102. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10103. /// </summary>
  10104. /// <returns></returns>
  10105. [HttpPost]
  10106. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10107. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  10108. {
  10109. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10110. int subId = dto.SubId, feeType = dto.FeeType;
  10111. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10112. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10113. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10114. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10115. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  10116. subInfo.Id = subId;
  10117. subInfo.ParentId = dto.DraftId;
  10118. if (feeType == 3) subInfo.Type = 1;
  10119. else if (feeType == 4) subInfo.Type = 2;
  10120. else if (feeType == 5) subInfo.Type = 3;
  10121. else if (feeType == 6) subInfo.Type = 4;
  10122. subInfo.CreateUserId = dto.CurrUserId;
  10123. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  10124. if (parentId < 1) return Ok(JsonView(false));
  10125. //子表op
  10126. if (subId < 1)
  10127. {
  10128. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10129. if (subAdd < 1) return Ok(JsonView(false));
  10130. }
  10131. else
  10132. {
  10133. var subUpd = await _sqlSugar.Updateable(subInfo)
  10134. .UpdateColumns(x => new
  10135. {
  10136. x.Days,
  10137. x.NationalTravelFeeId,
  10138. x.Cost,
  10139. x.Currency,
  10140. x.SubTotal
  10141. })
  10142. .WhereColumns(x => new { x.Id })
  10143. .ExecuteCommandAsync();
  10144. if (subUpd < 1) return Ok(JsonView(false));
  10145. }
  10146. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  10147. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10148. }
  10149. /// <summary>
  10150. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  10151. /// </summary>
  10152. /// <returns></returns>
  10153. [HttpPost]
  10154. [ApiExplorerSettings(IgnoreApi = true)]
  10155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10156. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  10157. {
  10158. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10159. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10160. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10161. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  10162. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  10163. {
  10164. Id = x.Id,
  10165. ParentId = dto.DraftId,
  10166. SetDataId = x.SetDataId,
  10167. Index = x.Index,
  10168. Cost = x.Cost,
  10169. Currency = x.Currency,
  10170. SubTotal = x.SubTotal,
  10171. CreateUserId = dto.CurrUserId,
  10172. Remark = x.Remark
  10173. }).ToList();
  10174. var adds = infos.Where(x => x.Id <= 0).ToList();
  10175. var upds = infos.Where(x => x.Id > 0).ToList();
  10176. if (adds.Count > 0)
  10177. {
  10178. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10179. if (add < 1) return Ok(JsonView(false));
  10180. }
  10181. if (upds.Count > 0)
  10182. {
  10183. var upd = await _sqlSugar.Updateable(adds)
  10184. .UpdateColumns(x => new
  10185. {
  10186. x.Index,
  10187. x.SetDataId,
  10188. x.Cost,
  10189. x.Currency,
  10190. x.SubTotal,
  10191. x.Remark
  10192. })
  10193. .WhereColumns(x => new { x.Id })
  10194. .ExecuteCommandAsync();
  10195. if (upd < 1) return Ok(JsonView(false));
  10196. }
  10197. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  10198. //消息通知
  10199. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  10200. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10201. return Ok(JsonView(new { itemTotal = itemTotal }));
  10202. }
  10203. /// <summary>
  10204. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  10205. /// </summary>
  10206. /// <returns></returns>
  10207. [HttpPost]
  10208. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10209. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  10210. {
  10211. int subId = dto.SubId, id = dto.DraftId;
  10212. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10213. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  10214. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10215. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  10216. subInfo.Id = subId;
  10217. subInfo.ParentId = id;
  10218. subInfo.CreateUserId = dto.CurrUserId;
  10219. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  10220. if (parentId < 1) return Ok(JsonView(false));
  10221. #region 子表op
  10222. if (subId < 1)//add
  10223. {
  10224. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10225. if (subAdd < 1) return Ok(JsonView(false));
  10226. }
  10227. else //upd
  10228. {
  10229. var subUpd = await _sqlSugar.Updateable(subInfo)
  10230. .UpdateColumns(x => new
  10231. {
  10232. x.Index,
  10233. x.SetDataId,
  10234. x.Cost,
  10235. x.Currency,
  10236. x.SubTotal,
  10237. x.Remark
  10238. })
  10239. .WhereColumns(x => new { x.Id })
  10240. .ExecuteCommandAsync();
  10241. if (subUpd < 1) return Ok(JsonView(false));
  10242. }
  10243. #endregion
  10244. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10245. ////消息通知
  10246. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10247. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10248. }
  10249. /// <summary>
  10250. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10251. /// </summary>
  10252. /// <returns></returns>
  10253. [HttpPost]
  10254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10255. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10256. {
  10257. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10258. if (data.Code != 0)
  10259. {
  10260. return Ok(JsonView(false, data.Msg));
  10261. }
  10262. return Ok(JsonView(true, "操作成功!", data.Data));
  10263. }
  10264. /// <summary>
  10265. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10266. /// </summary>
  10267. /// <param name="dto"></param>
  10268. /// <returns></returns>
  10269. [HttpPost]
  10270. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10271. {
  10272. var data = new Grp_DayOtherPriceDraft()
  10273. {
  10274. Id = dto.Id,
  10275. IsDel = 1,
  10276. DeleteUserId = dto.DeleteUserId,
  10277. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10278. };
  10279. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10280. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10281. return Ok(JsonView(false, "删除失败!"));
  10282. }
  10283. #endregion
  10284. #endregion
  10285. #region 团组经理模块 出入境费用报价表
  10286. /// <summary>
  10287. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  10288. /// </summary>
  10289. /// <returns></returns>
  10290. [HttpPost]
  10291. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10292. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  10293. {
  10294. var initRates = await GeneralMethod.EnterExitCostInitRate();
  10295. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  10296. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  10297. initRates.Insert(0, cnyInfo);
  10298. liveRates.Insert(0, cnyInfo);
  10299. return Ok(JsonView(true, "查询成功!", new
  10300. {
  10301. InitRates = initRates,
  10302. LiveRates = liveRates
  10303. }));
  10304. }
  10305. /// <summary>
  10306. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  10307. /// </summary>
  10308. /// <returns></returns>
  10309. [HttpPost]
  10310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10311. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  10312. {
  10313. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  10314. }
  10315. /// <summary>
  10316. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  10317. /// </summary>
  10318. /// <returns></returns>
  10319. [HttpPost]
  10320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10321. public async Task<IActionResult> EnterExitCostQuoteGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  10322. {
  10323. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  10324. }
  10325. /// <summary>
  10326. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  10327. /// </summary>
  10328. /// <returns></returns>
  10329. [HttpPost]
  10330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10331. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  10332. {
  10333. int groupId = dto.DiId,
  10334. currUserId = dto.CurrUserId;
  10335. if (groupId < 1) return Ok(JsonView(false,"请传入有效的GroupId;"));
  10336. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  10337. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10338. if (info.Code != StatusCodes.Status200OK) return Ok(info);
  10339. var infoView = info.Data as EnterExitCostInfoView;
  10340. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  10341. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  10342. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  10343. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  10344. var eecRates = infoView.Currencys;
  10345. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  10346. int pplNum = 1;
  10347. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  10348. var views = new List<QuoteSubItemInfo>();
  10349. #region 数据填充
  10350. var intTravelCosts = new List<QuoteSubItemInfo>();
  10351. #region 机票费用 1354
  10352. int intTravelIndex = 1;
  10353. if (infoView.SumJJC == 1)
  10354. {
  10355. intTravelCosts.Add(new QuoteSubItemInfo
  10356. {
  10357. ItemId = 1354,
  10358. Index = intTravelIndex,
  10359. FeeName = "经济舱",
  10360. UnitPrice = infoView.AirJJ,
  10361. Currency = "CNY",
  10362. Quantity = 1,
  10363. PplNum = 1,
  10364. TotalAmt = infoView.AirJJ,
  10365. Remark = "",
  10366. });
  10367. intTravelIndex++;
  10368. }
  10369. if (infoView.SumGWC == 1)
  10370. {
  10371. intTravelCosts.Add(new QuoteSubItemInfo
  10372. {
  10373. ItemId = 1354,
  10374. Index = intTravelIndex,
  10375. FeeName = "公务舱",
  10376. UnitPrice = infoView.AirGW,
  10377. Currency = "CNY",
  10378. Quantity = 1,
  10379. PplNum = 1,
  10380. TotalAmt = infoView.AirGW,
  10381. Remark = "",
  10382. });
  10383. intTravelIndex++;
  10384. }
  10385. if (infoView.SumTDC == 1)
  10386. {
  10387. intTravelCosts.Add(new QuoteSubItemInfo
  10388. {
  10389. ItemId = 1354,
  10390. Index = intTravelIndex,
  10391. FeeName = "头等舱",
  10392. UnitPrice = infoView.AirTD,
  10393. Currency = "CNY",
  10394. Quantity = 1,
  10395. PplNum = 1,
  10396. TotalAmt = infoView.AirTD,
  10397. Remark = "",
  10398. });
  10399. intTravelIndex++;
  10400. }
  10401. intTravelCosts.Add(new QuoteSubItemInfo
  10402. {
  10403. ItemId = 1354,
  10404. Index = intTravelIndex,
  10405. FeeName = "城市间交通费用",
  10406. UnitPrice = infoView.CityTranffic,
  10407. Currency = "CNY",
  10408. Quantity = 1,
  10409. PplNum = pplNum,
  10410. TotalAmt = infoView.CityTranffic * pplNum,
  10411. Remark = "",
  10412. });
  10413. views.AddRange(intTravelCosts);
  10414. #endregion
  10415. var accomCosts = new List<QuoteSubItemInfo>();
  10416. #region 住宿费 1355
  10417. if (infoView.QuarterageData.Any())
  10418. {
  10419. int accomIndex = 1;
  10420. int accomItemTypeId = 1355;
  10421. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  10422. foreach (var item in groupData)
  10423. {
  10424. string feeName = string.Empty;
  10425. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10426. if (countryInfo != null)
  10427. {
  10428. feeName = countryInfo.Country;
  10429. var city = countryInfo.City;
  10430. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10431. {
  10432. feeName += $"-{city}";
  10433. }
  10434. }
  10435. var hotelInfo = item.FirstOrDefault();
  10436. if (hotelInfo == null) continue;
  10437. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  10438. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10439. int quantity = item.ToList().Count;
  10440. accomCosts.Add(new QuoteSubItemInfo
  10441. {
  10442. ItemId = accomItemTypeId,
  10443. Index = accomIndex,
  10444. FeeName = feeName,
  10445. UnitPrice = hotelInfo.Cost,
  10446. Currency = thisCurrency,
  10447. Quantity = quantity,
  10448. PplNum = pplNum,
  10449. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  10450. Remark = "",
  10451. });
  10452. accomIndex++;
  10453. }
  10454. views.AddRange(accomCosts);
  10455. }
  10456. #endregion
  10457. var mealCosts = new List<QuoteSubItemInfo>();
  10458. #region 餐饮费 1356
  10459. if (infoView.BoardWagesData.Any())
  10460. {
  10461. var mealIndex = 1;
  10462. int mealItemTypeId = 1356;
  10463. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  10464. foreach (var item in groupData)
  10465. {
  10466. string feeName = string.Empty;
  10467. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10468. if (countryInfo != null)
  10469. {
  10470. feeName = countryInfo.Country;
  10471. var city = countryInfo.City;
  10472. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10473. {
  10474. feeName += $"-{city}";
  10475. }
  10476. }
  10477. var mealInfo = item.FirstOrDefault();
  10478. if (mealInfo == null) continue;
  10479. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  10480. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10481. int quantity = item.ToList().Count;
  10482. mealCosts.Add(new QuoteSubItemInfo
  10483. {
  10484. ItemId = mealItemTypeId,
  10485. Index = mealIndex,
  10486. FeeName = feeName,
  10487. UnitPrice = mealInfo.Cost,
  10488. Currency = thisCurrency,
  10489. Quantity = quantity,
  10490. PplNum = pplNum,
  10491. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  10492. Remark = "",
  10493. });
  10494. mealIndex++;
  10495. }
  10496. views.AddRange(mealCosts);
  10497. }
  10498. #endregion
  10499. var miscCosts = new List<QuoteSubItemInfo>();
  10500. #region 公杂费 1364
  10501. if (infoView.MiscellaneousFeeData.Any())
  10502. {
  10503. var miscIndex = 1;
  10504. int miscItemTypeId = 1364;
  10505. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  10506. foreach (var item in groupData)
  10507. {
  10508. string feeName = string.Empty;
  10509. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10510. if (countryInfo != null)
  10511. {
  10512. feeName = countryInfo.Country;
  10513. var city = countryInfo.City;
  10514. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10515. {
  10516. feeName += $"-{city}";
  10517. }
  10518. }
  10519. var miscInfo = item.FirstOrDefault();
  10520. if (miscInfo == null) continue;
  10521. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  10522. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10523. int quantity = item.ToList().Count;
  10524. mealCosts.Add(new QuoteSubItemInfo
  10525. {
  10526. ItemId = miscItemTypeId,
  10527. Index = miscIndex,
  10528. FeeName = feeName,
  10529. UnitPrice = miscInfo.Cost,
  10530. Currency = thisCurrency,
  10531. Quantity = quantity,
  10532. PplNum = pplNum,
  10533. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  10534. Remark = "",
  10535. });
  10536. miscIndex++;
  10537. }
  10538. views.AddRange(mealCosts);
  10539. }
  10540. #endregion
  10541. #region 签证+保险 1362
  10542. int visaInsIndex = 1;
  10543. int visaInsItemTypeId = 1362;
  10544. if (infoView.Visa > 0)
  10545. {
  10546. views.Add(new QuoteSubItemInfo() {
  10547. ItemId = visaInsItemTypeId,
  10548. Index = visaInsIndex,
  10549. FeeName = $"签证",
  10550. UnitPrice = infoView.Visa,
  10551. Currency = $"CNY",
  10552. Quantity = 1,
  10553. PplNum = pplNum,
  10554. TotalAmt = infoView.Visa * pplNum,
  10555. Remark = "",
  10556. });
  10557. visaInsIndex++;
  10558. }
  10559. if (infoView.Safe > 0)
  10560. {
  10561. views.Add(new QuoteSubItemInfo()
  10562. {
  10563. ItemId = visaInsItemTypeId,
  10564. Index = visaInsIndex,
  10565. FeeName = $"保险",
  10566. UnitPrice = infoView.Safe,
  10567. Currency = $"CNY",
  10568. Quantity = 1,
  10569. PplNum = pplNum,
  10570. TotalAmt = infoView.Safe * pplNum,
  10571. Remark = "",
  10572. });
  10573. }
  10574. #endregion
  10575. #region 服务费 1363
  10576. int serviceFeeIndex = 1;
  10577. int serviceFeeItemTypeId = 1363;
  10578. if (infoView.Service > 0)
  10579. {
  10580. views.Add(new QuoteSubItemInfo()
  10581. {
  10582. ItemId = serviceFeeItemTypeId,
  10583. Index = serviceFeeIndex,
  10584. FeeName = $"服务费",
  10585. UnitPrice = infoView.Service,
  10586. Currency = $"CNY",
  10587. Quantity = 1,
  10588. PplNum = pplNum,
  10589. TotalAmt = infoView.Service * pplNum,
  10590. Remark = "",
  10591. });
  10592. }
  10593. #endregion
  10594. #endregion
  10595. var result = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { });
  10596. result.Rates = eecRates.ToArray();
  10597. if (result.FeeItems.Any())
  10598. {
  10599. result.FeeItems.Select(x =>
  10600. {
  10601. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  10602. if (feeInfos.Any()) x.Infos = feeInfos;
  10603. return x;
  10604. }
  10605. )
  10606. .OrderBy(x => x.Index)
  10607. .ToList();
  10608. }
  10609. return Ok(JsonView(result));
  10610. }
  10611. /// <summary>
  10612. /// 团组模块 - 出入境费用报价表 - Info
  10613. /// </summary>
  10614. /// <returns></returns>
  10615. [HttpPost]
  10616. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10617. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  10618. {
  10619. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  10620. if (!info.Rates.Any())
  10621. {
  10622. var rates = await GeneralMethod.EnterExitCostInitRate();
  10623. info.Rates = rates.ToArray();
  10624. }
  10625. return Ok(JsonView(info));
  10626. }
  10627. /// <summary>
  10628. /// 团组模块 - 出入境费用报价表 - OP
  10629. /// </summary>
  10630. /// <returns></returns>
  10631. [HttpPost]
  10632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10633. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  10634. {
  10635. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  10636. }
  10637. /// <summary>
  10638. /// 团组模块 - 出入境费用报价表 - 删除 项
  10639. /// </summary>
  10640. /// <returns></returns>
  10641. [HttpPost]
  10642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10643. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  10644. {
  10645. if (dto.Id < 1) return Ok(JsonView(false,MsgTips.Id));
  10646. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10647. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  10648. }
  10649. /// <summary>
  10650. /// 团组模块 - 出入境费用报价表 - 导出
  10651. /// </summary>
  10652. /// <returns></returns>
  10653. [HttpPost]
  10654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10655. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  10656. {
  10657. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  10658. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10659. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id= dto.Id });
  10660. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  10661. var rates = info.Rates;
  10662. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  10663. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  10664. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  10665. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  10666. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  10667. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  10668. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1560); //邀请函发放时间
  10669. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1561); //公务活动
  10670. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1562); //签证+保险
  10671. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1563); //服务费
  10672. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1564); //公杂费
  10673. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1565); //税费
  10674. //获取模板
  10675. string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx");
  10676. var designer = new WorkbookDesigner();
  10677. designer.Workbook = new Workbook(tempPath);
  10678. designer.SetDataSource("QuoteName", info.Name);
  10679. designer.SetDataSource("CompanyTitle", "公司名称");
  10680. designer.SetDataSource("CompanyLabel", "");
  10681. #region 国际旅费
  10682. designer.SetDataSource("IntTravelTitle", intTravelCosts.ItemName);
  10683. if (intTravelCosts.Infos.Any())
  10684. {
  10685. var cabClassFilter = new string[] {"经济舱","公务舱","头等舱" };
  10686. string label = string.Empty;
  10687. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  10688. if (infos.Any())
  10689. {
  10690. label = $"{infos.Sum(x => x.PplNum)}人全程机票:{infos.Sum(x => x.TotalAmt).TruncDecimals(2)}元\r\n";
  10691. }
  10692. foreach (var item in intTravelCosts.Infos)
  10693. {
  10694. label += $"{item.FeeName}:{item.UnitPrice.TruncDecimals(2)}元/人*{item.PplNum}人\r\n";
  10695. }
  10696. label += $"\r\n以上小计:{intTravelCosts.TotalAmt.TruncDecimals(2)}元";
  10697. designer.SetDataSource("IntTravelLabel", label);
  10698. }
  10699. #endregion
  10700. #region 住宿费
  10701. designer.SetDataSource("AccomTitle", accomCosts.ItemName);
  10702. if (accomCosts.Infos.Any())
  10703. {
  10704. string currencyName = string.Empty;
  10705. decimal rate = 1.0000M;
  10706. string label = "全程五星酒店,每人1间房\r\n";
  10707. foreach (var item in accomCosts.Infos)
  10708. {
  10709. string hotelName = string.Empty;
  10710. if (item.FeeName.Contains("-"))
  10711. {
  10712. var feeName = item.FeeName.Split('-');
  10713. hotelName = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  10714. }
  10715. else hotelName = $"\r\n{item.FeeName}:";
  10716. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  10717. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  10718. rate = rateInfo?.Rate ?? 1.0000M;
  10719. label += $"{hotelName}{item.UnitPrice.TruncDecimals(2)}{currencyName}/间/晚*{item.Quantity.ToString("#0")}*{item.PplNum}人\r\n";
  10720. }
  10721. label += $"\r\n以上小计:{accomCosts.TotalAmt.TruncDecimals(2)}元({currencyName}汇率:{rate.TruncDecimals(4)})";
  10722. designer.SetDataSource("AccomLabel", label);
  10723. }
  10724. #endregion
  10725. #region 餐饮费
  10726. designer.SetDataSource("MealTitle", mealCosts.ItemName);
  10727. if (mealCosts.Infos.Any())
  10728. {
  10729. string currencyName = string.Empty;
  10730. decimal rate = 1.0000M;
  10731. string label = "全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n";
  10732. foreach (var item in mealCosts.Infos)
  10733. {
  10734. string name = string.Empty;
  10735. if (item.FeeName.Contains("-"))
  10736. {
  10737. var feeName = item.FeeName.Split('-');
  10738. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  10739. }
  10740. else name = $"\r\n{item.FeeName}:";
  10741. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  10742. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  10743. rate = rateInfo?.Rate ?? 1.0000M;
  10744. label += $"{name}{item.UnitPrice.TruncDecimals(2)}{currencyName}/天*{item.Quantity.ToString("#0")}*{item.PplNum}人\r\n";
  10745. }
  10746. label += $"\r\n以上小计:{accomCosts.TotalAmt.TruncDecimals(2)}元\r\n({currencyName}汇率:{rate.TruncDecimals(4)})";
  10747. designer.SetDataSource("MealLabel", label);
  10748. }
  10749. #endregion
  10750. #region 车辆安排
  10751. designer.SetDataSource("VehArrangeTitle", vehArranges.ItemName);
  10752. if (vehArranges.Infos.Any())
  10753. {
  10754. string currencyName = string.Empty;
  10755. decimal rate = 1.0000M;
  10756. string label = $"";
  10757. foreach (var item in vehArranges.Infos)
  10758. {
  10759. label += $"{item.Remark}\r\n\r\n{item.FeeName}\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元";
  10760. }
  10761. designer.SetDataSource("VehArrangeLabel", label);
  10762. }
  10763. #endregion
  10764. #region 邀请函发放对象
  10765. designer.SetDataSource("InviteToTitle", inviteTo.ItemName);
  10766. #endregion
  10767. designer.Process();
  10768. //文件名
  10769. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10770. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  10771. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  10772. return Ok(JsonView(true, "成功", url));
  10773. }
  10774. #endregion
  10775. #region 签证费用录入
  10776. /// <summary>
  10777. /// 根据diid查询签证费用列表
  10778. /// </summary>
  10779. /// <param name="dto"></param>
  10780. /// <returns></returns>
  10781. [HttpPost]
  10782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10783. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10784. {
  10785. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10786. if (groupData.Code != 0)
  10787. {
  10788. return Ok(JsonView(false, groupData.Msg));
  10789. }
  10790. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10791. }
  10792. /// <summary>
  10793. /// 根据签证费用Id查询单条数据及c表数据
  10794. /// </summary>
  10795. /// <param name="dto"></param>
  10796. /// <returns></returns>
  10797. [HttpPost]
  10798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10799. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10800. {
  10801. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10802. if (groupData.Code != 0)
  10803. {
  10804. return Ok(JsonView(false, groupData.Msg));
  10805. }
  10806. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10807. }
  10808. /// <summary>
  10809. /// 签证费用删除
  10810. /// </summary>
  10811. /// <param name="dto"></param>
  10812. /// <returns></returns>
  10813. [HttpPost]
  10814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10815. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10816. {
  10817. _sqlSugar.BeginTran();
  10818. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10819. if (!res)
  10820. {
  10821. _sqlSugar.RollbackTran();
  10822. return Ok(JsonView(false, "删除失败"));
  10823. }
  10824. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10825. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10826. .SetColumns(a => new Grp_CreditCardPayment()
  10827. {
  10828. IsDel = 1,
  10829. DeleteUserId = dto.DeleteUserId,
  10830. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10831. })
  10832. .ExecuteCommand();
  10833. if (resSub < 1)
  10834. {
  10835. _sqlSugar.RollbackTran();
  10836. return Ok(JsonView(false, "删除失败"));
  10837. }
  10838. _sqlSugar.CommitTran();
  10839. return Ok(JsonView(true, "删除成功!"));
  10840. }
  10841. /// <summary>
  10842. /// 签证费用录入下拉框初始化
  10843. /// </summary>
  10844. /// <returns></returns>
  10845. [HttpPost]
  10846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10847. public async Task<IActionResult> VisaPriceAddSelect()
  10848. {
  10849. //支付方式
  10850. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10851. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10852. //币种
  10853. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10854. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10855. //乘客类型
  10856. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10857. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10858. //卡类型
  10859. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10860. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10861. //代办费类型
  10862. var agencyFeeTypeData = new List<dynamic>() {
  10863. new { id = 0 , Text = "未选择" },
  10864. new { id = 1 , Text = "小公务" },
  10865. new { id = 2 , Text = "大公务" },
  10866. };
  10867. //签证费用标准国家Data
  10868. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10869. var data = new
  10870. {
  10871. Payment = _Payment,
  10872. CurrencyList = _CurrencyList,
  10873. PassengerType = _PassengerType,
  10874. BankCard = _BankCard,
  10875. AgencyFeeType = agencyFeeTypeData,
  10876. CountryFeeData = visaCountryFeeData
  10877. };
  10878. return Ok(JsonView(true, "查询成功!", data));
  10879. }
  10880. /// <summary>
  10881. /// 签证费用录入操作(Status:1.新增,2.修改)
  10882. /// </summary>
  10883. /// <param name="dto"></param>
  10884. /// <returns></returns>
  10885. [HttpPost]
  10886. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10887. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10888. {
  10889. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10890. if (groupData.Code != 0)
  10891. {
  10892. return Ok(JsonView(false, groupData.Msg));
  10893. }
  10894. #region 应用推送
  10895. try
  10896. {
  10897. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10898. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10899. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10900. //2024-10-21 新增LZ UID
  10901. var userIds = new List<int>() { 21 };
  10902. string title = $"系统通知";
  10903. string content = "";
  10904. var diId = dto.DiId;
  10905. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10906. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10907. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10908. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10909. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10910. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10911. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10912. }
  10913. catch (Exception ex)
  10914. {
  10915. }
  10916. #endregion
  10917. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10918. }
  10919. #endregion
  10920. #region 签证提成录入
  10921. /// <summary>
  10922. /// 签证提成录入
  10923. /// 基础数据
  10924. /// </summary>
  10925. /// <returns></returns>
  10926. [HttpGet]
  10927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10928. public async Task<IActionResult> VisaCommissionInit()
  10929. {
  10930. return Ok(await _visaCommissionRep.Init());
  10931. }
  10932. /// <summary>
  10933. /// 签证提成录入
  10934. /// Item
  10935. /// </summary>
  10936. /// <param name="_dto"></param>
  10937. /// <returns></returns>
  10938. [HttpPost]
  10939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10940. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10941. {
  10942. var validator = new VisaCommissionItemDtoValidator();
  10943. var validatorRes = await validator.ValidateAsync(_dto);
  10944. if (!validatorRes.IsValid)
  10945. {
  10946. StringBuilder sb = new StringBuilder();
  10947. foreach (var item in validatorRes.Errors)
  10948. {
  10949. sb.AppendLine(item.ErrorMessage);
  10950. }
  10951. return Ok(JsonView(false, sb.ToString()));
  10952. }
  10953. return Ok(await _visaCommissionRep.Item(_dto));
  10954. }
  10955. /// <summary>
  10956. /// 签证提成录入
  10957. /// Save
  10958. /// </summary>
  10959. /// <param name="_dto"></param>
  10960. /// <returns></returns>
  10961. [HttpPost]
  10962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10963. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10964. {
  10965. //参数验证
  10966. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10967. foreach (var item in _dto.Items)
  10968. {
  10969. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10970. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10971. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10972. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10973. }
  10974. return Ok(await _visaCommissionRep.Save(_dto));
  10975. }
  10976. /// <summary>
  10977. /// 签证提成录入
  10978. /// Create
  10979. /// </summary>
  10980. /// <param name="_dto"></param>
  10981. /// <returns></returns>
  10982. [HttpPost]
  10983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10984. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10985. {
  10986. var validator = new VisaCommissionCreateDtoValidator();
  10987. var validatorRes = await validator.ValidateAsync(_dto);
  10988. if (!validatorRes.IsValid)
  10989. {
  10990. StringBuilder sb = new StringBuilder();
  10991. foreach (var item in validatorRes.Errors)
  10992. {
  10993. sb.AppendLine(item.ErrorMessage);
  10994. }
  10995. return Ok(JsonView(false, sb.ToString()));
  10996. }
  10997. return Ok(await _visaCommissionRep.Create(_dto));
  10998. }
  10999. /// <summary>
  11000. /// 签证提成录入
  11001. /// Put(编辑)
  11002. /// </summary>
  11003. /// <param name="id"></param>
  11004. /// <param name="_dto"></param>
  11005. /// <returns></returns>
  11006. [HttpPut]
  11007. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11008. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  11009. {
  11010. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  11011. var validator = new VisaCommissionCreateDtoValidator();
  11012. var validatorRes = await validator.ValidateAsync(_dto);
  11013. if (!validatorRes.IsValid)
  11014. {
  11015. StringBuilder sb = new StringBuilder();
  11016. foreach (var item in validatorRes.Errors)
  11017. {
  11018. sb.AppendLine(item.ErrorMessage);
  11019. }
  11020. return Ok(JsonView(false, sb.ToString()));
  11021. }
  11022. return Ok(await _visaCommissionRep.Edit(id, _dto));
  11023. }
  11024. /// <summary>
  11025. /// 签证提成录入
  11026. /// Del
  11027. /// </summary>
  11028. /// <param name="id"></param>
  11029. /// <param name="currUserId"></param>
  11030. /// <returns></returns>
  11031. [HttpPost]
  11032. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11033. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  11034. {
  11035. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  11036. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  11037. return Ok(await _visaCommissionRep.Del(id, currUserId));
  11038. }
  11039. #endregion
  11040. #region op费用录入
  11041. /// <summary>
  11042. /// 根据diid查询op费用列表
  11043. /// </summary>
  11044. /// <param name="dto"></param>
  11045. /// <returns></returns>
  11046. [HttpPost]
  11047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11048. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  11049. {
  11050. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  11051. if (groupData.Code != 0)
  11052. {
  11053. return Ok(JsonView(false, groupData.Msg));
  11054. }
  11055. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11056. }
  11057. /// <summary>
  11058. /// 根据op费用Id查询单条数据及c表数据
  11059. /// </summary>
  11060. /// <param name="dto"></param>
  11061. /// <returns></returns>
  11062. [HttpPost]
  11063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11064. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  11065. {
  11066. try
  11067. {
  11068. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  11069. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  11070. var data = new
  11071. {
  11072. CarTouristGuideGround = _groupData,
  11073. CreditCardPayment = _creditCardPayment
  11074. };
  11075. return Ok(JsonView(true, "查询成功!", data));
  11076. }
  11077. catch (Exception ex)
  11078. {
  11079. return Ok(JsonView(false, "程序错误!"));
  11080. }
  11081. }
  11082. /// <summary>
  11083. /// op费用删除
  11084. /// </summary>
  11085. /// <param name="dto"></param>
  11086. /// <returns></returns>
  11087. [HttpPost]
  11088. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11089. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  11090. {
  11091. try
  11092. {
  11093. _sqlSugar.BeginTran();
  11094. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  11095. if (!res)
  11096. {
  11097. return Ok(JsonView(false, "删除失败"));
  11098. }
  11099. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  11100. {
  11101. IsDel = 1,
  11102. DeleteUserId = dto.DeleteUserId,
  11103. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11104. }).ExecuteCommandAsync();
  11105. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  11106. {
  11107. IsDel = 1,
  11108. DeleteUserId = dto.DeleteUserId,
  11109. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11110. }).ExecuteCommandAsync();
  11111. #region 删除超支相关数据
  11112. //删除导入的超支数据
  11113. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  11114. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  11115. {
  11116. IsDel = 1,
  11117. DeleteUserId = dto.DeleteUserId,
  11118. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11119. }).ExecuteCommand();
  11120. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  11121. {
  11122. IsDel = 1,
  11123. DeleteUserId = dto.DeleteUserId,
  11124. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11125. }).ExecuteCommand();
  11126. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  11127. {
  11128. IsDel = 1,
  11129. DeleteUserId = dto.DeleteUserId,
  11130. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11131. }).ExecuteCommand();
  11132. #endregion
  11133. _sqlSugar.CommitTran();
  11134. return Ok(JsonView(true, "删除成功!"));
  11135. }
  11136. catch (Exception ex)
  11137. {
  11138. _sqlSugar.RollbackTran();
  11139. return Ok(JsonView(false, "程序错误!" + ex.Message));
  11140. }
  11141. }
  11142. /// <summary>
  11143. /// op费用录入操作(Status:1.新增,2.修改)
  11144. /// </summary>
  11145. /// <param name="dto"></param>
  11146. /// <returns></returns>
  11147. [HttpPost]
  11148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11149. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  11150. {
  11151. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  11152. if (groupData.Code != 0)
  11153. {
  11154. return Ok(JsonView(false, groupData.Msg));
  11155. }
  11156. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11157. }
  11158. /// <summary>
  11159. /// 填写费用详细页面初始化绑定
  11160. /// </summary>
  11161. /// <param name="dto"></param>
  11162. /// <returns></returns>
  11163. [HttpPost]
  11164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11165. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  11166. {
  11167. try
  11168. {
  11169. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  11170. if (groupData.Code != 0)
  11171. {
  11172. return Ok(JsonView(false, groupData.Msg));
  11173. }
  11174. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11175. }
  11176. catch (Exception ex)
  11177. {
  11178. return Ok(JsonView(false, ex.Message));
  11179. }
  11180. }
  11181. /// <summary>
  11182. /// 根据op费用Id查询详细数据
  11183. /// </summary>
  11184. /// <param name="dto"></param>
  11185. /// <returns></returns>
  11186. [HttpPost]
  11187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11188. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  11189. {
  11190. try
  11191. {
  11192. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  11193. if (groupData.Code != 0)
  11194. {
  11195. return Ok(JsonView(false, groupData.Msg));
  11196. }
  11197. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11198. }
  11199. catch (Exception ex)
  11200. {
  11201. return Ok(JsonView(false, ex.Message));
  11202. }
  11203. }
  11204. /// <summary>
  11205. /// OP费用录入填写详情
  11206. /// </summary>
  11207. /// <param name="dto"></param>
  11208. /// <returns></returns>
  11209. [HttpPost]
  11210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11211. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  11212. {
  11213. try
  11214. {
  11215. #region 参数校验
  11216. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  11217. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  11218. if (di == null) return Ok(JsonView(false, "团组错误!"));
  11219. #endregion
  11220. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  11221. if (groupData.Code != 0)
  11222. {
  11223. return Ok(JsonView(false, groupData.Msg));
  11224. }
  11225. //自动审核
  11226. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  11227. #region 应用推送
  11228. try
  11229. {
  11230. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11231. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11232. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11233. //2024-10-21 新增LZ UID
  11234. var userIds = new List<int>() { 21 };
  11235. string title = $"系统通知";
  11236. var diId = dto.DiId;
  11237. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11238. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11239. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  11240. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11241. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  11242. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  11243. }
  11244. catch (Exception ex)
  11245. {
  11246. }
  11247. #endregion
  11248. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11249. }
  11250. catch (Exception ex)
  11251. {
  11252. return Ok(JsonView(false, ex.Message));
  11253. }
  11254. }
  11255. /// <summary>
  11256. /// 获取三公详细所有城市
  11257. /// </summary>
  11258. /// <returns></returns>
  11259. [HttpGet]
  11260. public IActionResult OpCarCityResult()
  11261. {
  11262. var jw = JsonView(false);
  11263. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  11264. {
  11265. x.Id,
  11266. x.Country,
  11267. x.City,
  11268. }).ToList();
  11269. if (data.Count > 0)
  11270. {
  11271. jw = JsonView(true, "获取成功!", data);
  11272. }
  11273. else
  11274. {
  11275. jw.Msg = "城市数据为空!";
  11276. jw.Data = new string[0];
  11277. }
  11278. return Ok(jw);
  11279. }
  11280. /// <summary>
  11281. /// 导出地接费用明细
  11282. /// </summary>
  11283. /// <param name="dto"></param>
  11284. /// <returns></returns>
  11285. [HttpPost]
  11286. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  11287. {
  11288. var jw = JsonView(false);
  11289. if (dto.Diid < 1)
  11290. {
  11291. jw.Msg = "请输入正确的diid!";
  11292. return Ok(jw);
  11293. }
  11294. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11295. if (group == null)
  11296. {
  11297. jw.Msg = "未找到团组信息!";
  11298. return Ok(jw);
  11299. }
  11300. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11301. if (localGuideArr.Count == 0)
  11302. {
  11303. jw.Msg = "该团组暂无地接信息!";
  11304. return Ok(jw);
  11305. }
  11306. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  11307. var overspendSoure = new Dictionary<int, int>
  11308. {
  11309. { 91, 982 }, //车
  11310. { 92 , 1059} ,//导游
  11311. { 994 , 1073}, //翻译
  11312. { 988 , 1074 }, //早餐
  11313. { 93 , 1075 }, //午餐
  11314. { 989 , 1076 }, //晚餐
  11315. };
  11316. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  11317. foreach (var groupArr in localGroup)
  11318. {
  11319. var keyValue = groupArr.Key;
  11320. if (int.TryParse(keyValue, out int cityid))
  11321. {
  11322. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  11323. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  11324. }
  11325. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  11326. foreach (var item in groupArr)
  11327. {
  11328. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  11329. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  11330. new Grp_CarTouristGuideGroundReservationsContentExtend
  11331. {
  11332. Count = a.Count,
  11333. CreateTime = a.CreateTime,
  11334. CreateUserId = a.CreateUserId,
  11335. CTGGRId = a.CTGGRId,
  11336. Currency = a.Currency,
  11337. DatePrice = a.DatePrice,
  11338. DeleteTime = a.DeleteTime,
  11339. DeleteUserId = a.DeleteUserId,
  11340. DiId = a.DiId,
  11341. Id = a.Id,
  11342. IsDel = a.IsDel,
  11343. Price = a.Price,
  11344. PriceContent = a.PriceContent,
  11345. Remark = a.Remark,
  11346. SId = a.SId,
  11347. SidName = b.Name,
  11348. Units = a.Units,
  11349. }
  11350. ).ToList();
  11351. if (content.Count > 0)
  11352. {
  11353. contentArr.Add(content);
  11354. }
  11355. }
  11356. //open excel
  11357. //set excel
  11358. //save excel
  11359. try
  11360. {
  11361. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  11362. IWorkbook workbook;
  11363. if (Path.GetExtension(filePath).ToLower() == ".xls")
  11364. {
  11365. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11366. }
  11367. else
  11368. {
  11369. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11370. }
  11371. ISheet sheet = workbook.GetSheetAt(0);
  11372. var rowStartIndex = 2;
  11373. var clounmCount = 10;
  11374. var initStyleRow = sheet.GetRow(2);
  11375. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  11376. //var overspendArrDetail =
  11377. var existsId = new List<CarCompare>();
  11378. var lastElem = arr.Last();
  11379. var thisSid = -1;
  11380. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  11381. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  11382. {
  11383. Name = "未知币种!",
  11384. Remark = "未知币种!",
  11385. };
  11386. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  11387. Action cloneRowFn = () =>
  11388. {
  11389. rowStartIndex++;
  11390. var cloneRow = sheet.CreateRow(rowStartIndex);
  11391. // 复制样式
  11392. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  11393. {
  11394. ICell sourceCell = initStyleRow.GetCell(i);
  11395. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  11396. // 确保单元格存在样式
  11397. if (sourceCell.CellStyle != null)
  11398. {
  11399. targetCell.CellStyle = sourceCell.CellStyle;
  11400. }
  11401. }
  11402. };
  11403. var mergeRow = () =>
  11404. {
  11405. for (int i = 2; i < sheet.LastRowNum; i++)
  11406. {
  11407. var row = sheet.GetRow(i);
  11408. var cellFirst = row.GetCell(0);
  11409. var thisIndex = i + 1;
  11410. while (thisIndex < sheet.LastRowNum)
  11411. {
  11412. var nextRow = sheet.GetRow(thisIndex);
  11413. var nextCellFirst = nextRow.GetCell(0);
  11414. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  11415. {
  11416. thisIndex++;
  11417. }
  11418. else
  11419. {
  11420. break;
  11421. }
  11422. }
  11423. thisIndex--;
  11424. if (thisIndex != i)
  11425. {
  11426. //合并row
  11427. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11428. i, // 起始行索引(0-based)
  11429. thisIndex, // 结束行索引(0-based)
  11430. 0, // 起始列索引(0-based)
  11431. 0 // 结束列索引(0-based)
  11432. );
  11433. sheet.AddMergedRegion(cellRangeAddress);
  11434. i = thisIndex;
  11435. }
  11436. }
  11437. };
  11438. var chaoshiNumber = 0;
  11439. var totalNumber = 0.00M;
  11440. string lastStr = "";
  11441. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  11442. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  11443. {
  11444. b.IsAuditGM,
  11445. x.Id,
  11446. x.Area,
  11447. b.PayPercentage,
  11448. b.PayMoney,
  11449. }).ToList();
  11450. string yesPayment = "", noPayment = "";
  11451. foreach (var item in queryCarArrByCityAndDiid)
  11452. {
  11453. if (item.IsAuditGM == 1)
  11454. {
  11455. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11456. }
  11457. else
  11458. {
  11459. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11460. }
  11461. }
  11462. lastStr = yesPayment + noPayment;
  11463. foreach (var item in arr)
  11464. {
  11465. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  11466. {
  11467. if (thisSid != item.SId)
  11468. {
  11469. if (thisSid == -1)
  11470. {
  11471. thisSid = item.SId;
  11472. }
  11473. else
  11474. {
  11475. //合并小计行
  11476. //创建合并区域的实例
  11477. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11478. rowStartIndex, // 起始行索引(0-based)
  11479. rowStartIndex, // 结束行索引(0-based)
  11480. 0, // 起始列索引(0-based)
  11481. 3 // 结束列索引(0-based)
  11482. );
  11483. sheet.AddMergedRegion(cellRangeAddress);
  11484. var CellStyle = workbook.CreateCellStyle();
  11485. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11486. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11487. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11488. for (int i = 0; i <= clounmCount; i++)
  11489. {
  11490. if (i > 6)
  11491. {
  11492. var CellStyle1 = workbook.CreateCellStyle();
  11493. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11494. IFont Font = workbook.CreateFont(); // 创建字体
  11495. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11496. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11497. CellStyle1.SetFont(Font);
  11498. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11499. }
  11500. else
  11501. {
  11502. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11503. }
  11504. }
  11505. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11506. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11507. //超时合计
  11508. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11509. //超时数
  11510. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11511. //超时合计费用
  11512. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11513. thisSid = item.SId;
  11514. cloneRowFn();
  11515. chaoshiNumber = 0;
  11516. totalNumber = 0;
  11517. }
  11518. }
  11519. IRow row = sheet.GetRow(rowStartIndex);
  11520. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11521. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  11522. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  11523. if (isOpenOverspendSoure)
  11524. {
  11525. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11526. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  11527. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  11528. }
  11529. for (int i = 0; i <= clounmCount; i++)
  11530. {
  11531. var cell = row.GetCell(i);
  11532. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  11533. if (cell == null)
  11534. {
  11535. cell = row.CreateCell(i);
  11536. }
  11537. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  11538. fontRed.CloneStyleFrom(cell.CellStyle);
  11539. IFont Font = workbook.CreateFont(); // 创建字体
  11540. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  11541. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11542. fontRed.SetFont(Font);
  11543. byte[] rgb = new byte[3] { 255, 242, 204 };
  11544. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  11545. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  11546. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  11547. if (workbook is XSSFWorkbook)
  11548. {
  11549. BackgroundColor255_242_204.FillForegroundColor = 0;
  11550. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  11551. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  11552. }
  11553. else
  11554. {
  11555. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  11556. }
  11557. if (i == 1 || i > 6)
  11558. {
  11559. if (i > 6)
  11560. {
  11561. fontRed.FillForegroundColor = 0;
  11562. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  11563. fontRed.FillPattern = FillPattern.SolidForeground;
  11564. }
  11565. cell.CellStyle = fontRed;
  11566. }
  11567. if (i > 2 && i < 7)
  11568. {
  11569. cell.CellStyle = BackgroundColor255_242_204;
  11570. }
  11571. cell.SetCellValue(setCellValue); //写入单元格
  11572. }
  11573. if (overspendSoure.ContainsKey(thisSid))
  11574. {
  11575. var overspendId = overspendSoure[thisSid];
  11576. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11577. }
  11578. cloneRowFn();
  11579. existsId.Add(new CarCompare
  11580. {
  11581. DataPrice = item.DatePrice.ObjToDate(),
  11582. Sid = item.SId
  11583. });
  11584. }
  11585. if (item.Equals(lastElem))
  11586. {
  11587. //合并小计行
  11588. //创建合并区域的实例
  11589. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11590. rowStartIndex, // 起始行索引(0-based)
  11591. rowStartIndex, // 结束行索引(0-based)
  11592. 0, // 起始列索引(0-based)
  11593. 3 // 结束列索引(0-based)
  11594. );
  11595. sheet.AddMergedRegion(cellRangeAddress);
  11596. var CellStyle = workbook.CreateCellStyle();
  11597. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11598. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11599. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11600. for (int i = 0; i <= clounmCount; i++)
  11601. {
  11602. if (i > 6)
  11603. {
  11604. var CellStyle1 = workbook.CreateCellStyle();
  11605. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11606. IFont Font = workbook.CreateFont(); // 创建字体
  11607. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11608. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11609. CellStyle1.SetFont(Font);
  11610. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11611. }
  11612. else
  11613. {
  11614. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11615. }
  11616. }
  11617. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11618. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11619. //超时合计
  11620. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11621. //超时数
  11622. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11623. //超时合计费用
  11624. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11625. cloneRowFn();
  11626. // 创建合并区域的实例
  11627. cellRangeAddress = new CellRangeAddress(
  11628. rowStartIndex, // 起始行索引(0-based)
  11629. rowStartIndex, // 结束行索引(0-based)
  11630. 0, // 起始列索引(0-based)
  11631. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  11632. );
  11633. // 添加合并区域
  11634. sheet.AddMergedRegion(cellRangeAddress);
  11635. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  11636. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  11637. }
  11638. }
  11639. mergeRow();
  11640. // 保存修改后的Excel文件到新文件
  11641. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  11642. // new FileStream(newFilePath, FileMode.CreateNew)
  11643. using (var stream = new MemoryStream())
  11644. {
  11645. workbook.Write(stream, true);
  11646. stream.Flush();
  11647. stream.Seek(0, SeekOrigin.Begin);
  11648. MemoryStream memoryStream = new MemoryStream();
  11649. stream.CopyTo(memoryStream);
  11650. memoryStream.Seek(0, SeekOrigin.Begin);
  11651. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  11652. }
  11653. workbook.Close();
  11654. workbook.Dispose();
  11655. }
  11656. catch (Exception ex)
  11657. {
  11658. jw.Msg = "出现异常!" + ex.Message;
  11659. return Ok(jw);
  11660. }
  11661. }
  11662. if (Zips.Count > 0)
  11663. {
  11664. IOOperatorHelper io = new IOOperatorHelper();
  11665. var byts = io.ConvertZipStream(Zips);
  11666. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  11667. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  11668. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  11669. }
  11670. else
  11671. {
  11672. jw.Msg = "暂无生成文件!";
  11673. }
  11674. return Ok(jw);
  11675. }
  11676. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  11677. {
  11678. string outStr = string.Empty;
  11679. switch (i)
  11680. {
  11681. case 0:
  11682. outStr = arr[0].SidName;
  11683. break;
  11684. case 1:
  11685. outStr = arr[0].DataPriceStr;
  11686. break;
  11687. case 2:
  11688. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  11689. break;
  11690. case 4:
  11691. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  11692. break;
  11693. case 7:
  11694. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11695. {
  11696. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  11697. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  11698. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  11699. }
  11700. break;
  11701. case 8:
  11702. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11703. {
  11704. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  11705. }
  11706. break;
  11707. case 9:
  11708. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11709. {
  11710. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  11711. }
  11712. break;
  11713. case 10:
  11714. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11715. {
  11716. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  11717. }
  11718. break;
  11719. }
  11720. return outStr;
  11721. }
  11722. #region OP行程单
  11723. /// <summary>
  11724. /// OP行程单初始化
  11725. /// </summary>
  11726. /// <param name="dto"></param>
  11727. /// <returns></returns>
  11728. [HttpPost]
  11729. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11730. {
  11731. var jw = JsonView(false);
  11732. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  11733. var group = groupList.First();
  11734. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11735. if (group == null)
  11736. {
  11737. jw.Msg = "暂无团组!";
  11738. return Ok(jw);
  11739. }
  11740. group = groupList.Find(x => x.Id == diid);
  11741. if (group == null)
  11742. {
  11743. jw.Msg = "请输入正确的团组ID!";
  11744. return Ok(jw);
  11745. }
  11746. string city = string.Empty;
  11747. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11748. if (blackCode.Count > 0)
  11749. {
  11750. var black = blackCode.First();
  11751. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11752. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11753. if (blackSp.Length > 0)
  11754. {
  11755. try
  11756. {
  11757. var cityArrCode = new List<string>(20);
  11758. foreach (var item in blackSp)
  11759. {
  11760. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11761. var IndexSelect = itemSp[2];
  11762. var cityArrCodeLength = cityArrCode.Count - 1;
  11763. var startCity = IndexSelect.Substring(0, 3);
  11764. if (cityArrCodeLength > 0)
  11765. {
  11766. var arrEndCity = cityArrCode[cityArrCodeLength];
  11767. if (arrEndCity != startCity)
  11768. {
  11769. cityArrCode.Add(startCity.ToUpper());
  11770. }
  11771. }
  11772. else
  11773. {
  11774. cityArrCode.Add(startCity.ToUpper());
  11775. }
  11776. var endCity = IndexSelect.Substring(3, 3);
  11777. cityArrCode.Add(endCity.ToUpper());
  11778. }
  11779. var cityThree = string.Empty;
  11780. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11781. cityThree = cityThree.TrimEnd(',');
  11782. if (string.IsNullOrWhiteSpace(cityThree))
  11783. {
  11784. throw new
  11785. Exception("error");
  11786. }
  11787. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11788. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11789. foreach (var item in cityArrCode)
  11790. {
  11791. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11792. if (find != null)
  11793. {
  11794. city += find.City + "/";
  11795. }
  11796. else
  11797. {
  11798. city += item + "三字码未收入/";
  11799. }
  11800. }
  11801. city = city.TrimEnd('/');
  11802. }
  11803. catch (Exception e)
  11804. {
  11805. city = "黑屏代码格式不正确!";
  11806. }
  11807. }
  11808. }
  11809. else
  11810. {
  11811. city = "未录入黑屏代码";
  11812. }
  11813. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11814. {
  11815. Date = x.Date,
  11816. Days = x.Days,
  11817. Diffgroup = x.Diffgroup,
  11818. Diid = x.Diid,
  11819. Traffic_First = x.Traffic_First,
  11820. Traffic_Second = x.Traffic_Second,
  11821. Trip = x.Trip,
  11822. WeekDay = x.WeekDay,
  11823. Id = x.Id
  11824. }).ToList();
  11825. jw.Data = new
  11826. {
  11827. groupList = groupList.Select(x => new
  11828. {
  11829. x.Id,
  11830. x.TeamName,
  11831. x.TourCode
  11832. }).ToList(),
  11833. groupInfo = new
  11834. {
  11835. group.VisitDays,
  11836. group.TourCode,
  11837. group.VisitPNumber,
  11838. group.TeamName,
  11839. city
  11840. },
  11841. OpTravelList
  11842. };
  11843. jw.Code = 200;
  11844. jw.Msg = "操作成功!";
  11845. return Ok(jw);
  11846. }
  11847. /// <summary>
  11848. /// 删除团组行程单
  11849. /// </summary>
  11850. /// <returns></returns>
  11851. [HttpPost]
  11852. public IActionResult DelTravel(DelOpTravelDto dto)
  11853. {
  11854. var jw = JsonView(false);
  11855. if (dto.UserId <= 0 || dto.Diid <= 0)
  11856. {
  11857. jw.Msg = "请输入正确的参数!";
  11858. return Ok(jw);
  11859. }
  11860. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11861. .SetColumns(x => new Grp_TravelList
  11862. {
  11863. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11864. DeleteUserId = dto.UserId,
  11865. IsDel = 1,
  11866. }).ExecuteCommand();
  11867. jw = JsonView(true);
  11868. return Ok(jw);
  11869. }
  11870. /// <summary>
  11871. /// 行程单保存
  11872. /// </summary>
  11873. /// <returns></returns>
  11874. [HttpPost]
  11875. public IActionResult TravelSave(TravelSaveDto dto)
  11876. {
  11877. var jw = JsonView(false);
  11878. if (dto.Arr.Count > 0)
  11879. {
  11880. try
  11881. {
  11882. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11883. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  11884. .ToList();
  11885. _sqlSugar.BeginTran();
  11886. foreach (var item in dto.Arr)
  11887. {
  11888. if (item.Id == 0)
  11889. {
  11890. throw new Exception("请传入正确的Id");
  11891. }
  11892. //比较上一次的差异
  11893. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11894. if (findTravel != null)
  11895. {
  11896. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11897. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11898. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  11899. }
  11900. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11901. .SetColumns(x => new Grp_TravelList
  11902. {
  11903. Trip = item.Trip
  11904. }).ExecuteCommand();
  11905. }
  11906. _sqlSugar.CommitTran();
  11907. jw = JsonView(true);
  11908. }
  11909. catch (Exception ex)
  11910. {
  11911. _sqlSugar.RollbackTran();
  11912. jw.Msg = "程序异常!" + ex.Message;
  11913. }
  11914. }
  11915. else
  11916. {
  11917. jw.Msg = "请传入正确的参数!";
  11918. }
  11919. return Ok(jw);
  11920. }
  11921. private string CheckStr(string original, string changed)
  11922. {
  11923. // 创建diff_match_patch对象
  11924. var dmp = new diff_match_patch();
  11925. // 计算差异
  11926. List<Diff> diffs = dmp.diff_main(original, changed);
  11927. // 清理和合并差异
  11928. dmp.diff_cleanupSemantic(diffs);
  11929. // 使用StringBuilder构建最终的字符串
  11930. StringBuilder finalString = new StringBuilder();
  11931. // 输出差异结果,并构建变动后的字符串
  11932. foreach (Diff diff in diffs)
  11933. {
  11934. switch (diff.operation)
  11935. {
  11936. case Operation.EQUAL:
  11937. // 相等的部分,直接添加到最终字符串
  11938. finalString.Append(diff.text);
  11939. break;
  11940. case Operation.INSERT:
  11941. // 插入的部分,添加标记并添加到最终字符串
  11942. finalString.Append("[++]" + diff.text + "[++]");
  11943. break;
  11944. case Operation.DELETE:
  11945. // 删除的部分,不添加到最终字符串
  11946. //finalString.Append("[++]" + diff.text + "[++]");
  11947. break;
  11948. }
  11949. }
  11950. // 输出变动后的字符串
  11951. return finalString.ToString();
  11952. }
  11953. private class tagContent
  11954. {
  11955. public DateTime Date { get; set; }
  11956. public string StartTag { get; set; }
  11957. public string EndTag { get; set; }
  11958. public string Content { get; set; }
  11959. public static int tagLength { get { return 3; } }
  11960. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11961. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11962. public bool IsFinally { get; set; }
  11963. }
  11964. private List<string> ExtractContentBetweenTags(string input, string tag)
  11965. {
  11966. List<string> results = new List<string>();
  11967. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11968. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11969. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11970. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11971. string[] strValueArr = new string[1];
  11972. foreach (System.Text.RegularExpressions.Match match in matches)
  11973. {
  11974. var strValue = match.Groups[1].Value;
  11975. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11976. }
  11977. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11978. return results;
  11979. }
  11980. /// <summary>
  11981. /// 导出行程单
  11982. /// </summary>
  11983. /// <param name="dto"></param>
  11984. /// <returns></returns>
  11985. [HttpPost]
  11986. public IActionResult ExportTravel(ExportTravelDto dto)
  11987. {
  11988. var jw = JsonView(false);
  11989. jw.Data = "";
  11990. int diid = 0;
  11991. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11992. if (Find == null)
  11993. {
  11994. jw.Msg = "请选择正确的团组!";
  11995. return Ok(jw);
  11996. }
  11997. else
  11998. {
  11999. diid = Find.Id;
  12000. }
  12001. //数据源
  12002. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  12003. DataTable dtBlack = null;
  12004. try
  12005. {
  12006. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  12007. }
  12008. catch (Exception)
  12009. {
  12010. jw.Msg = "机票黑屏代码有误!";
  12011. return Ok(jw);
  12012. }
  12013. string CityStr = string.Empty;
  12014. if (dtBlack.Rows.Count == 0)
  12015. {
  12016. jw.Msg = "机票黑屏代码有误!";
  12017. return Ok(jw);
  12018. }
  12019. else
  12020. {
  12021. foreach (DataRow row in dtBlack.Rows)
  12022. {
  12023. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12024. {
  12025. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  12026. return Ok(jw);
  12027. }
  12028. }
  12029. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  12030. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  12031. }
  12032. // 指定的文字
  12033. var targetTextDic = new Dictionary<string, List<string>>();
  12034. //创建数据源Table
  12035. DataTable dtSource = new DataTable();
  12036. dtSource.Columns.Add("Days", typeof(string));
  12037. dtSource.Columns.Add("Date", typeof(string));
  12038. dtSource.Columns.Add("Week", typeof(string));
  12039. dtSource.Columns.Add("Traffic", typeof(string));
  12040. dtSource.Columns.Add("Trip", typeof(string));
  12041. //获取数据,放到datatable
  12042. foreach (var item in _travelList)
  12043. {
  12044. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  12045. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  12046. .Replace(tagContent.TagFormat.Item2, string.Empty)
  12047. .Replace("[++]", string.Empty);
  12048. DataRow dr = dtSource.NewRow();
  12049. dr["Days"] = item.Days;
  12050. dr["Date"] = item.Date;
  12051. dr["Week"] = item.WeekDay;
  12052. dr["Traffic"] = item.Traffic_First
  12053. + "\r\n"
  12054. + item.Traffic_Second;
  12055. dr["Trip"] = item.Trip;
  12056. dtSource.Rows.Add(dr);
  12057. }
  12058. Dictionary<string, string> dic = new Dictionary<string, string>();
  12059. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  12060. dic.Add("City", CityStr);
  12061. dic.Add("Days", Find.VisitDays.ToString());
  12062. dic.Add("DeleCode", Find.TourCode);
  12063. dic.Add("Pnum", Find.VisitPNumber.ToString());
  12064. //模板路径
  12065. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  12066. //载入模板
  12067. Document doc = null;
  12068. DocumentBuilder builder = null;
  12069. try
  12070. {
  12071. //载入模板
  12072. doc = new Document(tempPath);
  12073. builder = new DocumentBuilder(doc);
  12074. }
  12075. catch (Exception)
  12076. {
  12077. jw.Msg = "模板位置不存在!";
  12078. return Ok(jw);
  12079. }
  12080. foreach (var key in dic.Keys)
  12081. {
  12082. Bookmark bookmark = doc.Range.Bookmarks[key];
  12083. if (bookmark != null)
  12084. {
  12085. builder.MoveToBookmark(key);
  12086. builder.Write(dic[key]);
  12087. }
  12088. }
  12089. //获取word里所有表格
  12090. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12091. //获取所填表格的序数
  12092. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12093. try
  12094. {
  12095. //循环赋值
  12096. for (int i = 0; i < dtSource.Rows.Count; i++)
  12097. {
  12098. builder.MoveToCell(0, i + 1, 0, 0);
  12099. builder.Write(dtSource.Rows[i]["Days"].ToString());
  12100. builder.MoveToCell(0, i + 1, 1, 0);
  12101. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  12102. builder.MoveToCell(0, i + 1, 2, 0);
  12103. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  12104. var trip = dtSource.Rows[i]["Trip"].ToString();
  12105. builder.MoveToCell(0, i + 1, 3, 0);
  12106. builder.Write(trip);
  12107. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  12108. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12109. // 获取特定索引的段落
  12110. Paragraph paragraph = (Paragraph)paragraphs[0];
  12111. Run run = paragraph.Runs[0];
  12112. Aspose.Words.Font font = run.Font;
  12113. font.Name = "黑体";
  12114. //设置双休红色
  12115. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  12116. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12117. paragraph = (Paragraph)paragraphs[1];
  12118. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  12119. {
  12120. run = paragraph.Runs[0];
  12121. font = run.Font;
  12122. font.Color = Color.Red;
  12123. }
  12124. }
  12125. }
  12126. catch (Exception ex)
  12127. {
  12128. }
  12129. //删除多余行
  12130. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  12131. {
  12132. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  12133. }
  12134. var targetTextList = new List<string>();
  12135. // 遍历文档中的表格
  12136. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  12137. {
  12138. foreach (Aspose.Words.Tables.Row row in table.Rows)
  12139. {
  12140. var cellIndex = 0;
  12141. foreach (Cell cell in row.Cells)
  12142. {
  12143. if (cellIndex == 1 && row.Cells.Count == 4)
  12144. {
  12145. foreach (var target in targetTextDic.Keys)
  12146. {
  12147. if (cell.GetText().Contains(target))
  12148. {
  12149. targetTextList = targetTextDic[target];
  12150. break;
  12151. }
  12152. }
  12153. }
  12154. // 遍历单元格中的所有段落
  12155. foreach (Paragraph paragraph in cell.Paragraphs)
  12156. {
  12157. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  12158. List<Run> runs = new List<Run>();
  12159. foreach (Run run in paragraph.Runs)
  12160. {
  12161. runs.Add(run);
  12162. }
  12163. foreach (Run run in runs)
  12164. {
  12165. foreach (var targetText in targetTextList)
  12166. {
  12167. // 检查文字是否包含指定文字
  12168. if (run.Text.Contains(targetText))
  12169. {
  12170. // 将包含的部分设置为红色
  12171. HighlightText(run, targetText, Color.Red);
  12172. }
  12173. }
  12174. }
  12175. }
  12176. cellIndex++;
  12177. }
  12178. }
  12179. }
  12180. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  12181. if (!Directory.Exists(savePath))
  12182. {
  12183. try
  12184. {
  12185. Directory.CreateDirectory(savePath);
  12186. }
  12187. catch
  12188. {
  12189. }
  12190. }
  12191. string path = savePath + Find.TeamName + "出访日程";
  12192. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  12193. try
  12194. {
  12195. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  12196. string postfix = ".docx";
  12197. if (dto.IsPDF == 1)
  12198. {
  12199. saveFormat = Aspose.Words.SaveFormat.Pdf;
  12200. postfix = ".pdf";
  12201. }
  12202. doc.Save(path + postfix, saveFormat);
  12203. jw = JsonView(true, "导出成功", ftpPath + postfix);
  12204. }
  12205. catch (Exception)
  12206. {
  12207. jw = JsonView(false);
  12208. }
  12209. return Ok(jw);
  12210. }
  12211. /// <summary>
  12212. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  12213. /// </summary>
  12214. /// <param name="num"></param>
  12215. /// <returns></returns>
  12216. string GetNum(string num)
  12217. {
  12218. string str = "";
  12219. switch (num)
  12220. {
  12221. case "1":
  12222. str = "一";
  12223. break;
  12224. case "2":
  12225. str = "二";
  12226. break;
  12227. case "3":
  12228. str = "三";
  12229. break;
  12230. case "4":
  12231. str = "四";
  12232. break;
  12233. case "5":
  12234. str = "五";
  12235. break;
  12236. case "6":
  12237. str = "六";
  12238. break;
  12239. case "7":
  12240. str = "七";
  12241. break;
  12242. case "8":
  12243. str = "八";
  12244. break;
  12245. case "9":
  12246. str = "九";
  12247. break;
  12248. case "10":
  12249. str = "十";
  12250. break;
  12251. case "11":
  12252. str = "十一";
  12253. break;
  12254. case "12":
  12255. str = "十二";
  12256. break;
  12257. case "一":
  12258. str = "1";
  12259. break;
  12260. case "二":
  12261. str = "2";
  12262. break;
  12263. case "三":
  12264. str = "3";
  12265. break;
  12266. case "四":
  12267. str = "4";
  12268. break;
  12269. case "五":
  12270. str = "5";
  12271. break;
  12272. case "六":
  12273. str = "6";
  12274. break;
  12275. case "七":
  12276. str = "7";
  12277. break;
  12278. case "八":
  12279. str = "8";
  12280. break;
  12281. case "九":
  12282. str = "9";
  12283. break;
  12284. case "十":
  12285. str = "10";
  12286. break;
  12287. case "十一":
  12288. str = "11";
  12289. break;
  12290. case "十二":
  12291. str = "12";
  12292. break;
  12293. }
  12294. return str;
  12295. }
  12296. // 高亮包含指定文字的部分
  12297. void HighlightText(Run run, string targetText, Color color)
  12298. {
  12299. string text = run.Text;
  12300. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  12301. if (startIndex >= 0)
  12302. {
  12303. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  12304. // 前部分
  12305. if (startIndex > 0)
  12306. {
  12307. Run beforeRun = (Run)run.Clone(true);
  12308. beforeRun.Text = text.Substring(0, startIndex);
  12309. parentParagraph.InsertBefore(beforeRun, run);
  12310. }
  12311. // 匹配部分
  12312. Run matchRun = (Run)run.Clone(true);
  12313. matchRun.Text = text.Substring(startIndex, targetText.Length);
  12314. matchRun.Font.Color = color;
  12315. parentParagraph.InsertBefore(matchRun, run);
  12316. // 后部分
  12317. if (startIndex + targetText.Length < text.Length)
  12318. {
  12319. Run afterRun = (Run)run.Clone(true);
  12320. afterRun.Text = text.Substring(startIndex + targetText.Length);
  12321. parentParagraph.InsertBefore(afterRun, run);
  12322. }
  12323. // 删除原始Run
  12324. run.Remove();
  12325. }
  12326. }
  12327. #endregion
  12328. #endregion
  12329. #region 团组成本
  12330. /// <summary>
  12331. /// 团组成本数据初始化
  12332. /// </summary>
  12333. /// <param name="dto"></param>
  12334. /// <returns></returns>
  12335. [HttpPost]
  12336. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  12337. {
  12338. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  12339. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  12340. WHEN COUNT(*) >= 0 THEN 'True'
  12341. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  12342. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  12343. ").ToList(); //团组列表
  12344. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  12345. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  12346. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  12347. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  12348. if (groupinfoValue != null)
  12349. {
  12350. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  12351. var spArr = new string[1] { countryArr };
  12352. if (countryArr.Contains("|"))
  12353. {
  12354. spArr = countryArr.Split("|");
  12355. }
  12356. else if (countryArr.Contains("、"))
  12357. {
  12358. spArr = countryArr.Split("、");
  12359. }
  12360. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  12361. {
  12362. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  12363. if (dbQueryCountry != null)
  12364. {
  12365. visaCountryInfoArr.Add(dbQueryCountry);
  12366. }
  12367. }
  12368. }
  12369. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  12370. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  12371. var create = _GroupCostRepository.
  12372. CreateGroupCostByBlackCode(dto.Diid);
  12373. if (groupCost.Count == 0 && create.Code == 0)
  12374. {
  12375. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  12376. }
  12377. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  12378. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  12379. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  12380. groupCostMap = groupCostMap.Select(x =>
  12381. {
  12382. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  12383. {
  12384. x.Date = dataForamt.ToString("yyyy-MM-dd");
  12385. }
  12386. return x;
  12387. }).ToList();
  12388. //GroupCostParameter.Add(new
  12389. // Grp_GroupCostParameter());
  12390. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  12391. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  12392. return Ok(JsonView(new
  12393. {
  12394. groupList,
  12395. groupInfo,
  12396. groupChecks,
  12397. groupCost = groupCostMap,
  12398. hotelNumber,
  12399. GroupCostParameter = GroupCostParameterMap,
  12400. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  12401. {
  12402. x.VisaCountry,
  12403. x.VisaPrice,
  12404. x.Id,
  12405. }).ToList(),
  12406. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  12407. blackCodeIsTrue = create.Code == 0 ? true : false,
  12408. hotelIsTrue = hotelIsTrue,
  12409. }));
  12410. }
  12411. /// <summary>
  12412. /// 团组成本信息保存
  12413. /// </summary>
  12414. /// <param name="dto"></param>
  12415. /// <returns></returns>
  12416. [HttpPost]
  12417. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  12418. {
  12419. if (dto.Diid <= 0 || dto.Userid <= 0)
  12420. {
  12421. return Ok(JsonView(false));
  12422. }
  12423. JsonView jw = null;
  12424. bool isTrue = false;
  12425. #region 复制团组成本
  12426. //if (dto.Diid == 2581)
  12427. //{
  12428. // dto.Diid = 2599;
  12429. // dto.CheckBoxs.ForEach(x =>
  12430. // {
  12431. // x.Diid = 2599;
  12432. // });
  12433. // dto.GroupCosts.ForEach(x =>
  12434. // {
  12435. // x.Diid = 2599;
  12436. // });
  12437. // dto.CostTypeHotelNumbers.ForEach(x =>
  12438. // {
  12439. // x.Diid = 2599;
  12440. // });
  12441. // dto.GroupCostParameters.ForEach(x =>
  12442. // {
  12443. // x.DiId = 2599;
  12444. // });
  12445. //}
  12446. #endregion
  12447. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  12448. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  12449. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  12450. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  12451. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  12452. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  12453. try
  12454. {
  12455. _sqlSugar.BeginTran();
  12456. isTrue = await _GroupCostRepository.
  12457. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  12458. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  12459. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  12460. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  12461. _sqlSugar.CommitTran();
  12462. jw = JsonView(true, "保存成功!", isTrue);
  12463. }
  12464. catch (Exception)
  12465. {
  12466. _sqlSugar.RollbackTran();
  12467. jw = JsonView(false);
  12468. }
  12469. return Ok(jw);
  12470. }
  12471. /// <summary>
  12472. /// 司兼导数据
  12473. /// </summary>
  12474. /// <param name="dto"></param>
  12475. /// <returns></returns>
  12476. [HttpPost]
  12477. public IActionResult GetCarGuides(CarGuidesDto dto)
  12478. {
  12479. JsonView jw = null;
  12480. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  12481. jw = JsonView(true, "获取成功!", Data);
  12482. return Ok(jw);
  12483. }
  12484. /// <summary>
  12485. /// 导游数据
  12486. /// </summary>
  12487. /// <param name="dto"></param>
  12488. /// <returns></returns>
  12489. [HttpPost]
  12490. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  12491. {
  12492. JsonView jw = null;
  12493. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  12494. // 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
  12495. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  12496. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  12497. jw = JsonView(true, "获取成功!", Data);
  12498. return Ok(jw);
  12499. }
  12500. /// <summary>
  12501. /// 成本车数据
  12502. /// </summary>
  12503. /// <param name="dto"></param>
  12504. /// <returns></returns>
  12505. [HttpPost]
  12506. public IActionResult GetCarInfo(CarGuidesDto dto)
  12507. {
  12508. JsonView jw = null;
  12509. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  12510. jw = JsonView(true, "获取成功!", Data);
  12511. return Ok(jw);
  12512. }
  12513. /// <summary>
  12514. /// 景点数据
  12515. /// </summary>
  12516. /// <param name="dto"></param>
  12517. /// <returns></returns>
  12518. [HttpPost]
  12519. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  12520. {
  12521. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  12522. return Ok(JsonView(true, "获取成功!", Data));
  12523. }
  12524. /// <summary>
  12525. /// 成本通知
  12526. /// </summary>
  12527. /// <param name="dto"></param>
  12528. /// <returns></returns>
  12529. [HttpPost]
  12530. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  12531. {
  12532. if (dto.Diid < 0)
  12533. {
  12534. return Ok(JsonView(false));
  12535. }
  12536. JsonView jw = null;
  12537. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  12538. if (GroupCostParameter != null)
  12539. {
  12540. int IsShare = 0;
  12541. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  12542. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  12543. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  12544. string msg = string.Empty;
  12545. if (isTrue)
  12546. {
  12547. if (IsShare == 0)
  12548. {
  12549. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  12550. }
  12551. else
  12552. {
  12553. #region 企微通知对应岗位用户
  12554. try
  12555. {
  12556. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  12557. }
  12558. catch (Exception ex)
  12559. {
  12560. }
  12561. #endregion
  12562. msg = "通知成功,其他模块操作人员可见此成本信息!";
  12563. }
  12564. jw = JsonView(isTrue, msg, new { IsShare });
  12565. }
  12566. else
  12567. {
  12568. msg = "修改失败!";
  12569. jw = JsonView(isTrue, msg);
  12570. }
  12571. }
  12572. else
  12573. {
  12574. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  12575. }
  12576. return Ok(jw);
  12577. }
  12578. /// <summary>
  12579. /// 导出报价单
  12580. /// </summary>
  12581. /// <param name="dto"></param>
  12582. /// <returns></returns>
  12583. [HttpPost]
  12584. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  12585. {
  12586. if (dto.Diid == 0)
  12587. {
  12588. return Ok(JsonView(false, "请传递团组id"));
  12589. }
  12590. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12591. if (deleInfo.Code != 0)
  12592. {
  12593. return Ok(JsonView(false, "团组信息查询失败!"));
  12594. }
  12595. var di = deleInfo.Data as DelegationInfoWebView;
  12596. if (di != null)
  12597. {
  12598. di.TeamName = di.TeamName.Replace("|", "、");
  12599. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  12600. //文件名
  12601. string strFileName = di.TeamName + "-收款账单.doc";
  12602. //获取模板
  12603. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  12604. //载入模板
  12605. Document doc = new Document(tmppath);
  12606. decimal TotalPrice = 0.00M;
  12607. string itemStr = string.Empty;
  12608. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  12609. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12610. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12611. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  12612. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  12613. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  12614. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  12615. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  12616. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  12617. foreach (var cost in groupCostType)
  12618. {
  12619. var List = cost.ToList();
  12620. if (cost.Key == "A")
  12621. {
  12622. foreach (var ListItem in List)
  12623. {
  12624. if (ListItem.number > 0)
  12625. {
  12626. if (ListItem.code.Contains("TBR"))
  12627. {
  12628. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12629. }
  12630. else
  12631. {
  12632. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12633. }
  12634. TotalPrice += (ListItem.number * ListItem.price);
  12635. }
  12636. }
  12637. }
  12638. else
  12639. {
  12640. itemStr = itemStr.Insert(0, "A段\r\n");
  12641. itemStr += "B段\r\n";
  12642. foreach (var ListItem in List)
  12643. {
  12644. if (ListItem.number > 0)
  12645. {
  12646. if (ListItem.code.Contains("TBR"))
  12647. {
  12648. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12649. }
  12650. else
  12651. {
  12652. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12653. }
  12654. TotalPrice += (ListItem.number * ListItem.price);
  12655. }
  12656. }
  12657. }
  12658. }
  12659. #region 替换Word模板书签内容
  12660. Dictionary<string, string> marks = new Dictionary<string, string>();
  12661. marks.Add("To", di.ClientUnit);//付款方
  12662. marks.Add("ToTel", di.TellPhone);//付款方电话
  12663. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  12664. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  12665. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  12666. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  12667. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  12668. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  12669. marks.Add("PayItemContent", itemStr);//详细信息
  12670. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  12671. #endregion
  12672. ////注
  12673. //if (doc.Range.Bookmarks["Attention"] != null)
  12674. //{
  12675. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  12676. // mark.Text = frList[0].Attention;
  12677. //}
  12678. foreach (var item in marks.Keys)
  12679. {
  12680. if (doc.Range.Bookmarks[item] != null)
  12681. {
  12682. Bookmark mark = doc.Range.Bookmarks[item];
  12683. mark.Text = marks[item];
  12684. }
  12685. }
  12686. byte[] bytes = null;
  12687. using (MemoryStream stream = new MemoryStream())
  12688. {
  12689. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  12690. bytes = stream.ToArray();
  12691. }
  12692. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  12693. return Ok(JsonView(true, "", new
  12694. {
  12695. Data = bytes,
  12696. strFileName,
  12697. }));
  12698. }
  12699. else
  12700. {
  12701. return Ok(JsonView(false, "团组信息不存在!"));
  12702. }
  12703. }
  12704. /// <summary>
  12705. /// 导出团组成本
  12706. /// </summary>
  12707. /// <param name="dto"></param>
  12708. /// <returns></returns>
  12709. [HttpPost]
  12710. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  12711. {
  12712. var jw = JsonView(false);
  12713. if (dto.Diid == 0)
  12714. {
  12715. return Ok(JsonView(false, "请传递团组id"));
  12716. }
  12717. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12718. if (deleInfo.Code != 0)
  12719. {
  12720. return Ok(JsonView(false, "团组信息查询失败!"));
  12721. }
  12722. var di = deleInfo.Data as DelegationInfoWebView;
  12723. if (di == null)
  12724. {
  12725. return Ok(JsonView(false, "团组信息查询失败!"));
  12726. }
  12727. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12728. WorkbookDesigner designer = new WorkbookDesigner();
  12729. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12730. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12731. for (int i = 0; i < List_GC.Count; i++)
  12732. {
  12733. GroupCost_Excel gc = new GroupCost_Excel();
  12734. gc.Id = List_GC[i].Id;
  12735. gc.Diid = List_GC[i].Diid.ToString();
  12736. gc.DAY = List_GC[i].DAY;
  12737. string week = "";
  12738. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12739. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12740. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12741. gc.ITIN = List_GC[i].ITIN;
  12742. gc.CarType = List_GC[i].CarType;
  12743. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12744. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12745. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12746. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12747. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12748. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12749. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12750. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12751. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12752. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12753. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12754. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12755. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12756. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12757. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12758. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12759. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12760. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12761. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12762. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12763. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12764. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12765. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12766. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12767. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12768. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12769. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12770. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12771. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12772. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12773. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12774. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12775. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12776. List_GC1.Add(gc);
  12777. }
  12778. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12779. dt.TableName = "TB";
  12780. //报表标题等不用dt的值
  12781. designer.SetDataSource("TeamName", dto.title.TeamName);
  12782. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12783. designer.SetDataSource("Tax", dto.title.Tax);
  12784. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12785. designer.SetDataSource("Currency", dto.title.Currency);
  12786. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12787. designer.SetDataSource("Rate", dto.title.Rate);
  12788. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12789. var Aparams = hotels.Find(x => x.Type == "Default");
  12790. if (Aparams == null)
  12791. {
  12792. return Ok(jw);
  12793. }
  12794. //酒店数量
  12795. var txtSGRNumber = Aparams.SGR.ToString();
  12796. var txtTBRNumber = Aparams.TBR.ToString();
  12797. var txtJSESNumber = Aparams.JSES.ToString();
  12798. var txtSUITENumbe = Aparams.SUITE.ToString();
  12799. if (dto.costType == "B")
  12800. {
  12801. Aparams = hotels.Find(x => x.Type == "A");
  12802. var Bparams = hotels.Find(x => x.Type == "B");
  12803. if (Aparams == null || Bparams == null)
  12804. {
  12805. return Ok(jw);
  12806. }
  12807. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12808. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12809. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12810. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12811. }
  12812. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12813. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12814. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12815. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12816. var ws = designer.Workbook.Worksheets[0];
  12817. int Row = List_GC.Count;
  12818. int startIndex = 11;
  12819. int HideRows = 0;
  12820. List<int> hideRowsList = new List<int>();
  12821. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12822. #region A段left数据
  12823. var left = dto.leftInfo.Find(x => x.Type == "A");
  12824. if (left == null)
  12825. {
  12826. return Ok(jw);
  12827. }
  12828. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12829. if (leftBindData != null)
  12830. {
  12831. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12832. designer.SetDataSource("VisaRS", leftBindData.rs);
  12833. designer.SetDataSource("VisaXS", leftBindData.xs);
  12834. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12835. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12836. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12837. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12838. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12839. }
  12840. else
  12841. {
  12842. hideRowsList.Add(Row + startIndex + HideRows);
  12843. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12844. }
  12845. HideRows += 2;
  12846. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12847. if (leftBindData != null)
  12848. {
  12849. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12850. designer.SetDataSource("BXRS", leftBindData.rs);
  12851. designer.SetDataSource("BXXS", leftBindData.xs);
  12852. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12853. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12854. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12855. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12856. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12857. }
  12858. else
  12859. {
  12860. hideRowsList.Add(Row + startIndex + HideRows);
  12861. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12862. }
  12863. HideRows += 2;
  12864. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12865. if (leftBindData != null)
  12866. {
  12867. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12868. designer.SetDataSource("HSRS", leftBindData.rs);
  12869. designer.SetDataSource("HSXS", leftBindData.xs);
  12870. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12871. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12872. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12873. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12874. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12875. }
  12876. else
  12877. {
  12878. hideRowsList.Add(Row + startIndex + HideRows);
  12879. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12880. }
  12881. HideRows += 2;
  12882. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12883. if (leftBindData != null)
  12884. {
  12885. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12886. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12887. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12888. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12889. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12890. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12891. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12892. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12893. }
  12894. else
  12895. {
  12896. hideRowsList.Add(Row + startIndex + HideRows);
  12897. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12898. }
  12899. HideRows += 2;
  12900. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12901. if (leftBindData != null)
  12902. {
  12903. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12904. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12905. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12906. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12907. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12908. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12909. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12910. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12911. }
  12912. else
  12913. {
  12914. hideRowsList.Add(Row + startIndex + HideRows);
  12915. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12916. }
  12917. HideRows += 2;
  12918. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12919. if (leftBindData != null)
  12920. {
  12921. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12922. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12923. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12924. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12925. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12926. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12927. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12928. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12929. }
  12930. else
  12931. {
  12932. hideRowsList.Add(Row + startIndex + HideRows);
  12933. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12934. }
  12935. HideRows += 2;
  12936. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12937. if (leftBindData != null)
  12938. {
  12939. ////TBR
  12940. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12941. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12942. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12943. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12944. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12945. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12946. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12947. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12948. }
  12949. else
  12950. {
  12951. hideRowsList.Add(Row + startIndex + HideRows);
  12952. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12953. }
  12954. HideRows += 2;
  12955. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12956. if (leftBindData != null)
  12957. {
  12958. ////SGR
  12959. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12960. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12961. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12962. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12963. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12964. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12965. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12966. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12967. }
  12968. else
  12969. {
  12970. hideRowsList.Add(Row + startIndex + HideRows);
  12971. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12972. }
  12973. HideRows += 2;
  12974. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12975. if (leftBindData != null)
  12976. {
  12977. ////JS/ES
  12978. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12979. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12980. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12981. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12982. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12983. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12984. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12985. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12986. }
  12987. else
  12988. {
  12989. hideRowsList.Add(Row + startIndex + HideRows);
  12990. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12991. }
  12992. HideRows += 2;
  12993. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12994. if (leftBindData != null)
  12995. {
  12996. ////SUITE
  12997. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12998. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12999. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  13000. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13001. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13002. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13003. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13004. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13005. }
  13006. else
  13007. {
  13008. hideRowsList.Add(Row + startIndex + HideRows);
  13009. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13010. }
  13011. HideRows += 2;
  13012. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  13013. if (leftBindData != null)
  13014. {
  13015. designer.SetDataSource("DJDRCB", leftBindData.cb);
  13016. designer.SetDataSource("DJRS", leftBindData.rs);
  13017. designer.SetDataSource("DJXS", leftBindData.xs);
  13018. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13019. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13020. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13021. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13022. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13023. }
  13024. else
  13025. {
  13026. hideRowsList.Add(Row + startIndex + HideRows);
  13027. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13028. }
  13029. HideRows += 2;
  13030. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13031. if (leftBindData != null)
  13032. {
  13033. designer.SetDataSource("HCPCB", leftBindData.cb);
  13034. designer.SetDataSource("HCPRS", leftBindData.rs);
  13035. designer.SetDataSource("HCPXS", leftBindData.xs);
  13036. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13037. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13038. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13039. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13040. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13041. }
  13042. else
  13043. {
  13044. hideRowsList.Add(Row + startIndex + HideRows);
  13045. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13046. }
  13047. HideRows += 2;
  13048. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13049. if (leftBindData != null)
  13050. {
  13051. designer.SetDataSource("CPCB", leftBindData.cb);
  13052. designer.SetDataSource("CPRS", leftBindData.rs);
  13053. designer.SetDataSource("CPXS", leftBindData.xs);
  13054. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13055. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13056. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13057. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13058. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13059. }
  13060. else
  13061. {
  13062. hideRowsList.Add(Row + startIndex + HideRows);
  13063. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13064. }
  13065. HideRows += 2;
  13066. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13067. if (leftBindData != null)
  13068. {
  13069. designer.SetDataSource("GWDRCD", leftBindData.cb);
  13070. designer.SetDataSource("GWRS", leftBindData.rs);
  13071. designer.SetDataSource("GWXS", leftBindData.xs);
  13072. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13073. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13074. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13075. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13076. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13077. }
  13078. else
  13079. {
  13080. hideRowsList.Add(Row + startIndex + HideRows);
  13081. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13082. }
  13083. HideRows += 2;
  13084. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13085. if (leftBindData != null)
  13086. {
  13087. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  13088. designer.SetDataSource("LYJRS", leftBindData.rs);
  13089. designer.SetDataSource("LYJXS", leftBindData.xs);
  13090. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13091. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13092. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13093. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13094. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13095. }
  13096. else
  13097. {
  13098. hideRowsList.Add(Row + startIndex + HideRows);
  13099. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13100. }
  13101. #endregion
  13102. #region A段Right信息
  13103. var right = dto.rightInfo.Find(x => x.Type == "A");
  13104. if (right == null)
  13105. {
  13106. return Ok(jw);
  13107. }
  13108. HideRows += 4;
  13109. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13110. if (rightBindData != null)
  13111. {
  13112. //经济舱 + 双人间 TBR
  13113. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  13114. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  13115. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13116. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  13117. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13118. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13119. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13120. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13121. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13122. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13123. }
  13124. else
  13125. {
  13126. hideRowsList.Add(Row + startIndex + HideRows);
  13127. }
  13128. HideRows += 2;
  13129. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13130. if (rightBindData != null)
  13131. {
  13132. //经济舱 + 单人间 SGR
  13133. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  13134. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  13135. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13136. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  13137. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13138. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13139. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13140. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13141. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13142. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13143. }
  13144. else
  13145. {
  13146. hideRowsList.Add(Row + startIndex + HideRows);
  13147. }
  13148. HideRows += 2;
  13149. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13150. if (rightBindData != null)
  13151. {
  13152. //公务舱 + 单人间 SGR
  13153. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  13154. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  13155. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13156. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  13157. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13158. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13159. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13160. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13161. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13162. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13163. }
  13164. else
  13165. {
  13166. hideRowsList.Add(Row + startIndex + HideRows);
  13167. }
  13168. HideRows += 2;
  13169. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13170. if (rightBindData != null)
  13171. {
  13172. //公务舱 + 小套房 JSES
  13173. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  13174. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  13175. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13176. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  13177. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13178. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13179. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13180. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13181. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13182. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13183. }
  13184. else
  13185. {
  13186. hideRowsList.Add(Row + startIndex + HideRows);
  13187. }
  13188. HideRows += 2;
  13189. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13190. if (rightBindData != null)
  13191. {
  13192. //公务舱 + 小套房 JSES
  13193. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  13194. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  13195. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13196. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  13197. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13198. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13199. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13200. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13201. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13202. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13203. }
  13204. else
  13205. {
  13206. hideRowsList.Add(Row + startIndex + HideRows);
  13207. }
  13208. HideRows += 2;
  13209. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13210. if (rightBindData != null)
  13211. {
  13212. //经济舱 + 大套房
  13213. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  13214. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  13215. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13216. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  13217. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13218. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13219. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13220. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13221. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13222. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13223. }
  13224. else
  13225. {
  13226. hideRowsList.Add(Row + startIndex + HideRows);
  13227. }
  13228. HideRows += 2;
  13229. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13230. if (rightBindData != null)
  13231. {
  13232. //头等舱 + 小套房 JSES
  13233. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  13234. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  13235. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13236. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  13237. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13238. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13239. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13240. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13241. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13242. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13243. }
  13244. else
  13245. {
  13246. hideRowsList.Add(Row + startIndex + HideRows);
  13247. }
  13248. HideRows += 2;
  13249. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13250. if (rightBindData != null)
  13251. {
  13252. //头等舱 + 大套房
  13253. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  13254. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  13255. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13256. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  13257. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13258. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13259. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13260. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13261. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13262. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13263. }
  13264. else
  13265. {
  13266. hideRowsList.Add(Row + startIndex + HideRows);
  13267. }
  13268. #endregion
  13269. #region B段标题清空
  13270. designer.SetDataSource("CostBDRCB", "");
  13271. designer.SetDataSource("CostBRS", "");
  13272. designer.SetDataSource("CostBXS", "");
  13273. designer.SetDataSource("CostBZCB", "");
  13274. designer.SetDataSource("CostBDRBJ", "");
  13275. designer.SetDataSource("CostBZBJ", "");
  13276. designer.SetDataSource("CostBDRLR", "");
  13277. designer.SetDataSource("CostBZLR", "");
  13278. designer.SetDataSource("CostBDRCBOM", "");
  13279. designer.SetDataSource("CostBRSOM", "");
  13280. designer.SetDataSource("CostBZCBOM", "");
  13281. designer.SetDataSource("CostBDRBJOM", "");
  13282. designer.SetDataSource("CostBZBJOM", "");
  13283. designer.SetDataSource("CostBDRLROM", "");
  13284. designer.SetDataSource("CostBZLROM", "");
  13285. #endregion
  13286. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  13287. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  13288. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  13289. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  13290. designer.SetDataSource("DJName", "地接(CNY)");
  13291. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  13292. designer.SetDataSource("CPName", "地接-船票(CNY)");
  13293. designer.SetDataSource("GWName", "公务(CNY)");
  13294. designer.SetDataSource("YQHName", "邀请函(CNY)");
  13295. designer.SetDataSource("LYJName", "零用金(CNY)");
  13296. designer.SetDataSource("HSName", "核酸检测(CNY)");
  13297. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  13298. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  13299. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  13300. designer.SetDataSource("BXName", "保险(CNY)");
  13301. designer.SetDataSource("VisaName", "签证(CNY)");
  13302. #region B段基本数据
  13303. if (dto.costType == "B")
  13304. {
  13305. left = dto.leftInfo.Find(x => x.Type == "B");
  13306. if (left == null)
  13307. {
  13308. return Ok(jw);
  13309. }
  13310. #region B段left数据
  13311. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  13312. if (leftBindData != null)
  13313. {
  13314. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  13315. designer.SetDataSource("BHSRS", leftBindData.rs);
  13316. designer.SetDataSource("BHSXS", leftBindData.xs);
  13317. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13318. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13319. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13320. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13321. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13322. }
  13323. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  13324. if (leftBindData != null)
  13325. {
  13326. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  13327. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  13328. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  13329. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13330. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13331. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13332. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13333. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13334. }
  13335. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  13336. if (leftBindData != null)
  13337. {
  13338. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  13339. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  13340. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  13341. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13342. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13343. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13344. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13345. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13346. }
  13347. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  13348. if (leftBindData != null)
  13349. {
  13350. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  13351. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  13352. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  13353. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13354. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13355. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13356. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13357. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13358. }
  13359. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13360. if (leftBindData != null)
  13361. {
  13362. designer.SetDataSource("BHCPCB", leftBindData.cb);
  13363. designer.SetDataSource("BHCPRS", leftBindData.rs);
  13364. designer.SetDataSource("BHCPXS", leftBindData.xs);
  13365. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13366. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13367. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13368. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13369. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13370. }
  13371. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13372. if (leftBindData != null)
  13373. {
  13374. designer.SetDataSource("BCPCB", leftBindData.cb);
  13375. designer.SetDataSource("BCPRS", leftBindData.rs);
  13376. designer.SetDataSource("BCPXS", leftBindData.xs);
  13377. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13378. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13379. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13380. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13381. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13382. }
  13383. //TBR
  13384. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  13385. if (leftBindData != null)
  13386. {
  13387. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  13388. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  13389. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  13390. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13391. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13392. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13393. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13394. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13395. }
  13396. //SGR
  13397. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  13398. if (leftBindData != null)
  13399. {
  13400. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  13401. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  13402. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  13403. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13404. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13405. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13406. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13407. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13408. }
  13409. //JS/ES
  13410. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  13411. if (leftBindData != null)
  13412. {
  13413. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  13414. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  13415. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  13416. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13417. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13418. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13419. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13420. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13421. }
  13422. //SUITE
  13423. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  13424. if (leftBindData != null)
  13425. {
  13426. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  13427. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  13428. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  13429. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13430. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13431. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13432. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13433. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13434. }
  13435. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  13436. if (leftBindData != null)
  13437. {
  13438. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  13439. designer.SetDataSource("BDJRS", leftBindData.rs);
  13440. designer.SetDataSource("BDJXS", leftBindData.xs);
  13441. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13442. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13443. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13444. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13445. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13446. }
  13447. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13448. if (leftBindData != null)
  13449. {
  13450. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  13451. designer.SetDataSource("BGWRS", leftBindData.rs);
  13452. designer.SetDataSource("BGWXS", leftBindData.xs);
  13453. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13454. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13455. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13456. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13457. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13458. }
  13459. #region 优化方案
  13460. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  13461. //excelBind.Add("零用金", new {
  13462. //cb="",
  13463. //rs="",
  13464. //xs ="",
  13465. //zcb = "",
  13466. //});
  13467. #endregion
  13468. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13469. if (leftBindData != null)
  13470. {
  13471. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  13472. designer.SetDataSource("BLYJRS", leftBindData.rs);
  13473. designer.SetDataSource("BLYJXS", leftBindData.xs);
  13474. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13475. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13476. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13477. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13478. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13479. }
  13480. #endregion
  13481. #region B段Right信息
  13482. right = dto.rightInfo.Find(x => x.Type == "B");
  13483. if (right == null)
  13484. {
  13485. return Ok(jw);
  13486. }
  13487. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13488. if (rightBindData != null)
  13489. {
  13490. //经济舱 + 双人间 TBR
  13491. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  13492. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  13493. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13494. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  13495. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13496. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13497. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13498. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13499. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13500. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13501. }
  13502. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13503. if (rightBindData != null)
  13504. {
  13505. //经济舱 + 单人间 SGR
  13506. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  13507. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  13508. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13509. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  13510. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13511. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13512. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13513. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13514. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13515. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13516. }
  13517. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13518. if (rightBindData != null)
  13519. {
  13520. //公务舱 + 单人间 SGR
  13521. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  13522. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  13523. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13524. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  13525. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13526. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13527. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13528. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13529. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13530. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13531. }
  13532. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13533. if (rightBindData != null)
  13534. {
  13535. //公务舱 + 小套房 JSES
  13536. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  13537. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  13538. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13539. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  13540. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13541. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13542. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13543. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13544. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13545. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13546. }
  13547. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13548. if (rightBindData != null)
  13549. {
  13550. //公务舱 + 小套房 JSES
  13551. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  13552. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  13553. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13554. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  13555. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13556. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13557. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13558. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13559. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13560. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13561. }
  13562. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13563. if (rightBindData != null)
  13564. {
  13565. //经济舱 + 大套房
  13566. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  13567. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  13568. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13569. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  13570. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13571. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13572. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13573. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13574. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13575. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13576. }
  13577. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13578. if (rightBindData != null)
  13579. {
  13580. //头等舱 + 小套房 JSES
  13581. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  13582. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  13583. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13584. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  13585. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13586. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13587. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13588. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13589. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13590. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13591. }
  13592. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13593. if (rightBindData != null)
  13594. {
  13595. //头等舱 + 大套房
  13596. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  13597. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  13598. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13599. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  13600. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13601. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13602. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13603. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13604. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13605. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13606. }
  13607. #endregion
  13608. #region 标题
  13609. designer.SetDataSource("CostBDRCB", "单人成本");
  13610. designer.SetDataSource("CostBRS", "人数");
  13611. designer.SetDataSource("CostBXS", "系数");
  13612. designer.SetDataSource("CostBZCB", "总成本");
  13613. designer.SetDataSource("CostBDRBJ", "单人报价");
  13614. designer.SetDataSource("CostBZBJ", "总报价");
  13615. designer.SetDataSource("CostBDRLR", "单人利润");
  13616. designer.SetDataSource("CostBZLR", "总利润");
  13617. designer.SetDataSource("CostBDRCBOM", "单人成本");
  13618. designer.SetDataSource("CostBRSOM", "人数");
  13619. designer.SetDataSource("CostBZCBOM", "总成本");
  13620. designer.SetDataSource("CostBDRBJOM", "单人报价");
  13621. designer.SetDataSource("CostBZBJOM", "总报价");
  13622. designer.SetDataSource("CostBDRLROM", "单人利润");
  13623. designer.SetDataSource("CostBZLROM", "总利润");
  13624. #endregion
  13625. }
  13626. #endregion
  13627. designer.SetDataSource("TzZCB2", TzZCB2);
  13628. designer.SetDataSource("TzZBJ2", TzZBJ2);
  13629. designer.SetDataSource("TzZLR2", TzZLR2);
  13630. string[] dataSourceKeys = new string[]
  13631. {
  13632. "VF",
  13633. "TGS",
  13634. "TGOF",
  13635. "TGM",
  13636. "TGA",
  13637. "TGTF",
  13638. "TGEF",
  13639. "CFM",
  13640. "CFOF",
  13641. "B",
  13642. "L",
  13643. "D",
  13644. "TBR",
  13645. "SGR",
  13646. "JSES",
  13647. "Suite",
  13648. "TV",
  13649. "1L",
  13650. "IF",
  13651. "EF",
  13652. "BRF",
  13653. "TE",
  13654. "TGT",
  13655. "DRVT",
  13656. "PC",
  13657. "TLF",
  13658. "ECT"
  13659. };
  13660. foreach (var item in dataSourceKeys)
  13661. {
  13662. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  13663. if (find != null)
  13664. {
  13665. designer.SetDataSource(item, find.text);
  13666. }
  13667. else
  13668. {
  13669. designer.SetDataSource(item, 0);
  13670. }
  13671. }
  13672. designer.SetDataSource(dt);
  13673. //根据数据源处理生成报表内容
  13674. designer.Process();
  13675. designer.Workbook.Worksheets[0].Name = "清单";
  13676. Worksheet sheet = designer.Workbook.Worksheets[0];
  13677. foreach (var Rowindex in hideRowsList)
  13678. {
  13679. ws.Cells.HideRows(Rowindex, 2);
  13680. }
  13681. byte[] bytes = null;
  13682. string strFileName = di.TeamName + "-团组-成本.xls";
  13683. using (MemoryStream stream = new MemoryStream())
  13684. {
  13685. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  13686. bytes = stream.ToArray();
  13687. }
  13688. return Ok(JsonView(true, "", new
  13689. {
  13690. Data = bytes,
  13691. strFileName,
  13692. }));
  13693. }
  13694. /// <summary>
  13695. /// 导出客户报表
  13696. /// </summary>
  13697. /// <returns></returns>
  13698. [HttpPost]
  13699. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  13700. {
  13701. var jw = JsonView(false);
  13702. if (dto.Diid == 0)
  13703. {
  13704. return Ok(JsonView(false, "请传递团组id"));
  13705. }
  13706. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13707. if (deleInfo.Code != 0)
  13708. {
  13709. return Ok(JsonView(false, "团组信息查询失败!"));
  13710. }
  13711. var di = deleInfo.Data as DelegationInfoWebView;
  13712. if (di == null)
  13713. {
  13714. return Ok(JsonView(false, "团组信息查询失败!"));
  13715. }
  13716. //文件名
  13717. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  13718. //获取模板
  13719. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13720. //载入模板
  13721. Document doc = new Document(tmppath);
  13722. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13723. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13724. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13725. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13726. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13727. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13728. if (AParameter == null)
  13729. {
  13730. return Ok(JsonView(false, "系数不存在!"));
  13731. }
  13732. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13733. , TzAirDesc, TzZCost;
  13734. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13735. = TzAirDesc = TzZCost = string.Empty;
  13736. TzNumber = AParameter.CostTypenumber.ToString();
  13737. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13738. CarGuides1 = dto.CarGuides1;
  13739. Meal = dto.Meal;
  13740. SubsidizedMeals = dto.SubsidizedMeals;
  13741. NightRepair = dto.NightRepair;
  13742. AttractionsTickets = dto.AttractionsTickets;
  13743. MiscellaneousFees = dto.MiscellaneousFees;
  13744. ATip = dto.ATip;
  13745. TzHotelDesc = "";
  13746. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13747. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13748. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13749. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13750. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13751. TzAirDesc = "";
  13752. TzZCost = dto.TzZCost;
  13753. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13754. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13755. var index = 1;
  13756. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13757. foreach (var item in TzHotelDescArr)
  13758. {
  13759. if (AinfoArr != null)
  13760. {
  13761. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13762. if (Ainfo != null)
  13763. {
  13764. if (int.Parse(Ainfo.rs) <= 0)
  13765. {
  13766. continue;
  13767. }
  13768. var hotelText = string.Empty;
  13769. switch (item)
  13770. {
  13771. case "SGR":
  13772. hotelText = "单人间";
  13773. break;
  13774. case "JSES":
  13775. hotelText = "小套房";
  13776. break;
  13777. case "SUITE":
  13778. hotelText = "套房";
  13779. break;
  13780. case "TBR":
  13781. hotelText = "双人间";
  13782. break;
  13783. }
  13784. if (item != "TBR")
  13785. {
  13786. 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";
  13787. }
  13788. else
  13789. {
  13790. 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";
  13791. }
  13792. index++;
  13793. }
  13794. }
  13795. }
  13796. index = 1;
  13797. foreach (var item in TzAirDescArr)
  13798. {
  13799. if (AinfoArr != null)
  13800. {
  13801. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13802. if (Ainfo != null)
  13803. {
  13804. if (int.Parse(Ainfo.rs) <= 0)
  13805. {
  13806. continue;
  13807. }
  13808. 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";
  13809. index++;
  13810. }
  13811. }
  13812. }
  13813. if (dto.costType == "B")
  13814. {
  13815. if (BParameter == null)
  13816. {
  13817. return Ok(JsonView(false, "B段系数不存在!"));
  13818. }
  13819. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13820. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13821. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13822. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13823. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13824. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13825. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13826. foreach (var item in TzHotelDescArr)
  13827. {
  13828. if (AinfoArr != null)
  13829. {
  13830. TzHotelDesc += "B段信息 \r\n";
  13831. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13832. if (Ainfo != null)
  13833. {
  13834. if (int.Parse(Ainfo.rs) <= 0)
  13835. {
  13836. continue;
  13837. }
  13838. var hotelText = string.Empty;
  13839. switch (item)
  13840. {
  13841. case "SGR":
  13842. hotelText = "单人间";
  13843. break;
  13844. case "JSES":
  13845. hotelText = "小套房";
  13846. break;
  13847. case "SUITE":
  13848. hotelText = "套房";
  13849. break;
  13850. case "TBR":
  13851. hotelText = "双人间";
  13852. break;
  13853. }
  13854. if (item != "TBR")
  13855. {
  13856. 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";
  13857. }
  13858. else
  13859. {
  13860. 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";
  13861. }
  13862. index++;
  13863. }
  13864. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13865. }
  13866. }
  13867. index = 1;
  13868. foreach (var item in TzAirDescArr)
  13869. {
  13870. if (AinfoArr != null)
  13871. {
  13872. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13873. if (Ainfo != null)
  13874. {
  13875. if (int.Parse(Ainfo.rs) <= 0)
  13876. {
  13877. continue;
  13878. }
  13879. 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";
  13880. index++;
  13881. }
  13882. }
  13883. }
  13884. }
  13885. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13886. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13887. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13888. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13889. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13890. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13891. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13892. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13893. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13894. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13895. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13896. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13897. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13898. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13899. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13900. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13901. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13902. DickeyValue.Add("TzZCost", TzZCost);
  13903. foreach (var key in DickeyValue.Keys)
  13904. {
  13905. if (doc.Range.Bookmarks[key] != null)
  13906. {
  13907. Bookmark mark = doc.Range.Bookmarks[key];
  13908. mark.Text = DickeyValue[key];
  13909. }
  13910. }
  13911. byte[] bytes = null;
  13912. string strFileName = di.TeamName + "-客户报价.doc";
  13913. using (MemoryStream stream = new MemoryStream())
  13914. {
  13915. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13916. bytes = stream.ToArray();
  13917. }
  13918. return Ok(JsonView(true, "", new
  13919. {
  13920. Data = bytes,
  13921. strFileName,
  13922. }));
  13923. }
  13924. /// <summary>
  13925. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13926. /// </summary>
  13927. /// <param name="dto"></param>
  13928. /// <returns></returns>
  13929. [HttpPost]
  13930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13931. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13932. {
  13933. try
  13934. {
  13935. #region 参数验证
  13936. if (dto.DiId < 0)
  13937. {
  13938. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13939. }
  13940. List<int> cTableIds = new List<int>() {
  13941. 76 ,//酒店预订
  13942. 77 ,//行程
  13943. 79 ,//车/导游地接
  13944. 80 ,//签证
  13945. 81 ,//邀请/公务活
  13946. 82 ,//团组客户保险
  13947. 85 ,//机票预订
  13948. 98 ,//其他款项
  13949. 285 ,//收款退还
  13950. 751 ,//酒店早餐
  13951. 1015 // 超支费用
  13952. };
  13953. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13954. {
  13955. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13956. }
  13957. #endregion
  13958. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13959. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13960. if (_GroupCostParameters.Count <= 0)
  13961. {
  13962. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13963. }
  13964. if (_GroupCostParameters[0].IsShare == 0)
  13965. {
  13966. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13967. }
  13968. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13969. //处理date为空问题
  13970. if (_GroupCosts.Count > 0)
  13971. {
  13972. for (int i = 0; i < _GroupCosts.Count; i++)
  13973. {
  13974. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13975. {
  13976. if (i > 0)
  13977. {
  13978. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13979. }
  13980. }
  13981. }
  13982. }
  13983. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13984. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13985. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13986. string currCode = "";
  13987. #region currCode 验证
  13988. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13989. if (isInt)
  13990. {
  13991. var currData = currDatas.Find(it => it.Id == intCurrency);
  13992. if (currData != null)
  13993. {
  13994. currCode = currData.Name;
  13995. }
  13996. }
  13997. else
  13998. {
  13999. currCode = _GroupCostParameters[0].Currency.Trim();
  14000. }
  14001. #endregion
  14002. //op,酒店单段模式存储
  14003. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  14004. {
  14005. CurrencyCode = currCode,
  14006. Rate = _GroupCostParameters[0].Rate,
  14007. CostType = _GroupCostParameters[0].CostType,
  14008. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  14009. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  14010. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  14011. };
  14012. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  14013. if (_GroupCostParameters.Count == 2)
  14014. {
  14015. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  14016. }
  14017. foreach (var item in _GroupCostParameters)
  14018. {
  14019. decimal _rate = 1;
  14020. decimal _rate1 = item.Rate;
  14021. decimal _scale = 1;
  14022. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  14023. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  14024. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  14025. //if (userInfo != null)
  14026. //{
  14027. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  14028. // {
  14029. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  14030. // {
  14031. // _scale = 1.00M;
  14032. // }
  14033. // }
  14034. //}
  14035. #endregion
  14036. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  14037. {
  14038. CurrencyCode = currCode,
  14039. Rate = _rate1,
  14040. CostType = item.CostType,
  14041. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  14042. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  14043. CostTypeNumber = item.CostTypenumber
  14044. };
  14045. if (_GroupCostParameters.Count > 1)
  14046. {
  14047. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  14048. }
  14049. else
  14050. {
  14051. modulePromptInfo.CostTypeNumber = item.LYJRS;
  14052. }
  14053. if (dto.CTable == 79)//
  14054. {
  14055. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  14056. modulePromptInfo.TotalCost = item.DJCB;
  14057. }
  14058. List<string> costTypes = new List<string>() { "A", "B" };
  14059. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  14060. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  14061. if (_GroupCostsDuplicates.Count() == 1)
  14062. {
  14063. _GroupCostsTypeData = _GroupCosts;
  14064. }
  14065. else
  14066. {
  14067. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  14068. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  14069. }
  14070. /*
  14071. * 76 酒店预订
  14072. * 77 行程
  14073. * 79 车/导游地接
  14074. * 80 签证
  14075. * 81 邀请/公务活动
  14076. * 82 团组客户保险
  14077. * 85 机票预订
  14078. * 98 其他款项
  14079. * 285 收款退还
  14080. * 751 酒店早餐
  14081. * 1015 超支费用
  14082. */
  14083. switch (dto.CTable)
  14084. {
  14085. case 76: // 酒店预订
  14086. _ModuleSubPromptInfo.AddRange(
  14087. _GroupCostsTypeData.Select(it => new
  14088. {
  14089. it.DAY,
  14090. it.Date,
  14091. it.ACCON,
  14092. it.ITIN,
  14093. it.SGR,
  14094. it.TBR,
  14095. it.JS_ES,
  14096. it.Suite
  14097. })
  14098. );
  14099. break;
  14100. case 79: // 车/导游地接
  14101. _ModuleSubPromptInfo.AddRange(
  14102. _GroupCostsTypeData.Select(it => new
  14103. {
  14104. Date = it.Date, //日期
  14105. CarFee = it.CarCost * _rate * _scale, //车费用
  14106. CarType = it.CarType, //车型
  14107. DriverFee = it.CFS * _rate * _scale, //司机工资
  14108. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  14109. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  14110. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  14111. GuideFee = it.TGS * _rate * _scale, //导游费用
  14112. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  14113. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  14114. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  14115. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  14116. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  14117. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  14118. Breakfast = it.B * _rate * _scale, //早餐费
  14119. Lunch = it.L * _rate * _scale, //午餐费
  14120. Dinner = it.D * _rate * _scale, //晚餐费
  14121. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  14122. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  14123. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  14124. TicketFee = it.EF * _rate * _scale, //门票费
  14125. TicketRemark = it.EFR, //门票费描述
  14126. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  14127. TravelSupplies = it.TE * _rate * _scale, //出行物资
  14128. SpentCash = it.PC * _rate * _scale, //零用金
  14129. LeadersFee = it.TLF * _rate * _scale, //领队费
  14130. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  14131. })
  14132. );
  14133. break;
  14134. case 85: // 机票
  14135. List<dynamic> datas = new List<dynamic>();
  14136. datas.Add(
  14137. new
  14138. {
  14139. AirType = "经济舱",
  14140. AirNum = item.JJCRS,
  14141. AirDRCB = item.JJCCB,
  14142. AirZCB = (item.JJCRS * item.JJCCB)
  14143. }
  14144. );
  14145. datas.Add(
  14146. new
  14147. {
  14148. AirType = "公务舱",
  14149. AirNum = item.GWCRS,
  14150. AirDRCB = item.GWCCB,
  14151. AirZCB = (item.GWCRS * item.GWCCB)
  14152. }
  14153. );
  14154. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  14155. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  14156. modulePromptInfo.Data = new
  14157. {
  14158. airFeeData = datas,
  14159. airInitData = initDatas
  14160. };
  14161. _ModulePromptInfos.Add(modulePromptInfo);
  14162. break;
  14163. default:
  14164. break;
  14165. }
  14166. }
  14167. if (dto.CTable != 85)
  14168. {
  14169. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  14170. _ModulePromptInfos.Add(_ModulePromptInfo);
  14171. }
  14172. _view.ModulePromptInfos = _ModulePromptInfos;
  14173. return Ok(JsonView(true, "操作成功!", _view));
  14174. }
  14175. catch (Exception ex)
  14176. {
  14177. return Ok(JsonView(false, ex.Message));
  14178. }
  14179. }
  14180. /// <summary>
  14181. /// 根据黑屏代码重新生成行程
  14182. /// </summary>
  14183. /// <param name="dto"></param>
  14184. /// <returns></returns>
  14185. [HttpPost]
  14186. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  14187. {
  14188. var jw = JsonView(false);
  14189. var Create = _GroupCostRepository.
  14190. CreateGroupCostByBlackCode(dto.Diid);
  14191. jw.Msg = Create.Msg;
  14192. if (Create.Code == 0)
  14193. {
  14194. jw.Code = 200;
  14195. jw.Data = new
  14196. {
  14197. groupCost = Create.Data,
  14198. blackCodeIsTrue = true
  14199. };
  14200. }
  14201. else
  14202. {
  14203. jw.Code = 400;
  14204. jw.Data = new
  14205. {
  14206. groupCost = Create.Data,
  14207. blackCodeIsTrue = false,
  14208. };
  14209. }
  14210. return Ok(jw);
  14211. }
  14212. /// <summary>
  14213. /// 成本获取OP历史车费用
  14214. /// </summary>
  14215. /// <param name="dto"></param>
  14216. /// <returns></returns>
  14217. [HttpPost]
  14218. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  14219. {
  14220. var jw = JsonView(false);
  14221. try
  14222. {
  14223. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  14224. //获取现有所有车的数据
  14225. if (!dto.Param.IsNullOrWhiteSpace())
  14226. {
  14227. string sql = $@"
  14228. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  14229. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  14230. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  14231. 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
  14232. AND gctggr.ServiceEndTime is not NULL
  14233. ORDER by gctggrc.id DESC
  14234. ";
  14235. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  14236. var numeberResult = await Task.Run(() =>
  14237. {
  14238. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  14239. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  14240. return numberArr;
  14241. });
  14242. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  14243. foreach (var item in numeberResult)
  14244. {
  14245. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  14246. {
  14247. Country = "数据异常!",
  14248. City = string.Empty,
  14249. };
  14250. item.Area = find.Country + " " + find.City;
  14251. }
  14252. dbResult.AddRange(numeberResult);
  14253. if (dto.Param.Contains("、"))
  14254. {
  14255. var sp = dto.Param.Split("、");
  14256. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14257. .Where(x =>
  14258. {
  14259. return System.Array.Exists(sp, e =>
  14260. {
  14261. bool where = false;
  14262. if (x.Area != null)
  14263. {
  14264. where = x.Area.Contains(e);
  14265. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14266. {
  14267. return false;
  14268. }
  14269. }
  14270. if (x.PriceName != null && !where)
  14271. {
  14272. where = x.PriceName.Contains(e);
  14273. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14274. {
  14275. return false;
  14276. }
  14277. }
  14278. return where;
  14279. });
  14280. }).ToList();
  14281. }
  14282. else
  14283. {
  14284. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14285. .Where(x =>
  14286. {
  14287. bool where = false;
  14288. if (x.Area != null)
  14289. {
  14290. where = x.Area.Contains(dto.Param);
  14291. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14292. {
  14293. return false;
  14294. }
  14295. }
  14296. if (x.PriceName != null && !where)
  14297. {
  14298. where = x.PriceName.Contains(dto.Param);
  14299. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14300. {
  14301. return false;
  14302. }
  14303. }
  14304. return where;
  14305. }
  14306. )
  14307. .ToList();
  14308. }
  14309. }
  14310. var view = dbResult.Select(x =>
  14311. {
  14312. decimal dp = 0.00M;
  14313. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  14314. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  14315. if (string.IsNullOrWhiteSpace(x.DatePrice))
  14316. {
  14317. if (startB && endB)
  14318. {
  14319. var timesp = endD.Subtract(startD);
  14320. if ((timesp.Days + 1) != 0)
  14321. {
  14322. dp = x.Price / (timesp.Days + 1);
  14323. }
  14324. }
  14325. }
  14326. else
  14327. {
  14328. dp = x.Price;
  14329. }
  14330. return new
  14331. {
  14332. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  14333. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  14334. x.Area,
  14335. x.id,
  14336. price = x.Price.ToString("F2"),
  14337. x.PriceName,
  14338. x.PriceContent,
  14339. x.TeamName,
  14340. x.DatePrice,
  14341. dayPrice = dp.ToString("F2"),
  14342. };
  14343. }).OrderByDescending(x => x.id).ToList();
  14344. jw = JsonView(true, "获取成功!", view);
  14345. }
  14346. catch (Exception e)
  14347. {
  14348. jw = JsonView(false, e.Message);
  14349. }
  14350. return Ok(jw);
  14351. }
  14352. #endregion
  14353. #region 酒店预订 新 雷怡 2023-12-28 17:45
  14354. /// <summary>
  14355. /// 酒店预订
  14356. /// 酒店费用列表 根据团组Id查询
  14357. /// </summary>
  14358. /// <param name="_dto"></param>
  14359. /// <returns></returns>
  14360. [HttpPost]
  14361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14362. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  14363. {
  14364. #region 参数验证
  14365. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14366. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14367. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14368. #region 团组操作权限验证 76 酒店预定模块
  14369. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14370. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14371. #endregion
  14372. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14373. #region 页面操作权限验证
  14374. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14375. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14376. #endregion
  14377. #endregion
  14378. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  14379. }
  14380. /// <summary>
  14381. /// 酒店预订
  14382. /// 基础数据
  14383. /// </summary>
  14384. /// <param name="_dto"></param>
  14385. /// <returns></returns>
  14386. [HttpPost]
  14387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14388. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  14389. {
  14390. #region 参数验证
  14391. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14392. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14393. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14394. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14395. #region 页面操作权限验证
  14396. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14397. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14398. #endregion
  14399. #region 团组操作权限验证 76 酒店预定模块
  14400. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14401. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14402. #endregion
  14403. #endregion
  14404. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  14405. }
  14406. /// <summary>
  14407. /// 酒店预订
  14408. /// 创建 入住卷号码
  14409. /// </summary>
  14410. /// <param name="_dto"></param>
  14411. /// <returns></returns>
  14412. [HttpPost]
  14413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14414. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  14415. {
  14416. #region 参数验证
  14417. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14418. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14419. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14420. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14421. #region 页面操作权限验证
  14422. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14423. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14424. #endregion
  14425. #region 团组操作权限验证 76 酒店预定模块
  14426. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14427. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14428. #endregion
  14429. #endregion
  14430. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  14431. if (data.Code != 0)
  14432. {
  14433. return Ok(JsonView(false, data.Msg));
  14434. }
  14435. return Ok(JsonView(true, data.Msg, data.Data));
  14436. }
  14437. /// <summary>
  14438. /// 酒店预订
  14439. /// 详情
  14440. /// </summary>
  14441. /// <param name="_dto"></param>
  14442. /// <returns></returns>
  14443. [HttpPost]
  14444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14445. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  14446. {
  14447. #region 参数验证
  14448. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  14449. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14450. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  14451. #region 团组操作权限验证 76 酒店预定模块
  14452. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14453. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14454. #endregion
  14455. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14456. #region 页面操作权限验证
  14457. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14458. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14459. #endregion
  14460. #endregion
  14461. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  14462. }
  14463. /// <summary>
  14464. /// 酒店预订
  14465. /// Add Or Edit
  14466. /// </summary>
  14467. /// <param name="_dto"></param>
  14468. /// <returns></returns>
  14469. [HttpPost]
  14470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14471. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  14472. {
  14473. #region 参数验证
  14474. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14475. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14476. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14477. #region 团组操作权限验证 76 酒店预定模块
  14478. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14479. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14480. #endregion
  14481. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14482. #region 页面操作权限验证
  14483. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14484. if (_dto.Id == 0) // Add
  14485. {
  14486. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14487. }
  14488. else if (_dto.Id > 1) // Edit
  14489. {
  14490. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  14491. }
  14492. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  14493. #endregion
  14494. #endregion
  14495. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  14496. if (_view.Code != 200)
  14497. {
  14498. return Ok(_view);
  14499. }
  14500. #region 成本无酒店价格数据进入超支
  14501. _sqlSugar.BeginTran();
  14502. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  14503. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  14504. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  14505. for (int i = 0; i < groupCost.Count; i++)
  14506. {
  14507. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  14508. {
  14509. groupCost[i].Date = groupCost[i - 1].Date;
  14510. }
  14511. }
  14512. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  14513. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  14514. List<Fin_GroupExtraCostDto_OP>();
  14515. if (start_Bool && end_Bool)
  14516. {
  14517. while (start_Time < end_Time)
  14518. {
  14519. foreach (var item in groupCost_Grp)
  14520. {
  14521. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  14522. {
  14523. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  14524. {
  14525. extraCostList.Add(new
  14526. Fin_GroupExtraCostDto_OP
  14527. {
  14528. Area = _dto.AreaId,
  14529. coefficient = 1.5M,
  14530. createUser = _dto.UserId,
  14531. currency = _dto.CardPriceCurrency,
  14532. diId = _dto.DiId,
  14533. ManagerConfirm = 0,
  14534. SupervisorConfirm = 0,
  14535. SYsupervisorConfirm = 0,
  14536. editType = 1,
  14537. PortType = 1,
  14538. price = _dto.CardPrice,
  14539. PriceCount = 1,
  14540. priceType = 1027,
  14541. priceDetailType = 1044,
  14542. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  14543. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  14544. });
  14545. }
  14546. }
  14547. }
  14548. start_Time = start_Time.AddDays(1);
  14549. }
  14550. }
  14551. if (extraCostList.Any())
  14552. {
  14553. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  14554. }
  14555. _sqlSugar.CommitTran();
  14556. #endregion
  14557. #region 应用推送
  14558. try
  14559. {
  14560. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14561. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14562. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14563. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14564. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14565. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14566. var diId = _dto.DiId;
  14567. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14568. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14569. #region 操作记录
  14570. var opInfo = new Crm_TableOperationRecord()
  14571. {
  14572. TableName = "Grp_HotelReservations",
  14573. PortType = _dto.PortType,
  14574. DataId = hotelId,
  14575. CreateUserId = _dto.UserId
  14576. };
  14577. //var opStatus = OperationEnum.NoOperation;
  14578. if (_dto.Id < 1) //添加操作
  14579. {
  14580. opInfo.OperationItem = OperationEnum.Add;
  14581. }
  14582. else if (_dto.Id > 0)
  14583. {
  14584. opInfo.OperationItem = OperationEnum.Edit;
  14585. }
  14586. string opRemark = string.Empty;
  14587. if (ccpInfo != null)
  14588. {
  14589. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  14590. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  14591. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  14592. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  14593. }
  14594. opInfo.Remark = opRemark;
  14595. await _tableorRep.AddAsync(opInfo);
  14596. #endregion
  14597. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  14598. //2024-10-21 新增LZ UID
  14599. var userIds = new List<int>() { 21 };
  14600. string title = $"费用审核";
  14601. string content = "";
  14602. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14603. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14604. try
  14605. {
  14606. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  14607. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  14608. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  14609. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  14610. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  14611. }
  14612. catch (Exception ex)
  14613. {
  14614. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  14615. }
  14616. }
  14617. catch (Exception ex)
  14618. {
  14619. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  14620. }
  14621. try
  14622. {
  14623. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14624. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14625. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14626. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14627. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14628. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14629. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14630. //自动审核
  14631. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  14632. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  14633. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  14634. //2024-10-21 新增LZ UID
  14635. var userIds = new List<int>() { 21 };
  14636. string title = $"系统通知";
  14637. var diId = _dto.DiId;
  14638. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14639. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14640. string content = "";
  14641. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14642. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14643. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14644. }
  14645. catch (Exception ex)
  14646. {
  14647. }
  14648. #endregion
  14649. return Ok(_view);
  14650. }
  14651. /// <summary>
  14652. /// 酒店自动审核测试
  14653. /// Add Or Edit
  14654. /// </summary>
  14655. /// <param name="diid"></param>
  14656. /// <param name="dataId"></param>
  14657. /// <returns></returns>
  14658. [HttpPost]
  14659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14660. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  14661. {
  14662. #region 应用推送
  14663. try
  14664. {
  14665. //自动审核
  14666. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  14667. }
  14668. catch (Exception ex)
  14669. {
  14670. return Ok(JsonView(false, "操作失败"));
  14671. }
  14672. #endregion
  14673. return Ok(JsonView(false, "操作成功"));
  14674. }
  14675. /// <summary>
  14676. /// 酒店预订
  14677. /// Del
  14678. /// </summary>
  14679. /// <param name="_dto"></param>
  14680. /// <returns></returns>
  14681. [HttpPost]
  14682. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14683. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  14684. {
  14685. #region 参数验证
  14686. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14687. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14688. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14689. #region 团组操作权限验证 76 酒店预定模块
  14690. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14691. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14692. #endregion
  14693. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14694. #region 页面操作权限验证
  14695. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14696. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14697. #endregion
  14698. #endregion
  14699. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  14700. #region 操作记录
  14701. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  14702. {
  14703. TableName = "Grp_HotelReservations",
  14704. PortType = _dto.PortType,
  14705. OperationItem = OperationEnum.Del,
  14706. DataId = _dto.Id,
  14707. CreateUserId = _dto.UserId
  14708. });
  14709. #endregion
  14710. return Ok(data);
  14711. }
  14712. /// <summary>
  14713. /// 酒店预订
  14714. /// 生成VOUCHER
  14715. /// 2024.05.06 之前版本
  14716. /// </summary>
  14717. /// <param name="_dto"></param>
  14718. /// <returns></returns>
  14719. [HttpPost]
  14720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14721. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  14722. {
  14723. try
  14724. {
  14725. #region 参数验证
  14726. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14727. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14728. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14729. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14730. #region 团组操作权限验证 76 酒店预定模块
  14731. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14732. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14733. #endregion
  14734. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14735. #region 页面操作权限验证
  14736. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14737. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14738. #endregion
  14739. #endregion
  14740. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14741. //判断数据是否完整
  14742. if (hr != null)
  14743. {
  14744. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14745. {
  14746. string strFileName = "HotelStatement/";
  14747. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14748. if (dele != null)
  14749. strFileName += dele.TourCode;
  14750. //载入模板
  14751. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14752. Document doc = new Document(sss);
  14753. DocumentBuilder builder = new DocumentBuilder(doc);
  14754. #region 替换Word模板书签内容
  14755. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14756. //入住卷预定号码
  14757. if (doc.Range.Bookmarks["VNO"] != null)
  14758. {
  14759. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14760. mark.Text = hr.CheckNumber;
  14761. }
  14762. //酒店时间
  14763. if (doc.Range.Bookmarks["Date"] != null)
  14764. {
  14765. Bookmark mark = doc.Range.Bookmarks["Date"];
  14766. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14767. }
  14768. //团号
  14769. if (doc.Range.Bookmarks["TNo"] != null)
  14770. {
  14771. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14772. mark.Text = dele.TourCode;
  14773. }
  14774. //预定号码
  14775. if (doc.Range.Bookmarks["BookingId"] != null)
  14776. {
  14777. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14778. mark.Text = hr.ReservationsNo;
  14779. }
  14780. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14781. {
  14782. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14783. mark.Text = hr.DetermineNo;
  14784. }
  14785. //酒店城市
  14786. if (doc.Range.Bookmarks["City"] != null)
  14787. {
  14788. Bookmark mark = doc.Range.Bookmarks["City"];
  14789. mark.Text = hr.City;
  14790. }
  14791. //酒店名称
  14792. if (doc.Range.Bookmarks["HName"] != null)
  14793. {
  14794. Bookmark mark = doc.Range.Bookmarks["HName"];
  14795. mark.Text = hr.HotelName;
  14796. }
  14797. //酒店地址
  14798. if (doc.Range.Bookmarks["Address"] != null)
  14799. {
  14800. Bookmark mark = doc.Range.Bookmarks["Address"];
  14801. mark.Text = hr.HotelAddress;
  14802. }
  14803. //酒店电话
  14804. if (doc.Range.Bookmarks["Tel"] != null)
  14805. {
  14806. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14807. mark.Text = hr.HotelTel;
  14808. }
  14809. //酒店传真
  14810. if (doc.Range.Bookmarks["Fax"] != null)
  14811. {
  14812. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14813. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14814. {
  14815. mark.Text = hr.HotelFax;
  14816. }
  14817. }
  14818. //入住时间
  14819. if (doc.Range.Bookmarks["CIn"] != null)
  14820. {
  14821. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14822. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14823. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14824. }
  14825. //退房时间
  14826. if (doc.Range.Bookmarks["COut"] != null)
  14827. {
  14828. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14829. Bookmark mark = doc.Range.Bookmarks["COut"];
  14830. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14831. }
  14832. //客户名称
  14833. if (doc.Range.Bookmarks["GName"] != null)
  14834. {
  14835. string guestName = "";
  14836. string[] clients = new string[] { };
  14837. if (hr.GuestName.Contains(","))
  14838. {
  14839. clients = hr.GuestName.Split(",");
  14840. }
  14841. else
  14842. {
  14843. clients = new string[] { hr.GuestName };
  14844. }
  14845. List<int> clientIds_int = new List<int>();
  14846. if (clients.Length > 0)
  14847. {
  14848. foreach (var item in clients)
  14849. {
  14850. if (item.IsNumeric())
  14851. {
  14852. clientIds_int.Add(int.Parse(item));
  14853. }
  14854. }
  14855. }
  14856. if (clientIds_int.Count > 0)
  14857. {
  14858. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14859. foreach (var client in _clientDatas)
  14860. {
  14861. //男
  14862. if (client.Sex == 0) guestName += $"Mr.";
  14863. //女
  14864. else if (client.Sex == 1) guestName += $"Ms.";
  14865. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14866. {
  14867. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14868. }
  14869. //guestName += $"{client.Pinyin},";
  14870. }
  14871. if (guestName.Length > 0)
  14872. {
  14873. guestName = guestName.Substring(0, guestName.Length - 1);
  14874. }
  14875. }
  14876. else
  14877. {
  14878. guestName = hr.GuestName;
  14879. }
  14880. Bookmark mark = doc.Range.Bookmarks["GName"];
  14881. mark.Text = guestName;
  14882. }
  14883. //房间介绍
  14884. if (doc.Range.Bookmarks["ROOM"] != null)
  14885. {
  14886. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14887. mark.Text = hr.RoomExplanation;
  14888. }
  14889. //报价描述
  14890. if (doc.Range.Bookmarks["NOTE"] != null)
  14891. {
  14892. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14893. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14894. if (ss != null)
  14895. mark.Text = ss.Name;
  14896. }
  14897. //入住时间
  14898. if (doc.Range.Bookmarks["CheckIn"] != null)
  14899. {
  14900. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14901. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14902. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14903. }
  14904. //退房时间
  14905. if (doc.Range.Bookmarks["CheckOut"] != null)
  14906. {
  14907. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14908. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14909. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14910. }
  14911. //日期
  14912. if (doc.Range.Bookmarks["DT"] != null)
  14913. {
  14914. Bookmark mark = doc.Range.Bookmarks["DT"];
  14915. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14916. }
  14917. //名称
  14918. if (doc.Range.Bookmarks["VName"] != null)
  14919. {
  14920. Bookmark mark = doc.Range.Bookmarks["VName"];
  14921. mark.Text = hr.HotelName;
  14922. }
  14923. //号码
  14924. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14925. {
  14926. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14927. mark.Text = hr.CheckNumber;
  14928. }
  14929. #endregion
  14930. strFileName += "VOUCHER.doc";
  14931. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14932. doc.Save(fileDir);
  14933. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14934. return Ok(JsonView(true, "操作成功!", Url));
  14935. }
  14936. else
  14937. {
  14938. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14939. }
  14940. }
  14941. else
  14942. {
  14943. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14944. }
  14945. }
  14946. catch (Exception ex)
  14947. {
  14948. return Ok(JsonView(false, ex.Message));
  14949. }
  14950. }
  14951. /// <summary>
  14952. /// 酒店预订
  14953. /// 生成VOUCHER
  14954. /// 2024.05.06 之后版本
  14955. /// </summary>
  14956. /// <param name="_dto"></param>
  14957. /// <returns></returns>
  14958. [HttpPost]
  14959. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14960. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14961. {
  14962. #region 参数验证
  14963. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14964. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14965. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14966. #region 团组操作权限验证 76 酒店预定模块
  14967. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14968. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14969. #endregion
  14970. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14971. #region 页面操作权限验证
  14972. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14973. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14974. #endregion
  14975. #endregion
  14976. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14977. //判断数据是否完整
  14978. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14979. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14980. string strFileName = "HotelStatement/";
  14981. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14982. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14983. #region 数据处理
  14984. List<int> guestIds = new List<int>();
  14985. //int index = 0;
  14986. foreach (var item in hrDtas)
  14987. {
  14988. if (item.GuestName.Contains(","))
  14989. {
  14990. string[] guestIdArr = item.GuestName.Split(',');
  14991. foreach (var guestIdStr in guestIdArr)
  14992. {
  14993. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14994. if (guestBool)
  14995. {
  14996. guestIds.Add(guestId);
  14997. }
  14998. }
  14999. }
  15000. else guestNames += item.GuestName;
  15001. var voucherInfo = new HotelVoucherInfoView()
  15002. {
  15003. HotelName = item.HotelName,
  15004. CheckInDate = item.CheckInDate,
  15005. CheckOutDate = item.CheckOutDate,
  15006. ConfirmationNumber = item.DetermineNo.Trim(),
  15007. RoomType = item.RoomExplanation
  15008. };
  15009. vouchers.Add(voucherInfo);
  15010. }
  15011. if (guestIds.Count > 0)
  15012. {
  15013. guestIds = guestIds.Distinct().ToList();
  15014. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  15015. if (guestDatas.Count > 0)
  15016. {
  15017. guestNames = "";
  15018. foreach (var guest in guestDatas)
  15019. {
  15020. string guestName = "";
  15021. if (guest.Sex == 0) guestName += @"MR.";
  15022. else if (guest.Sex == 1) guestName += @"MS.";
  15023. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  15024. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  15025. guestNames += @$"{guestName.Trim()}、";
  15026. }
  15027. if (guestNames.Length > 0)
  15028. {
  15029. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  15030. }
  15031. }
  15032. }
  15033. #endregion
  15034. //载入模板
  15035. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  15036. Document doc = new Document(sss);
  15037. DocumentBuilder builder = new DocumentBuilder(doc);
  15038. if (doc.Range.Bookmarks["GuestName"] != null)
  15039. {
  15040. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  15041. mark.Text = guestNames;
  15042. }
  15043. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15044. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  15045. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  15046. for (int i = 1; i <= vouchers.Count; i++)
  15047. {
  15048. HotelVoucherInfoView hviv = vouchers[i - 1];
  15049. builder.MoveToCell(0, i, 0, 0);
  15050. builder.Write(hviv.HotelName);
  15051. builder.MoveToCell(0, i, 1, 0);
  15052. builder.Write(hviv.CheckInDate);
  15053. builder.MoveToCell(0, i, 2, 0);
  15054. builder.Write(hviv.CheckOutDate);
  15055. builder.MoveToCell(0, i, 3, 0);
  15056. builder.Write(hviv.RoomType);
  15057. builder.MoveToCell(0, i, 4, 0);
  15058. builder.Write(hviv.ConfirmationNumber);
  15059. }
  15060. //删除多余行
  15061. int currRowIndex = vouchers.Count + 1;
  15062. int delRows = 21 - currRowIndex;
  15063. if (delRows > 0)
  15064. {
  15065. for (int i = 0; i < delRows; i++)
  15066. {
  15067. table.Rows.RemoveAt(currRowIndex);
  15068. //cultivateRowIndex++;
  15069. }
  15070. }
  15071. strFileName += "VOUCHER.docx";
  15072. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15073. doc.Save(fileDir);
  15074. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15075. return Ok(JsonView(true, "操作成功!", Url));
  15076. }
  15077. /// <summary>
  15078. /// 酒店预订
  15079. /// 生成VOUCHER 批量生成
  15080. /// New
  15081. /// </summary>
  15082. /// <param name="_dto"></param>
  15083. /// <returns></returns>
  15084. [HttpPost]
  15085. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15086. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  15087. {
  15088. #region 参数验证
  15089. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15090. if (_dto.PageId < 1) _dto.PageId = 28;
  15091. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15092. #region 团组操作权限验证 76 酒店预定模块
  15093. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15094. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15095. #endregion
  15096. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15097. #region 页面操作权限验证
  15098. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15099. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15100. #endregion
  15101. #endregion
  15102. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  15103. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  15104. .OrderBy(x => x.CheckInDate)
  15105. .ToListAsync();
  15106. //判断数据是否完整
  15107. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  15108. string strFileName = "HotelStatement/";
  15109. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  15110. if (dele != null)
  15111. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  15112. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  15113. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  15114. .Where(it => it.IsDel == 0)
  15115. .ToListAsync();
  15116. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  15117. for (int i = 0; i < hrDtas.Count; i++)
  15118. {
  15119. string guestNames = string.Empty;
  15120. List<int> guestIds = new List<int>();
  15121. var item = hrDtas[i];
  15122. //处理客户姓名
  15123. if (item.GuestName.Contains(","))
  15124. {
  15125. string[] guestIdArr = item.GuestName.Split(',');
  15126. foreach (var guestIdStr in guestIdArr)
  15127. if (int.TryParse(guestIdStr, out int guestId))
  15128. guestIds.Add(guestId);
  15129. }
  15130. else
  15131. {
  15132. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  15133. if (guestIdBool)
  15134. {
  15135. guestIds.Add(guestId);
  15136. }
  15137. //NaN
  15138. if (item.GuestName.Contains("NaN"))
  15139. {
  15140. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  15141. }
  15142. }
  15143. if (guestIds.Count > 0)
  15144. {
  15145. guestIds = guestIds.Distinct().ToList();
  15146. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  15147. if (guestDatas1.Count > 0)
  15148. {
  15149. guestNames = "";
  15150. foreach (var guest in guestDatas1)
  15151. {
  15152. string guestName = "";
  15153. if (guest.Sex == 0) guestName += @"MR.";
  15154. else if (guest.Sex == 1) guestName += @"MS.";
  15155. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  15156. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  15157. guestNames += @$"{guestName.Trim()}、";
  15158. }
  15159. if (guestNames.Length > 0)
  15160. {
  15161. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  15162. }
  15163. }
  15164. }
  15165. //if (!string.IsNullOrEmpty(guestNames))
  15166. //{
  15167. hrDtas[i].GuestName = guestNames;
  15168. //}
  15169. }
  15170. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  15171. Document doc = new Document();
  15172. DocumentBuilder builder = new DocumentBuilder(doc);
  15173. try
  15174. {
  15175. builder.MoveToDocumentStart();
  15176. foreach (var item in hrDtas)
  15177. {
  15178. //标题
  15179. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15180. builder.ParagraphFormat.LineSpacing = 1;
  15181. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15182. builder.ParagraphFormat.Style.Font.Size = 9;
  15183. builder.ParagraphFormat.Style.Font.Bold = true;
  15184. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15185. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  15186. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15187. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15188. builder.ParagraphFormat.LineSpacing = 1;
  15189. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15190. builder.ParagraphFormat.Style.Font.Size = 9;
  15191. builder.ParagraphFormat.Style.Font.Bold = true;
  15192. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  15193. builder.StartTable();
  15194. // 设置边框颜色
  15195. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  15196. //设置边框样式
  15197. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  15198. //表格
  15199. #region 第一行
  15200. builder.InsertCell();
  15201. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15202. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15203. //builder.CellFormat.AllowAutoFit = false;
  15204. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15205. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15206. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15207. builder.CellFormat.WrapText = true; //自动换行
  15208. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15209. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  15210. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15211. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15212. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15213. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15214. builder.Write("TOUR NO:");
  15215. builder.InsertCell();
  15216. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15217. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15218. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15219. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15220. builder.ParagraphFormat.Style.Font.Bold = false;
  15221. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15222. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15223. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15224. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15225. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15226. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15227. builder.Write($"{dele?.TourCode ?? "-"}");
  15228. builder.InsertCell();
  15229. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15230. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15231. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15232. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15233. builder.ParagraphFormat.Style.Font.Bold = false;
  15234. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15235. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15236. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15237. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15238. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15239. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15240. builder.Write($"CITY:");
  15241. builder.InsertCell();
  15242. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15243. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15244. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15245. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15246. builder.ParagraphFormat.Style.Font.Bold = false;
  15247. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15248. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15249. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15250. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15251. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15252. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15253. builder.Write($"{item.City}");
  15254. builder.EndRow();
  15255. #endregion
  15256. #region 第二行
  15257. builder.InsertCell();
  15258. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15259. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15260. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15261. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15262. builder.ParagraphFormat.Style.Font.Bold = false;
  15263. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15264. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15265. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15266. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15267. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15268. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15269. builder.Write("CONFIRMATION NO:");
  15270. builder.InsertCell();
  15271. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15272. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15273. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15274. builder.ParagraphFormat.Style.Font.Bold = false;
  15275. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15276. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15277. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15278. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15279. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15280. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15281. builder.CellFormat.VerticalMerge = CellMerge.None;
  15282. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15283. builder.Write($"{item.DetermineNo}");
  15284. builder.InsertCell();
  15285. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15286. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15287. builder.InsertCell();
  15288. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15289. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15290. builder.EndRow();
  15291. #endregion
  15292. #region 第三行
  15293. builder.InsertCell();
  15294. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15295. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15296. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15297. builder.ParagraphFormat.Style.Font.Bold = false;
  15298. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15299. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15300. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15301. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15302. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15303. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15304. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15305. builder.Write($"HOTEL NAME:");
  15306. builder.InsertCell();
  15307. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15308. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15309. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15310. builder.ParagraphFormat.Style.Font.Bold = false;
  15311. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15312. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15313. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15314. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15315. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15316. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15317. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15318. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15319. builder.Write($"{item.HotelName}");
  15320. builder.InsertCell();
  15321. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15322. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15323. builder.InsertCell();
  15324. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15325. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15326. builder.EndRow();
  15327. #endregion
  15328. #region 第四行
  15329. builder.InsertCell();
  15330. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15331. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15332. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15333. builder.ParagraphFormat.Style.Font.Bold = false;
  15334. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15335. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15336. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15337. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15338. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15339. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15340. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15341. builder.Write($"HOTEL ADDRESS:");
  15342. builder.InsertCell();
  15343. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15344. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15345. builder.ParagraphFormat.Style.Font.Size = 8;
  15346. builder.ParagraphFormat.Style.Font.Bold = false;
  15347. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15348. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15349. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15350. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15351. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15352. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15353. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15354. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15355. builder.Write($"{item.HotelAddress}");
  15356. builder.InsertCell();
  15357. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15358. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15359. builder.InsertCell();
  15360. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15361. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15362. builder.EndRow();
  15363. #endregion
  15364. #region 第五行
  15365. builder.InsertCell();
  15366. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15367. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15368. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15369. builder.ParagraphFormat.Style.Font.Bold = false;
  15370. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15371. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15372. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15373. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15374. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15375. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15376. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15377. builder.Write("TEL:");
  15378. builder.InsertCell();
  15379. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15380. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15381. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15382. builder.ParagraphFormat.Style.Font.Bold = false;
  15383. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15384. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15385. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15386. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15387. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15388. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15389. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15390. builder.Write($"{item.HotelTel}");
  15391. builder.InsertCell();
  15392. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15393. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15394. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15395. builder.ParagraphFormat.Style.Font.Bold = false;
  15396. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15397. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15398. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15399. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15400. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15401. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15402. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15403. builder.Write($"FAX:");
  15404. builder.InsertCell();
  15405. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15406. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15407. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15408. builder.ParagraphFormat.Style.Font.Bold = false;
  15409. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15410. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15411. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15412. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15413. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15414. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15415. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15416. builder.Write($"{item.HotelFax}");
  15417. builder.EndRow();
  15418. #endregion
  15419. #region 第六行
  15420. builder.InsertCell();
  15421. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15422. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15423. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15424. builder.ParagraphFormat.Style.Font.Bold = false;
  15425. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15426. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15427. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15428. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15429. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15430. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15431. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15432. builder.Write("CHECK IN:");
  15433. builder.InsertCell();
  15434. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15435. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15436. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15437. builder.ParagraphFormat.Style.Font.Bold = false;
  15438. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15439. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15440. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15441. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15442. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15443. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15444. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15445. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  15446. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  15447. builder.Write($"{checkInStr}");
  15448. builder.InsertCell();
  15449. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15450. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15451. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15452. builder.ParagraphFormat.Style.Font.Bold = false;
  15453. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15454. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15455. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15456. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15457. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15458. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15459. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15460. builder.Write($"CHECK OUT:");
  15461. builder.InsertCell();
  15462. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15463. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15464. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15465. builder.ParagraphFormat.Style.Font.Bold = false;
  15466. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15467. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15468. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15469. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15470. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15471. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15472. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15473. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  15474. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  15475. builder.Write($"{checkOutStr}");
  15476. builder.EndRow();
  15477. #endregion
  15478. #region 第七行
  15479. builder.InsertCell();
  15480. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15481. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15482. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15483. builder.ParagraphFormat.Style.Font.Bold = false;
  15484. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15485. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15486. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15487. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15488. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15489. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15490. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15491. builder.Write($"GUEST NAME:");
  15492. builder.InsertCell();
  15493. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15494. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15495. builder.ParagraphFormat.Style.Font.Size = 8;
  15496. builder.ParagraphFormat.Style.Font.Bold = false;
  15497. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15498. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15499. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15500. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15501. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15502. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15503. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15504. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15505. builder.Write($"{item.GuestName}");
  15506. builder.InsertCell();
  15507. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15508. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15509. builder.InsertCell();
  15510. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15511. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15512. builder.EndRow();
  15513. #endregion
  15514. #region 第八行
  15515. builder.InsertCell();
  15516. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15517. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15518. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15519. builder.ParagraphFormat.Style.Font.Bold = false;
  15520. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15521. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15522. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15523. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15524. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15525. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15526. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15527. builder.Write($"ROOM TYPE:");
  15528. builder.InsertCell();
  15529. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15530. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15531. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15532. builder.ParagraphFormat.Style.Font.Bold = false;
  15533. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15534. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15535. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15536. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15537. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15538. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15539. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15540. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15541. builder.Write($"{item.RoomExplanation}");
  15542. builder.InsertCell();
  15543. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15544. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15545. builder.InsertCell();
  15546. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15547. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15548. builder.EndRow();
  15549. #endregion
  15550. #region 第九行
  15551. builder.InsertCell();
  15552. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15553. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15554. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15555. builder.ParagraphFormat.Style.Font.Bold = false;
  15556. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15557. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15558. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15559. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15560. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15561. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15562. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15563. builder.Write($"NOTE:");
  15564. builder.InsertCell();
  15565. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15566. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15567. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15568. builder.ParagraphFormat.Style.Font.Bold = false;
  15569. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15570. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15571. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15572. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15573. builder.Write($"ROOM WITH BREAKFAST AND TAX ONLY.\r\nTHIS SERVICE IS PAYABLE BY C-TRIP. FOR EXTRA CHARGE TO BE COLLECTED FROM THE GUEST.");
  15574. builder.InsertCell();
  15575. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15576. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15577. builder.InsertCell();
  15578. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15579. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15580. builder.EndRow();
  15581. #endregion
  15582. builder.EndTable();
  15583. //换行
  15584. builder.Writeln("");
  15585. builder.Writeln("");
  15586. }
  15587. #region 获取文档中的所有表格 设置文字自适应
  15588. // 获取文档中的所有表格。
  15589. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  15590. {
  15591. // 遍历表格中的所有行。
  15592. foreach (Aspose.Words.Tables.Row row in table.Rows)
  15593. {
  15594. foreach (Cell cell in row.Cells)
  15595. {
  15596. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  15597. cellFormat.Width = 0;
  15598. }
  15599. }
  15600. }
  15601. #endregion
  15602. #region 设置页眉
  15603. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  15604. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  15605. if (System.IO.File.Exists(voucherHeaderPath))
  15606. {
  15607. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  15608. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  15609. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  15610. Shape shape = builder.InsertImage(imageBytes);
  15611. // 调整图片位置
  15612. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  15613. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  15614. shape.Top = 50; // 将图片距离页眉上边缘的距离
  15615. shape.Left = 0; // 将图片距离页面左边缘的距离
  15616. shape.Width = 81; // 设置图片宽度
  15617. shape.Height = 36; // 设置图片高度
  15618. }
  15619. //靠右
  15620. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  15621. //// 设置页脚上下边距
  15622. //builder.PageSetup.HeaderDistance = 42;
  15623. // 添加页眉线
  15624. Aspose.Words.Border borderHeader = null;
  15625. try
  15626. {
  15627. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  15628. }
  15629. catch (Exception e)
  15630. {
  15631. // TODO Auto-generated catch block
  15632. //e.printStackTrace();
  15633. }
  15634. borderHeader.Shadow = true;
  15635. borderHeader.DistanceFromText = 2;
  15636. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  15637. #endregion
  15638. }
  15639. catch (Exception ex)
  15640. {
  15641. }
  15642. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15643. doc.Save(fileDir);
  15644. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15645. return Ok(JsonView(true, "操作成功!", Url));
  15646. }
  15647. /// <summary>
  15648. /// 酒店预订
  15649. /// 生成 预定成本 Excel
  15650. /// </summary>
  15651. /// <param name="_dto"></param>
  15652. /// <returns></returns>
  15653. [HttpPost]
  15654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15655. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  15656. {
  15657. #region 参数验证
  15658. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  15659. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  15660. if (!vadalitorRes.IsValid)
  15661. {
  15662. var errors = new StringBuilder();
  15663. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  15664. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  15665. }
  15666. #region 团组操作权限验证 76 酒店预定模块
  15667. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15668. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15669. #endregion
  15670. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15671. #region 页面操作权限验证
  15672. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15673. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15674. #endregion
  15675. #endregion
  15676. decimal _rate = 1.00M;
  15677. string _currency = string.Empty;
  15678. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  15679. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15680. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  15681. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15682. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  15683. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  15684. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  15685. if (_GroupCostParameter == null)
  15686. {
  15687. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  15688. bool isIntType = int.TryParse(_currency, out int currId);
  15689. if (isIntType)
  15690. {
  15691. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15692. }
  15693. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15694. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15695. if (currInfo == null)
  15696. {
  15697. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15698. }
  15699. else _rate = currInfo.Rate;
  15700. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  15701. {
  15702. _rate = _GroupCostParameter.Rate;
  15703. }
  15704. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15705. //string strFileName = "HotelStatement/";
  15706. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15707. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15708. var rateDatas = new List<dynamic>();
  15709. #region 数据处理
  15710. foreach (var item in hrDtas)
  15711. {
  15712. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15713. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15714. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15715. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15716. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15717. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  15718. {
  15719. continue;
  15720. }
  15721. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15722. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  15723. string singleRoomFeeStr = string.Empty,
  15724. doubleRoomFeeStr = string.Empty,
  15725. suiteRoomFeeStr = string.Empty,
  15726. otherRoomFeeStr = string.Empty,
  15727. payMoneyStr = string.Empty,
  15728. cardPriceStr = string.Empty;
  15729. if (roomCurr.Equals("CNY"))
  15730. {
  15731. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15732. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15733. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15734. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15735. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15736. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15737. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15738. }
  15739. else
  15740. {
  15741. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15742. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15743. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15744. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15745. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15746. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15747. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15748. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15749. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15750. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15751. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15752. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15753. if (ccpPaymentCurrency.Equals("CNY"))
  15754. {
  15755. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15756. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15757. }
  15758. else
  15759. {
  15760. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15761. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15762. }
  15763. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15764. if (hotelcardPriceCurrency.Equals("CNY"))
  15765. {
  15766. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15767. }
  15768. else
  15769. {
  15770. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15771. }
  15772. }
  15773. string breakfastPriceStr = string.Empty,
  15774. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15775. governmentRentStr = string.Empty,
  15776. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15777. cityTaxStr = string.Empty,
  15778. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15779. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15780. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15781. {
  15782. if (breakfastCurrency1.Equals("CNY"))
  15783. {
  15784. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15785. }
  15786. else
  15787. {
  15788. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15789. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15790. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15791. }
  15792. }
  15793. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15794. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15795. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15796. {
  15797. if (governmentRentCurrency.Equals("CNY"))
  15798. {
  15799. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15800. }
  15801. else
  15802. {
  15803. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15804. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15805. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15806. }
  15807. }
  15808. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15809. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15810. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15811. {
  15812. if (cityTaxStrCurrency1.Equals("CNY"))
  15813. {
  15814. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15815. }
  15816. else
  15817. {
  15818. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15819. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15820. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15821. }
  15822. }
  15823. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15824. int payDId = roomInfo?.PayDId ?? 0;
  15825. pcfds.Add(new HotelReservations_PCFD_View()
  15826. {
  15827. City = item.City,
  15828. HotelName = item.HotelName,
  15829. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15830. // SingleRoomCount = item.SingleRoomCount,
  15831. SingleRoomPrice = singleRoomFeeStr,
  15832. // DoubleRoomCount = item.DoubleRoomCount,
  15833. DoubleRoomPrice = doubleRoomFeeStr,
  15834. //SuiteRoomCount = item.SuiteRoomCount,
  15835. SuiteRoomPrice = suiteRoomFeeStr,
  15836. OtherRoomPrice = otherRoomFeeStr,
  15837. //OtherRoomCount = item.OtherRoomCount,
  15838. BreakfastPrice = breakfastPriceStr,
  15839. GovernmentRent = governmentRentStr,
  15840. CityTax = cityTaxStr,
  15841. RoomExplanation = item.RoomExplanation,
  15842. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15843. PayTime = roomInfo?.ConsumptionDate,
  15844. BankNo = roomInfo?.BankNo,
  15845. PayMoney = payMoneyStr,
  15846. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15847. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15848. CardPrice = cardPriceStr,
  15849. Remark = ccpInfo.Remark
  15850. });
  15851. }
  15852. #endregion
  15853. //载入模板
  15854. WorkbookDesigner designer = new WorkbookDesigner();
  15855. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15856. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15857. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15858. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15859. var rateDatas1 = rateDatas.Distinct();
  15860. var rateStr = string.Empty;
  15861. foreach (var item in rateDatas1)
  15862. {
  15863. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15864. }
  15865. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15866. designer.SetDataSource("Opertor", userInfo.CnName);
  15867. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15868. dt.TableName = "ViewMyHotelReservations";
  15869. designer.SetDataSource(dt);
  15870. designer.Process();
  15871. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15872. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15873. designer.Workbook.Save(serverPath);
  15874. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15875. #region 删除指定行
  15876. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15877. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15878. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15879. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15880. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15881. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15882. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15883. cssIndex = dt.Columns["CityTax"].Ordinal,
  15884. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15885. remarkIndex = dt.Columns["Remark"].Ordinal;
  15886. //删除指定列
  15887. foreach (DataRow item in dt.Rows)
  15888. {
  15889. string singleStr = item["SingleRoomPrice"].ToString();
  15890. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15891. if (containsDigitButNotZero1) singleDel = false;
  15892. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15893. string doubleStr = item["DoubleRoomPrice"].ToString();
  15894. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15895. if (containsDigitButNotZero2) doubleDel = false;
  15896. string suiteStr = item["SuiteRoomPrice"].ToString();
  15897. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15898. if (containsDigitButNotZero3) suiteDel = false;
  15899. string otherStr = item["OtherRoomPrice"].ToString();
  15900. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15901. if (containsDigitButNotZero4) otherDel = false;
  15902. string zcStr = item["BreakfastPrice"].ToString();
  15903. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15904. if (containsDigitButNotZero5) zcDel = false;
  15905. string dsStr = item["GovernmentRent"].ToString();
  15906. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15907. if (containsDigitButNotZero6) dsDel = false;
  15908. string cssStr = item["CityTax"].ToString();
  15909. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15910. if (containsDigitButNotZero7) cssDel = false;
  15911. string cpStr = item["ConsumptionPatterns"].ToString();
  15912. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15913. string remarkStr = item["Remark"].ToString();
  15914. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15915. }
  15916. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15917. DeleteColumn(serverPath, cpIndex, cpDel);
  15918. DeleteColumn(serverPath, dsIndex, dsDel);
  15919. DeleteColumn(serverPath, cssIndex, cssDel);
  15920. DeleteColumn(serverPath, zcIndex, zcDel);
  15921. DeleteColumn(serverPath, otherIndex, otherDel);
  15922. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15923. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15924. DeleteColumn(serverPath, singleIndex, singleDel);
  15925. #endregion
  15926. //只保留第一个表格
  15927. DeleteSheet(serverPath);
  15928. return Ok(JsonView(true, "操作成功", url = rst));
  15929. }
  15930. else
  15931. {
  15932. _currency = _GroupCostParameter.Currency;
  15933. bool isIntType = int.TryParse(_currency, out int currId);
  15934. if (isIntType)
  15935. {
  15936. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15937. }
  15938. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15939. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15940. if (currInfo == null)
  15941. {
  15942. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15943. }
  15944. if (!_currency.ToUpper().Equals("CNY"))
  15945. {
  15946. _rate = _GroupCostParameter.Rate;
  15947. }
  15948. _rate = currInfo.Rate;
  15949. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15950. //string strFileName = "HotelStatement/";
  15951. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15952. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15953. #region 数据处理
  15954. foreach (var item in hrDtas)
  15955. {
  15956. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15957. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15958. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15959. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15960. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15961. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15962. string singleRoomFeeStr = string.Empty,
  15963. doubleRoomFeeStr = string.Empty,
  15964. suiteRoomFeeStr = string.Empty,
  15965. otherRoomFeeStr = string.Empty,
  15966. payMoneyStr = string.Empty,
  15967. cardPriceStr = string.Empty;
  15968. if (roomCurr.Equals(_currency))
  15969. {
  15970. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15971. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15972. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15973. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15974. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15975. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15976. }
  15977. else
  15978. {
  15979. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15980. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15981. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15982. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15983. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15984. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15985. }
  15986. string breakfastPriceStr = string.Empty,
  15987. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15988. governmentRentStr = string.Empty,
  15989. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15990. cityTaxStrStr = string.Empty,
  15991. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15992. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15993. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15994. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15995. int payDId = roomInfo?.PayDId ?? 0;
  15996. pcfds.Add(new HotelReservations_PCFD_View()
  15997. {
  15998. City = item.City,
  15999. HotelName = item.HotelName,
  16000. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  16001. // SingleRoomCount = item.SingleRoomCount,
  16002. SingleRoomPrice = singleRoomFeeStr,
  16003. // DoubleRoomCount = item.DoubleRoomCount,
  16004. DoubleRoomPrice = doubleRoomFeeStr,
  16005. //SuiteRoomCount = item.SuiteRoomCount,
  16006. SuiteRoomPrice = suiteRoomFeeStr,
  16007. OtherRoomPrice = otherRoomFeeStr,
  16008. //OtherRoomCount = item.OtherRoomCount,
  16009. BreakfastPrice = breakfastPriceStr,
  16010. GovernmentRent = governmentRentStr,
  16011. CityTax = cityTaxStrStr,
  16012. RoomExplanation = item.RoomExplanation,
  16013. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  16014. PayTime = roomInfo?.ConsumptionDate,
  16015. BankNo = roomInfo?.BankNo,
  16016. PayMoney = payMoneyStr,
  16017. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  16018. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  16019. CardPrice = cardPriceStr,
  16020. Remark = ccpInfo.Remark
  16021. });
  16022. }
  16023. #endregion
  16024. //载入模板
  16025. WorkbookDesigner designer = new WorkbookDesigner();
  16026. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  16027. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  16028. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  16029. designer.SetDataSource("TourNo", groupInfo.TourCode);
  16030. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  16031. designer.SetDataSource("Opertor", userInfo.CnName);
  16032. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  16033. dt.TableName = "ViewMyHotelReservations";
  16034. designer.SetDataSource(dt);
  16035. designer.Process();
  16036. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  16037. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  16038. designer.Workbook.Save(serverPath);
  16039. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  16040. #region 删除指定行
  16041. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  16042. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  16043. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  16044. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  16045. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  16046. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  16047. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  16048. cssIndex = dt.Columns["CityTax"].Ordinal,
  16049. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  16050. remarkIndex = dt.Columns["Remark"].Ordinal;
  16051. //删除指定列
  16052. foreach (DataRow item in dt.Rows)
  16053. {
  16054. string singleStr = item["SingleRoomPrice"].ToString();
  16055. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  16056. if (containsDigitButNotZero1) singleDel = false;
  16057. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  16058. string doubleStr = item["DoubleRoomPrice"].ToString();
  16059. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16060. if (containsDigitButNotZero2) doubleDel = false;
  16061. string suiteStr = item["SuiteRoomPrice"].ToString();
  16062. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16063. if (containsDigitButNotZero3) suiteDel = false;
  16064. string otherStr = item["OtherRoomPrice"].ToString();
  16065. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  16066. if (containsDigitButNotZero4) otherDel = false;
  16067. string zcStr = item["BreakfastPrice"].ToString();
  16068. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  16069. if (containsDigitButNotZero5) zcDel = false;
  16070. string dsStr = item["GovernmentRent"].ToString();
  16071. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  16072. if (containsDigitButNotZero6) dsDel = false;
  16073. string cssStr = item["CityTax"].ToString();
  16074. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  16075. if (containsDigitButNotZero7) cssDel = false;
  16076. string cpStr = item["ConsumptionPatterns"].ToString();
  16077. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  16078. string remarkStr = item["Remark"].ToString();
  16079. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  16080. }
  16081. DeleteColumn(serverPath, remarkIndex, remarkDel);
  16082. DeleteColumn(serverPath, cpIndex, cpDel);
  16083. DeleteColumn(serverPath, dsIndex, dsDel);
  16084. DeleteColumn(serverPath, cssIndex, cssDel);
  16085. DeleteColumn(serverPath, zcIndex, zcDel);
  16086. DeleteColumn(serverPath, otherIndex, otherDel);
  16087. DeleteColumn(serverPath, suiteIndex, suiteDel);
  16088. DeleteColumn(serverPath, doubleIndex, doubleDel);
  16089. DeleteColumn(serverPath, singleIndex, singleDel);
  16090. #endregion
  16091. //只保留第一个表格
  16092. DeleteSheet(serverPath);
  16093. return Ok(JsonView(true, "操作成功", url = rst));
  16094. }
  16095. //return Ok(JsonView(false));
  16096. }
  16097. /// <summary>
  16098. /// 删除指定列
  16099. /// </summary>
  16100. /// <param name="file"></param>
  16101. /// <param name="columnIndex"></param>
  16102. /// <param name="isDel"></param>
  16103. private void DeleteColumn(string file, int columnIndex, bool isDel)
  16104. {
  16105. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16106. //wb.Save(file);
  16107. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  16108. if (sheet1 != null)
  16109. {
  16110. if (isDel)
  16111. {
  16112. Cells cells = sheet1.Cells;
  16113. cells.DeleteColumn(columnIndex);
  16114. }
  16115. }
  16116. wb.Save(file);
  16117. }
  16118. /// <summary>
  16119. /// 删除sheet
  16120. /// </summary>
  16121. /// <param name="file"></param>
  16122. /// <param name="sheetName"></param>
  16123. private void DeleteSheet(string file, string sheetName = "")
  16124. {
  16125. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16126. //wb.Save(file);
  16127. List<string> sheets = new List<string>();
  16128. foreach (var item in wb.Worksheets)
  16129. {
  16130. sheets.Add(item.Name);
  16131. }
  16132. if (sheets.Count > 0)
  16133. {
  16134. sheets.RemoveAt(0);//不删除第一个sheet
  16135. foreach (var item in sheets)
  16136. {
  16137. wb.Worksheets.RemoveAt(item);
  16138. }
  16139. }
  16140. wb.Save(file);
  16141. }
  16142. /// <summary>
  16143. /// 酒店预订
  16144. /// 确认单
  16145. /// </summary>
  16146. /// <param name="_dto"></param>
  16147. /// <returns></returns>
  16148. [HttpPost]
  16149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16150. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  16151. {
  16152. try
  16153. {
  16154. #region 参数验证
  16155. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  16156. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16157. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  16158. #region 团组操作权限验证 76 酒店预定模块
  16159. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16160. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  16161. #endregion
  16162. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16163. #region 页面操作权限验证
  16164. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16165. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16166. #endregion
  16167. #endregion
  16168. //团组信息
  16169. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  16170. //酒店数据
  16171. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  16172. if (listhoteldata.Count < 0)
  16173. {
  16174. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  16175. }
  16176. //利datatable存储
  16177. DataTable dt = new DataTable();
  16178. dt.Columns.Add("CheckInDate", typeof(string));
  16179. dt.Columns.Add("City", typeof(string));
  16180. dt.Columns.Add("Hotel", typeof(string));
  16181. dt.Columns.Add("Room", typeof(string));
  16182. for (int i = 0; i < listhoteldata.Count; i++)
  16183. {
  16184. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  16185. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  16186. while (dayStart < dayEnd)
  16187. {
  16188. string temp = "";
  16189. DataRow row = dt.NewRow();
  16190. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  16191. row["City"] = listhoteldata[i].City;
  16192. row["Hotel"] = listhoteldata[i].HotelName;
  16193. if (listhoteldata[i].SingleRoomCount > 0)
  16194. {
  16195. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  16196. }
  16197. if (listhoteldata[i].DoubleRoomCount > 0)
  16198. {
  16199. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  16200. }
  16201. if (listhoteldata[i].SuiteRoomCount > 0)
  16202. {
  16203. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  16204. }
  16205. if (listhoteldata[i].OtherRoomCount > 0)
  16206. {
  16207. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  16208. }
  16209. row["Room"] = temp;
  16210. dt.Rows.Add(row);
  16211. dayStart = dayStart.AddDays(1);
  16212. }
  16213. }
  16214. Dictionary<string, string> dic = new Dictionary<string, string>();
  16215. dic.Add("Dele", di.TeamName);
  16216. dic.Add("City", di.VisitCountry);
  16217. //模板路径
  16218. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  16219. //载入模板
  16220. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  16221. DocumentBuilder builder = new DocumentBuilder(doc);
  16222. foreach (var key in dic.Keys)
  16223. {
  16224. builder.MoveToBookmark(key);
  16225. builder.Write(dic[key]);
  16226. }
  16227. //获取word里所有表格
  16228. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16229. //获取所填表格的序数
  16230. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16231. var rowStart = tableOne.Rows[0]; //获取第1行
  16232. //循环赋值
  16233. for (int i = 0; i < dt.Rows.Count; i++)
  16234. {
  16235. builder.MoveToCell(0, i + 1, 0, 0);
  16236. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  16237. builder.MoveToCell(0, i + 1, 1, 0);
  16238. builder.Write(dt.Rows[i]["City"].ToString());
  16239. builder.MoveToCell(0, i + 1, 2, 0);
  16240. builder.Write(dt.Rows[i]["Hotel"].ToString());
  16241. builder.MoveToCell(0, i + 1, 3, 0);
  16242. builder.Write(dt.Rows[i]["Room"].ToString());
  16243. }
  16244. //删除多余行
  16245. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  16246. {
  16247. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  16248. }
  16249. string strFileName = di.TeamName + "酒店确认单.doc";
  16250. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  16251. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  16252. return Ok(JsonView(true, "成功", url));
  16253. }
  16254. catch (Exception ex)
  16255. {
  16256. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  16257. }
  16258. }
  16259. #endregion
  16260. #region 团组状态
  16261. /// <summary>
  16262. /// 团组状态列表 Page
  16263. /// </summary>
  16264. /// <param name="dto">团组列表请求dto</param>
  16265. /// <returns></returns>
  16266. [HttpPost]
  16267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16268. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  16269. {
  16270. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16271. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  16272. {
  16273. string sqlWhere = string.Empty;
  16274. if (dto.IsSure == 0) //未完成
  16275. {
  16276. sqlWhere += string.Format(@" And IsSure = 0");
  16277. }
  16278. else if (dto.IsSure == 1) //已完成
  16279. {
  16280. sqlWhere += string.Format(@" And IsSure = 1");
  16281. }
  16282. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  16283. {
  16284. string tj = dto.SearchCriteria;
  16285. 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}%')",
  16286. tj, tj, tj, tj, tj);
  16287. }
  16288. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  16289. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  16290. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  16291. From (
  16292. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  16293. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  16294. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  16295. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  16296. From Grp_DelegationInfo gdi
  16297. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  16298. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  16299. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  16300. Where gdi.IsDel = 0 {0}
  16301. ) temp ", sqlWhere);
  16302. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  16303. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  16304. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  16305. }
  16306. else
  16307. {
  16308. return Ok(JsonView(false, "查询失败"));
  16309. }
  16310. }
  16311. /// <summary>
  16312. /// 团组状态
  16313. /// 设置操作完成
  16314. /// </summary>
  16315. /// <param name="dto">团组列表请求dto</param>
  16316. /// <returns></returns>
  16317. [HttpPost]
  16318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16319. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  16320. {
  16321. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16322. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  16323. {
  16324. Id = dto.Id,
  16325. IsSure = 1
  16326. };
  16327. var result = await _sqlSugar.Updateable(_DelegationInfo)
  16328. .UpdateColumns(it => new { it.IsSure })
  16329. .WhereColumns(it => new { it.Id })
  16330. .ExecuteCommandAsync();
  16331. if (result > 0)
  16332. {
  16333. return Ok(JsonView(true, "操作完成!"));
  16334. }
  16335. return Ok(JsonView(false, "操作失败!"));
  16336. }
  16337. #endregion
  16338. #region 保险费用录入
  16339. /// <summary>
  16340. /// 根据团组Id查询保险费用列表
  16341. /// </summary>
  16342. /// <param name="dto"></param>
  16343. /// <returns></returns>
  16344. [HttpPost]
  16345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16346. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  16347. {
  16348. Result groupData = await _customersRep.CustomersByDiId(dto);
  16349. if (groupData.Code != 0)
  16350. {
  16351. return Ok(JsonView(false, groupData.Msg));
  16352. }
  16353. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16354. }
  16355. /// <summary>
  16356. /// 根据保险费用Id查询保险费用详细
  16357. /// </summary>
  16358. /// <param name="dto"></param>
  16359. /// <returns></returns>
  16360. [HttpPost]
  16361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16362. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  16363. {
  16364. try
  16365. {
  16366. Result groupData = await _customersRep.CustomersById(dto);
  16367. if (groupData.Code != 0)
  16368. {
  16369. return Ok(JsonView(false, groupData.Msg));
  16370. }
  16371. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16372. }
  16373. catch (Exception ex)
  16374. {
  16375. return Ok(JsonView(false, ex.Message));
  16376. }
  16377. }
  16378. /// <summary>
  16379. /// 保险费用录入页面初始化绑定
  16380. /// </summary>
  16381. /// <param name="dto"></param>
  16382. /// <returns></returns>
  16383. [HttpPost]
  16384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16385. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  16386. {
  16387. try
  16388. {
  16389. Result groupData = await _customersRep.CustomersInitialize(dto);
  16390. if (groupData.Code != 0)
  16391. {
  16392. return Ok(JsonView(false, groupData.Msg));
  16393. }
  16394. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16395. }
  16396. catch (Exception ex)
  16397. {
  16398. return Ok(JsonView(false, ex.Message));
  16399. }
  16400. }
  16401. /// <summary>
  16402. /// 保险费用操作(Status:1.新增,2.修改)
  16403. /// </summary>
  16404. /// <param name="dto"></param>
  16405. /// <returns></returns>
  16406. [HttpPost]
  16407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16408. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  16409. {
  16410. Result groupData = await _customersRep.OpCustomers(dto);
  16411. if (groupData.Code != 0)
  16412. {
  16413. return Ok(JsonView(false, groupData.Msg));
  16414. }
  16415. #region 应用推送
  16416. try
  16417. {
  16418. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  16419. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  16420. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  16421. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16422. //自动审核
  16423. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  16424. //2024-10-21 新增LZ UID
  16425. var userIds = new List<int>() { 21 };
  16426. string title = $"系统通知";
  16427. var diId = dto.DiId;
  16428. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16429. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16430. string content = "";
  16431. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16432. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16433. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16434. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  16435. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  16436. }
  16437. catch (Exception ex)
  16438. {
  16439. }
  16440. #endregion
  16441. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16442. }
  16443. /// <summary>
  16444. /// 保险文件上传
  16445. /// </summary>
  16446. /// <param name="file"></param>
  16447. /// <returns></returns>
  16448. [HttpPost]
  16449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16450. public async Task<IActionResult> UploadCus(IFormFile file)
  16451. {
  16452. try
  16453. {
  16454. if (file != null)
  16455. {
  16456. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16457. //文件名称
  16458. string projectFileName = file.FileName;
  16459. //上传的文件的路径
  16460. string filePath = "";
  16461. if (!Directory.Exists(fileDir))
  16462. {
  16463. Directory.CreateDirectory(fileDir);
  16464. }
  16465. //上传的文件的路径
  16466. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  16467. using (FileStream fs = System.IO.File.Create(filePath))
  16468. {
  16469. file.CopyTo(fs);
  16470. fs.Flush();
  16471. }
  16472. return Ok(JsonView(true, "上传成功!", projectFileName));
  16473. }
  16474. else
  16475. {
  16476. return Ok(JsonView(false, "上传失败!"));
  16477. }
  16478. }
  16479. catch (Exception ex)
  16480. {
  16481. return Ok(JsonView(false, "程序错误!"));
  16482. throw;
  16483. }
  16484. }
  16485. /// <summary>
  16486. /// 保险删除指定文件
  16487. /// </summary>
  16488. /// <param name="dto"></param>
  16489. /// <returns></returns>
  16490. [HttpPost]
  16491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16492. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  16493. {
  16494. try
  16495. {
  16496. string filePath = "";
  16497. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16498. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  16499. //int id = 0;
  16500. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  16501. // 删除该文件
  16502. try
  16503. {
  16504. System.IO.File.Delete(filePath);
  16505. 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()
  16506. {
  16507. Attachment = "",
  16508. }).ExecuteCommandAsync();
  16509. if (result != 0)
  16510. {
  16511. return Ok(JsonView(true, "成功!"));
  16512. }
  16513. else
  16514. {
  16515. return Ok(JsonView(false, "失败!"));
  16516. }
  16517. }
  16518. catch (Exception)
  16519. {
  16520. 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()
  16521. {
  16522. Attachment = "",
  16523. }).ExecuteCommandAsync();
  16524. if (result != 0)
  16525. {
  16526. return Ok(JsonView(true, "成功!"));
  16527. }
  16528. else
  16529. {
  16530. return Ok(JsonView(false, "失败!"));
  16531. }
  16532. }
  16533. }
  16534. catch (Exception ex)
  16535. {
  16536. return Ok(JsonView(false, "程序错误!"));
  16537. throw;
  16538. }
  16539. }
  16540. /// <summary>
  16541. /// 保险费用操作(删除)
  16542. /// </summary>
  16543. /// <param name="dto"></param>
  16544. /// <returns></returns>
  16545. [HttpPost]
  16546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16547. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  16548. {
  16549. try
  16550. {
  16551. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  16552. if (!res)
  16553. {
  16554. return Ok(JsonView(false, "删除失败"));
  16555. }
  16556. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  16557. {
  16558. IsDel = 1,
  16559. DeleteUserId = dto.DeleteUserId,
  16560. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16561. }).ExecuteCommandAsync();
  16562. return Ok(JsonView(true, "删除成功!"));
  16563. }
  16564. catch (Exception ex)
  16565. {
  16566. return Ok(JsonView(false, "程序错误!"));
  16567. throw;
  16568. }
  16569. }
  16570. #endregion
  16571. #region 接团客户名单 PageId 104
  16572. /// <summary>
  16573. /// 接团客户名单
  16574. /// 迁移数据(慎用!)
  16575. /// </summary>
  16576. /// <returns></returns>
  16577. [HttpPost]
  16578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16579. public async Task<IActionResult> PostTourClientListChange()
  16580. {
  16581. try
  16582. {
  16583. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  16584. //var groupClinetData1
  16585. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  16586. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  16587. int updateCount = 0;
  16588. if (oldOAClientList.Count > 0)
  16589. {
  16590. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  16591. _sqlSugar.BeginTran();
  16592. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  16593. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  16594. foreach (var item in oldOAClientList)
  16595. {
  16596. int comId = 0;
  16597. string format = "yyyy-MM-dd HH:mm:ss";
  16598. string data11 = "1990-01-01 00:00";
  16599. var data1 = IsValidDate(item.OPdate, format);
  16600. if (data1) data11 = item.OPdate;
  16601. //客户公司验证
  16602. if (!string.IsNullOrEmpty(item.Company))
  16603. {
  16604. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  16605. if (clientComInfo == null) // add
  16606. {
  16607. var addInfo = new Crm_CustomerCompany()
  16608. {
  16609. CompanyAbbreviation = "",
  16610. CompanyFullName = item.Company,
  16611. Address = "",
  16612. PostCodes = "",
  16613. LastedOpUserId = item.OPer,
  16614. LastedOpDt = Convert.ToDateTime(data11),
  16615. CreateUserId = item.OPer,
  16616. CreateTime = Convert.ToDateTime(data11),
  16617. IsDel = 0
  16618. };
  16619. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  16620. if (comId1 > 0) comId = comId1;
  16621. }
  16622. else comId = clientComInfo.Id;
  16623. }
  16624. //客户人员验证
  16625. int clientId = 0;
  16626. string name = item.LastName + item.Name;
  16627. if (!string.IsNullOrEmpty(name))
  16628. {
  16629. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  16630. if (clientInfo == null)
  16631. {
  16632. DateTime? dateTime = null;
  16633. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  16634. if (isDt) dateTime = birthDayDt;
  16635. var addInfo1 = new Crm_DeleClient()
  16636. {
  16637. CrmCompanyId = comId,
  16638. DiId = -1,
  16639. LastName = item.LastName,
  16640. FirstName = item.Name,
  16641. OldName = "",
  16642. Pinyin = item.Pinyin,
  16643. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  16644. Marriage = 0,
  16645. Phone = item.Phone,
  16646. Job = item.Job,
  16647. BirthDay = dateTime
  16648. };
  16649. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  16650. if (clientId1 > 0) clientId = clientId1;
  16651. }
  16652. else clientId = clientInfo.Id;
  16653. }
  16654. if (clientId < 1)
  16655. {
  16656. continue;
  16657. }
  16658. int airType = 0;
  16659. if (item.AirType == "超经舱") airType = 459;
  16660. else if (item.AirType == "公务舱") airType = 458;
  16661. else if (item.AirType == "经济舱") airType = 460;
  16662. else if (item.AirType == "其他") airType = 565;
  16663. else if (item.AirType == "头等舱") airType = 457;
  16664. var _TourClientListEntity = new Grp_TourClientList()
  16665. {
  16666. DiId = item.Diid,
  16667. ClientId = clientId,
  16668. CreateUserId = item.OPer,
  16669. CreateTime = Convert.ToDateTime(data11),
  16670. Remark = item.Remark,
  16671. IsDel = item.Isdel,
  16672. ShippingSpaceTypeId = airType,
  16673. ShippingSpaceSpecialNeeds = item.AirRemark,
  16674. HotelSpecialNeeds = item.RoomType
  16675. };
  16676. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  16677. if (_TourClientList > 0)
  16678. {
  16679. updateCount++;
  16680. }
  16681. }
  16682. _sqlSugar.CommitTran();
  16683. }
  16684. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  16685. }
  16686. catch (Exception ex)
  16687. {
  16688. _sqlSugar.RollbackTran();
  16689. return Ok(JsonView(false, ex.Message));
  16690. }
  16691. //return Ok(JsonView(true));
  16692. }
  16693. private bool IsValidDate(string dateString, string format)
  16694. {
  16695. DateTime dateValue;
  16696. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  16697. return valid;
  16698. }
  16699. /// <summary>
  16700. /// 接团客户名单
  16701. /// 根据团组Id查询List
  16702. /// </summary>
  16703. /// <param name="_dto"></param>
  16704. /// <returns></returns>
  16705. [HttpPost]
  16706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16707. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  16708. {
  16709. #region 参数验证
  16710. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  16711. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  16712. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  16713. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16714. #region 页面操作权限验证
  16715. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16716. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16717. #endregion
  16718. #endregion
  16719. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  16720. if (viewData.Code != 0)
  16721. {
  16722. return Ok(JsonView(false, viewData.Msg));
  16723. }
  16724. return Ok(JsonView(viewData.Data));
  16725. }
  16726. /// <summary>
  16727. /// 接团客户名单
  16728. /// 基础数据 Init
  16729. /// </summary>
  16730. /// <param name="_dto"></param>
  16731. /// <returns></returns>
  16732. [HttpPost]
  16733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16734. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16735. {
  16736. #region 参数验证
  16737. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16738. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16739. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16740. #region 页面操作权限验证
  16741. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16742. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16743. #endregion
  16744. #endregion
  16745. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16746. }
  16747. /// <summary>
  16748. /// 接团客户名单
  16749. /// 根据 Id查询 Details
  16750. /// </summary>
  16751. /// <param name="_dto"></param>
  16752. /// <returns></returns>
  16753. [HttpPost]
  16754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16755. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16756. {
  16757. #region 参数验证
  16758. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16759. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16760. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16761. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16762. #region 页面操作权限验证
  16763. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16764. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16765. #endregion
  16766. #endregion
  16767. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16768. if (viewData.Code != 0)
  16769. {
  16770. return Ok(JsonView(false, viewData.Msg));
  16771. }
  16772. return Ok(JsonView(viewData.Data));
  16773. }
  16774. /// <summary>
  16775. /// 接团客户名单
  16776. /// Add Or Edit
  16777. /// </summary>
  16778. /// <param name="_dto"></param>
  16779. /// <returns></returns>
  16780. [HttpPost]
  16781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16782. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16783. {
  16784. #region 参数验证
  16785. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16786. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16787. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16788. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16789. #region 页面操作权限验证
  16790. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16791. if (_dto.Id == 0) //添加
  16792. {
  16793. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16794. }
  16795. else if (_dto.Id >= 0) //修改
  16796. {
  16797. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16798. }
  16799. #endregion
  16800. #endregion
  16801. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16802. if (viewData.Code != 0)
  16803. {
  16804. return Ok(JsonView(false, viewData.Msg));
  16805. }
  16806. return Ok(JsonView(true));
  16807. }
  16808. /// <summary>
  16809. /// 接团客户名单
  16810. /// json字符串 AddMultiple(添加多个)
  16811. /// </summary>
  16812. /// <param name="_dto"></param>
  16813. /// <returns></returns>
  16814. [HttpPost]
  16815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16816. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16817. {
  16818. #region 参数验证
  16819. string jsonLabel = _dto.JsonLabel;
  16820. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16821. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16822. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16823. #region 页面操作权限验证
  16824. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16825. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16826. #endregion
  16827. #endregion
  16828. var request = new TourClientListAddMultipleDto();
  16829. request.DiId = _dto.DiId;
  16830. request.UserId = _dto.UserId;
  16831. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16832. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16833. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16834. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16835. var infos = new List<TourClientListInfo>();
  16836. foreach (var data in datas)
  16837. {
  16838. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16839. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16840. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16841. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16842. {
  16843. continue;
  16844. }
  16845. infos.Add(new TourClientListInfo()
  16846. {
  16847. IsAccompany = 1,
  16848. LastName = lastName,
  16849. FirstName = firstName,
  16850. Pinyin = lastNameEn + @"/" + firstNameEn,
  16851. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  16852. CompanyFullName = data.CompanyFullName,
  16853. Job = data.Job
  16854. });
  16855. }
  16856. if (infos.Any())
  16857. {
  16858. var viewData = await _tourClientListRep._AddMultiple(request);
  16859. if (viewData.Code != 0)
  16860. {
  16861. return Ok(JsonView(false, viewData.Msg));
  16862. }
  16863. return Ok(JsonView(true));
  16864. }
  16865. return Ok(JsonView(false));
  16866. }
  16867. /// <summary>
  16868. /// 接团客户名单
  16869. /// AddMultiple(添加多个)
  16870. /// </summary>
  16871. /// <param name="_dto"></param>
  16872. /// <returns></returns>
  16873. [HttpPost]
  16874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16875. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16876. {
  16877. #region 参数验证
  16878. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16879. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16880. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16881. #region 页面操作权限验证
  16882. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16883. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16884. #endregion
  16885. #endregion
  16886. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16887. if (viewData.Code != 0)
  16888. {
  16889. return Ok(JsonView(false, viewData.Msg));
  16890. }
  16891. return Ok(JsonView(true));
  16892. }
  16893. /// <summary>
  16894. /// 接团客户名单
  16895. /// Del
  16896. /// </summary>
  16897. /// <param name="_dto"></param>
  16898. /// <returns></returns>
  16899. [HttpPost]
  16900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16901. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16902. {
  16903. #region 参数验证
  16904. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16905. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16906. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16907. #region 页面操作权限验证
  16908. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16909. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16910. #endregion
  16911. #endregion
  16912. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16913. if (viewData.Code != 0)
  16914. {
  16915. return Ok(JsonView(false, viewData.Msg));
  16916. }
  16917. return Ok(JsonView(true));
  16918. }
  16919. /// <summary>
  16920. /// 接团客户名单
  16921. /// 文件下载 客户名单
  16922. /// </summary>
  16923. /// <param name="_dto"></param>
  16924. /// <returns></returns>
  16925. [HttpPost]
  16926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16927. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16928. {
  16929. #region 参数验证
  16930. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16931. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16932. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16933. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16934. #region 页面操作权限验证
  16935. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16936. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16937. #endregion
  16938. #endregion
  16939. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16940. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16941. From Grp_TourClientList tcl
  16942. Left Join
  16943. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16944. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16945. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16946. From Crm_DeleClient dc
  16947. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16948. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16949. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16950. Where dc.IsDel = 0) temp
  16951. On temp.DcId =tcl.ClientId
  16952. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16953. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16954. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16955. //载入模板
  16956. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16957. if (_dto.Language == 1)
  16958. {
  16959. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16960. }
  16961. //载入模板
  16962. var doc = new Document(tempPath);
  16963. DocumentBuilder builder = new DocumentBuilder(doc);
  16964. //获取word里所有表格
  16965. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16966. //获取所填表格的序数
  16967. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16968. var rowStart = tableOne.Rows[0]; //获取第1行
  16969. if (_dto.Language == 0)
  16970. {
  16971. //循环赋值
  16972. for (int i = 0; i < DcList.Count; i++)
  16973. {
  16974. EncryptionProcessor.DecryptProperties(DcList[i]);
  16975. builder.MoveToCell(0, i + 1, 0, 0);
  16976. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16977. builder.MoveToCell(0, i + 1, 1, 0);
  16978. int sex = DcList[i].Sex;
  16979. string sexStr = string.Empty;
  16980. if (sex == 0) sexStr = "男";
  16981. else if (sex == 1) sexStr = "女";
  16982. else sexStr = "未设置";
  16983. builder.Write(sexStr);
  16984. builder.MoveToCell(0, i + 1, 2, 0);
  16985. string birthDay = DcList[i].BirthDay;
  16986. string birthDayStr = string.Empty;
  16987. if (!string.IsNullOrEmpty(birthDay))
  16988. {
  16989. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16990. }
  16991. builder.Write(birthDayStr);
  16992. builder.MoveToCell(0, i + 1, 3, 0);
  16993. string company = "";
  16994. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16995. {
  16996. company = DcList[i].CompanyFullName.ToString();
  16997. }
  16998. builder.Write(company);
  16999. builder.MoveToCell(0, i + 1, 4, 0);
  17000. builder.Write(DcList[i].Job);
  17001. }
  17002. }
  17003. else if (_dto.Language == 1)
  17004. {
  17005. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  17006. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  17007. List<string> transArrayStr = new List<string>();
  17008. string transStrRes1 = "";
  17009. for (int i = 0; i < DcList.Count; i++)
  17010. {
  17011. var dc = DcList[i];
  17012. EncryptionProcessor.DecryptProperties(dc);
  17013. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  17014. if (dc.Job.Equals("暂无")) dc.Job = "-";
  17015. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  17016. if (DcList.Count - 1 == i) transStrRes1 += str1;
  17017. else transStrRes1 += $"{str1}|";
  17018. }
  17019. //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";
  17020. string transStrRes = "";
  17021. if (transStrRes1.Length > 0)
  17022. {
  17023. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  17024. }
  17025. //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
  17026. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  17027. //List<string> transArray = new List<string> { };
  17028. List<TranslateInfo> transArray = new List<TranslateInfo>();
  17029. if (transStrRes.Contains("|"))
  17030. {
  17031. string[] transArray1 = transStrRes.Split('|');
  17032. if (transArray1.Length > 0)
  17033. {
  17034. foreach (var item in transArray1)
  17035. {
  17036. if (item.Contains("&"))
  17037. {
  17038. string[] transArray2 = item.Split('&');
  17039. int index = 0;
  17040. string companyName = "", job = "";
  17041. if (transArray2.Length > 0)
  17042. {
  17043. bool success = int.TryParse(transArray2[0].Trim(), out index);
  17044. if (1 < transArray2.Length) companyName = transArray2[1];
  17045. if (2 < transArray2.Length) job = transArray2[2];
  17046. }
  17047. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  17048. }
  17049. }
  17050. }
  17051. }
  17052. //循环赋值
  17053. for (int i = 0; i < DcList.Count; i++)
  17054. {
  17055. string PYName = "";
  17056. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  17057. {
  17058. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  17059. string PY_First = DcList[i].Pinyin.Split('/')[1];
  17060. PYName = PY_First + " " + PY_Last;
  17061. }
  17062. else
  17063. {
  17064. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  17065. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  17066. PYName = PY_First + " " + PY_Last;
  17067. }
  17068. builder.MoveToCell(0, i + 1, 0, 0);
  17069. builder.Write(PYName);
  17070. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  17071. builder.MoveToCell(0, i + 1, 1, 0);
  17072. builder.Write(sex);
  17073. DateTime birthDt;
  17074. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  17075. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  17076. builder.MoveToCell(0, i + 1, 2, 0);
  17077. builder.Write(birthday);
  17078. string company = string.Empty, job = string.Empty;
  17079. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  17080. if (dcTransInfo != null)
  17081. {
  17082. company = dcTransInfo.CompanyName;
  17083. job = dcTransInfo.Job;
  17084. }
  17085. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  17086. {
  17087. //查询对照表
  17088. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  17089. if (tempCec != null)
  17090. {
  17091. company = tempCec.enName;
  17092. }
  17093. //翻译
  17094. else
  17095. {
  17096. }
  17097. }
  17098. builder.MoveToCell(0, i + 1, 3, 0);
  17099. builder.Write(company);
  17100. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  17101. {
  17102. //查询对照表
  17103. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  17104. if (tempPec != null)
  17105. {
  17106. job = tempPec.enName;
  17107. }
  17108. //翻译
  17109. else
  17110. {
  17111. }
  17112. }
  17113. builder.MoveToCell(0, i + 1, 4, 0);
  17114. builder.Write(job);
  17115. }
  17116. }
  17117. //删除多余行
  17118. while (tableOne.Rows.Count > DcList.Count + 1)
  17119. {
  17120. tableOne.Rows.RemoveAt(DcList.Count + 1);
  17121. }
  17122. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  17123. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  17124. doc.Save(fileDir);
  17125. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  17126. return Ok(JsonView(true, "操作成功!", Url));
  17127. }
  17128. private class TranslateInfo
  17129. {
  17130. public int Index { get; set; }
  17131. public string CompanyName { get; set; }
  17132. public string Job { get; set; }
  17133. }
  17134. #endregion
  17135. #region 团组倒推表
  17136. /// <summary>
  17137. /// 倒推表基础数据
  17138. /// Init
  17139. /// </summary>
  17140. /// <returns></returns>
  17141. [HttpPost]
  17142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17143. public async Task<IActionResult> PostInvertedListInit()
  17144. {
  17145. var viewData = await _invertedListRep._Init();
  17146. if (viewData.Code != 0)
  17147. {
  17148. return Ok(JsonView(false, viewData.Msg));
  17149. }
  17150. return Ok(JsonView(viewData.Data));
  17151. }
  17152. /// <summary>
  17153. /// 倒推表
  17154. /// Info
  17155. /// </summary>
  17156. /// <param name="dto"></param>
  17157. /// <returns></returns>
  17158. [HttpPost]
  17159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17160. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  17161. {
  17162. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  17163. if (viewData.Code != 0)
  17164. {
  17165. return Ok(JsonView(false, viewData.Msg));
  17166. }
  17167. return Ok(JsonView(viewData.Data));
  17168. }
  17169. /// <summary>
  17170. /// 倒推表
  17171. /// Create
  17172. /// </summary>
  17173. /// <param name="dto"></param>
  17174. /// <returns></returns>
  17175. [HttpPost]
  17176. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17177. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  17178. {
  17179. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  17180. if (viewData.Code != 0)
  17181. {
  17182. return Ok(JsonView(false, viewData.Msg));
  17183. }
  17184. return Ok(JsonView(viewData.Data));
  17185. }
  17186. /// <summary>
  17187. /// 倒推表
  17188. /// Update
  17189. /// </summary>
  17190. /// <param name="dto"></param>
  17191. /// <returns></returns>
  17192. [HttpPost]
  17193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17194. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  17195. {
  17196. var viewData = await _invertedListRep._Update(dto);
  17197. if (viewData.Code != 0)
  17198. {
  17199. return Ok(JsonView(false, viewData.Msg));
  17200. }
  17201. return Ok(JsonView(viewData.Data));
  17202. }
  17203. /// <summary>
  17204. /// 倒推表
  17205. /// File Download
  17206. /// </summary>
  17207. /// <param name="dto"></param>
  17208. /// <returns></returns>
  17209. [HttpPost]
  17210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17211. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  17212. {
  17213. var info2 = await _invertedListRep._Info(1, dto.DiId);
  17214. if (info2.Code != 0)
  17215. {
  17216. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  17217. }
  17218. var info1 = info2.Data as InvertedListInfoView;
  17219. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  17220. string teamName = "";
  17221. if (info != null) teamName = info.TeamName;
  17222. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  17223. var doc = new Document();
  17224. var builder = new DocumentBuilder(doc);
  17225. #region old insert
  17226. ////载入模板
  17227. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  17228. //Document doc = new Document(tempPath);
  17229. //DocumentBuilder builder = new DocumentBuilder(doc);
  17230. //利用键值对存放数据
  17231. //Dictionary<string, string> dic = new Dictionary<string, string>();
  17232. //dic.Add("TeamName", teamName);
  17233. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  17234. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  17235. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  17236. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  17237. //dic.Add("SQRemark", info1.ApprovalRemark);
  17238. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  17239. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  17240. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  17241. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  17242. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  17243. //dic.Add("QZRemark", info1.VisaInformationRemark);
  17244. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  17245. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  17246. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  17247. //dic.Add("CQRemark", info1.IssueVisaRemark);
  17248. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  17249. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  17250. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  17251. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  17252. //#region 填充word模板书签内容
  17253. //foreach (var key in dic.Keys)
  17254. //{
  17255. // builder.MoveToBookmark(key);
  17256. // builder.Write(dic[key]);
  17257. //}
  17258. //#endregion
  17259. #endregion
  17260. #region New Insert
  17261. string titleFont = $"仿宋",
  17262. contentFont = $"仿宋";
  17263. var fontColor = Color.FromArgb(64, 64, 64);
  17264. //设置标题 团组名称
  17265. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17266. builder.Font.Name = titleFont;
  17267. builder.Font.Color = fontColor;
  17268. builder.Font.Size = 12;
  17269. builder.Font.Bold = true;
  17270. builder.Writeln(teamName);
  17271. //设置副标题 团组出访时间
  17272. builder.Font.Size = 12;
  17273. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  17274. builder.Writeln();
  17275. var backgroundColor = Color.FromArgb(199, 199, 199);
  17276. var table = builder.StartTable();
  17277. builder.InsertCell();
  17278. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  17279. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  17280. builder.CellFormat.Borders.LineWidth = 1;
  17281. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  17282. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  17283. builder.RowFormat.Height = 40;
  17284. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17285. builder.Font.Name = contentFont;
  17286. builder.Font.Size = 12;
  17287. builder.Font.Bold = true;
  17288. builder.Font.Color = fontColor;
  17289. builder.Write("时间");
  17290. builder.InsertCell();
  17291. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  17292. builder.Write("流程");
  17293. builder.InsertCell();
  17294. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  17295. builder.Write("说明");
  17296. builder.EndRow();
  17297. //报批资料准备
  17298. if (info1.IsSelectedAirportd)
  17299. {
  17300. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  17301. }
  17302. //报批/提供送签资料
  17303. if (info1.IsSelectedApprovalData)
  17304. {
  17305. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  17306. }
  17307. //出批件护照办理
  17308. if (info1.IsSelectedIssueApproval)
  17309. {
  17310. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  17311. }
  17312. //签证资料准备
  17313. if (info1.IsSelectedVisaInfo)
  17314. {
  17315. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  17316. }
  17317. //送签
  17318. if (info1.IsSelectedSendVisa)
  17319. {
  17320. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  17321. }
  17322. //出签
  17323. if (info1.IsSelectedIssueVisa)
  17324. {
  17325. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  17326. }
  17327. //机票
  17328. if (info1.IsSelectedAirTicket)
  17329. {
  17330. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  17331. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  17332. }
  17333. //酒店
  17334. if (info1.IsSelectedHotel)
  17335. {
  17336. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  17337. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  17338. }
  17339. //开行前会
  17340. if (info1.IsSelectedPreTripMeeting)
  17341. {
  17342. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  17343. }
  17344. //送机
  17345. if (info1.IsSelectedAirportdDropOff)
  17346. {
  17347. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  17348. }
  17349. builder.EndTable();
  17350. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  17351. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  17352. for (int i = 0; i < table.Rows.Count; i++)
  17353. {
  17354. var row = table.Rows[i];
  17355. //设置宽度
  17356. row.Cells[0].CellFormat.Width = 20.00;
  17357. row.Cells[1].CellFormat.Width = 30.00;
  17358. row.Cells[2].CellFormat.Width = 50.00;
  17359. if (i != 0)
  17360. {
  17361. //边框设置
  17362. InvertedListFileDownloadSetBorders(row.Cells, 0);
  17363. InvertedListFileDownloadSetBorders(row.Cells, 1);
  17364. InvertedListFileDownloadSetBorders(row.Cells, 2);
  17365. }
  17366. }
  17367. #region 页脚插入图片
  17368. // 创建页脚
  17369. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  17370. doc.FirstSection.HeadersFooters.Add(footer);
  17371. Paragraph para = new Paragraph(doc);
  17372. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  17373. footer.AppendChild(para);
  17374. builder.MoveTo(para);
  17375. string imagePath = "./Images/FMGJ_Log.png";
  17376. builder.InsertImage(imagePath);
  17377. #endregion
  17378. #endregion
  17379. var fileDir = AppSettingsHelper.Get("WordBasePath");
  17380. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  17381. string filePath = fileDir + $@"InvertedList/{fileName}";
  17382. doc.Save(filePath);
  17383. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  17384. return Ok(JsonView(true, "操作成功!", Url));
  17385. }
  17386. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime,string content,string reamrk)
  17387. {
  17388. var fontColor = Color.FromArgb(64, 64, 64);
  17389. builder.InsertCell();
  17390. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  17391. builder.RowFormat.Height = 40;
  17392. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17393. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17394. builder.Font.Name = fontName;
  17395. builder.Font.Size = 8;
  17396. builder.Font.Bold = true;
  17397. builder.Font.Color = fontColor;
  17398. builder.Write(dateTime);
  17399. builder.InsertCell();
  17400. builder.Font.Size = 9;
  17401. builder.Font.Bold = true;
  17402. builder.Font.Color = fontColor;
  17403. builder.Write(content);
  17404. builder.InsertCell();
  17405. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17406. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17407. builder.Font.Size = 9;
  17408. builder.Font.Bold = false;
  17409. builder.Font.Color = fontColor;
  17410. builder.Write(reamrk);
  17411. builder.EndRow();
  17412. }
  17413. private void InvertedListFileDownloadSetBorders(CellCollection cell,int index)
  17414. {
  17415. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  17416. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  17417. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  17418. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  17419. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  17420. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  17421. }
  17422. #endregion
  17423. #region 会务倒推表
  17424. /// <summary>
  17425. /// 会务倒推表
  17426. /// Init
  17427. /// </summary>
  17428. /// <returns></returns>
  17429. [HttpPost]
  17430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17431. public async Task<IActionResult> InforRetrogressTableInit()
  17432. {
  17433. var groupData = await _groupRepository.PostShareGroupInfos(1);
  17434. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  17435. return Ok(JsonView(false, groupData.Msg));
  17436. }
  17437. /// <summary>
  17438. /// 会务倒推表
  17439. /// ExcelDownload
  17440. /// </summary>
  17441. /// <param name="dto"></param>
  17442. /// <returns></returns>
  17443. [HttpPost]
  17444. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  17445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17446. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  17447. {
  17448. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  17449. var validatorRes = await validator.ValidateAsync(dto);
  17450. if (!validatorRes.IsValid)
  17451. {
  17452. StringBuilder sb = new StringBuilder();
  17453. foreach (var item in validatorRes.Errors)
  17454. {
  17455. sb.AppendLine(item.ErrorMessage);
  17456. }
  17457. return Ok(JsonView(false, sb.ToString()));
  17458. }
  17459. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  17460. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  17461. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  17462. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  17463. #region Excel
  17464. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  17465. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  17466. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  17467. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  17468. var fileNamePrefix = string.Empty;
  17469. if (days >= 30)
  17470. {
  17471. tempPath += $"会务工作倒推进度表(30天).xlsx";
  17472. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  17473. }
  17474. else if (days < 30 && days > 7)
  17475. {
  17476. tempPath += $"会务工作倒推进度表(15天).xlsx";
  17477. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  17478. }
  17479. else if (days <= 7)
  17480. {
  17481. tempPath += $"会务工作倒推进度表(7天).xlsx";
  17482. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  17483. }
  17484. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  17485. fileName = CommonFun.ValidFileName(fileName);
  17486. //载入模板
  17487. WorkbookDesigner designer = new WorkbookDesigner();
  17488. designer.Workbook = new Workbook(tempPath);
  17489. designer.Process();
  17490. if (!Directory.Exists(savePath))
  17491. {
  17492. Directory.CreateDirectory(savePath);
  17493. }
  17494. string serverPath = $"{savePath}{fileName}";
  17495. designer.Workbook.Save(serverPath);
  17496. string rst = $"{servicePath}{ftpPath}{fileName}";
  17497. #endregion
  17498. return Ok(JsonView(new { url = rst }));
  17499. }
  17500. #endregion
  17501. #region 三公签证费用(签证费、代办费)
  17502. /// <summary>
  17503. /// 三公签证费用(签证费、代办费)
  17504. /// List
  17505. /// </summary>
  17506. /// <returns></returns>
  17507. [HttpPost]
  17508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17509. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  17510. {
  17511. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  17512. if (_view.Code != 0)
  17513. {
  17514. return Ok(JsonView(false, _view.Msg));
  17515. }
  17516. return Ok(JsonView(true, "操作成功!", _view.Data));
  17517. }
  17518. /// <summary>
  17519. /// 三公签证费用(签证费、代办费)
  17520. /// Add Or Update
  17521. /// </summary>
  17522. /// <returns></returns>
  17523. [HttpPost]
  17524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17525. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  17526. {
  17527. var _view = await _visaFeeInfoRep._Update(_dto);
  17528. if (_view.Code != 0)
  17529. {
  17530. return Ok(JsonView(false, _view.Msg));
  17531. }
  17532. return Ok(JsonView(true, _view.Msg));
  17533. }
  17534. #endregion
  17535. #region 酒店询价
  17536. /// <summary>
  17537. /// 酒店询价
  17538. /// Init
  17539. /// </summary>
  17540. /// <returns></returns>
  17541. [HttpPost]
  17542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17543. public async Task<IActionResult> PostHotelInquiryInit()
  17544. {
  17545. var res = await _hotelInquiryRep._Init();
  17546. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17547. return Ok(JsonView(true, res.Msg, res.Data));
  17548. }
  17549. /// <summary>
  17550. /// 酒店询价
  17551. /// page Item
  17552. /// </summary>
  17553. /// <param name="_dto"></param>
  17554. /// <returns></returns>
  17555. [HttpPost]
  17556. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17557. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  17558. {
  17559. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  17560. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17561. var view = res.Data as PageDataViewBase;
  17562. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  17563. }
  17564. /// <summary>
  17565. /// 酒店询价
  17566. /// info
  17567. /// </summary>
  17568. /// <param name="_dto"></param>
  17569. /// <returns></returns>
  17570. [HttpPost]
  17571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17572. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  17573. {
  17574. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  17575. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17576. return Ok(JsonView(true, res.Msg, res.Data));
  17577. }
  17578. /// <summary>
  17579. /// 酒店询价
  17580. /// Add Or Edit
  17581. /// </summary>
  17582. /// <param name="_dto"></param>
  17583. /// <returns></returns>
  17584. [HttpPost]
  17585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17586. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  17587. {
  17588. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  17589. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17590. return Ok(JsonView(true, res.Msg, res.Data));
  17591. }
  17592. /// <summary>
  17593. /// 酒店询价
  17594. /// Del
  17595. /// </summary>
  17596. /// <param name="_dto"></param>
  17597. /// <returns></returns>
  17598. [HttpPost]
  17599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17600. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  17601. {
  17602. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  17603. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17604. return Ok(JsonView(true, res.Msg, res.Data));
  17605. }
  17606. #endregion
  17607. #region 下载匹配op行程单
  17608. /// <summary>
  17609. /// 匹配op行程单
  17610. /// Init
  17611. /// </summary>
  17612. /// <param name="dto">团组列表请求dto</param>
  17613. /// <returns></returns>
  17614. [HttpPost]
  17615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17616. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  17617. {
  17618. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17619. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  17620. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  17621. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  17622. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  17623. .Where(it => it.IsDel == 0)
  17624. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  17625. .OrderByDescending(it => it.VisitStartDate)
  17626. .ToList();
  17627. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  17628. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17629. var diids = groupInfos.Select(it => it.Id).ToList();
  17630. List<string> countrys = new List<string>();
  17631. foreach (var item in country)
  17632. {
  17633. var data = _groupRepository.FormartTeamName(item);
  17634. var dataArray = _groupRepository.GroupSplitCountry(data);
  17635. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17636. }
  17637. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  17638. List<string> areaArray = new List<string>(); //GetGroupCityLine
  17639. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  17640. foreach (var item in areaItem)
  17641. {
  17642. string areaStr = item.Value;
  17643. if (!string.IsNullOrEmpty(areaStr))
  17644. {
  17645. string[] str1 = areaStr.Split("-");
  17646. if (str1.Length > 0)
  17647. {
  17648. areaArray.AddRange(str1);
  17649. }
  17650. }
  17651. }
  17652. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  17653. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  17654. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  17655. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  17656. .ToList();
  17657. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  17658. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  17659. .Where(it => countriesIds.Contains(it.Id))
  17660. .Select(it => new { it.Id, Name = it.Name_CN })
  17661. .ToList();
  17662. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  17663. .Select(it => it.TeamName).ToList();
  17664. stopwatch.Stop();
  17665. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  17666. }
  17667. ///// <summary>
  17668. ///// 匹配op行程单
  17669. ///// Init 查询区域数据
  17670. ///// </summary>
  17671. ///// <param name="dto">团组列表请求dto</param>
  17672. ///// <returns></returns>
  17673. //[HttpPost]
  17674. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17675. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  17676. //{
  17677. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17678. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  17679. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  17680. // if (string.IsNullOrEmpty(countriesDataStr))
  17681. // {
  17682. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  17683. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  17684. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  17685. // }
  17686. // else
  17687. // {
  17688. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  17689. // }
  17690. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  17691. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  17692. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  17693. // List<dynamic> childList = new List<dynamic>();
  17694. // int parentId = dto.CountriesId;
  17695. // if (provinceData.Count > 1)
  17696. // {
  17697. // foreach (var item1 in provinceData)
  17698. // {
  17699. // List<dynamic> childList1 = new List<dynamic>();
  17700. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  17701. // foreach (var item2 in citiesData1)
  17702. // {
  17703. // List<dynamic> childList2 = new List<dynamic>();
  17704. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17705. // foreach (var item3 in countiesData1)
  17706. // {
  17707. // childList2.Add(new
  17708. // {
  17709. // id = item3.Id,
  17710. // parentId = item2.Id,
  17711. // level = "district",
  17712. // name = item3.Name_CN,
  17713. // });
  17714. // }
  17715. // childList1.Add(new
  17716. // {
  17717. // id = item2.Id,
  17718. // parentId = item1.Id,
  17719. // level = "city",
  17720. // name = item2.Name_CN,
  17721. // childList = childList2
  17722. // });
  17723. // }
  17724. // childList.Add(new
  17725. // {
  17726. // id = item1.Id,
  17727. // parentId = parentId,
  17728. // level = "province",
  17729. // name = item1.Name_CN,
  17730. // childList = childList1
  17731. // });
  17732. // }
  17733. // //城市
  17734. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  17735. // foreach (var item2 in citiesData2)
  17736. // {
  17737. // List<dynamic> childList22 = new List<dynamic>();
  17738. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17739. // foreach (var item3 in countiesData1)
  17740. // {
  17741. // childList22.Add(new
  17742. // {
  17743. // id = item3.Id,
  17744. // parentId = item2.Id,
  17745. // level = "district",
  17746. // name = item3.Name_CN,
  17747. // });
  17748. // }
  17749. // childList.Add(new
  17750. // {
  17751. // id = item2.Id,
  17752. // parentId = parentId,
  17753. // level = "city",
  17754. // name = item2.Name_CN,
  17755. // childList = childList22
  17756. // });
  17757. // }
  17758. // }
  17759. // else
  17760. // {
  17761. // foreach (var item2 in citiesData)
  17762. // {
  17763. // string cname = item2.Name_CN;
  17764. // List<dynamic> childList1 = new List<dynamic>();
  17765. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17766. // foreach (var item3 in countiesData1)
  17767. // {
  17768. // childList1.Add(new
  17769. // {
  17770. // Id = item3.Id,
  17771. // parentId = item2.Id,
  17772. // level = "district",
  17773. // name = item3.Name_CN
  17774. // });
  17775. // }
  17776. // childList.Add(new
  17777. // {
  17778. // id = item2.Id,
  17779. // parentId = parentId,
  17780. // level = "city",
  17781. // name = item2.Name_CN,
  17782. // childList = childList1
  17783. // });
  17784. // }
  17785. // }
  17786. // stopwatch.Stop();
  17787. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  17788. //}
  17789. /// <summary>
  17790. /// 匹配op行程单
  17791. /// 接团信息列表 Page
  17792. /// </summary>
  17793. /// <param name="dto">团组列表请求dto</param>
  17794. /// <returns></returns>
  17795. [HttpPost]
  17796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17797. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  17798. {
  17799. var swatch = new Stopwatch();
  17800. swatch.Start();
  17801. #region 参数验证
  17802. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17803. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17804. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17805. #region 页面操作权限验证
  17806. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17807. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  17808. #endregion
  17809. #endregion
  17810. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17811. {
  17812. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  17813. //string sqlWhere = "";
  17814. if (!string.IsNullOrEmpty(dto.Country))
  17815. {
  17816. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  17817. }
  17818. if (!string.IsNullOrEmpty(dto.Area))
  17819. {
  17820. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  17821. }
  17822. if (!string.IsNullOrEmpty(dto.TeamName))
  17823. {
  17824. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  17825. }
  17826. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  17827. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  17828. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  17829. swatch.Stop();
  17830. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  17831. }
  17832. else
  17833. {
  17834. return Ok(JsonView(false, "查询失败"));
  17835. }
  17836. }
  17837. /// <summary>
  17838. /// 匹配op行程单
  17839. /// 行程单下载
  17840. /// </summary>
  17841. /// <param name="dto">团组列表请求dto</param>
  17842. /// <returns></returns>
  17843. [HttpPost]
  17844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17845. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  17846. {
  17847. #region 参数验证
  17848. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17849. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17850. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17851. #region 页面操作权限验证
  17852. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17853. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  17854. #endregion
  17855. #endregion
  17856. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17857. {
  17858. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  17859. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  17860. }
  17861. else
  17862. {
  17863. return Ok(JsonView(false, "下载失败!"));
  17864. }
  17865. }
  17866. #endregion
  17867. #region 国家信息 数据 注释
  17868. //[HttpPost]
  17869. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  17870. //{
  17871. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  17872. // foreach (var item in dto)
  17873. // {
  17874. // infos.Add(new Grp_GroupsTaskAssignment()
  17875. // {
  17876. // DIId = item,
  17877. // CTId = 82,
  17878. // UId = 248,
  17879. // IsEnable = 1,
  17880. // CreateUserId = 233,
  17881. // CreateTime = DateTime.Now,
  17882. // IsDel = 0
  17883. // });
  17884. // infos.Add(new Grp_GroupsTaskAssignment()
  17885. // {
  17886. // DIId = item,
  17887. // CTId = 82,
  17888. // UId = 286,
  17889. // IsEnable = 1,
  17890. // CreateUserId = 233,
  17891. // CreateTime = DateTime.Now,
  17892. // IsDel = 0
  17893. // });
  17894. // }
  17895. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  17896. // return Ok("操作成功");
  17897. //}
  17898. //public class paramJsonDto
  17899. //{
  17900. // public List<CountriesInfo> str { get; set; }
  17901. //}
  17902. //[HttpPost]
  17903. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  17904. //{
  17905. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  17906. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  17907. // List<Sys_Cities> cities = new List<Sys_Cities>();
  17908. // List<Sys_Cities> districts = new List<Sys_Cities>();
  17909. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17910. // _sqlSugar.BeginTran();
  17911. // int countitiesIndex = 0;
  17912. // foreach (var item in dto.str)
  17913. // {
  17914. // dynamic data = item.c;
  17915. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  17916. // if (data != null)
  17917. // {
  17918. // countitiesIndex++;
  17919. // foreach (var item1 in data)
  17920. // {
  17921. // string cnname = item1.cn;
  17922. // string enname = item1.en;
  17923. // Sys_Cities provinceInfo = new Sys_Cities()
  17924. // {
  17925. // CountriesId = countriesId,
  17926. // Name_CN = cnname,
  17927. // Name_EN = enname,
  17928. // ParentId = 0,
  17929. // IsCapital = 1,
  17930. // CreateUserId = 208,
  17931. // CreateTime = DateTime.Now,
  17932. // IsDel = 0
  17933. // };
  17934. // if (item1.lv == "province") //省份
  17935. // {
  17936. // provinceInfo.Level = 1;
  17937. // int provinceId = 0;
  17938. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  17939. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  17940. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17941. // var data1 = item1.c;
  17942. // foreach (var item2 in data1)
  17943. // {
  17944. // if (item2.lv == "city")
  17945. // {
  17946. // string citycnname = item2.cn;
  17947. // string cityenname = item2.en;
  17948. // Sys_Cities cityInfo = new Sys_Cities()
  17949. // {
  17950. // CountriesId = countriesId,
  17951. // ParentId = provinceId,
  17952. // Level = 2,
  17953. // Name_CN = citycnname,
  17954. // Name_EN = cityenname,
  17955. // IsCapital = 1,
  17956. // CreateUserId = 208,
  17957. // CreateTime = DateTime.Now,
  17958. // IsDel = 0
  17959. // };
  17960. // if (item2.c != null)
  17961. // {
  17962. // int cityId = 0;
  17963. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  17964. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17965. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  17966. // foreach (var item3 in item2.c)
  17967. // {
  17968. // if (item3.lv == "district")
  17969. // {
  17970. // var districtInfo = new Sys_Cities()
  17971. // {
  17972. // CountriesId = countriesId,
  17973. // Name_CN = item3.cn,
  17974. // Name_EN = item3.en,
  17975. // Level = 3,
  17976. // ParentId = cityId,
  17977. // IsCapital = 1,
  17978. // CreateUserId = 208,
  17979. // CreateTime = DateTime.Now,
  17980. // IsDel = 0
  17981. // };
  17982. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17983. // //{
  17984. // districts.Add(districtInfo);
  17985. // //}
  17986. // }
  17987. // }
  17988. // }
  17989. // else
  17990. // {
  17991. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  17992. // //{
  17993. // cities.Add(cityInfo);
  17994. // //}
  17995. // }
  17996. // }
  17997. // }
  17998. // }
  17999. // else if (item1.lv == "city")//城市
  18000. // {
  18001. // provinceInfo.Level = 2;
  18002. // if (item1.c != null)
  18003. // {
  18004. // int cityId = 0;
  18005. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  18006. // if (citiesInfo != null) cityId = citiesInfo.Id;
  18007. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  18008. // foreach (var item3 in item1.c)
  18009. // {
  18010. // if (item3.lv == "district")
  18011. // {
  18012. // var districtInfo = new Sys_Cities()
  18013. // {
  18014. // CountriesId = countriesId,
  18015. // Name_CN = item3.cn,
  18016. // Name_EN = item3.en,
  18017. // Level = 3,
  18018. // ParentId = cityId,
  18019. // IsCapital = 1,
  18020. // CreateUserId = 208,
  18021. // CreateTime = DateTime.Now,
  18022. // IsDel = 0
  18023. // };
  18024. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  18025. // //{
  18026. // districts.Add(districtInfo);
  18027. // //}
  18028. // }
  18029. // }
  18030. // }
  18031. // else
  18032. // {
  18033. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  18034. // //{
  18035. // cities.Add(provinceInfo);
  18036. // //}
  18037. // }
  18038. // }
  18039. // }
  18040. // }
  18041. // }
  18042. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  18043. // cities = cities.Distinct().ToList();
  18044. // districts = districts.Distinct().ToList();
  18045. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  18046. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  18047. // cities.AddRange(districts);
  18048. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  18049. // //_sqlSugar.RollbackTran();
  18050. // _sqlSugar.CommitTran();
  18051. // return Ok(JsonView(false, "操作成功!"));
  18052. //}
  18053. //[HttpPost]
  18054. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  18055. //{
  18056. // List<CountitiesInfo> infos = dto.MyProperty;
  18057. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  18058. // _sqlSugar.BeginTran();
  18059. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  18060. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  18061. // foreach (var item in infos)
  18062. // {
  18063. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  18064. // if (countryInfo != null)
  18065. // {
  18066. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  18067. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  18068. // if (cityInfo1 != null)
  18069. // {
  18070. // cityInfo1.IsCapital = 0;
  18071. // cityInfos.Add(cityInfo1);
  18072. // }
  18073. // }
  18074. // }
  18075. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  18076. // .UpdateColumns(it => it.IsCapital)
  18077. // .WhereColumns(it => it.Id)
  18078. // .ExecuteCommand();
  18079. // //_sqlSugar.RollbackTran();
  18080. // _sqlSugar.CommitTran();
  18081. // return Ok(JsonView(false, "操作成功!"));
  18082. //}
  18083. //public class CounrtiesDto
  18084. //{
  18085. // public List<CountitiesInfo> MyProperty { get; set; }
  18086. //}
  18087. //public class CountitiesInfo
  18088. //{
  18089. // /// <summary>
  18090. // /// 圣约翰
  18091. // /// </summary>
  18092. // public string capital_name_chinese { get; set; }
  18093. // /// <summary>
  18094. // ///
  18095. // /// </summary>
  18096. // public string capital_name { get; set; }
  18097. // /// <summary>
  18098. // ///
  18099. // /// </summary>
  18100. // public string country_type { get; set; }
  18101. // /// <summary>
  18102. // /// 安提瓜和巴布达
  18103. // /// </summary>
  18104. // public string country_name_chinese { get; set; }
  18105. // /// <summary>
  18106. // /// 安提瓜和巴布达
  18107. // /// </summary>
  18108. // public string country_name_chinese_short { get; set; }
  18109. // /// <summary>
  18110. // /// 安提瓜和巴布达
  18111. // /// </summary>
  18112. // public string country_name_chinese_UN { get; set; }
  18113. // /// <summary>
  18114. // ///
  18115. // /// </summary>
  18116. // public string country_name_english_abbreviation { get; set; }
  18117. // /// <summary>
  18118. // ///
  18119. // /// </summary>
  18120. // public string country_name_english_formal { get; set; }
  18121. // /// <summary>
  18122. // ///
  18123. // /// </summary>
  18124. // public string country_name_english_UN { get; set; }
  18125. // /// <summary>
  18126. // ///
  18127. // /// </summary>
  18128. // public string continent_name { get; set; }
  18129. // /// <summary>
  18130. // ///
  18131. // /// </summary>
  18132. // public string subregion_name { get; set; }
  18133. // /// <summary>
  18134. // ///
  18135. // /// </summary>
  18136. // public string country_code2 { get; set; }
  18137. // /// <summary>
  18138. // ///
  18139. // /// </summary>
  18140. // public string country_code3 { get; set; }
  18141. // /// <summary>
  18142. // ///
  18143. // /// </summary>
  18144. // public string phone_code { get; set; }
  18145. //}
  18146. //public class CountriesInfo : BasicInfo
  18147. //{
  18148. // public List<CitiesInfo> c { get; set; }
  18149. //}
  18150. //public class CitiesInfo : BasicInfo
  18151. //{
  18152. // public List<AreaInfo> c { get; set; }
  18153. //}
  18154. //public class AreaInfo : BasicInfo
  18155. //{
  18156. // public List<AreaInfo> c { get; set; }
  18157. //}
  18158. //public class BasicInfo
  18159. //{
  18160. // public string code { get; set; }
  18161. // public string cn { get; set; }
  18162. // public string lv { get; set; }
  18163. // public string en { get; set; }
  18164. //}
  18165. #endregion
  18166. #region 查看邀请方
  18167. /// <summary>
  18168. /// 查看邀请方
  18169. /// 邀请方信息 Init
  18170. /// </summary>
  18171. /// <param name="dto"></param>
  18172. /// <returns></returns>
  18173. [HttpPost]
  18174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18175. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  18176. {
  18177. string sqlWhere = string.Empty;
  18178. if (!string.IsNullOrEmpty(dto.Search))
  18179. {
  18180. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  18181. }
  18182. string sql = string.Format($@"Select
  18183. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  18184. Id,
  18185. UnitName
  18186. From Res_InvitationOfficialActivityData
  18187. Where IsDel = 0
  18188. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  18189. RefAsync<int> total = 0;
  18190. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18191. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  18192. }
  18193. /// <summary>
  18194. /// 查看邀请方
  18195. /// 国家信息 Init
  18196. /// </summary>
  18197. /// <param name="dto"></param>
  18198. /// <returns></returns>
  18199. [HttpPost]
  18200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18201. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  18202. {
  18203. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  18204. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  18205. var diids = groupInfos.Select(it => it.Id).ToList();
  18206. List<string> countrys = new List<string>();
  18207. foreach (var item in country)
  18208. {
  18209. var data = _groupRepository.FormartTeamName(item);
  18210. var dataArray = _groupRepository.GroupSplitCountry(data);
  18211. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  18212. }
  18213. countrys = countrys.Distinct().ToList();
  18214. for (int i = 0; i < countrys.Count; i++)
  18215. {
  18216. string item = countrys[i];
  18217. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  18218. {
  18219. countrys.Remove(item);
  18220. i--;
  18221. }
  18222. }
  18223. RefAsync<int> total = 0;
  18224. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  18225. .Where(it => countrys.Contains(it.Name_CN))
  18226. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18227. .Select(it => new { id = it.Id, name = it.Name_CN })
  18228. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18229. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18230. }
  18231. /// <summary>
  18232. /// 查看邀请方
  18233. /// 城市信息 Init
  18234. /// </summary>
  18235. /// <param name="dto"></param>
  18236. /// <returns></returns>
  18237. [HttpPost]
  18238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18239. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  18240. {
  18241. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  18242. RefAsync<int> total = 0;
  18243. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  18244. .Where(it => it.CountriesId == dto.CountiesId)
  18245. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18246. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  18247. .Select(it => new { id = it.Id, name = it.Name_CN })
  18248. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18249. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18250. }
  18251. /// <summary>
  18252. /// 查看邀请方
  18253. /// 团组名称 Init
  18254. /// </summary>
  18255. /// <param name="dto"></param>
  18256. /// <returns></returns>
  18257. [HttpPost]
  18258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18259. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  18260. {
  18261. var watch = new Stopwatch();
  18262. watch.Start();
  18263. RefAsync<int> total = 0;
  18264. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  18265. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  18266. .Where((oa, di) => oa.IsDel == 0)
  18267. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  18268. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  18269. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  18270. .Distinct()
  18271. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18272. watch.Stop();
  18273. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  18274. }
  18275. /// <summary>
  18276. /// 查看邀请方
  18277. /// 团组 & 邀请方信息
  18278. /// </summary>
  18279. /// <param name="dto"></param>
  18280. /// <returns></returns>
  18281. [HttpPost]
  18282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18283. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  18284. {
  18285. var watch = new Stopwatch();
  18286. watch.Start();
  18287. RefAsync<int> total = 0;
  18288. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  18289. .AS("Grp_DelegationInfo")
  18290. .Includes(x => x.InvitingInfos)
  18291. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  18292. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  18293. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  18294. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  18295. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  18296. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  18297. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18298. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  18299. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  18300. infos.ForEach(x =>
  18301. {
  18302. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  18303. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  18304. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  18305. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  18306. });
  18307. watch.Stop();
  18308. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  18309. }
  18310. #endregion
  18311. #region 报批行程
  18312. /// <summary>
  18313. /// 报批行程初始化
  18314. /// </summary>
  18315. /// <param name="dto"></param>
  18316. /// <returns></returns>
  18317. [HttpPost]
  18318. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  18319. {
  18320. const int chiNumber = 5;
  18321. var jw = JsonView(false);
  18322. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  18323. var group = groupList.First();
  18324. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  18325. group = groupList.First(x => x.Id == diid);
  18326. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18327. .Where(x => x.DiId == diid && x.IsDel == 0)
  18328. .ToArray();
  18329. var count = 1;
  18330. foreach (var item in blackCodeList)
  18331. {
  18332. if (string.IsNullOrWhiteSpace(item.Title))
  18333. {
  18334. item.Title = "未设置名称数据" + count;
  18335. }
  18336. count++;
  18337. };
  18338. if (group == null)
  18339. {
  18340. jw.Msg = "暂无团组!";
  18341. return Ok(jw);
  18342. }
  18343. var data = new
  18344. {
  18345. groupList = groupList.Select(x => new
  18346. {
  18347. x.TeamName,
  18348. x.Id
  18349. }),
  18350. content = new ArrayList(),
  18351. groupInfo = new
  18352. {
  18353. group.VisitDays,
  18354. group.TourCode,
  18355. group.VisitPNumber,
  18356. group.TeamName,
  18357. group.Id,
  18358. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  18359. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  18360. },
  18361. blackCodeList = blackCodeList.Select(x => new
  18362. {
  18363. x.Title,
  18364. x.Id
  18365. }),
  18366. FileTempList = new ArrayList()
  18367. {
  18368. new { Index = 1,FileName = "旧模板" },
  18369. new { Index = 2,FileName = "省外办" },
  18370. new { Index = 3,FileName = "市外办" },
  18371. }
  18372. };
  18373. var resultArr = new ArrayList();
  18374. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  18375. #region 默认不生成行程
  18376. //if (content.Count == 0)
  18377. //{
  18378. // var stay = "-";
  18379. // var cityPath = "-";
  18380. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18381. // .Where(x => x.DiId == diid && x.IsDel == 0)
  18382. // .ToList();
  18383. // //添加城市路径以及住宿地
  18384. // //黑屏代码数据
  18385. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  18386. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18387. // {
  18388. // jw = JsonView(true, "黑屏代码有误!", data);
  18389. // return Ok(jw);
  18390. // }
  18391. // data = data with
  18392. // {
  18393. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  18394. // {
  18395. // x.Title,
  18396. // x.Id,
  18397. // }).ToArray())
  18398. // };
  18399. // foreach (DataRow row in dtBlack.Rows)
  18400. // {
  18401. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18402. // {
  18403. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  18404. // return Ok(jw);
  18405. // }
  18406. // }
  18407. // //黑屏代码获取时间区间
  18408. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18409. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18410. // _sqlSugar.BeginTran();
  18411. // for (int i = 0; i < timeArr.Count; i++)
  18412. // {
  18413. // stay = "-";
  18414. // cityPath = "-";
  18415. // DateTime NewData = DateTime.Parse(timeArr[i]);
  18416. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18417. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18418. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18419. // if (tbSelect.Length > 0)
  18420. // {
  18421. // List<string> threeCodeStr = new List<string>();
  18422. // foreach (var item in tbSelect)
  18423. // {
  18424. // var threeCode = item["Three"].ToString() ?? "";
  18425. // if (threeCode.Length == 6)
  18426. // {
  18427. // var start = threeCode.Substring(0, 3);
  18428. // var end = threeCode.Substring(3, 3);
  18429. // if (threeCodeStr.Count == 0)
  18430. // {
  18431. // threeCodeStr.Add(start);
  18432. // threeCodeStr.Add(end);
  18433. // }
  18434. // else
  18435. // {
  18436. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18437. // {
  18438. // threeCodeStr.Add(end);
  18439. // }
  18440. // else
  18441. // {
  18442. // threeCodeStr.Add(start);
  18443. // threeCodeStr.Add(end);
  18444. // }
  18445. // }
  18446. // }
  18447. // }
  18448. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18449. // var last = threeCodeStr.Last();
  18450. // foreach (var item in threeCodeStr)
  18451. // {
  18452. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18453. // if (item.Equals(last))
  18454. // {
  18455. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18456. // }
  18457. // }
  18458. // cityPath = cityPath.Trim('-');
  18459. // }
  18460. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  18461. // appro.Diid = diid ?? -1;
  18462. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18463. // appro.Id = thisId;
  18464. // appro.CreateUserId = dto.UserId;
  18465. // appro.CreateTime = DateTime.Now;
  18466. // content.Add(appro);
  18467. // }
  18468. // _sqlSugar.CommitTran();
  18469. //}
  18470. #endregion
  18471. foreach (var x in content)
  18472. {
  18473. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  18474. if (chiList.Count < chiNumber)
  18475. {
  18476. for (int i = chiList.Count; i < chiNumber; i++)
  18477. {
  18478. chiList.Add(new Grp_ApprovalTravelDetails());
  18479. }
  18480. }
  18481. resultArr.Add(new
  18482. {
  18483. x.Id,
  18484. x.Date,
  18485. x.Diid,
  18486. chiList = chiList.Select(x1 => new
  18487. {
  18488. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18489. x1.Details,
  18490. x1.ParentId,
  18491. x1.Id
  18492. })
  18493. });
  18494. }
  18495. data = data with
  18496. {
  18497. content = resultArr,
  18498. };
  18499. jw = JsonView(true, "获取成功!", data);
  18500. return Ok(jw);
  18501. }
  18502. /// <summary>
  18503. /// 报批行程删除
  18504. /// </summary>
  18505. /// <param name="dto"></param>
  18506. /// <returns></returns>
  18507. [HttpPost]
  18508. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  18509. {
  18510. var jw = JsonView(false);
  18511. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18512. if (group == null)
  18513. {
  18514. jw.Msg = "团组参数有误!";
  18515. return Ok(jw);
  18516. }
  18517. try
  18518. {
  18519. _sqlSugar.BeginTran();
  18520. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  18521. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  18522. {
  18523. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18524. DeleteUserId = dto.uesrId,
  18525. IsDel = 1
  18526. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  18527. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  18528. {
  18529. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18530. DeleteUserId = dto.uesrId,
  18531. IsDel = 1
  18532. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  18533. _sqlSugar.CommitTran();
  18534. jw = JsonView(true, "删除成功");
  18535. }
  18536. catch (Exception ex)
  18537. {
  18538. jw = JsonView(false, ex.Message);
  18539. }
  18540. return Ok(jw);
  18541. }
  18542. /// <summary>
  18543. /// 报批行程保存
  18544. /// </summary>
  18545. /// <param name="dto"></param>
  18546. /// <returns></returns>
  18547. [HttpPost]
  18548. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  18549. {
  18550. var jw = JsonView(false);
  18551. var Find = dto.Arr.Find(x => x.id == 0);
  18552. if (Find != null)
  18553. {
  18554. jw.Msg = "生成的ID为0!";
  18555. return Ok(jw);
  18556. }
  18557. foreach (var item in dto.Arr)
  18558. {
  18559. foreach (var chi in item.chiList)
  18560. {
  18561. if (chi.parentId == 0)
  18562. {
  18563. chi.parentId = item.id;
  18564. }
  18565. }
  18566. }
  18567. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  18568. _sqlSugar.BeginTran();
  18569. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  18570. {
  18571. var parentIds = dto.Arr.Select(x => x.id).ToList();
  18572. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  18573. {
  18574. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18575. DeleteUserId = dto.UserId,
  18576. IsDel = 1
  18577. }).ExecuteCommand();
  18578. }
  18579. try
  18580. {
  18581. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  18582. {
  18583. CreateTime = DateTime.Now,
  18584. CreateUserId = dto.UserId,
  18585. Details = x.details,
  18586. ParentId = x.parentId,
  18587. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18588. Remark = "",
  18589. IsDel = 0
  18590. }).ToList()).ExecuteCommand();
  18591. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  18592. {
  18593. Id = x.id,
  18594. Details = x.details,
  18595. ParentId = x.parentId,
  18596. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18597. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  18598. {
  18599. Details = x.Details,
  18600. ParentId = x.ParentId,
  18601. Time = x.Time
  18602. }).ExecuteCommand();
  18603. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  18604. {
  18605. Id = x.id,
  18606. Date = x.date,
  18607. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  18608. {
  18609. Date = x.Date
  18610. }).ExecuteCommand();
  18611. _sqlSugar.CommitTran();
  18612. jw = JsonView(true, "保存成功!");
  18613. }
  18614. catch (Exception ex)
  18615. {
  18616. _sqlSugar.RollbackTran();
  18617. jw = JsonView(false, "保存失败!" + ex.Message);
  18618. }
  18619. return Ok(jw);
  18620. }
  18621. /// <summary>
  18622. /// 报批行程生成
  18623. /// </summary>
  18624. /// <param name="dto"></param>
  18625. /// <returns></returns>
  18626. [HttpPost]
  18627. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  18628. {
  18629. var jw = JsonView(false);
  18630. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18631. if (group == null)
  18632. {
  18633. jw.Msg = "暂无该团组!";
  18634. return Ok(jw);
  18635. }
  18636. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  18637. //黑屏代码数据
  18638. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  18639. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18640. {
  18641. jw.Msg = "黑屏代码有误!";
  18642. return Ok(jw);
  18643. }
  18644. foreach (DataRow row in dtBlack.Rows)
  18645. {
  18646. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18647. {
  18648. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  18649. return Ok(jw);
  18650. }
  18651. }
  18652. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  18653. var resultArr = new ArrayList();
  18654. //if (officialActivitiesArr.Count == 0)
  18655. //{
  18656. // jw.Msg = "暂无公务出访信息!";
  18657. // return Ok(jw);
  18658. //}
  18659. try
  18660. {
  18661. _sqlSugar.BeginTran();
  18662. DeleteApprovalJourney(new
  18663. Domain.Dtos.Groups.DeleteApprovalJourney
  18664. {
  18665. Diid = dto.Diid,
  18666. uesrId = dto.Userid
  18667. });
  18668. var stay = "-";
  18669. var cityPath = "-";
  18670. //添加城市路径以及住宿地
  18671. //黑屏代码获取时间区间
  18672. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18673. var empty = "【未收入该三字码!请机票同事录入】";
  18674. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18675. for (int i = 0; i < timeArr.Count; i++)
  18676. {
  18677. stay = "-";
  18678. cityPath = "-";
  18679. var chiarr = new List<Grp_ApprovalTravelDetails>();
  18680. DateTime NewData = DateTime.Parse(timeArr[i]);
  18681. //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();
  18682. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18683. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  18684. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  18685. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  18686. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  18687. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  18688. if (tbSelect.Length > 0)
  18689. {
  18690. List<string> threeCodeStr = new List<string>();
  18691. bool isTrade = false;
  18692. string trip = string.Empty;
  18693. var rowLast = tbSelect.Last();
  18694. var rowFirst = tbSelect.First();
  18695. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  18696. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  18697. var takeOffTime = DateTime.Parse(timeArr[i]);
  18698. var fallToTime = DateTime.Parse(timeArr[i]);
  18699. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  18700. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  18701. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  18702. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  18703. foreach (var item in tbSelect)
  18704. {
  18705. var start = string.Empty;
  18706. var end = string.Empty;
  18707. var threeCode = item["Three"].ToString() ?? "";
  18708. if (threeCode.Length == 6)
  18709. {
  18710. start = threeCode.Substring(0, 3);
  18711. end = threeCode.Substring(3, 3);
  18712. if (threeCodeStr.Count == 0)
  18713. {
  18714. threeCodeStr.Add(start);
  18715. threeCodeStr.Add(end);
  18716. }
  18717. else
  18718. {
  18719. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18720. {
  18721. threeCodeStr.Add(end);
  18722. }
  18723. else
  18724. {
  18725. threeCodeStr.Add(start);
  18726. threeCodeStr.Add(end);
  18727. }
  18728. }
  18729. }
  18730. //处理机票信息
  18731. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  18732. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  18733. if (start_Object == null)
  18734. {
  18735. start_Object = new Res_ThreeCode()
  18736. {
  18737. AirPort = empty,
  18738. AirPort_En = empty,
  18739. City = empty,
  18740. Country = empty,
  18741. Four = empty,
  18742. Three = empty,
  18743. };
  18744. }
  18745. if (end_Object == null)
  18746. {
  18747. end_Object = new Res_ThreeCode()
  18748. {
  18749. AirPort = empty,
  18750. AirPort_En = empty,
  18751. City = empty,
  18752. Country = empty,
  18753. Four = empty,
  18754. Three = empty,
  18755. };
  18756. }
  18757. //机型判断
  18758. string airModel = item["AirModel"].ToString();
  18759. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  18760. string flightTime = item["FlightTime"].ToString();
  18761. if (flightTime!.Contains(":"))
  18762. {
  18763. flightTime = flightTime.Replace(":", "小时");
  18764. flightTime += "分钟";
  18765. }
  18766. if (flightTime.Contains("H"))
  18767. {
  18768. flightTime = flightTime.Replace("H", "小时");
  18769. }
  18770. if (flightTime.Contains("M"))
  18771. {
  18772. flightTime = flightTime.Replace("M", "分钟");
  18773. }
  18774. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  18775. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  18776. {
  18777. flightTime = flightDataTime.Hour > 0
  18778. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  18779. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  18780. ? flightDataTime.Minute.ToString() + "分钟" : "";
  18781. }
  18782. //航班号
  18783. string flightcode = item["Fliagtcode"].ToString();
  18784. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  18785. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  18786. if (aircompany == null)
  18787. {
  18788. aircompany = new Res_AirCompany
  18789. {
  18790. CnName = hsEmpty,
  18791. EnName = hsEmpty,
  18792. ShortCode = hsEmpty,
  18793. };
  18794. }
  18795. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  18796. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  18797. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  18798. if (isTrade)
  18799. {
  18800. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  18801. }
  18802. else
  18803. {
  18804. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  18805. }
  18806. }
  18807. chiarr.Add(new Grp_ApprovalTravelDetails
  18808. {
  18809. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  18810. CreateTime = DateTime.Now,
  18811. CreateUserId = dto.Userid,
  18812. ParentId = 0,
  18813. Details = trip
  18814. });
  18815. //添加乘车语句
  18816. chiarr.Add(new Grp_ApprovalTravelDetails
  18817. {
  18818. Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  18819. CreateTime = DateTime.Now,
  18820. CreateUserId = dto.Userid,
  18821. ParentId = 0,
  18822. Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  18823. });
  18824. if (i != timeArr.Count - 1)
  18825. {
  18826. fallToTime = fallToTime.AddHours(2.5);
  18827. foreach (var item in Times)
  18828. {
  18829. //排列公务时间
  18830. if (fallToTime.Hour < item.Item1)
  18831. {
  18832. chiarr.Add(new Grp_ApprovalTravelDetails
  18833. {
  18834. Time = $"{item.Item2} - {item.Item3}",
  18835. CreateTime = DateTime.Now,
  18836. CreateUserId = dto.Userid,
  18837. ParentId = 0,
  18838. Details = "公务活动"
  18839. });
  18840. }
  18841. }
  18842. }
  18843. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18844. var last = threeCodeStr.Last();
  18845. foreach (var item in threeCodeStr)
  18846. {
  18847. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18848. if (item.Equals(last))
  18849. {
  18850. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18851. }
  18852. }
  18853. cityPath = cityPath.Trim('-');
  18854. }
  18855. else
  18856. {
  18857. foreach (var item in Times)
  18858. {
  18859. chiarr.Add(new Grp_ApprovalTravelDetails
  18860. {
  18861. Time = $"{item.Item2} - {item.Item3}",
  18862. CreateTime = DateTime.Now,
  18863. CreateUserId = dto.Userid,
  18864. ParentId = 0,
  18865. Details = "公务活动"
  18866. });
  18867. }
  18868. }
  18869. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18870. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18871. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")"+ "第" + intToString(i + 1) + "天 ";
  18872. appro.Diid = dto.Diid;
  18873. appro.CreateUserId = dto.Userid;
  18874. appro.CreateTime = DateTime.Now;
  18875. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18876. appro.Id = thisId;
  18877. //foreach (var item in gwinfo)
  18878. //{
  18879. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  18880. // chi.Details = "拜访" + item.Client;
  18881. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  18882. // {
  18883. // chi.Details += "," + item.ReqSample;
  18884. // }
  18885. // chi.ParentId = thisId;
  18886. // chi.Time = item.Time;
  18887. // chiarr.Add(chi);
  18888. //}
  18889. if (chiarr.Count < 6)
  18890. {
  18891. for (int j = chiarr.Count; j < 6; j++)
  18892. {
  18893. chiarr.Add(new
  18894. Grp_ApprovalTravelDetails());
  18895. }
  18896. }
  18897. resultArr.Add(new
  18898. {
  18899. appro.Id,
  18900. appro.Date,
  18901. appro.Diid,
  18902. chiList = chiarr.Select(x1 => new
  18903. {
  18904. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18905. x1.Details,
  18906. x1.ParentId,
  18907. x1.Id
  18908. })
  18909. });
  18910. }
  18911. _sqlSugar.CommitTran();
  18912. jw = JsonView(true, "生成成功!", resultArr);
  18913. }
  18914. catch (Exception ex)
  18915. {
  18916. jw.Code = 400;
  18917. jw.Msg = "生成失败!" + ex.Message;
  18918. }
  18919. return Ok(jw);
  18920. }
  18921. /// <summary>
  18922. /// 报批行程word导出
  18923. /// </summary>
  18924. /// <param name="dto"></param>
  18925. /// <returns></returns>
  18926. [HttpPost]
  18927. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  18928. {
  18929. var jw = JsonView(false);
  18930. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18931. if (group == null)
  18932. {
  18933. jw.Msg = "暂无该团组!";
  18934. return Ok(jw);
  18935. }
  18936. //模板路径
  18937. string tempPath = AppSettingsHelper.Get("WordBasePath")+ "Template/";
  18938. var fileName = string.Empty;
  18939. string titleFont = string.Empty,timeFont = string.Empty, contentFont = string.Empty;
  18940. bool bold = false;
  18941. if (dto.FileIndex == 1)
  18942. {
  18943. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  18944. }
  18945. else if (dto.FileIndex == 2)
  18946. {
  18947. fileName = "省外办-报批.docx";
  18948. bold = false;
  18949. titleFont = "方正黑体简体";
  18950. timeFont = "Times New Roman";
  18951. contentFont = "方正仿宋_GBK";
  18952. }
  18953. else if (dto.FileIndex == 3)
  18954. {
  18955. fileName = "市外办-报批.docx";
  18956. titleFont = "方正黑体简体";
  18957. timeFont = "Times New Roman";
  18958. contentFont = "方正仿宋简体";
  18959. }
  18960. tempPath = tempPath + fileName;
  18961. //载入模板
  18962. Document doc = new Document(tempPath);
  18963. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18964. //获取所填表格的序数
  18965. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18966. Aspose.Words.Tables.Row titleRowClone = null;
  18967. Aspose.Words.Tables.Row CenterRowClone = null;
  18968. int index = 0;
  18969. int indexChi = 0;
  18970. int SetIndex = 0;
  18971. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  18972. //获取数据,放到datatable
  18973. foreach (var item in ApprovalTravelArr)
  18974. {
  18975. if (index > 0)
  18976. {
  18977. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  18978. tableOne.AppendChild(titleRowClone);
  18979. }
  18980. var textTime = item.Date;
  18981. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  18982. SetCells(tableOne, doc, SetIndex, 0, textTime,titleFont,bold);
  18983. SetIndex++;
  18984. if (ChiRep.Count > 0)
  18985. {
  18986. foreach (var itemChi in ChiRep)
  18987. {
  18988. var txtTime = itemChi.Time;
  18989. var txtDetail = itemChi.Details;
  18990. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  18991. {
  18992. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  18993. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  18994. //indexChi++;
  18995. //SetIndex++;
  18996. break;
  18997. }
  18998. if (indexChi > 0)
  18999. {
  19000. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  19001. tableOne.AppendChild(CenterRowClone);
  19002. }
  19003. SetCells(tableOne, doc, SetIndex, 0, txtTime,timeFont,bold);
  19004. SetCells(tableOne, doc, SetIndex, 1, txtDetail,contentFont, bold);
  19005. indexChi++;
  19006. SetIndex++;
  19007. }
  19008. }
  19009. //else
  19010. //{
  19011. // if (indexChi > 0)
  19012. // {
  19013. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  19014. // tableOne.AppendChild(CenterRowClone);
  19015. // }
  19016. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  19017. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  19018. // indexChi++;
  19019. // SetIndex++;
  19020. //}
  19021. index++;
  19022. }
  19023. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  19024. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName,Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  19025. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  19026. jw.Code = 200;
  19027. jw.Msg = "";
  19028. return Ok(jw);
  19029. }
  19030. private string intToString(int numberVal)
  19031. {
  19032. string numberval = numberVal.ToString();
  19033. Dictionary<char, string> Number = new Dictionary<char, string>();
  19034. Number.Add('1', "一");
  19035. Number.Add('2', "二");
  19036. Number.Add('3', "三");
  19037. Number.Add('4', "四");
  19038. Number.Add('5', "五");
  19039. Number.Add('6', "六");
  19040. Number.Add('7', "七");
  19041. Number.Add('8', "八");
  19042. Number.Add('9', "九");
  19043. string stringNumberVal = string.Empty;
  19044. for (int i = 0; i < numberval.Length; i++)
  19045. {
  19046. if (i == 0)
  19047. {
  19048. stringNumberVal += Number[numberval[i]];
  19049. }
  19050. else if (i >= 1)
  19051. {
  19052. if (numberval[i] == '0')
  19053. {
  19054. stringNumberVal = "十";
  19055. }
  19056. else
  19057. {
  19058. stringNumberVal += "十" + Number[numberval[i]];
  19059. }
  19060. }
  19061. }
  19062. return stringNumberVal;
  19063. }
  19064. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val,string font ,bool bold)
  19065. {
  19066. //获取table中的某个单元格,从0开始
  19067. Cell lshCell = table.Rows[rows].Cells[cells];
  19068. //将单元格中段落移除
  19069. foreach (Paragraph item in lshCell.Paragraphs)
  19070. {
  19071. lshCell.Paragraphs.Remove(item);
  19072. }
  19073. if (val.Contains("\r\n"))
  19074. {
  19075. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  19076. foreach (var item in spArr)
  19077. {
  19078. //新建一个段落
  19079. Paragraph p = new Paragraph(doc);
  19080. var r = new Run(doc, item);
  19081. //设置字体
  19082. if (!string.IsNullOrEmpty(font))
  19083. {
  19084. r.Font.Name = font;
  19085. }
  19086. r.Font.Bold = bold;
  19087. //把设置的值赋给之前新建的段落
  19088. p.AppendChild(r);
  19089. //将此段落加到单元格内
  19090. lshCell.AppendChild(p);
  19091. }
  19092. }
  19093. else
  19094. {
  19095. //新建一个段落
  19096. Paragraph p = new Paragraph(doc);
  19097. var r = new Run(doc, val);
  19098. //设置字体
  19099. if (!string.IsNullOrEmpty(font))
  19100. {
  19101. r.Font.Name = font;
  19102. }
  19103. r.Font.Bold = bold;
  19104. //把设置的值赋给之前新建的段落
  19105. p.AppendChild(r);
  19106. //将此段落加到单元格内
  19107. lshCell.AppendChild(p);
  19108. }
  19109. }
  19110. [HttpPost]
  19111. public async Task<IActionResult> ServerHttp(string paramStr)
  19112. {
  19113. paramStr = paramStr.TrimEnd('\'');
  19114. paramStr = paramStr.TrimStart('\'');
  19115. JsonView jw = JsonView(false);
  19116. JObject param = JObject.Parse(paramStr);
  19117. if (!param.ContainsKey("url"))
  19118. {
  19119. jw.Msg = "url null";
  19120. return Ok(jw);
  19121. }
  19122. string url = param["url"]!.ToString();
  19123. var methon = "get";
  19124. Dictionary<string, string> headValues = null;
  19125. string bodyStr = string.Empty;
  19126. if (param.ContainsKey("methon"))
  19127. {
  19128. methon = param["methon"]!.ToString().ToLower();
  19129. }
  19130. if (param.ContainsKey("header"))
  19131. {
  19132. var header = param["header"]!.ToString();
  19133. JObject headerJobject = JObject.Parse(header);
  19134. headValues = new Dictionary<string, string>();
  19135. foreach (JProperty item in headerJobject.Properties())
  19136. {
  19137. var value = item.Value.ToString();
  19138. var head = item.Path;
  19139. headValues.Add(head, value);
  19140. }
  19141. }
  19142. HttpClient client = new HttpClient();
  19143. string responseString = string.Empty;
  19144. StringContent content = null;
  19145. if (headValues != null)
  19146. {
  19147. foreach (var item in headValues.Keys)
  19148. {
  19149. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  19150. {
  19151. if (param.ContainsKey("body"))
  19152. {
  19153. bodyStr = param["body"]!.ToString();
  19154. }
  19155. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  19156. }
  19157. else
  19158. {
  19159. client.DefaultRequestHeaders.Add(item, headValues[item]);
  19160. }
  19161. }
  19162. }
  19163. try
  19164. {
  19165. if (methon == "get")
  19166. {
  19167. responseString = await client.GetStringAsync(url);
  19168. }
  19169. else if (methon == "post")
  19170. {
  19171. var request = new HttpRequestMessage(HttpMethod.Post, url)
  19172. {
  19173. Content = content
  19174. };
  19175. var response = await client.SendAsync(request);
  19176. try
  19177. {
  19178. Stream responseStream = await response.Content.ReadAsStreamAsync();
  19179. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  19180. {
  19181. using (StreamReader reader = new StreamReader(gzipStream))
  19182. {
  19183. responseString = await reader.ReadToEndAsync();
  19184. }
  19185. }
  19186. }
  19187. catch (Exception)
  19188. {
  19189. responseString = await response.Content.ReadAsStringAsync();
  19190. }
  19191. }
  19192. else
  19193. {
  19194. responseString = "methon error";
  19195. }
  19196. jw = JsonView(true, "success", responseString);
  19197. }
  19198. catch (Exception ex)
  19199. {
  19200. jw.Msg = "error " + ex.Message;
  19201. jw.Data = ex.StackTrace;
  19202. }
  19203. finally
  19204. {
  19205. client.Dispose();
  19206. }
  19207. return Ok(jw);
  19208. }
  19209. #endregion
  19210. #region 团组接待意见调查
  19211. /// <summary>
  19212. /// 团组接待意见调查 - 信息管理
  19213. /// 基础数据(团组)
  19214. /// </summary>
  19215. /// <returns></returns>
  19216. [HttpGet]
  19217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19218. public async Task<IActionResult> OpinionaireInit()
  19219. {
  19220. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  19221. .Select(x => new
  19222. {
  19223. x.Id,
  19224. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  19225. })
  19226. .OrderByDescending(x => x.Id)
  19227. .ToListAsync();
  19228. return Ok(JsonView(groupData, groupData.Count));
  19229. }
  19230. /// <summary>
  19231. /// 团组接待意见调查 - 信息管理
  19232. /// 列表
  19233. /// </summary>
  19234. /// <param name="groupId"></param>
  19235. /// <returns></returns>
  19236. [HttpGet("{groupId}")]
  19237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19238. public async Task<IActionResult> OpinionaireManageList(int groupId)
  19239. {
  19240. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19241. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  19242. .Select(x => new
  19243. {
  19244. x.Id,
  19245. x.TourGuideName,
  19246. x.CityName,
  19247. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  19248. x.CreateTime
  19249. })
  19250. .OrderBy(x => x.Id)
  19251. .ToListAsync();
  19252. return Ok(JsonView(data));
  19253. }
  19254. /// <summary>
  19255. /// 团组接待意见调查 - 信息管理
  19256. /// 保存
  19257. /// </summary>
  19258. /// <param name="dto"></param>
  19259. /// <returns></returns>
  19260. [HttpPost]
  19261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19262. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  19263. {
  19264. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19265. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19266. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19267. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  19268. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  19269. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  19270. _opinionaireRep.BeginTran();
  19271. if (addData != null && addData.Count > 0)
  19272. {
  19273. foreach (var item in addData)
  19274. {
  19275. item.CreateUserId = currUserInfo.UserId;
  19276. item.DiId = dto.DiId;
  19277. }
  19278. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  19279. }
  19280. if (updData != null && updData.Count > 0)
  19281. {
  19282. var upd = await _opinionaireRep._sqlSugar
  19283. .Updateable(updData)
  19284. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  19285. .WhereColumns(x => new { x.Id })
  19286. .ExecuteCommandAsync();
  19287. }
  19288. _opinionaireRep.CommitTran();
  19289. return Ok(JsonView("操作成功!"));
  19290. }
  19291. /// <summary>
  19292. /// 团组接待意见调查 - 信息管理
  19293. /// 删除
  19294. /// </summary>
  19295. /// <param name="id"></param>
  19296. /// <returns></returns>
  19297. [HttpDelete("{id}")]
  19298. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19299. public async Task<IActionResult> OpinionaireManageDel(int id)
  19300. {
  19301. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19302. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19303. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  19304. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  19305. if (!del) return Ok(JsonView("操作失败!"));
  19306. return Ok(JsonView("操作成功!"));
  19307. }
  19308. /// <summary>
  19309. /// 团组接待意见调查 - 用户
  19310. /// 列表
  19311. /// </summary>
  19312. /// <param name="diId"></param>
  19313. /// <returns></returns>
  19314. [HttpGet("{diId}")]
  19315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19316. public async Task<IActionResult> OpinionaireUserList(int diId)
  19317. {
  19318. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19319. var sql = string.Format(@"
  19320. SELECT
  19321. o.Id,
  19322. o.DiId,
  19323. di.TeamName AS 'GroupName',
  19324. di.VisitPNumber AS 'PeopleNumber',
  19325. di.ClientName AS 'LeadGroup',
  19326. di.VisitCountry AS 'Travel',
  19327. di.VisitDays AS 'Days',
  19328. o.CityName,
  19329. o.TourGuideName,
  19330. o.Catering,
  19331. o.CateringReason,
  19332. o.Stay,
  19333. o.StayReason,
  19334. o.[Route],
  19335. o.RouteReason,
  19336. o.OfficialActivity,
  19337. o.OfficialActivityReason,
  19338. o.TourGuide,
  19339. o.TourGuideReason,
  19340. o.[Translate],
  19341. o.TranslateReason,
  19342. o.Trip,
  19343. o.TripReason,
  19344. o.ESFileName,
  19345. o.SignatureDate,
  19346. o.Remark
  19347. FROM
  19348. Grp_Opinionaire o
  19349. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  19350. WHERE
  19351. o.IsDel = 0
  19352. AND o.DiId = {0}
  19353. ORDER BY
  19354. o.Id ASC", diId);
  19355. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  19356. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  19357. return Ok(JsonView(data));
  19358. }
  19359. /// <summary>
  19360. /// 团组接待意见调查 - 用户
  19361. /// 保存
  19362. /// </summary>
  19363. /// <param name="dto"></param>
  19364. /// <returns></returns>
  19365. [HttpPost]
  19366. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19367. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  19368. {
  19369. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  19370. foreach (var item in dto)
  19371. {
  19372. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  19373. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  19374. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  19375. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  19376. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  19377. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  19378. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  19379. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  19380. }
  19381. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  19382. if (!Directory.Exists(filePathBase))
  19383. {
  19384. Directory.CreateDirectory(filePathBase);
  19385. }
  19386. #region 上传文件
  19387. var filePaths = new List<string>();
  19388. foreach (var item in dto)
  19389. {
  19390. var file = item.File;
  19391. // 将文件保存到指定位置
  19392. var filePath = Path.Combine(filePathBase, file.FileName);
  19393. using (var stream = new FileStream(filePath, FileMode.Create))
  19394. {
  19395. await file.CopyToAsync(stream);
  19396. }
  19397. //验证文件是否上传成功
  19398. if (!System.IO.File.Exists(filePath))
  19399. {
  19400. foreach (var filePathStr in filePaths)
  19401. {
  19402. System.IO.File.Delete(filePathStr);
  19403. }
  19404. return Ok(JsonView(false, "文件上传失败!"));
  19405. }
  19406. item.ESFileName = file.FileName;
  19407. }
  19408. #endregion
  19409. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  19410. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  19411. .UpdateColumns(x => new
  19412. {
  19413. x.Catering,
  19414. x.CateringReason,
  19415. x.Stay,
  19416. x.StayReason,
  19417. x.Route,
  19418. x.RouteReason,
  19419. x.OfficialActivity,
  19420. x.OfficialActivityReason,
  19421. x.TourGuide,
  19422. x.TourGuideReason,
  19423. x.Translate,
  19424. x.TranslateReason,
  19425. x.Trip,
  19426. x.TripReason,
  19427. x.ESFileName,
  19428. x.SignatureDate,
  19429. x.Remark
  19430. })
  19431. .WhereColumns(x => new { x.Id })
  19432. .ExecuteCommandAsync();
  19433. if (upd < 1)
  19434. {
  19435. foreach (var filePathStr in filePaths)
  19436. {
  19437. System.IO.File.Delete(filePathStr);
  19438. }
  19439. return Ok(JsonView(false));
  19440. }
  19441. return Ok(JsonView(true));
  19442. }
  19443. #endregion
  19444. #region 团组餐厅相关信息
  19445. /// <summary>
  19446. /// 团组相关餐厅信息
  19447. /// 基础数据(团组)
  19448. /// </summary>
  19449. /// <returns></returns>
  19450. [HttpGet]
  19451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19452. public async Task<IActionResult> RestaurantInit()
  19453. {
  19454. return Ok(await _restaurantRep.InitAsync());
  19455. }
  19456. /// <summary>
  19457. /// 团组相关餐厅信息
  19458. /// Item
  19459. /// </summary>
  19460. /// <param name="dto"></param>
  19461. /// <returns></returns>
  19462. [HttpPost]
  19463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19464. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  19465. {
  19466. int portType = dto.PortType,
  19467. groupId = dto.GroupId;
  19468. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19469. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19470. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  19471. }
  19472. /// <summary>
  19473. /// 团组相关餐厅信息
  19474. /// List
  19475. /// </summary>
  19476. /// <param name="dto"></param>
  19477. /// <returns></returns>
  19478. [HttpPost]
  19479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19480. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  19481. {
  19482. int portType = dto.PortType,
  19483. groupId = dto.GroupId;
  19484. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19485. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19486. var sql = string.Format(@" SELECT
  19487. ri.Id,
  19488. ri.GroupId,
  19489. ri.Date,
  19490. ri.StartTime,
  19491. ri.EndTime,
  19492. CASE WHEN ri.Type = 1 THEN '早餐'
  19493. WHEN ri.Type = 2 THEN '午餐'
  19494. WHEN ri.Type = 3 THEN '晚餐'
  19495. ELSE '其他'
  19496. END AS 'Type',
  19497. ri.Name,
  19498. ri.Address,
  19499. ri.Tel,
  19500. ri.Remark,
  19501. ri.CreateTime,
  19502. u.CnName AS CreateUserName
  19503. FROM
  19504. Grp_RestaurantInfo ri
  19505. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  19506. WHERE
  19507. ri.IsDel = 0
  19508. AND ri.GroupId = {0}
  19509. ORDER BY
  19510. ri.Date ASC
  19511. ", groupId);
  19512. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  19513. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  19514. return Ok(JsonView(infos));
  19515. }
  19516. /// <summary>
  19517. /// 团组相关餐厅信息
  19518. /// Info
  19519. /// </summary>
  19520. /// <param name="dto"></param>
  19521. /// <returns></returns>
  19522. [HttpPost]
  19523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19524. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  19525. {
  19526. int portType = dto.PortType,
  19527. id = dto.Id;
  19528. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19529. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19530. return Ok(await _restaurantRep.InfoAsync(portType, id));
  19531. }
  19532. /// <summary>
  19533. /// 团组相关餐厅信息
  19534. /// Op
  19535. /// </summary>
  19536. /// <param name="dto"></param>
  19537. /// <returns></returns>
  19538. [HttpPost]
  19539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19540. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  19541. {
  19542. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19543. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19544. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  19545. return Ok(await _restaurantRep.OpAsync(dto));
  19546. }
  19547. /// <summary>
  19548. /// 团组相关餐厅信息
  19549. /// Del
  19550. /// </summary>
  19551. /// <param name="dto"></param>
  19552. /// <returns></returns>
  19553. [HttpPost]
  19554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19555. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  19556. {
  19557. int userId = dto.DeleteUserId;
  19558. var id = dto.Id;
  19559. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19560. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19561. return Ok(await _restaurantRep.DelAsync(dto));
  19562. }
  19563. #endregion
  19564. // /// <summary>
  19565. // ///
  19566. // /// </summary>
  19567. // /// <param name="_dto"></param>
  19568. // /// <returns></returns>
  19569. // [HttpPost]
  19570. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19571. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19572. // {
  19573. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19574. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  19575. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  19576. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19577. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  19578. // dic_psg.Add("客人", 974);
  19579. // dic_psg.Add("司机", 975);
  19580. // dic_psg.Add("导游", 976);
  19581. // dic_psg.Add("公司内部人员", 977);
  19582. // dic_psg.Add("司机/导游/公司内部人员", 978);
  19583. // foreach (var item in list_visa)
  19584. // {
  19585. // Grp_VisaInfo temp = new Grp_VisaInfo();
  19586. // temp.Id = item.Id;
  19587. // temp.DIId = item.DIId;
  19588. // temp.VisaClient = item.VisaClient;
  19589. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  19590. // temp.VisaCurrency = item.VisaCurrency;
  19591. // temp.IsThird = item.IsThird;
  19592. // if (dic_psg.ContainsKey(item.PassengerType))
  19593. // {
  19594. // temp.PassengerType = dic_psg[item.PassengerType];
  19595. // }
  19596. // else {
  19597. // temp.PassengerType = -1;
  19598. // }
  19599. // temp.VisaNumber = item.VisaNumber;
  19600. // temp.VisaFreeNumber = item.VisaFreeNumber;
  19601. // temp.CreateUserId = item.Operators;
  19602. // DateTime dt_ct;
  19603. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  19604. // if (b_ct)
  19605. // {
  19606. // temp.CreateTime = dt_ct;
  19607. // }
  19608. // else
  19609. // {
  19610. // temp.CreateTime = DateTime.Now;
  19611. // }
  19612. // temp.DeleteTime = "";
  19613. // temp.DeleteUserId = 0;
  19614. // temp.Remark = item.Remark;
  19615. // if (string.IsNullOrEmpty(temp.Remark)) {
  19616. // temp.Remark = "";
  19617. // }
  19618. // temp.IsDel = item.IsDel;
  19619. // temp.VisaDescription = item.VisaAttachment;
  19620. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  19621. //([Id]
  19622. // ,[DIId]
  19623. // ,[VisaClient]
  19624. // ,[VisaPrice]
  19625. // ,[VisaCurrency]
  19626. // ,[IsThird]
  19627. // ,[PassengerType]
  19628. // ,[VisaNumber]
  19629. // ,[VisaFreeNumber]
  19630. // ,[CreateUserId]
  19631. // ,[CreateTime]
  19632. // ,[DeleteTime]
  19633. // ,[DeleteUserId]
  19634. // ,[Remark]
  19635. // ,[IsDel]
  19636. // ,[visaDescription])
  19637. // VALUES
  19638. // ({0},{1},'{2}',{3},{4}
  19639. //,{5},{6},{7},{8},{9}
  19640. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  19641. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  19642. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  19643. //);
  19644. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  19645. // }
  19646. // return Ok(JsonView(true, "操作成功!"));
  19647. // }
  19648. /// <summary>
  19649. /// 123132123
  19650. /// </summary>
  19651. /// <param name="_dto"></param>
  19652. /// <returns></returns>
  19653. [HttpPost]
  19654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19655. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19656. {
  19657. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19658. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  19659. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  19660. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19661. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  19662. dicDetail.Add(789, 1034);
  19663. dicDetail.Add(790, 1035);
  19664. dicDetail.Add(791, 1036);
  19665. dicDetail.Add(792, 1037);
  19666. dicDetail.Add(793, 1038);
  19667. dicDetail.Add(794, 1039);
  19668. dicDetail.Add(795, 1040);
  19669. dicDetail.Add(796, 1041);
  19670. dicDetail.Add(797, 1042);
  19671. dicDetail.Add(798, 1043);
  19672. dicDetail.Add(801, 1044);
  19673. dicDetail.Add(802, 1045);
  19674. dicDetail.Add(803, 1046);
  19675. Dictionary<int, int> dic = new Dictionary<int, int>();
  19676. dic.Add(806, 1027);
  19677. dic.Add(807, 1028);
  19678. dic.Add(808, 1029);
  19679. dic.Add(809, 1030);
  19680. dic.Add(810, 1031);
  19681. dic.Add(811, 1032);
  19682. dic.Add(812, 1033);
  19683. foreach (var item in list_visa)
  19684. {
  19685. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  19686. temp.Coefficient = item.coefficient;
  19687. DateTime dtCrt;
  19688. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  19689. if (b1)
  19690. {
  19691. temp.CreateTime = dtCrt;
  19692. }
  19693. else
  19694. {
  19695. temp.CreateTime = DateTime.Now;
  19696. }
  19697. temp.CreateUserId = item.Operators;
  19698. temp.DeleteTime = "";
  19699. temp.DeleteUserId = 0;
  19700. temp.DiId = int.Parse(item.DIID);
  19701. temp.FilePath = item.FilePath;
  19702. temp.IsDel = item.IsDel;
  19703. temp.Price = item.Price;
  19704. temp.PriceCount = 1;
  19705. temp.PriceCurrency = item.Currency;
  19706. int detailId = 0;
  19707. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  19708. {
  19709. detailId = dicDetail[item.PriceTypeDetail];
  19710. }
  19711. temp.PriceDetailType = detailId;
  19712. temp.PriceDt = DateTime.Now;
  19713. temp.PriceName = item.PriceName;
  19714. temp.PriceSum = item.Price;
  19715. int tid = 0;
  19716. if (dic.ContainsKey(item.PriceType))
  19717. {
  19718. tid = dic[item.PriceType];
  19719. }
  19720. temp.PriceType = tid;
  19721. temp.Remark = item.Remark;
  19722. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  19723. }
  19724. return Ok(JsonView(true, "操作成功!"));
  19725. }
  19726. [HttpPost]
  19727. public IActionResult TimeTest()
  19728. {
  19729. var jw = JsonView(false, "error");
  19730. _sqlSugar.BeginTran();
  19731. try
  19732. {
  19733. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  19734. .Select(x => new Crm_NewClientData
  19735. {
  19736. Id = x.Id,
  19737. Client = x.Client,
  19738. Contact = x.Contact,
  19739. Location = x.Location,
  19740. })
  19741. .ToList();
  19742. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  19743. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  19744. Stopwatch stopwatch = new Stopwatch();
  19745. // 开始计时
  19746. stopwatch.Start();
  19747. foreach (var item in clientList)
  19748. {
  19749. EncryptionProcessor.DecryptProperties(item);
  19750. }
  19751. stopwatch.Stop();
  19752. jw.Code = 200;
  19753. jw.Data = stopwatch.ElapsedMilliseconds;
  19754. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  19755. }
  19756. catch (Exception ex)
  19757. {
  19758. jw.Code = 400;
  19759. jw.Msg = ex.Message;
  19760. }
  19761. return Ok(jw);
  19762. }
  19763. }
  19764. }