GroupsController.cs 1.0 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901
  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.Drawing.Printing;
  51. using System.Globalization;
  52. using System.IO.Compression;
  53. using System.Text.Json;
  54. using System.Web;
  55. using System.Xml.Linq;
  56. using TencentCloud.Ocr.V20181119.Models;
  57. using static OASystem.API.OAMethodLib.JWTHelper;
  58. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  59. using Bookmark = Aspose.Words.Bookmark;
  60. using Cell = Aspose.Words.Tables.Cell;
  61. using Table = Aspose.Words.Tables.Table;
  62. namespace OASystem.API.Controllers
  63. {
  64. /// <summary>
  65. /// 团组相关
  66. /// </summary>
  67. //[Authorize]
  68. [Route("api/[controller]/[action]")]
  69. public class GroupsController : ControllerBase
  70. {
  71. private readonly ILogger<GroupsController> _logger;
  72. private readonly GrpScheduleRepository _grpScheduleRep;
  73. private readonly IMapper _mapper;
  74. private readonly DelegationInfoRepository _groupRepository;
  75. private readonly TaskAssignmentRepository _taskAssignmentRep;
  76. private readonly AirTicketResRepository _airTicketResRep;
  77. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  78. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  79. private readonly DelegationEnDataRepository _delegationEnDataRep;
  80. private readonly DelegationVisaRepository _delegationVisaRep;
  81. private readonly VisaPriceRepository _visaPriceRep;
  82. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  83. private readonly HotelPriceRepository _hotelPriceRep;
  84. private readonly CustomersRepository _customersRep;
  85. private readonly MessageRepository _message;
  86. private readonly SqlSugarClient _sqlSugar;
  87. private readonly TourClientListRepository _tourClientListRep;
  88. private readonly TeamRateRepository _teamRateRep;
  89. #region 成本相关
  90. private readonly CheckBoxsRepository _checkBoxs;
  91. private readonly GroupCostRepository _GroupCostRepository;
  92. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  93. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  94. #endregion
  95. private readonly SetDataRepository _setDataRep;
  96. private string url;
  97. private string path;
  98. private readonly EnterExitCostRepository _enterExitCostRep;
  99. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  100. private readonly UsersRepository _usersRep;
  101. private readonly IJuHeApiService _juHeApi;
  102. private readonly InvertedListRepository _invertedListRep;
  103. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  104. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  105. private readonly ThreeCodeRepository _threeCodeRepository;
  106. private readonly HotelInquiryRepository _hotelInquiryRep;
  107. private readonly FeeAuditRepository _feeAuditRep;
  108. private readonly VisaCommissionRepository _visaCommissionRep;
  109. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  110. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  111. private readonly List<CurrencyInfo> _currencyInit;
  112. private readonly List<int> _portTypeData;
  113. private readonly TableOperationRecordRepository _tableorRep;
  114. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  115. private readonly RestaurantRepository _restaurantRep;
  116. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  117. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  118. /// <summary>
  119. /// 构造函数
  120. /// </summary>
  121. /// <param name="logger"></param>
  122. /// <param name="mapper"></param>
  123. /// <param name="hubContext"></param>
  124. /// <param name="sqlSugar"></param>
  125. /// <param name="grpScheduleRep"></param>
  126. /// <param name="groupRepository"></param>
  127. /// <param name="taskAssignmentRep"></param>
  128. /// <param name="airTicketResRep"></param>
  129. /// <param name="decreasePaymentsRep"></param>
  130. /// <param name="InvitationOfficialActivitiesRep"></param>
  131. /// <param name="delegationEnDataRep"></param>
  132. /// <param name="enterExitCostRep"></param>
  133. /// <param name="delegationVisaRep"></param>
  134. /// <param name="message"></param>
  135. /// <param name="visaPriceRep"></param>
  136. /// <param name="carTouristGuideGroundRep"></param>
  137. /// <param name="checkBoxs"></param>
  138. /// <param name="GroupCostRepository"></param>
  139. /// <param name="CostTypeHotelNumberRepository"></param>
  140. /// <param name="GroupCostParameterRepository"></param>
  141. /// <param name="hotelPriceRep"></param>
  142. /// <param name="customersRep"></param>
  143. /// <param name="setDataRep"></param>
  144. /// <param name="tourClientListRep"></param>
  145. /// <param name="teamRateRep"></param>
  146. /// <param name="usersRep"></param>
  147. /// <param name="juHeApi"></param>
  148. /// <param name="invertedListRep"></param>
  149. /// <param name="visaFeeInfoRep"></param>
  150. /// <param name="ticketBlackCodeRep"></param>
  151. /// <param name="hotelInquiryRep"></param>
  152. /// <param name="threeCodeRepository"></param>
  153. /// <param name="feeAuditRep"></param>
  154. /// <param name="visaCommissionRep"></param>
  155. /// <param name="ffrRep"></param>
  156. /// <param name="opinionaireRep"></param>
  157. /// <param name="tableorRep"></param>
  158. /// <param name="enterExitCostDraftRep"></param>
  159. /// <param name="restaurantRep"></param>
  160. /// <param name="enterExitCostQuoteRep"></param>
  161. /// <param name="grpOrderPreInfoRep"></param>
  162. public GroupsController(
  163. ILogger<GroupsController> logger,
  164. IMapper mapper,
  165. IHubContext<ChatHub, IChatClient> hubContext,
  166. SqlSugarClient sqlSugar,
  167. GrpScheduleRepository grpScheduleRep,
  168. DelegationInfoRepository groupRepository,
  169. TaskAssignmentRepository taskAssignmentRep,
  170. AirTicketResRepository airTicketResRep,
  171. DecreasePaymentsRepository decreasePaymentsRep,
  172. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  173. DelegationEnDataRepository delegationEnDataRep,
  174. EnterExitCostRepository enterExitCostRep,
  175. DelegationVisaRepository delegationVisaRep,
  176. MessageRepository message,
  177. VisaPriceRepository visaPriceRep,
  178. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  179. CheckBoxsRepository checkBoxs,
  180. GroupCostRepository GroupCostRepository,
  181. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  182. GroupCostParameterRepository GroupCostParameterRepository,
  183. HotelPriceRepository hotelPriceRep,
  184. CustomersRepository customersRep,
  185. SetDataRepository setDataRep,
  186. TourClientListRepository tourClientListRep,
  187. TeamRateRepository teamRateRep,
  188. UsersRepository usersRep, IJuHeApiService juHeApi,
  189. InvertedListRepository invertedListRep,
  190. VisaFeeInfoRepository visaFeeInfoRep,
  191. TicketBlackCodeRepository ticketBlackCodeRep,
  192. HotelInquiryRepository hotelInquiryRep,
  193. ThreeCodeRepository threeCodeRepository,
  194. FeeAuditRepository feeAuditRep,
  195. VisaCommissionRepository visaCommissionRep,
  196. ForeignReceivablesRepository ffrRep,
  197. OpinionaireRepository opinionaireRep,
  198. TableOperationRecordRepository tableorRep,
  199. EnterExitCostDraftRepository enterExitCostDraftRep,
  200. RestaurantRepository restaurantRep,
  201. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  202. GroupOrderPreInfoRepository grpOrderPreInfoRep
  203. )
  204. {
  205. _logger = logger;
  206. _mapper = mapper;
  207. _grpScheduleRep = grpScheduleRep;
  208. _groupRepository = groupRepository;
  209. _taskAssignmentRep = taskAssignmentRep;
  210. _airTicketResRep = airTicketResRep;
  211. _sqlSugar = sqlSugar;
  212. url = AppSettingsHelper.Get("ExcelBaseUrl");
  213. path = AppSettingsHelper.Get("ExcelBasePath");
  214. if (!System.IO.Directory.Exists(path))
  215. {
  216. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  217. }
  218. _decreasePaymentsRep = decreasePaymentsRep;
  219. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  220. _delegationEnDataRep = delegationEnDataRep;
  221. _enterExitCostRep = enterExitCostRep;
  222. _delegationVisaRep = delegationVisaRep;
  223. _message = message;
  224. _visaPriceRep = visaPriceRep;
  225. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  226. _checkBoxs = checkBoxs;
  227. _GroupCostRepository = GroupCostRepository;
  228. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  229. _GroupCostParameterRepository = GroupCostParameterRepository;
  230. _hotelPriceRep = hotelPriceRep;
  231. _customersRep = customersRep;
  232. _setDataRep = setDataRep;
  233. _tourClientListRep = tourClientListRep;
  234. _teamRateRep = teamRateRep;
  235. _hubContext = hubContext;
  236. _usersRep = usersRep;
  237. _juHeApi = juHeApi;
  238. _invertedListRep = invertedListRep;
  239. _visaFeeInfoRep = visaFeeInfoRep;
  240. _ticketBlackCodeRep = ticketBlackCodeRep;
  241. _hotelInquiryRep = hotelInquiryRep;
  242. _threeCodeRepository = threeCodeRepository;
  243. _feeAuditRep = feeAuditRep;
  244. _visaCommissionRep = visaCommissionRep;
  245. _ffrRep = ffrRep;
  246. _opinionaireRep = opinionaireRep;
  247. _currencyInit = new List<CurrencyInfo>()
  248. {
  249. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  250. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  251. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  252. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  253. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  254. };
  255. _portTypeData = new List<int>() { 2, 3 };
  256. _tableorRep = tableorRep;
  257. _enterExitCostDraftRep = enterExitCostDraftRep;
  258. _restaurantRep = restaurantRep;
  259. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  260. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  261. }
  262. #region 流程管控
  263. /// <summary>
  264. /// 获取团组流程管控信息
  265. /// </summary>
  266. /// <param name="_jsonDto"></param>
  267. /// <returns></returns>
  268. [HttpPost]
  269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  270. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  271. {
  272. if (string.IsNullOrEmpty(_jsonDto.Paras))
  273. {
  274. return Ok(JsonView(false, "参数为空"));
  275. }
  276. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  277. if (_ScheduleDto != null)
  278. {
  279. if (_ScheduleDto.SearchType == 2)//获取列表
  280. {
  281. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  282. return Ok(JsonView(_grpScheduleViewList));
  283. }
  284. else//获取对象
  285. {
  286. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  287. if (_grpScheduleView != null)
  288. {
  289. return Ok(JsonView(_grpScheduleView));
  290. }
  291. }
  292. }
  293. else
  294. {
  295. return Ok(JsonView(false, "参数反序列化失败"));
  296. }
  297. return Ok(JsonView(false, "暂无数据!"));
  298. }
  299. /// <summary>
  300. /// 修改团组流程管控详细表数据
  301. /// </summary>
  302. /// <param name="dto"></param>
  303. /// <returns></returns>
  304. [HttpPost]
  305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  306. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  307. {
  308. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  309. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  310. .SetColumns(it => it.Duty == _detail.Duty)
  311. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  312. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  313. .SetColumns(it => it.JobContent == _detail.JobContent)
  314. .SetColumns(it => it.Remark == _detail.Remark)
  315. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  316. .Where(s => s.Id == dto.Id)
  317. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  318. .ExecuteCommandAsync();
  319. if (result > 0)
  320. {
  321. return Ok(JsonView(true, "保存成功!"));
  322. }
  323. return Ok(JsonView(false, "保存失败!"));
  324. }
  325. /// <summary>
  326. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  327. /// </summary>
  328. /// <param name="dto"></param>
  329. /// <returns></returns>
  330. [HttpPost]
  331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  332. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  333. {
  334. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  335. _detail.IsDel = 1;
  336. _detail.DeleteUserId = dto.Duty;
  337. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  338. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  339. .SetColumns(it => it.IsDel == _detail.IsDel)
  340. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  341. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  342. .Where(it => it.Id == dto.Id)
  343. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  344. //.WhereColumns(s => s.Id == dto.Id)
  345. .ExecuteCommandAsync();
  346. if (result > 0)
  347. {
  348. return Ok(JsonView(true, "删除成功!"));
  349. }
  350. return Ok(JsonView(false, "删除失败!"));
  351. }
  352. /// <summary>
  353. /// 增加团组流程管控详细表数据
  354. /// </summary>
  355. /// <param name="dto"></param>
  356. /// <returns></returns>
  357. [HttpPost]
  358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  359. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  360. {
  361. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  362. if (DateTime.Now < _detail.ExpectBeginDt)
  363. {
  364. _detail.StepStatus = 0;
  365. }
  366. else
  367. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  368. _detail.StepStatus = 1;
  369. }
  370. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  371. if (result > 0)
  372. {
  373. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  374. return Ok(JsonView(true, "添加成功!", _result));
  375. }
  376. return Ok(JsonView(false, "添加失败!"));
  377. }
  378. #endregion
  379. #region 团组前期信息
  380. /// <summary>
  381. /// 团组前期信息 List
  382. /// </summary>
  383. /// <returns></returns>
  384. [HttpPost]
  385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  386. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  387. {
  388. var search = dto.Search;
  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. .ToListAsync();
  407. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  408. int total = list.Count;
  409. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  410. var listPageData1 = listPageData
  411. .Skip((dto.PageIndex - 1) * dto.PageSize)
  412. .Take(dto.PageSize)
  413. .ToList();
  414. var infoIds = listPageData1.Select(x => x.Id).ToList();
  415. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  416. .Where(x => x.IsDel == 0 && x.STid == 109)
  417. .ToArrayAsync();
  418. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  419. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  420. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  421. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  422. .ToListAsync();
  423. foreach (var item in listPageData1)
  424. {
  425. var typeDatas1 = typeDatas.Select(x => new
  426. {
  427. Id = x.Id,
  428. Name = x.Name,
  429. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  430. }).ToArray();
  431. item.VersionDetails = typeDatas1;
  432. }
  433. return Ok(JsonView(listPageData1, listPageData1.Count));
  434. }
  435. /// <summary>
  436. /// 团组前期信息 Init
  437. /// </summary>
  438. /// <returns></returns>
  439. [HttpGet("{userId}")]
  440. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  441. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  442. {
  443. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  444. }
  445. /// <summary>
  446. /// 国家数据源
  447. /// </summary>
  448. /// <returns></returns>
  449. [HttpGet]
  450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  451. public async Task<IActionResult> CountryInit()
  452. {
  453. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  454. return Ok(JsonView(countrys));
  455. }
  456. /// <summary>
  457. /// 城市数据源
  458. /// </summary>
  459. /// <returns></returns>
  460. [HttpGet("{countryLabel}")]
  461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  462. public async Task<IActionResult> CityByCountry(string countryLabel)
  463. {
  464. countryLabel=HttpUtility.UrlDecode(countryLabel);
  465. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  466. var citys = Array.Empty<string?>();
  467. if (countryList.Any())
  468. {
  469. var cityDatas = await _sqlSugar
  470. .Queryable<Grp_NationalTravelFee>()
  471. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  472. .ToArrayAsync();
  473. foreach (var item in cityDatas)
  474. {
  475. if (item.City.Contains("城市"))
  476. {
  477. item.City = item.Country + "-所有城市";
  478. }
  479. }
  480. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  481. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  482. }
  483. return Ok(JsonView(citys));
  484. }
  485. /// <summary>
  486. /// 团组前期信息 Info
  487. /// </summary>
  488. /// <param name="id">Id</param>
  489. /// <param name="tempId">Id</param>
  490. /// <returns></returns>
  491. [HttpGet("{id}/{tempId}")]
  492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  493. public async Task<IActionResult> GroupOrderPreInfo(int id,int tempId = 1404)
  494. {
  495. return Ok(await _grpOrderPreInfoRep.InfoAsync(id, tempId));
  496. }
  497. /// <summary>
  498. /// 团组前期信息 Save
  499. /// </summary>
  500. /// <param name="dto">Id</param>
  501. /// <returns></returns>
  502. [HttpPost]
  503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  504. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  505. {
  506. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  507. }
  508. /// <summary>
  509. /// 团组前期信息 文件下载
  510. /// </summary>
  511. /// <param name="id">Id</param>
  512. /// <param name="tempId">Id</param>
  513. /// <returns></returns>
  514. [HttpGet("{id}/{tempId}")]
  515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  516. public async Task<IActionResult> GroupOrderPreInfoFileDownload(int id, int tempId = 1404)
  517. {
  518. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  519. var data = view.Data as GrpOrderPreInfoView;
  520. #region Excel
  521. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  522. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  523. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  524. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  525. var fileNamePrefix = string.Empty;
  526. if (tempId == 1405)
  527. {
  528. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  529. fileNamePrefix = $"{data.Name}_无商邀版";
  530. }
  531. else if (tempId == 1406)
  532. {
  533. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  534. fileNamePrefix = $"{data.Name}_有商邀版";
  535. }
  536. else
  537. {
  538. //tempId == 1404 默认下载
  539. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  540. fileNamePrefix = $"{data.Name}_单接送机";
  541. }
  542. foreach (var item in data.Items)
  543. {
  544. var obj = item.NewValue;
  545. if (obj == null) item.OriginVal = "";
  546. else if (obj.Equals("有") || obj.Equals("无"))
  547. {
  548. item.OriginVal = obj.ToString();
  549. }
  550. else if (obj is object[] objArray)
  551. {
  552. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  553. item.OriginVal = string.Join("、", stringArray);
  554. }
  555. else if (obj is string[] stringArray)
  556. {
  557. item.OriginVal = string.Join("、", stringArray);
  558. } else if (obj.Equals("-"))
  559. {
  560. item.OriginVal = "";
  561. }
  562. }
  563. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  564. fileName = CommonFun.ValidFileName(fileName);
  565. //载入模板
  566. WorkbookDesigner designer = new WorkbookDesigner();
  567. designer.Workbook = new Workbook(tempPath);
  568. if (tempId == 1406)
  569. {
  570. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  571. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  572. for (int i = 1; i <= view2.Length; i++)
  573. {
  574. view2[i - 1].Index = i;
  575. }
  576. designer.SetDataSource("View1", view1);
  577. designer.SetDataSource("View2", view2);
  578. }
  579. else
  580. {
  581. designer.SetDataSource("View", data.Items);
  582. }
  583. designer.Process();
  584. if (!Directory.Exists(savePath))
  585. {
  586. Directory.CreateDirectory(savePath);
  587. }
  588. string serverPath = $"{savePath}{fileName}";
  589. designer.Workbook.Save(serverPath);
  590. string rst = $"{servicePath}{ftpPath}{fileName}";
  591. #endregion
  592. return Ok(JsonView(new { url = rst }));
  593. }
  594. #endregion
  595. #region 团组基本信息
  596. /// <summary>
  597. /// 接团信息列表
  598. /// </summary>
  599. /// <param name="dto">团组列表请求dto</param>
  600. /// <returns></returns>
  601. [HttpPost]
  602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  603. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  604. {
  605. var groupData = await _groupRepository.GetGroupList(dto);
  606. if (groupData.Code != 0)
  607. {
  608. return Ok(JsonView(false, groupData.Msg));
  609. }
  610. return Ok(JsonView(groupData.Data));
  611. }
  612. /// <summary>
  613. /// 分页查询团组列表
  614. /// </summary>
  615. /// <param name="dto"></param>
  616. /// <returns></returns>
  617. [HttpPost]
  618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  619. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  620. {
  621. var watch = new Stopwatch();
  622. watch.Start();
  623. RefAsync<int> total = 0;
  624. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  625. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  626. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  627. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  628. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  629. .Distinct()
  630. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  631. watch.Stop();
  632. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  633. }
  634. /// <summary>
  635. /// 接团信息列表 Page Init
  636. /// </summary>
  637. /// <returns></returns>
  638. [HttpPost]
  639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  640. public async Task<IActionResult> PostGroupPageListInit()
  641. {
  642. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  643. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  644. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  645. var _view = new
  646. {
  647. depData = depDatas,
  648. rankData = rankDatas
  649. };
  650. return Ok(JsonView(true, "查询成功!", _view));
  651. }
  652. /// <summary>
  653. /// 接团信息列表 Page
  654. /// </summary>
  655. /// <param name="dto">团组列表请求dto</param>
  656. /// <returns></returns>
  657. [HttpPost]
  658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  659. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  660. {
  661. #region 参数验证
  662. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  663. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  664. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  665. #region 页面操作权限验证
  666. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  667. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  668. #endregion
  669. #endregion
  670. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  671. {
  672. string sqlWhere = string.Empty;
  673. if (dto.IsSure == 0) //未完成
  674. {
  675. sqlWhere += string.Format(@" And IsSure = 0");
  676. }
  677. else if (dto.IsSure == 1) //已完成
  678. {
  679. sqlWhere += string.Format(@" And IsSure = 1");
  680. }
  681. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  682. {
  683. string tj = dto.SearchCriteria;
  684. 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}%')",
  685. tj, tj, tj, tj, tj);
  686. }
  687. if (int.TryParse(dto.Rank, out int rankId))
  688. {
  689. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  690. }
  691. string sqlWhere1 = string.Empty;
  692. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  693. {
  694. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  695. }
  696. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  697. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  698. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  699. JietuanOperator,IsSure,CreateTime,IsBid
  700. From (
  701. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  702. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  703. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  704. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  705. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  706. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  707. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  708. From Grp_DelegationInfo gdi
  709. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  710. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  711. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  712. Where gdi.IsDel = 0 {0}
  713. ) temp {1}", sqlWhere, sqlWhere1);
  714. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  715. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  716. var _view = new
  717. {
  718. PageFuncAuth = pageFunAuthView,
  719. Data = _DelegationList
  720. };
  721. return Ok(JsonView(true, "查询成功!", _view, total));
  722. }
  723. else
  724. {
  725. return Ok(JsonView(false, "查询失败"));
  726. }
  727. }
  728. /// <summary>
  729. /// 团组列表
  730. /// </summary>
  731. /// <returns></returns>
  732. [HttpPost]
  733. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  734. {
  735. #region 参数验证
  736. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  737. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  738. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  739. #region 页面操作权限验证
  740. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  741. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  742. #endregion
  743. #endregion
  744. if (dto.PortType != 1 && dto.PortType != 2)
  745. {
  746. return Ok(JsonView(false, "查询失败!"));
  747. }
  748. string orderbyStr = "order by gdi.CreateTime Desc";
  749. string sqlWhere = string.Empty;
  750. if (dto.IsSure == 0) //未完成
  751. {
  752. sqlWhere += string.Format(@" And IsSure = 0");
  753. }
  754. else if (dto.IsSure == 1) //已完成
  755. {
  756. sqlWhere += string.Format(@" And IsSure = 1");
  757. }
  758. //团组类型
  759. if (dto.TeamDid > 0)
  760. {
  761. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  762. }
  763. //团组名称
  764. if (!string.IsNullOrEmpty(dto.TeamName))
  765. {
  766. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  767. }
  768. //客户名称
  769. if (!string.IsNullOrEmpty(dto.ClientName))
  770. {
  771. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  772. }
  773. //客户单位
  774. if (!string.IsNullOrEmpty(dto.ClientUnit))
  775. {
  776. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  777. }
  778. //出访时间
  779. if (!string.IsNullOrEmpty(dto.visitDataTime))
  780. {
  781. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  782. orderbyStr = "order by gdi.VisitDate";
  783. }
  784. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  785. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  786. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  787. JietuanOperator,IsSure,CreateTime
  788. From (
  789. Select row_number() over({0}) as Row_Number,
  790. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  791. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  792. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  793. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  794. From Grp_DelegationInfo gdi
  795. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  796. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  797. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  798. Where gdi.IsDel = 0 {1}
  799. ) temp ", orderbyStr, sqlWhere);
  800. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  801. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  802. #region 处理所属部门
  803. /*
  804. * 1.sq 和 gyy 等显示 市场部
  805. * 2.王鸽和主管及张总还有管理员号统一国交部
  806. * 2-1. 4 管理员 ,21 张海麟
  807. */
  808. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  809. List<int> userIds1 = new List<int>() { 4, 21 };
  810. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  811. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  812. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  813. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  814. .ToList();
  815. foreach (var item in _DelegationList)
  816. {
  817. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  818. }
  819. #endregion
  820. var _view = new
  821. {
  822. PageFuncAuth = pageFunAuthView,
  823. Data = _DelegationList
  824. };
  825. return Ok(JsonView(true, "查询成功!", _view, total));
  826. }
  827. /// <summary>
  828. /// 接团信息详情
  829. /// </summary>
  830. /// <param name="dto">团组info请求dto</param>
  831. /// <returns></returns>
  832. [HttpPost]
  833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  834. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  835. {
  836. var groupData = await _groupRepository.GetGroupInfo(dto);
  837. if (groupData.Code != 0)
  838. {
  839. return Ok(JsonView(false, groupData.Msg));
  840. }
  841. return Ok(JsonView(groupData.Data));
  842. }
  843. /// <summary>
  844. /// 接团信息 编辑添加
  845. /// 基础信息数据源
  846. /// </summary>
  847. /// <param name="dto"></param>
  848. /// <returns></returns>
  849. [HttpPost]
  850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  851. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  852. {
  853. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  854. if (groupData.Code != 0)
  855. {
  856. return Ok(JsonView(false, groupData.Msg));
  857. }
  858. return Ok(JsonView(groupData.Data));
  859. }
  860. /// <summary>
  861. /// 接团信息 操作(增改)
  862. /// </summary>
  863. /// <param name="dto"></param>
  864. /// <returns></returns>
  865. [HttpPost]
  866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  867. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  868. {
  869. // 创建 Stopwatch 实例
  870. Stopwatch stopwatch = Stopwatch.StartNew();
  871. decimal ffrPrice = 0.00M;
  872. DateTime? visitDt = null;
  873. if (dto.Status == 2)
  874. {
  875. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  876. if (groupInfo != null)
  877. {
  878. ffrPrice = groupInfo.PaymentMoney;
  879. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  880. }
  881. }
  882. var groupData = await _groupRepository.GroupOperation(dto);
  883. if (groupData.Code != 0)
  884. {
  885. return Ok(JsonView(false, groupData.Msg));
  886. }
  887. int diId = 0;
  888. try
  889. {
  890. //添加时 默认加入团组汇率
  891. if (dto.Status == 1) //添加
  892. {
  893. diId = groupData.Data;
  894. //添加默认币种
  895. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  896. //默认分配权限
  897. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  898. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  899. var _managerIds = new List<int>() { 22, 32, 21 };
  900. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  901. if (userIds.Count > 0)
  902. {
  903. userIds.Add(208);
  904. //创建团组管控
  905. GroupStepForDelegation.CreateWorkStep(diId);
  906. //发送消息
  907. string groupName = dto.TeamName;
  908. string createGroupUser = string.Empty;
  909. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  910. if (userInfo != null) createGroupUser = userInfo.CnName;
  911. string title = $"系统通知";
  912. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  913. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  914. }
  915. //默认创建倒推表
  916. await _invertedListRep._Create(dto.UserId, diId);
  917. }
  918. else if (dto.Status == 2)
  919. {
  920. diId = dto.Id;
  921. }
  922. #region 签证人员团组时间通知
  923. #region 计算出访起止时间
  924. var startTime = new DateTime();
  925. var endTime = new DateTime();
  926. if (DateTime.TryParse(dto.VisitDate, out startTime))
  927. {
  928. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  929. }
  930. #endregion
  931. #endregion
  932. #region 团组操作默认添加/修改收款账单
  933. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  934. {
  935. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  936. .Where(x => x.IsDel == 0 &&
  937. x.Diid == diId &&
  938. x.Remark.Equals("预付款")
  939. )
  940. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  941. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  942. .FirstAsync();
  943. ffrInfo = new Fin_ForeignReceivables()
  944. {
  945. Diid = diId,
  946. PriceName = dto.ClientUnit,
  947. Price = dto.PaymentMoney,
  948. Count = 1,
  949. Unit = $"元",
  950. ItemSumPrice = dto.PaymentMoney,
  951. Rate = 1.0000M,
  952. Currency = 836,
  953. AddingWay = 0,
  954. CreateUserId = dto.UserId,
  955. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  956. Remark = $"预付款"
  957. };
  958. if (ffrInfo == null) //Add
  959. {
  960. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  961. }
  962. else //修改
  963. {
  964. await _sqlSugar.Updateable(ffrInfo)
  965. .UpdateColumns(x => new
  966. {
  967. x.PriceName,
  968. x.Price,
  969. x.ItemSumPrice,
  970. x.CreateTime,
  971. x.CreateUserId
  972. })
  973. .WhereColumns(x => x.Id)
  974. .ExecuteCommandAsync();
  975. }
  976. }
  977. #endregion
  978. if (diId > 0)
  979. {
  980. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  981. }
  982. // 停止计时
  983. stopwatch.Stop();
  984. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  985. }
  986. catch (Exception ex)
  987. {
  988. // 停止计时
  989. stopwatch.Stop();
  990. Logs("[response]" + JsonConvert.SerializeObject(dto));
  991. Logs(ex.Message);
  992. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  993. }
  994. // 停止计时
  995. stopwatch.Stop();
  996. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  997. }
  998. /// <summary>
  999. /// 接团流程操作(增改)
  1000. /// 安卓端使用 建团时添加客户名单
  1001. /// </summary>
  1002. /// <param name="dto"></param>
  1003. /// <returns></returns>
  1004. [HttpPost]
  1005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1006. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1007. {
  1008. #region 参数验证
  1009. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1010. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1011. #region 页面操作权限验证
  1012. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1013. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1014. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1015. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1016. #endregion
  1017. #endregion
  1018. try
  1019. {
  1020. //_sqlSugar.BeginTran();
  1021. decimal ffrPrice = 0.00M;
  1022. DateTime? visitDt = null;
  1023. if (dto.Status == 2)
  1024. {
  1025. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1026. if (groupInfo != null)
  1027. {
  1028. ffrPrice = groupInfo.PaymentMoney;
  1029. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1030. }
  1031. }
  1032. var _dto = new GroupOperationDto();
  1033. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1034. var groupData = await _groupRepository.GroupOperation(_dto);
  1035. if (groupData.Code != 0)
  1036. {
  1037. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1038. }
  1039. int diId = 0;
  1040. //添加时 默认加入团组汇率
  1041. if (dto.Status == 1) //添加
  1042. {
  1043. diId = groupData.Data;
  1044. //添加默认币种
  1045. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1046. //默认分配权限
  1047. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1048. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1049. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1050. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1051. if (userIds.Count > 0)
  1052. {
  1053. userIds.Add(208);
  1054. //创建团组管控
  1055. GroupStepForDelegation.CreateWorkStep(diId);
  1056. //发送消息
  1057. string groupName = dto.TeamName;
  1058. string createGroupUser = string.Empty;
  1059. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1060. if (userInfo != null) createGroupUser = userInfo.CnName;
  1061. string title = $"系统通知";
  1062. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1063. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1064. }
  1065. #region 应用推送
  1066. try
  1067. {
  1068. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1069. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1070. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1071. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1072. {
  1073. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1074. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1075. }
  1076. }
  1077. catch (Exception ex)
  1078. {
  1079. }
  1080. #endregion
  1081. //默认创建倒推表
  1082. await _invertedListRep._Create(dto.UserId, diId);
  1083. }
  1084. if (dto.Status == 2)
  1085. {
  1086. diId = dto.Id;
  1087. if (diId == 0)
  1088. {
  1089. //_sqlSugar.RollbackTran();
  1090. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1091. }
  1092. }
  1093. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1094. if (viewData.Code != 0)
  1095. {
  1096. //_sqlSugar.RollbackTran();
  1097. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1098. }
  1099. #region 团组操作默认添加/修改收款账单
  1100. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1101. {
  1102. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1103. .Where(x => x.IsDel == 0 &&
  1104. x.Diid == diId &&
  1105. x.Remark.Equals("预付款")
  1106. )
  1107. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1108. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1109. .FirstAsync();
  1110. ffrInfo = new Fin_ForeignReceivables()
  1111. {
  1112. Diid = diId,
  1113. PriceName = dto.ClientUnit,
  1114. Price = dto.PaymentMoney,
  1115. Count = 1,
  1116. Unit = $"元",
  1117. ItemSumPrice = dto.PaymentMoney,
  1118. Rate = 1.0000M,
  1119. Currency = 836,
  1120. AddingWay = 0,
  1121. CreateUserId = dto.UserId,
  1122. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1123. Remark = $"预付款"
  1124. };
  1125. if (ffrInfo == null) //Add
  1126. {
  1127. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1128. }
  1129. else //修改
  1130. {
  1131. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1132. .UpdateColumns(x => new
  1133. {
  1134. x.PriceName,
  1135. x.Price,
  1136. x.ItemSumPrice,
  1137. x.CreateTime,
  1138. x.CreateUserId
  1139. })
  1140. .WhereColumns(x => x.Id)
  1141. .ExecuteCommandAsync();
  1142. }
  1143. }
  1144. #endregion
  1145. #region 签证人员团组时间通知
  1146. #region 计算出访起止时间
  1147. var startTime = new DateTime();
  1148. var endTime = new DateTime();
  1149. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1150. {
  1151. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1152. }
  1153. #endregion
  1154. if (diId > 0)
  1155. {
  1156. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1157. }
  1158. #endregion
  1159. //_sqlSugar.CommitTran();
  1160. return Ok(JsonView(true, "添加成功"));
  1161. }
  1162. catch (Exception ex)
  1163. {
  1164. _sqlSugar.RollbackTran();
  1165. return Ok(JsonView(false, ex.Message));
  1166. }
  1167. }
  1168. /// <summary>
  1169. /// 接团流程操作(增改)
  1170. /// 安卓端使用 建团时添加客户名单
  1171. /// </summary>
  1172. /// <param name="dto"></param>
  1173. /// <returns></returns>
  1174. [HttpPost]
  1175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1176. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1177. {
  1178. #region 参数验证
  1179. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1180. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1181. #region 页面操作权限验证
  1182. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1183. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1184. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1185. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1186. #endregion
  1187. #endregion
  1188. _sqlSugar.BeginTran();
  1189. decimal ffrPrice = 0.00M;
  1190. DateTime? visitDt = null;
  1191. if (dto.Status == 2)
  1192. {
  1193. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1194. if (groupInfo != null)
  1195. {
  1196. ffrPrice = groupInfo.PaymentMoney;
  1197. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1198. }
  1199. }
  1200. var _dto = new GroupOperationDto();
  1201. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1202. var groupData = await _groupRepository.GroupOperation(_dto);
  1203. if (groupData.Code != 0)
  1204. {
  1205. _sqlSugar.RollbackTran();
  1206. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1207. }
  1208. try
  1209. {
  1210. int diId = 0;
  1211. //添加时 默认加入团组汇率
  1212. if (dto.Status == 1) //添加
  1213. {
  1214. diId = groupData.Data;
  1215. //添加默认币种
  1216. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1217. //默认分配权限
  1218. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1219. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1220. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1221. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1222. if (userIds.Count > 0)
  1223. {
  1224. userIds.Add(208);
  1225. //创建团组管控
  1226. GroupStepForDelegation.CreateWorkStep(diId);
  1227. //发送消息
  1228. string groupName = dto.TeamName;
  1229. string createGroupUser = string.Empty;
  1230. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1231. if (userInfo != null) createGroupUser = userInfo.CnName;
  1232. string title = $"系统通知";
  1233. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1234. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1235. }
  1236. #region 应用推送
  1237. try
  1238. {
  1239. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1240. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1241. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1242. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1243. {
  1244. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1245. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1246. }
  1247. }
  1248. catch (Exception ex)
  1249. {
  1250. _sqlSugar.CommitTran();
  1251. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1252. }
  1253. #endregion
  1254. //默认创建倒推表
  1255. await _invertedListRep._Create(dto.UserId, diId);
  1256. }
  1257. else if (dto.Status == 2)
  1258. {
  1259. diId = dto.Id;
  1260. if (diId == 0)
  1261. {
  1262. _sqlSugar.RollbackTran();
  1263. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1264. }
  1265. }
  1266. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1267. if (viewData.Code != 0)
  1268. {
  1269. _sqlSugar.RollbackTran();
  1270. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1271. }
  1272. #region 团组操作默认添加/修改收款账单
  1273. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1274. {
  1275. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1276. .Where(x => x.IsDel == 0 &&
  1277. x.Diid == diId &&
  1278. x.Remark.Equals("预付款")
  1279. )
  1280. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1281. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1282. .FirstAsync();
  1283. ffrInfo = new Fin_ForeignReceivables()
  1284. {
  1285. Diid = diId,
  1286. PriceName = dto.ClientUnit,
  1287. Price = dto.PaymentMoney,
  1288. Count = 1,
  1289. Unit = $"元",
  1290. ItemSumPrice = dto.PaymentMoney,
  1291. Rate = 1.0000M,
  1292. Currency = 836,
  1293. AddingWay = 0,
  1294. CreateUserId = dto.UserId,
  1295. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1296. Remark = $"预付款"
  1297. };
  1298. if (ffrInfo == null) //Add
  1299. {
  1300. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1301. }
  1302. else //修改
  1303. {
  1304. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1305. .UpdateColumns(x => new
  1306. {
  1307. x.PriceName,
  1308. x.Price,
  1309. x.ItemSumPrice,
  1310. x.CreateTime,
  1311. x.CreateUserId
  1312. })
  1313. .WhereColumns(x => x.Id)
  1314. .ExecuteCommandAsync();
  1315. }
  1316. }
  1317. #endregion
  1318. #region 签证人员团组时间通知
  1319. #region 计算出访起止时间
  1320. var startTime = new DateTime();
  1321. var endTime = new DateTime();
  1322. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1323. {
  1324. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1325. }
  1326. #endregion
  1327. if (diId > 0)
  1328. {
  1329. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1330. }
  1331. #endregion
  1332. _sqlSugar.CommitTran();
  1333. return Ok(JsonView(true));
  1334. }
  1335. catch (Exception ex)
  1336. {
  1337. _sqlSugar.RollbackTran();
  1338. return Ok(JsonView(false, ex.Message));
  1339. }
  1340. }
  1341. /// <summary>
  1342. /// 接团信息 操作(删除)
  1343. /// </summary>
  1344. /// <param name="dto"></param>
  1345. /// <returns></returns>
  1346. [HttpPost]
  1347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1348. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1349. {
  1350. var diId = dto.Id;
  1351. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1352. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1353. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1354. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1355. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1356. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1357. #endregion
  1358. var groupData = await _groupRepository.GroupDel(dto);
  1359. if (groupData.Code != 0)
  1360. {
  1361. return Ok(JsonView(false, groupData.Msg));
  1362. }
  1363. return Ok(JsonView(true));
  1364. }
  1365. /// <summary>
  1366. /// 获取团组销售报价号
  1367. /// 团组添加时 使用
  1368. /// </summary>
  1369. /// <returns></returns>
  1370. [HttpPost]
  1371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1372. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1373. {
  1374. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1375. if (groupData.Code != 0)
  1376. {
  1377. return Ok(JsonView(false, groupData.Msg));
  1378. }
  1379. object salesQuoteNo = new
  1380. {
  1381. SalesQuoteNo = groupData.Data
  1382. };
  1383. return Ok(JsonView(salesQuoteNo));
  1384. }
  1385. /// <summary>
  1386. /// 设置确认出团
  1387. /// </summary>
  1388. /// <param name="dto"></param>
  1389. /// <returns></returns>
  1390. [HttpPost]
  1391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1392. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1393. {
  1394. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1395. if (groupData.Code != 0)
  1396. {
  1397. return Ok(JsonView(false, groupData.Msg));
  1398. }
  1399. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1400. #region OA消息推送
  1401. try
  1402. {
  1403. string groupName = groupInfo.TeamName;
  1404. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1405. string title = $"系统通知";
  1406. string content = $"团组[{groupName}]已确认出团!";
  1407. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1408. }
  1409. catch (Exception ex)
  1410. {
  1411. }
  1412. #endregion
  1413. #region 应用推送
  1414. try
  1415. {
  1416. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1417. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1418. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1419. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1420. {
  1421. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1422. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1423. }
  1424. }
  1425. catch (Exception ex)
  1426. {
  1427. }
  1428. #endregion
  1429. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1430. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1431. }
  1432. /// <summary>
  1433. /// 获取团组名称data And 签证国别Data
  1434. /// </summary>
  1435. /// <param name="dto"></param>
  1436. /// <returns></returns>
  1437. [HttpPost]
  1438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1439. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1440. {
  1441. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1442. if (groupData.Code != 0)
  1443. {
  1444. return Ok(JsonView(false, groupData.Msg));
  1445. }
  1446. return Ok(JsonView(groupData.Data));
  1447. }
  1448. /// <summary>
  1449. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1450. /// </summary>
  1451. /// <returns></returns>
  1452. [HttpPost]
  1453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1454. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1455. {
  1456. try
  1457. {
  1458. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1459. if (groupData.Code != 0)
  1460. {
  1461. return Ok(JsonView(false, groupData.Msg));
  1462. }
  1463. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1464. }
  1465. catch (Exception ex)
  1466. {
  1467. return Ok(JsonView(false, "程序错误!"));
  1468. throw;
  1469. }
  1470. }
  1471. /// <summary>
  1472. /// 团组清单 Excel
  1473. /// </summary>
  1474. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1475. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1476. /// <returns></returns>
  1477. [HttpGet]
  1478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1479. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1480. {
  1481. DateTime _beginDt, _endDt;
  1482. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1483. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1484. if (!beginBool && !endBool)
  1485. {
  1486. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1487. }
  1488. string sql = string.Format(@"
  1489. SELECT
  1490. ROW_NUMBER,
  1491. Id,
  1492. SalesQuoteNo,
  1493. TourCode,
  1494. TeamTypeId,
  1495. TeamType,
  1496. TeamLevId,
  1497. TeamLev,
  1498. TeamName,
  1499. ClientName,
  1500. ClientUnit,
  1501. VisitDate,
  1502. VisitDays,
  1503. VisitPNumber,
  1504. JietuanOperatorId,
  1505. JietuanOperator,
  1506. IsSure,
  1507. CreateUserName,
  1508. IsBid
  1509. FROM
  1510. (
  1511. SELECT
  1512. ROW_NUMBER() OVER(
  1513. ORDER BY
  1514. gdi.CreateTime Desc
  1515. ) AS ROW_NUMBER,
  1516. gdi.Id,
  1517. SalesQuoteNo,
  1518. TourCode,
  1519. ssd.Id TeamTypeId,
  1520. ssd.Name TeamType,
  1521. ssd1.Id TeamLevId,
  1522. ssd1.Name TeamLev,
  1523. TeamName,
  1524. ClientName,
  1525. ClientUnit,
  1526. VisitDate,
  1527. VisitDays,
  1528. VisitPNumber,
  1529. JietuanOperator JietuanOperatorId,
  1530. su.CnName JietuanOperator,
  1531. IsSure,
  1532. gdi.CreateTime,
  1533. su1.CnName As CreateUserName,
  1534. gdi.IsBid
  1535. FROM
  1536. Grp_DelegationInfo gdi
  1537. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1538. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1539. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1540. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1541. WHERE
  1542. gdi.IsDel = 0
  1543. AND gdi.IsBid = 0
  1544. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1545. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1546. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1547. #region 处理所属部门
  1548. /*
  1549. * 1.sq 和 gyy 等显示 市场部
  1550. * 2.王鸽和主管及张总还有管理员号统一国交部
  1551. * 2-1. 4 管理员 ,21 张海麟
  1552. */
  1553. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1554. List<int> userIds1 = new List<int>() { 4, 21 };
  1555. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1556. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1557. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1558. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1559. .ToListAsync();
  1560. var droupIds = groupList.Select(it => it.Id).ToList();
  1561. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1562. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1563. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1564. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1565. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1566. {
  1567. DiId = tcl.DiId,
  1568. LastName = dc.LastName,
  1569. FirstName = dc.FirstName,
  1570. Sex = dc.Sex,
  1571. Birthday = dc.BirthDay,
  1572. Company = cc.CompanyFullName,
  1573. Job = dc.Job,
  1574. CreateTime = tcl.CreateTime,
  1575. })
  1576. .ToList();
  1577. foreach (var item in groupList)
  1578. {
  1579. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1580. string groupFirstName = "";
  1581. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1582. if (currDatas.Any())
  1583. {
  1584. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1585. }
  1586. item.GroupFirst = groupFirstName;
  1587. }
  1588. #endregion
  1589. #region Excel
  1590. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1591. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1592. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1593. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1594. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1595. //载入模板
  1596. WorkbookDesigner designer = new WorkbookDesigner();
  1597. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1598. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1599. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1600. dt.TableName = "GroupList";
  1601. designer.SetDataSource(dt);
  1602. designer.Process();
  1603. if (!Directory.Exists(savePath))
  1604. {
  1605. Directory.CreateDirectory(savePath);
  1606. }
  1607. string serverPath = $"{savePath}{fileName}";
  1608. designer.Workbook.Save(serverPath);
  1609. string rst = $"{servicePath}{ftpPath}{fileName}";
  1610. #endregion
  1611. return Ok(JsonView(true, "操作成功!", rst));
  1612. }
  1613. #endregion
  1614. #region 团组&签证
  1615. /// <summary>
  1616. /// 根据团组Id获取签证客户信息List
  1617. /// </summary>
  1618. /// <param name="dto">请求dto</param>
  1619. /// <returns></returns>
  1620. [HttpPost]
  1621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1622. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1623. {
  1624. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1625. if (groupData.Code != 0)
  1626. {
  1627. return Ok(JsonView(false, groupData.Msg));
  1628. }
  1629. return Ok(JsonView(groupData.Data));
  1630. }
  1631. /// <summary>
  1632. /// IOS获取团组签证拍照上传进度01(团组列表)
  1633. /// </summary>
  1634. /// <param name="dto">请求dto</param>
  1635. /// <returns></returns>
  1636. [HttpPost]
  1637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1638. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1639. {
  1640. if (dto == null)
  1641. {
  1642. return Ok(JsonView(false, "参数为空"));
  1643. }
  1644. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1645. return Ok(JsonView(visaList));
  1646. }
  1647. /// <summary>
  1648. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1649. /// </summary>
  1650. /// <returns></returns>
  1651. [HttpPost]
  1652. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1653. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1654. {
  1655. if (dto == null)
  1656. {
  1657. return Ok(JsonView(false, "请求错误:"));
  1658. }
  1659. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1660. return Ok(JsonView(list));
  1661. }
  1662. /// <summary>
  1663. /// IOS获取团组签证拍照上传进度03(相册)
  1664. /// </summary>
  1665. /// <returns></returns>
  1666. [HttpPost]
  1667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1668. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1669. {
  1670. if (dto == null)
  1671. {
  1672. return Ok(JsonView(false, "请求错误:"));
  1673. }
  1674. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1675. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1676. list.ForEach(s => s.url = url);
  1677. return Ok(JsonView(list));
  1678. }
  1679. /// <summary>
  1680. /// IOS获取团组签证拍照上传进度04(图片上传)
  1681. /// </summary>
  1682. /// <param name="dto"></param>
  1683. /// <returns></returns>
  1684. [HttpPost]
  1685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1686. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1687. {
  1688. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1689. //if (!string.IsNullOrEmpty(result))
  1690. //{
  1691. //}
  1692. //else {
  1693. // return Ok(JsonView(false, "上传失败"));
  1694. //}
  1695. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1696. int sucNum = 0;
  1697. try
  1698. {
  1699. foreach (var item in dto.base64DataList)
  1700. {
  1701. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1702. string result = DecodeBase64ToImage(item, imageName);
  1703. if (!string.IsNullOrEmpty(result))
  1704. {
  1705. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1706. pic.CreateUserId = dto.CreateUserId;
  1707. pic.PicName = imageName;
  1708. pic.PicPath = result;
  1709. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1710. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1711. if (insertResult > 0)
  1712. {
  1713. sucNum++;
  1714. }
  1715. }
  1716. }
  1717. }
  1718. catch (Exception ex)
  1719. {
  1720. return Ok(JsonView(false, ex.Message));
  1721. }
  1722. string msg = string.Format(@"成功上传{0}张", sucNum);
  1723. return Ok(JsonView(true, msg));
  1724. }
  1725. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  1726. {
  1727. string filename = "";//声明一个string类型的相对路径
  1728. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1729. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1730. try//会有异常抛出,try,catch一下
  1731. {
  1732. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1733. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1734. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1735. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1736. //文件名称
  1737. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1738. //上传的文件的路径
  1739. string filePath = "";
  1740. if (!Directory.Exists(fileDir))
  1741. {
  1742. Directory.CreateDirectory(fileDir);
  1743. }
  1744. //上传的文件的路径
  1745. filePath = fileDir + filename;
  1746. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1747. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1748. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1749. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1750. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1751. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1752. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1753. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1754. bitmap.Dispose();
  1755. }
  1756. catch (Exception e)
  1757. {
  1758. string massage = e.Message;
  1759. Logs("IOS图片上传Error:" + massage);
  1760. //filename = e.Message;
  1761. }
  1762. return filename;//返回相对路径
  1763. }
  1764. /// <summary>
  1765. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1766. /// </summary>
  1767. /// <param name="dto"></param>
  1768. /// <returns></returns>
  1769. [HttpPost]
  1770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1771. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1772. {
  1773. if (dto == null)
  1774. {
  1775. return Ok(JsonView(false, "请求错误:"));
  1776. }
  1777. string msg = "参数错误";
  1778. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1779. {
  1780. try
  1781. {
  1782. //_delegationVisaRep.BeginTran();
  1783. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1784. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1785. .Where(s => s.Id == dto.visaProgressCustomerId)
  1786. .ExecuteCommandAsync();
  1787. if (updCount > 0 && dto.publishCode == 1)
  1788. {
  1789. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1790. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1791. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1792. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1793. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1794. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1795. if (groupData == null)
  1796. {
  1797. _delegationVisaRep.RollbackTran();
  1798. }
  1799. string title = string.Format(@"[签证进度更新]");
  1800. string content = string.Format(@"测试文本");
  1801. bool rst = await _message.AddMsg(new MessageDto()
  1802. {
  1803. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1804. IssuerId = dto.publisher,
  1805. Title = title,
  1806. Content = content,
  1807. ReleaseTime = DateTime.Now,
  1808. UIdList = new List<int> {
  1809. 234
  1810. }
  1811. });
  1812. if (rst)
  1813. {
  1814. return Ok(JsonView(true, "发送通知成功"));
  1815. }
  1816. }
  1817. //_delegationVisaRep.CommitTran();
  1818. }
  1819. catch (Exception)
  1820. {
  1821. //_delegationVisaRep.RollbackTran();
  1822. }
  1823. }
  1824. return Ok(JsonView(true, msg));
  1825. }
  1826. #endregion
  1827. #region 团组任务分配
  1828. /// <summary>
  1829. /// 团组任务分配初始化
  1830. /// </summary>
  1831. /// <returns></returns>
  1832. [HttpPost]
  1833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1834. public async Task<IActionResult> GetTaskAssignmen()
  1835. {
  1836. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1837. if (groupData.Code != 0)
  1838. {
  1839. return Ok(JsonView(false, groupData.Msg));
  1840. }
  1841. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1842. }
  1843. /// <summary>
  1844. /// 团组任务分配查询
  1845. /// </summary>
  1846. /// <param name="dto"></param>
  1847. /// <returns></returns>
  1848. [HttpPost]
  1849. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1850. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1851. {
  1852. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1853. if (groupData.Code != 0)
  1854. {
  1855. return Ok(JsonView(false, groupData.Msg));
  1856. }
  1857. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1858. }
  1859. /// <summary>
  1860. /// 团组任务分配操作
  1861. /// </summary>
  1862. /// <param name="dto"></param>
  1863. /// <returns></returns>
  1864. [HttpPost]
  1865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1866. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1867. {
  1868. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1869. if (groupData.Code != 0)
  1870. {
  1871. return Ok(JsonView(false, groupData.Msg));
  1872. }
  1873. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1874. }
  1875. /// <summary>
  1876. /// 团组任务分配
  1877. /// 批量分配
  1878. /// 查询团组
  1879. /// </summary>
  1880. /// <param name="dto"></param>
  1881. /// <returns></returns>
  1882. [HttpPost]
  1883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1884. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1885. {
  1886. //参数验证
  1887. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1888. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1889. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1890. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1891. }
  1892. /// <summary>
  1893. /// 团组任务分配
  1894. /// 批量分配
  1895. /// </summary>
  1896. /// <param name="dto"></param>
  1897. /// <returns></returns>
  1898. [HttpPost]
  1899. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1900. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1901. {
  1902. //参数验证
  1903. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1904. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1905. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1906. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1907. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1908. }
  1909. #endregion
  1910. #region 团组费用审核
  1911. /// <summary>
  1912. /// 费用审核
  1913. /// 团组列表 Page
  1914. /// </summary>
  1915. /// <param name="_dto">团组列表请求dto</param>
  1916. /// <returns></returns>
  1917. [HttpPost]
  1918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1919. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1920. {
  1921. #region 参数验证
  1922. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1923. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1924. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1925. #region 页面操作权限验证
  1926. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1927. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1928. #endregion
  1929. #endregion
  1930. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1931. {
  1932. string sqlWhere = string.Empty;
  1933. if (_dto.IsSure == 0) //未完成
  1934. {
  1935. sqlWhere += string.Format(@" And IsSure = 0");
  1936. }
  1937. else if (_dto.IsSure == 1) //已完成
  1938. {
  1939. sqlWhere += string.Format(@" And IsSure = 1");
  1940. }
  1941. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1942. {
  1943. string tj = _dto.SearchCriteria;
  1944. 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}%')",
  1945. tj, tj, tj, tj, tj);
  1946. }
  1947. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1948. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1949. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1950. From (
  1951. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1952. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1953. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1954. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1955. From Grp_DelegationInfo gdi
  1956. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1957. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1958. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1959. Where gdi.IsDel = 0 {0}
  1960. ) temp ", sqlWhere);
  1961. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1962. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1963. var _view = new
  1964. {
  1965. PageFuncAuth = pageFunAuthView,
  1966. Data = _DelegationList
  1967. };
  1968. return Ok(JsonView(true, "查询成功!", _view, total));
  1969. }
  1970. else
  1971. {
  1972. return Ok(JsonView(false, "查询失败"));
  1973. }
  1974. }
  1975. /// <summary>
  1976. /// 获取团组费用审核
  1977. /// </summary>
  1978. /// <param name="_dto"></param>
  1979. /// <returns></returns>
  1980. [HttpPost]
  1981. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1982. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1983. {
  1984. try
  1985. {
  1986. #region 参数验证
  1987. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1988. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1989. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1990. #region 页面操作权限验证
  1991. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1992. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1993. #endregion
  1994. #endregion
  1995. var _view = new Grp_CreditCardPaymentView();
  1996. var clientNameList = getSimplClientList(_dto.DiId);
  1997. #region 费用清单
  1998. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1999. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2000. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2001. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2002. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2003. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2004. /*
  2005. * 76://酒店预订
  2006. */
  2007. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2008. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2009. /*
  2010. * 79://车/导游地接
  2011. */
  2012. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2013. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2014. /*
  2015. * 80: //签证
  2016. */
  2017. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2018. /*
  2019. *81: //邀请/公务活动
  2020. */
  2021. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2022. /*
  2023. * 82: //团组客户保险
  2024. */
  2025. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2026. /*
  2027. * Lable = 85 机票预订
  2028. */
  2029. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2030. /*
  2031. * 85 机票预定
  2032. */
  2033. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2034. /*
  2035. * 98 其他款项
  2036. */
  2037. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2038. /*
  2039. * 285:收款退还
  2040. */
  2041. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2042. /*
  2043. * 1015: //超支费用
  2044. */
  2045. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2046. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2047. /*
  2048. * 币种信息
  2049. */
  2050. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2051. /*
  2052. * 车/导游地接 费用类型
  2053. */
  2054. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2055. /*
  2056. * 车/导游地接 费用类型
  2057. */
  2058. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2059. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2060. /*
  2061. * 用户信息
  2062. */
  2063. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2064. /*
  2065. * 费用模块
  2066. */
  2067. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2068. string priceModule = string.Empty;
  2069. if (sdPriceName != null)
  2070. {
  2071. priceModule = sdPriceName.Name;
  2072. }
  2073. /*
  2074. * 成本信息
  2075. */
  2076. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2077. decimal _groupRate = 0.0000M;
  2078. string _groupCurrencyCode = "-";
  2079. if (groupCost != null)
  2080. {
  2081. _groupRate = groupCost.Rate;
  2082. if (int.TryParse(groupCost.Currency, out int _currency))
  2083. {
  2084. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2085. }
  2086. else _groupCurrencyCode = groupCost.Currency;
  2087. }
  2088. string costContentSql = $"Select * From Grp_GroupCost";
  2089. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2090. //处理日期为空的天数
  2091. for (int i = 0; i < groupCostDetails.Count; i++)
  2092. if (i != 0)
  2093. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2094. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2095. /*
  2096. * 处理详情数据
  2097. */
  2098. foreach (var entity in entityList)
  2099. {
  2100. var _detail = new Grp_CreditCardPaymentDetailView();
  2101. _detail.Id = entity.Id;
  2102. _detail.PriceName = priceModule;
  2103. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2104. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2105. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2106. //处理金额
  2107. if (entity.CTable == 1015)
  2108. {
  2109. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2110. if (czInfo != null)
  2111. {
  2112. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2113. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2114. }
  2115. }
  2116. /*
  2117. * 应付款金额
  2118. */
  2119. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2120. string PaymentCurrency_WaitPay = "Unknown";
  2121. string hotelCurrncyCode = "Unknown";
  2122. string hotelCurrncyName = "Unknown";
  2123. if (sdPaymentCurrency_WaitPay != null)
  2124. {
  2125. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2126. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2127. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2128. if (hotelCurrncyCode.Equals("CNY"))
  2129. {
  2130. entity.DayRate = 1.0000M;
  2131. }
  2132. }
  2133. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2134. /*
  2135. * 此次付款金额
  2136. */
  2137. decimal CurrPayStr = 0.00M,
  2138. OriginalCurrPay = 0.00M;
  2139. if (entity.PayPercentage == 0)
  2140. {
  2141. if (entity.PayThenMoney != 0)
  2142. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2143. }
  2144. else
  2145. {
  2146. if (entity.PayMoney != 0)
  2147. {
  2148. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2149. }
  2150. }
  2151. //if (_dto.Label == 79)
  2152. //{
  2153. // string original = string.Empty;
  2154. // if (hotelCurrncyCode.Equals("CNY"))
  2155. // {
  2156. // OriginalCurrPay = CurrPayStr;
  2157. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2158. // }
  2159. // else
  2160. // {
  2161. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2162. // //760 EUR(7600.00 CNY)
  2163. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2164. // }
  2165. //}
  2166. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2167. string original = string.Empty;
  2168. if (hotelCurrncyCode.Equals("CNY"))
  2169. {
  2170. OriginalCurrPay = CurrPayStr;
  2171. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2172. }
  2173. else
  2174. {
  2175. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2176. //760 EUR(7600.00 CNY)
  2177. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2178. }
  2179. /*
  2180. * 剩余尾款
  2181. */
  2182. decimal BalanceStr = 0;
  2183. if (CurrPayStr != 0)
  2184. {
  2185. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2186. BalanceStr = 0;
  2187. else
  2188. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2189. }
  2190. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2191. /*
  2192. * Bus名称
  2193. */
  2194. _detail.BusName = "待增加";
  2195. /*
  2196. *费用所属
  2197. */
  2198. switch (entity.CTable)
  2199. {
  2200. case 76://酒店预订
  2201. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2202. if (hotelReservations != null)
  2203. {
  2204. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2205. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2206. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2207. string roomFeeStr = "", roomFeestr1 = "";
  2208. //是否比较房型价格
  2209. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2210. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2211. roomFeeStr += $"<br/>";
  2212. var roomTotal = 0.00M;
  2213. if (hotelReservations.SingleRoomPrice > 0)
  2214. {
  2215. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  2216. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2217. //__isSingle = true;
  2218. roomTotal += fee;
  2219. }
  2220. if (hotelReservations.DoubleRoomPrice > 0)
  2221. {
  2222. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  2223. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2224. // __isDouble = true;
  2225. roomTotal += fee;
  2226. }
  2227. if (hotelReservations.SuiteRoomPrice > 0)
  2228. {
  2229. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  2230. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2231. //__isSuite = true;
  2232. roomTotal += fee;
  2233. }
  2234. if (hotelReservations.OtherRoomPrice > 0)
  2235. {
  2236. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2237. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2238. //__isOther = true;
  2239. roomTotal += fee;
  2240. }
  2241. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2242. else roomFeeStr += " 0.00 * 0";
  2243. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2244. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2245. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2246. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2247. /*
  2248. * 费用类型
  2249. * 1:房费
  2250. * 2:早餐
  2251. * 3:地税
  2252. * 4:城市税
  2253. * </summary>
  2254. */
  2255. //地税
  2256. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2257. if (governmentRentData != null)
  2258. {
  2259. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2260. governmentRentFee = governmentRentData.Price;
  2261. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2262. if (governmentRentCurrData != null)
  2263. {
  2264. governmentRentCode = governmentRentCurrData.Name;
  2265. governmentRentName = $"({governmentRentCurrData.Remark})";
  2266. }
  2267. }
  2268. //城市税
  2269. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2270. if (cityTaxData != null)
  2271. {
  2272. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2273. cityTaxFee = cityTaxData.Price;
  2274. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2275. if (cityTaxCurrData != null)
  2276. {
  2277. cityTaxCode = cityTaxCurrData.Name;
  2278. cityTaxName = $"({cityTaxCurrData.Remark})";
  2279. }
  2280. }
  2281. //酒店早餐
  2282. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2283. if (breakfastData != null)
  2284. {
  2285. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2286. breakfastFee = breakfastData.Price;
  2287. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2288. if (breakfastCurrData != null)
  2289. {
  2290. breakfastCode = breakfastCurrData.Name;
  2291. breakfastName = $"({breakfastCurrData.Remark})";
  2292. }
  2293. }
  2294. //房间费用
  2295. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2296. if (roomData != null)
  2297. {
  2298. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2299. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2300. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2301. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2302. roomFee = roomData.Price;
  2303. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2304. if (roomCurrData != null)
  2305. {
  2306. roomCode = roomCurrData.Name;
  2307. roomName = $"({roomCurrData.Remark})";
  2308. }
  2309. }
  2310. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2311. string hotelCostStr = "";
  2312. decimal hotelCsotTotal = 0.00M;
  2313. if (groupCost != null)
  2314. {
  2315. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2316. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2317. }
  2318. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2319. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2320. string hotelCost_day = "";
  2321. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2322. foreach (var item in hotelCostDetails1)
  2323. {
  2324. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2325. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2326. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2327. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2328. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2329. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2330. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2331. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2332. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2333. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2334. hotelCost_day += @$"<br/>";
  2335. }
  2336. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2337. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2338. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2339. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2340. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2341. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2342. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2343. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2344. $"房间说明: {hotelReservations.Remark} <br/>" +
  2345. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2346. $"{hotelBreakfastStr}" +
  2347. $"{hotelGovernmentRentStr}" +
  2348. $"{hotelCityTaxStr}";
  2349. _detail.PriceNameContent = hotelReservations.HotelName;
  2350. }
  2351. break;
  2352. case 79://车/导游地接
  2353. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2354. if (touristGuideGroundReservations != null)
  2355. {
  2356. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2357. {
  2358. _detail.BusName = touristGuideGroundReservations.BusName;
  2359. }
  2360. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2361. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2362. //if (isInt)
  2363. //{
  2364. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2365. // if (cityInfo != null)
  2366. // {
  2367. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2368. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2369. // if (carFeeItem != null)
  2370. // {
  2371. // nameContent += $@"({carFeeItem.Name})";
  2372. // }
  2373. // _detail.PriceNameContent = nameContent;
  2374. // }
  2375. //}
  2376. //else
  2377. //{
  2378. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2379. //}
  2380. var touristGuideGroundReservationsContents =
  2381. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2382. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2383. foreach (var item in touristGuideGroundReservationsContents)
  2384. {
  2385. string typeName = "Unknown";
  2386. string carCurrencyCode = "Unknown";
  2387. string carCurrencyName = "Unknown";
  2388. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2389. if (carTypeData != null) typeName = carTypeData.Name;
  2390. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2391. if (currencyData != null)
  2392. {
  2393. carCurrencyCode = currencyData.Name;
  2394. carCurrencyName = currencyData.Remark;
  2395. }
  2396. //op、成本 币种是否一致
  2397. bool IsCurrencyAgreement = false;
  2398. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2399. string opCostStr = string.Empty;
  2400. decimal opCostTypePrice = 0.00M;
  2401. #region 处理成本各项费用
  2402. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2403. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2404. if (opCost.Count > 0)
  2405. {
  2406. switch (item.SId)
  2407. {
  2408. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2409. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2410. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2411. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2412. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2413. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2414. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2415. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2416. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2417. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2418. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2419. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2420. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2421. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2422. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2423. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2424. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2425. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2426. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2427. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2428. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2429. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2430. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2431. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2432. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2433. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2434. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2435. }
  2436. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2437. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2438. }
  2439. #endregion
  2440. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2441. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2442. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2443. $"{opTypeStr} {opCostStr}<br/>" +
  2444. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2445. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2446. }
  2447. _detail.PriceMsgContent = priceMsg;
  2448. }
  2449. break;
  2450. case 80: //签证
  2451. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2452. if (visaInfo != null)
  2453. {
  2454. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2455. _detail.PriceNameContent = visaInfo.VisaDescription;
  2456. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2457. }
  2458. break;
  2459. case 81: //邀请/公务活动
  2460. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2461. if (_ioa != null)
  2462. {
  2463. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2464. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2465. sendCurrName = "Unknown", //快递费用币种 Name
  2466. sendCurrCode = "Unknown", //快递费用币种 Code
  2467. eventsCurrName = "Unknown", //公务活动费币种 Name
  2468. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2469. translateCurrName = "Unknown", //公务翻译费 Name
  2470. translateCurrCode = "Unknown"; //公务翻译费 Code
  2471. #region 处理费用币种
  2472. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2473. if (inviteCurrData != null)
  2474. {
  2475. inviteCurrName = inviteCurrData.Remark;
  2476. inviteCurrCode = inviteCurrData.Name;
  2477. }
  2478. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2479. if (sendCurrData != null)
  2480. {
  2481. sendCurrName = sendCurrData.Remark;
  2482. sendCurrCode = sendCurrData.Name;
  2483. }
  2484. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2485. if (eventsCurrData != null)
  2486. {
  2487. eventsCurrName = eventsCurrData.Remark;
  2488. eventsCurrCode = eventsCurrData.Name;
  2489. }
  2490. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2491. if (translateCurrData != null)
  2492. {
  2493. translateCurrName = translateCurrData.Remark;
  2494. translateCurrCode = translateCurrData.Name;
  2495. }
  2496. #endregion
  2497. _detail.PriceNameContent = _ioa.InviterArea;
  2498. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2499. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2500. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2501. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2502. $@"备注:" + _ioa.Remark + "<br/>";
  2503. }
  2504. break;
  2505. case 82: //团组客户保险
  2506. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2507. if (customers != null)
  2508. {
  2509. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2510. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2511. }
  2512. break;
  2513. case 85: //机票预订
  2514. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2515. if (jpRes != null)
  2516. {
  2517. string FlightsDescription = jpRes.FlightsDescription;
  2518. string PriceDescription = jpRes.PriceDescription;
  2519. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2520. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2521. }
  2522. break;
  2523. case 98://其他款项
  2524. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2525. if (gdpRes != null)
  2526. {
  2527. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2528. _detail.PriceNameContent = gdpRes.PriceName;
  2529. }
  2530. break;
  2531. case 285://收款退还
  2532. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2533. if (refundAndOtherMoney != null)
  2534. {
  2535. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2536. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2537. }
  2538. break;
  2539. case 751://酒店早餐
  2540. break;
  2541. case 1015://超支费用
  2542. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2543. if (groupExtraCost != null)
  2544. {
  2545. _detail.PriceNameContent = groupExtraCost.PriceName;
  2546. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2547. }
  2548. break;
  2549. default:
  2550. break;
  2551. }
  2552. /*
  2553. * 申请人
  2554. */
  2555. string operatorName = " - ";
  2556. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2557. if (_opUser != null)
  2558. {
  2559. operatorName = _opUser.CnName;
  2560. }
  2561. _detail.OperatorName = operatorName;
  2562. /*
  2563. * 审核人
  2564. */
  2565. string auditOperatorName = "Unknown";
  2566. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2567. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2568. else
  2569. {
  2570. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2571. if (_adUser != null)
  2572. {
  2573. auditOperatorName = _adUser.CnName;
  2574. }
  2575. }
  2576. _detail.AuditOperatorName = auditOperatorName;
  2577. /*
  2578. * 超预算比例
  2579. */
  2580. string overBudgetStr = "";
  2581. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2582. else if (entity.ExceedBudget == 0)
  2583. {
  2584. if (entity.CTable == 76 || entity.CTable == 79)
  2585. {
  2586. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2587. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2588. }
  2589. else
  2590. {
  2591. overBudgetStr = "未超预算";
  2592. }
  2593. }
  2594. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2595. _detail.OverBudget = overBudgetStr;
  2596. decimal auditFee = 0.00M; //已审核金额 人名币
  2597. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2598. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2599. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2600. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2601. {
  2602. auditedFeeOriginal = entity.PayMoney;
  2603. auditFee = CurrPayStr;
  2604. }
  2605. else if (entity.IsAuditGM == 0)
  2606. {
  2607. unAuditFeeCNY = CurrPayStr;
  2608. unAuditFeeOriginal = OriginalCurrPay;
  2609. OriginalCurrPay = 0.00M;
  2610. }
  2611. /*
  2612. * 费用总计
  2613. */
  2614. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2615. {
  2616. CurrencyId = entity.PaymentCurrency,
  2617. CurrencyName = PaymentCurrency_WaitPay,
  2618. AmountPayable = entity.PayMoney,
  2619. ThisPayment = OriginalCurrPay,
  2620. BalancePayment = BalanceStr,
  2621. AuditedFunds = auditFee,
  2622. AuditedFundsOriginal = auditedFeeOriginal,
  2623. UnAuditFundsCNY = unAuditFeeCNY,
  2624. UnAuditFundsOriginal = unAuditFeeOriginal
  2625. });
  2626. _detail.IsAuditGM = entity.IsAuditGM;
  2627. detailList.Add(_detail);
  2628. }
  2629. #endregion
  2630. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2631. /*
  2632. * 下方描述处理
  2633. */
  2634. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2635. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2636. if (ccpCurrencyPrice != null)
  2637. {
  2638. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2639. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2640. }
  2641. else
  2642. {
  2643. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2644. }
  2645. string amountPayableStr = string.Format(@"应付款总金额: ");
  2646. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2647. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2648. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2649. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2650. foreach (var item in nonDuplicat)
  2651. {
  2652. var currencyName = item.CurrencyName;
  2653. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2654. if (strs.Count > 0)
  2655. {
  2656. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2657. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2658. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2659. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2660. //单独处理此次付款金额
  2661. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2662. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2663. //单独处理已审核费用
  2664. //if (item.CurrencyId == 836) //人民币
  2665. //{
  2666. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2667. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2668. //}
  2669. //else
  2670. //{
  2671. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2672. //}
  2673. if (currencyName.Equals("CNY"))
  2674. {
  2675. //已审核费用
  2676. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2677. //未审核费用
  2678. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2679. }
  2680. else
  2681. {
  2682. //已审核费用
  2683. 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"));
  2684. //未审核费用
  2685. 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"));
  2686. }
  2687. }
  2688. }
  2689. _view.TotalStr1 = amountPayableStr[..^1];
  2690. _view.TotalStr2 = thisPaymentStr[..^1];
  2691. _view.TotalStr3 = balancePaymentStr[..^1];
  2692. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  2693. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2694. var _view1 = new
  2695. {
  2696. PageFuncAuth = pageFunAuthView,
  2697. Data = _view
  2698. };
  2699. return Ok(JsonView(_view1));
  2700. }
  2701. catch (Exception ex)
  2702. {
  2703. return Ok(JsonView(false, ex.Message));
  2704. }
  2705. }
  2706. /// <summary>
  2707. /// 费用审核
  2708. /// 修改团组费用审核状态
  2709. /// </summary>
  2710. /// <param name="_dto">参数Json字符串</param>
  2711. /// <returns></returns>
  2712. [HttpPost]
  2713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2714. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2715. {
  2716. #region 参数验证
  2717. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2718. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2719. #endregion
  2720. #region 页面操作权限验证
  2721. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2722. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2723. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2724. #endregion
  2725. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2726. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2727. DateTime dtNow = DateTime.Now;
  2728. _groupRepository.BeginTran();
  2729. int rst = 0;
  2730. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2731. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2732. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2733. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2734. List<dynamic> msgDatas = new List<dynamic>();
  2735. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2736. foreach (var item in idList)
  2737. {
  2738. int CreditId = int.Parse(item);
  2739. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2740. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2741. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2742. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2743. .Where(s => s.Id == CreditId)
  2744. .ExecuteCommandAsync();
  2745. if (result < 1)
  2746. {
  2747. rst = -1;
  2748. _groupRepository.RollbackTran();
  2749. return Ok(JsonView(false, "操作失败并回滚!"));
  2750. }
  2751. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2752. if (creditData != null)
  2753. {
  2754. #region 应用通知配置
  2755. try
  2756. {
  2757. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2758. }
  2759. catch (Exception ex)
  2760. {
  2761. }
  2762. #endregion
  2763. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2764. string groupNameStr = string.Empty;
  2765. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2766. if (groupData != null) groupNameStr = groupData.TeamName;
  2767. string creditTypeStr = string.Empty;
  2768. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2769. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2770. string creditCurrency = string.Empty;
  2771. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2772. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2773. if (creditCurrency.Equals("CNY"))
  2774. {
  2775. creditData.DayRate = 1.0000M;
  2776. }
  2777. if (creditData.PayPercentage == 0.00M)
  2778. {
  2779. creditData.PayPercentage = 100M;
  2780. }
  2781. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2782. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2783. string msgContent = "";
  2784. if (creditCurrency.Equals("CNY"))
  2785. {
  2786. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2787. }
  2788. else
  2789. {
  2790. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2791. }
  2792. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2793. }
  2794. }
  2795. if (rst == 0)
  2796. {
  2797. _groupRepository.CommitTran();
  2798. foreach (var item in msgDatas)
  2799. {
  2800. //发送消息
  2801. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2802. }
  2803. #region 应用推送
  2804. try
  2805. {
  2806. foreach (var ccpId in dic_ccp_user.Keys)
  2807. {
  2808. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2809. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2810. }
  2811. }
  2812. catch (Exception)
  2813. {
  2814. }
  2815. #endregion
  2816. return Ok(JsonView(true, "操作成功!"));
  2817. }
  2818. return Ok(JsonView(false, "操作失败!"));
  2819. }
  2820. #endregion
  2821. #region 机票费用录入
  2822. /// <summary>
  2823. /// 机票录入当前登录人可操作团组
  2824. /// </summary>
  2825. /// <param name="dto"></param>
  2826. /// <returns></returns>
  2827. [HttpPost]
  2828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2829. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2830. {
  2831. try
  2832. {
  2833. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2834. if (groupData.Code != 0)
  2835. {
  2836. return Ok(JsonView(false, groupData.Msg));
  2837. }
  2838. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2839. }
  2840. catch (Exception ex)
  2841. {
  2842. return Ok(JsonView(false, "程序错误!"));
  2843. throw;
  2844. }
  2845. }
  2846. /// <summary>
  2847. /// 机票费用录入列表
  2848. /// </summary>
  2849. /// <param name="dto"></param>
  2850. /// <returns></returns>
  2851. [HttpPost]
  2852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2853. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2854. {
  2855. try
  2856. {
  2857. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2858. if (groupData.Code != 0)
  2859. {
  2860. return Ok(JsonView(false, groupData.Msg));
  2861. }
  2862. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2863. }
  2864. catch (Exception ex)
  2865. {
  2866. return Ok(JsonView(false, ex.Message));
  2867. throw;
  2868. }
  2869. }
  2870. /// <summary>
  2871. /// 根据id查询费用录入信息
  2872. /// </summary>
  2873. /// <param name="dto"></param>
  2874. /// <returns></returns>
  2875. [HttpPost]
  2876. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2877. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2878. {
  2879. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2880. if (groupData.Code != 0)
  2881. {
  2882. return Ok(JsonView(false, groupData.Msg));
  2883. }
  2884. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2885. }
  2886. /// <summary>
  2887. /// 机票费用录入操作(Status:1.新增,2.修改)
  2888. /// </summary>
  2889. /// <param name="dto"></param>
  2890. /// <returns></returns>
  2891. [HttpPost]
  2892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2893. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2894. {
  2895. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2896. if (groupData.Code != 0)
  2897. {
  2898. return Ok(JsonView(false, groupData.Msg));
  2899. }
  2900. #region 应用推送
  2901. try
  2902. {
  2903. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2904. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2905. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2906. //2024-10-21 新增LZ UID
  2907. var userIds = new List<int>() { 21 };
  2908. string title = $"系统通知";
  2909. string content = "";
  2910. var diId = dto.AirTicketResOpData.DiId;
  2911. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2912. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2913. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2914. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2915. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2916. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2917. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2918. }
  2919. catch (Exception ex)
  2920. {
  2921. }
  2922. #endregion
  2923. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2924. }
  2925. /// <summary>
  2926. /// 根据舱位类型查询接团客户名单信息
  2927. /// </summary>
  2928. /// <param name="dto"></param>
  2929. /// <returns></returns>
  2930. [HttpPost]
  2931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2932. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2933. {
  2934. try
  2935. {
  2936. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2937. if (crm_Groups.Count != 0)
  2938. {
  2939. List<dynamic> Customer = new List<dynamic>();
  2940. foreach (var item in crm_Groups)
  2941. {
  2942. var data = new
  2943. {
  2944. Id = item.Id,
  2945. Pinyin = item.Pinyin,
  2946. Name = item.LastName + item.FirstName
  2947. };
  2948. Customer.Add(data);
  2949. }
  2950. return Ok(JsonView(true, "查询成功!", Customer));
  2951. }
  2952. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2953. }
  2954. catch (Exception ex)
  2955. {
  2956. return Ok(JsonView(false, "程序错误!"));
  2957. throw;
  2958. }
  2959. }
  2960. /// <summary>
  2961. /// 根据团号获取客户信息
  2962. /// </summary>
  2963. /// <param name="dto"></param>
  2964. /// <returns></returns>
  2965. [HttpPost]
  2966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2967. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2968. {
  2969. var jw = JsonView(false);
  2970. if (dto.DIID < 1)
  2971. {
  2972. jw.Msg += "请输入正确的diid";
  2973. return Ok(jw);
  2974. }
  2975. var arr = getSimplClientList(dto.DIID);
  2976. jw = JsonView(true, "获取成功!", arr);
  2977. return Ok(jw);
  2978. }
  2979. private List<SimplClientInfo> getSimplClientList(int diId)
  2980. {
  2981. 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);
  2982. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2983. foreach (var item in arr)
  2984. {
  2985. EncryptionProcessor.DecryptProperties(item);
  2986. }
  2987. return arr;
  2988. }
  2989. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2990. {
  2991. string result = origin;
  2992. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2993. {
  2994. string[] temparr = origin.Split(',');
  2995. string fistrStr = temparr[0];
  2996. int count = temparr.Count();
  2997. int tempId;
  2998. bool success = int.TryParse(fistrStr, out tempId);
  2999. if (success)
  3000. {
  3001. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3002. if (tempInfo != null)
  3003. {
  3004. if (count > 1)
  3005. {
  3006. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  3007. }
  3008. else
  3009. {
  3010. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  3011. }
  3012. }
  3013. }
  3014. }
  3015. return result;
  3016. }
  3017. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  3018. {
  3019. string result = origin;
  3020. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3021. {
  3022. string[] temparr = origin.Split(',');
  3023. result = "";
  3024. foreach (var item in temparr)
  3025. {
  3026. int tempId;
  3027. bool success = int.TryParse(item, out tempId);
  3028. if (success)
  3029. {
  3030. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3031. if (tempInfo != null)
  3032. {
  3033. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  3034. }
  3035. }
  3036. }
  3037. }
  3038. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  3039. return result;
  3040. }
  3041. /// <summary>
  3042. /// 机票费用录入,删除
  3043. /// </summary>
  3044. /// <param name="dto"></param>
  3045. /// <returns></returns>
  3046. [HttpPost]
  3047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3048. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  3049. {
  3050. try
  3051. {
  3052. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3053. if (res)
  3054. {
  3055. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  3056. {
  3057. IsDel = 1,
  3058. DeleteUserId = dto.DeleteUserId,
  3059. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3060. }).ExecuteCommandAsync();
  3061. return Ok(JsonView(true, "删除成功!"));
  3062. }
  3063. return Ok(JsonView(false, "删除失败!"));
  3064. }
  3065. catch (Exception ex)
  3066. {
  3067. return Ok(JsonView(false, "程序错误!"));
  3068. throw;
  3069. }
  3070. }
  3071. /// <summary>
  3072. /// 导出机票录入报表
  3073. /// </summary>
  3074. /// <param name="dto"></param>
  3075. /// <returns></returns>
  3076. [HttpPost]
  3077. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3078. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  3079. {
  3080. try
  3081. {
  3082. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  3083. if (groupData.Code != 0)
  3084. {
  3085. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3086. }
  3087. else
  3088. {
  3089. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  3090. if (AirTicketReservations.Count != 0)
  3091. {
  3092. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  3093. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  3094. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  3095. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  3096. WorkbookDesigner designer = new WorkbookDesigner();
  3097. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  3098. decimal countCost = 0;
  3099. foreach (var item in AirTicketReservations)
  3100. {
  3101. #region 处理客人姓名
  3102. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  3103. item.ClientName = clientNames;
  3104. #endregion
  3105. if (item.BankType == "其他")
  3106. {
  3107. item.BankNo = "--";
  3108. }
  3109. else
  3110. {
  3111. if (!string.IsNullOrEmpty(item.BankType))
  3112. {
  3113. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  3114. }
  3115. }
  3116. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  3117. item.Price = System.Decimal.Round(item.Price, 2);
  3118. countCost += Convert.ToDecimal(item.Price);
  3119. }
  3120. designer.SetDataSource("Export", AirTicketReservations);
  3121. designer.SetDataSource("ExportDiCode", diCode);
  3122. designer.SetDataSource("ExportDiName", diName);
  3123. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  3124. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  3125. designer.Process();
  3126. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  3127. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  3128. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  3129. return Ok(JsonView(true, "成功", url = rst));
  3130. }
  3131. else
  3132. {
  3133. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  3134. }
  3135. }
  3136. }
  3137. catch (Exception ex)
  3138. {
  3139. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  3140. throw;
  3141. }
  3142. }
  3143. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3144. /// <summary>
  3145. /// 行程单导出
  3146. /// </summary>
  3147. /// <param name="dto"></param>
  3148. /// <returns></returns>
  3149. [HttpPost]
  3150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3151. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  3152. {
  3153. try
  3154. {
  3155. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  3156. if (groupData.Code != 0)
  3157. {
  3158. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  3159. }
  3160. else
  3161. {
  3162. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  3163. if (dto.Language == "CN")
  3164. {
  3165. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  3166. DocumentBuilder builder = new DocumentBuilder(doc);
  3167. int tableIndex = 0;//表格索引
  3168. //得到文档中的第一个表格
  3169. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3170. foreach (var item in _AirTicketReservations)
  3171. {
  3172. #region 处理固定数据
  3173. string[] FlightsCode = item.FlightsCode.Split('/');
  3174. if (FlightsCode.Length != 0)
  3175. {
  3176. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3177. if (_AirCompany != null)
  3178. {
  3179. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3180. }
  3181. else
  3182. {
  3183. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3184. }
  3185. }
  3186. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3187. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3188. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3189. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3190. string name = "";
  3191. foreach (string clientName in nameArray)
  3192. {
  3193. if (!name.Contains(clientName))
  3194. {
  3195. name += clientName + ",";
  3196. }
  3197. }
  3198. if (!string.IsNullOrWhiteSpace(name))
  3199. {
  3200. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3201. }
  3202. else
  3203. {
  3204. table.Range.Bookmarks["ClientName"].Text = "--";
  3205. }
  3206. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3207. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3208. table.Range.Bookmarks["JointTicket"].Text = "--";
  3209. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3210. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3211. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3212. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3213. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3214. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3215. #endregion
  3216. #region 循环数据处理
  3217. List<AirInfo> airs = new List<AirInfo>();
  3218. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3219. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3220. for (int i = 0; i < FlightsCode.Length; i++)
  3221. {
  3222. AirInfo air = new AirInfo();
  3223. string[] tempstr = DayArray[i]
  3224. .Replace("\r\n", string.Empty)
  3225. .Replace("\\r\\n", string.Empty)
  3226. .TrimStart().TrimEnd()
  3227. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3228. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3229. string starCity = "";
  3230. if (star_Three != null)
  3231. {
  3232. starCity = star_Three.AirPort;
  3233. }
  3234. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3235. string EndCity = "";
  3236. if (End_Three != null)
  3237. {
  3238. EndCity = End_Three.AirPort;
  3239. }
  3240. air.Destination = starCity + "/" + EndCity;
  3241. air.Flight = FlightsCode[i];
  3242. air.SeatingClass = item.CTypeName;
  3243. string dateTime = tempstr[2];
  3244. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3245. air.FlightDate = DateTemp;
  3246. air.DepartureTime = tempstr[5];
  3247. air.LandingTime = tempstr[6];
  3248. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3249. air.TicketStatus = "--";
  3250. air.Luggage = "--";
  3251. air.DepartureTerminal = "--";
  3252. air.LandingTerminal = "--";
  3253. airs.Add(air);
  3254. }
  3255. int row = 13;
  3256. for (int i = 0; i < airs.Count; i++)
  3257. {
  3258. if (airs.Count > 2)
  3259. {
  3260. for (int j = 0; j < airs.Count - 2; j++)
  3261. {
  3262. var CopyRow = table.Rows[12].Clone(true);
  3263. table.Rows.Add(CopyRow);
  3264. }
  3265. }
  3266. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3267. int index = 0;
  3268. foreach (PropertyInfo property in properties)
  3269. {
  3270. string value = property.GetValue(airs[i]).ToString();
  3271. Cell ishcel0 = table.Rows[row].Cells[index];
  3272. Paragraph p = new Paragraph(doc);
  3273. string s = value;
  3274. p.AppendChild(new Run(doc, s));
  3275. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3276. ishcel0.AppendChild(p);
  3277. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3278. index++;
  3279. }
  3280. row++;
  3281. }
  3282. #endregion
  3283. Paragraph lastParagraph = new Paragraph(doc);
  3284. //第一个表格末尾加段落
  3285. table.ParentNode.InsertAfter(lastParagraph, table);
  3286. //复制第一个表格
  3287. Table cloneTable = (Table)table.Clone(true);
  3288. //在文档末尾段落后面加入复制的表格
  3289. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3290. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3291. {
  3292. int rownewsIndex = 13;
  3293. for (int i = 0; i < 2; i++)
  3294. {
  3295. var CopyRow = table.Rows[12].Clone(true);
  3296. table.Rows.RemoveAt(13);
  3297. table.Rows.Add(CopyRow);
  3298. rownewsIndex++;
  3299. }
  3300. }
  3301. else
  3302. {
  3303. table.Rows.RemoveAt(12);
  3304. }
  3305. cloneTable.Rows.RemoveAt(12);
  3306. }
  3307. if (_AirTicketReservations.Count != 0)
  3308. {
  3309. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3310. if (FlightsCode.Length != 0)
  3311. {
  3312. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3313. if (_AirCompany != null)
  3314. {
  3315. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3316. }
  3317. else
  3318. {
  3319. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3320. }
  3321. }
  3322. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3323. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3324. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3325. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3326. string name = "";
  3327. foreach (string clientName in nameArray)
  3328. {
  3329. if (!name.Contains(clientName))
  3330. {
  3331. name += clientName + ",";
  3332. }
  3333. }
  3334. if (!string.IsNullOrWhiteSpace(name))
  3335. {
  3336. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3337. }
  3338. else
  3339. {
  3340. table.Range.Bookmarks["ClientName"].Text = "--";
  3341. }
  3342. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3343. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3344. table.Range.Bookmarks["JointTicket"].Text = "--";
  3345. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3346. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3347. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3348. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3349. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3350. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3351. }
  3352. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3353. //保存合并后的文档
  3354. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3355. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3356. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3357. return Ok(JsonView(true, "成功!", rst));
  3358. }
  3359. else
  3360. {
  3361. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3362. DocumentBuilder builder = new DocumentBuilder(doc);
  3363. int tableIndex = 0;//表格索引
  3364. //得到文档中的第一个表格
  3365. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3366. List<string> texts = new List<string>();
  3367. foreach (var item in _AirTicketReservations)
  3368. {
  3369. string[] FlightsCode = item.FlightsCode.Split('/');
  3370. if (FlightsCode.Length != 0)
  3371. {
  3372. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3373. if (_AirCompany != null)
  3374. {
  3375. if (!transDic.ContainsKey(_AirCompany.CnName))
  3376. {
  3377. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3378. }
  3379. }
  3380. else
  3381. {
  3382. if (!transDic.ContainsKey("--"))
  3383. {
  3384. transDic.Add("--", "--");
  3385. }
  3386. }
  3387. }
  3388. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3389. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3390. string name = "";
  3391. foreach (string clientName in nameArray)
  3392. {
  3393. name += clientName + ",";
  3394. }
  3395. if (!texts.Contains(name))
  3396. {
  3397. texts.Add(name);
  3398. }
  3399. List<AirInfo> airs = new List<AirInfo>();
  3400. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3401. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3402. for (int i = 0; i < FlightsCode.Length; i++)
  3403. {
  3404. AirInfo air = new AirInfo();
  3405. string[] tempstr = DayArray[i]
  3406. .Replace("\r\n", string.Empty)
  3407. .Replace("\\r\\n", string.Empty)
  3408. .TrimStart().TrimEnd()
  3409. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3410. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3411. if (star_Three != null)
  3412. {
  3413. if (!transDic.ContainsKey(star_Three.AirPort))
  3414. {
  3415. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3416. }
  3417. }
  3418. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3419. if (End_Three != null)
  3420. {
  3421. if (!transDic.ContainsKey(End_Three.AirPort))
  3422. {
  3423. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3424. }
  3425. }
  3426. if (!texts.Contains(item.CTypeName))
  3427. {
  3428. texts.Add(item.CTypeName);
  3429. }
  3430. }
  3431. }
  3432. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  3433. if (transData.Count > 0)
  3434. {
  3435. foreach (TranslateResult item in transData)
  3436. {
  3437. if (!transDic.ContainsKey(item.Query))
  3438. {
  3439. transDic.Add(item.Query, item.Translation);
  3440. }
  3441. }
  3442. }
  3443. foreach (var item in _AirTicketReservations)
  3444. {
  3445. #region 处理固定数据
  3446. string[] FlightsCode = item.FlightsCode.Split('/');
  3447. if (FlightsCode.Length != 0)
  3448. {
  3449. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3450. if (_AirCompany != null)
  3451. {
  3452. string str = "--";
  3453. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3454. if (!string.IsNullOrEmpty(translateResult))
  3455. {
  3456. str = translateResult;
  3457. str = _airTicketResRep.Processing(str);
  3458. }
  3459. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3460. }
  3461. else
  3462. {
  3463. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3464. }
  3465. }
  3466. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3467. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3468. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3469. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3470. string names = "";
  3471. foreach (string clientName in nameArray)
  3472. {
  3473. names += clientName + ",";
  3474. }
  3475. if (!string.IsNullOrWhiteSpace(names))
  3476. {
  3477. string str = "--";
  3478. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3479. if (!string.IsNullOrEmpty(translateResult))
  3480. {
  3481. str = translateResult;
  3482. str = _airTicketResRep.Processing(str);
  3483. }
  3484. table.Range.Bookmarks["ClientName"].Text = str;
  3485. }
  3486. else
  3487. {
  3488. table.Range.Bookmarks["ClientName"].Text = "--";
  3489. }
  3490. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3491. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3492. table.Range.Bookmarks["JointTicket"].Text = "--";
  3493. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3494. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3495. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3496. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3497. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3498. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3499. #endregion
  3500. #region 循环数据处理
  3501. List<AirInfo> airs = new List<AirInfo>();
  3502. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3503. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3504. for (int i = 0; i < FlightsCode.Length; i++)
  3505. {
  3506. AirInfo air = new AirInfo();
  3507. string[] tempstr = DayArray[i]
  3508. .Replace("\r\n", string.Empty)
  3509. .Replace("\\r\\n", string.Empty)
  3510. .TrimStart().TrimEnd()
  3511. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3512. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3513. string starCity = "";
  3514. if (star_Three != null)
  3515. {
  3516. string str2 = "--";
  3517. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3518. if (!string.IsNullOrEmpty(translateResult2))
  3519. {
  3520. str2 = translateResult2;
  3521. str2 = _airTicketResRep.Processing(str2);
  3522. }
  3523. starCity = str2;
  3524. }
  3525. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3526. string EndCity = "";
  3527. if (End_Three != null)
  3528. {
  3529. string str1 = "--";
  3530. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3531. if (!string.IsNullOrEmpty(translateResult1))
  3532. {
  3533. str1 = translateResult1;
  3534. str1 = _airTicketResRep.Processing(str1);
  3535. }
  3536. EndCity = str1;
  3537. }
  3538. air.Destination = starCity + "/" + EndCity;
  3539. air.Flight = FlightsCode[i];
  3540. string str = "--";
  3541. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3542. if (!string.IsNullOrEmpty(translateResult))
  3543. {
  3544. str = translateResult;
  3545. str = _airTicketResRep.Processing(str);
  3546. }
  3547. air.SeatingClass = str;
  3548. string dateTime = tempstr[2];
  3549. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3550. air.FlightDate = DateTemp;
  3551. air.DepartureTime = tempstr[5];
  3552. air.LandingTime = tempstr[6];
  3553. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3554. air.TicketStatus = "--";
  3555. air.Luggage = "--";
  3556. air.DepartureTerminal = "--";
  3557. air.LandingTerminal = "--";
  3558. airs.Add(air);
  3559. }
  3560. int row = 13;
  3561. for (int i = 0; i < airs.Count; i++)
  3562. {
  3563. if (airs.Count > 2)
  3564. {
  3565. for (int j = 0; j < airs.Count - 2; j++)
  3566. {
  3567. var CopyRow = table.Rows[12].Clone(true);
  3568. table.Rows.Add(CopyRow);
  3569. }
  3570. }
  3571. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3572. int index = 0;
  3573. foreach (PropertyInfo property in properties)
  3574. {
  3575. string value = property.GetValue(airs[i]).ToString();
  3576. Cell ishcel0 = table.Rows[row].Cells[index];
  3577. Paragraph p = new Paragraph(doc);
  3578. string s = value;
  3579. p.AppendChild(new Run(doc, s));
  3580. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3581. ishcel0.AppendChild(p);
  3582. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3583. //ishcel0.CellFormat.VerticalAlignment=
  3584. index++;
  3585. }
  3586. row++;
  3587. }
  3588. #endregion
  3589. Paragraph lastParagraph = new Paragraph(doc);
  3590. //第一个表格末尾加段落
  3591. table.ParentNode.InsertAfter(lastParagraph, table);
  3592. //复制第一个表格
  3593. Table cloneTable = (Table)table.Clone(true);
  3594. //在文档末尾段落后面加入复制的表格
  3595. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3596. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3597. {
  3598. int rownewsIndex = 13;
  3599. for (int i = 0; i < 2; i++)
  3600. {
  3601. var CopyRow = table.Rows[12].Clone(true);
  3602. table.Rows.RemoveAt(13);
  3603. table.Rows.Add(CopyRow);
  3604. rownewsIndex++;
  3605. }
  3606. }
  3607. else
  3608. {
  3609. table.Rows.RemoveAt(12);
  3610. }
  3611. cloneTable.Rows.RemoveAt(12);
  3612. }
  3613. if (_AirTicketReservations.Count != 0)
  3614. {
  3615. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3616. if (FlightsCode.Length != 0)
  3617. {
  3618. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3619. if (_AirCompany != null)
  3620. {
  3621. string str = "--";
  3622. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3623. if (!string.IsNullOrEmpty(translateResult))
  3624. {
  3625. str = translateResult;
  3626. str = _airTicketResRep.Processing(str);
  3627. }
  3628. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3629. }
  3630. else
  3631. {
  3632. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3633. }
  3634. }
  3635. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3636. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3637. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3638. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3639. string names = "";
  3640. foreach (string clientName in nameArray)
  3641. {
  3642. names += clientName + ",";
  3643. }
  3644. if (!string.IsNullOrWhiteSpace(names))
  3645. {
  3646. string str = "--";
  3647. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3648. if (!string.IsNullOrEmpty(translateResult))
  3649. {
  3650. str = translateResult;
  3651. str = _airTicketResRep.Processing(str);
  3652. }
  3653. table.Range.Bookmarks["ClientName"].Text = str;
  3654. }
  3655. else
  3656. {
  3657. table.Range.Bookmarks["ClientName"].Text = "--";
  3658. }
  3659. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3660. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3661. table.Range.Bookmarks["JointTicket"].Text = "--";
  3662. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3663. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3664. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3665. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3666. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3667. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3668. }
  3669. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3670. //保存合并后的文档
  3671. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3672. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3673. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3674. return Ok(JsonView(true, "成功!", rst));
  3675. }
  3676. }
  3677. }
  3678. catch (Exception ex)
  3679. {
  3680. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3681. throw;
  3682. }
  3683. }
  3684. #endregion
  3685. #region 团组增减款项 --> 其他款项
  3686. /// <summary>
  3687. /// 团组增减款项下拉框绑定
  3688. /// </summary>
  3689. /// <param name="dto"></param>
  3690. /// <returns></returns>
  3691. [HttpPost]
  3692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3693. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3694. {
  3695. #region 参数验证
  3696. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3697. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3698. #endregion
  3699. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3700. }
  3701. /// <summary>
  3702. /// 根据团组Id查询团组增减款项
  3703. /// </summary>
  3704. /// <param name="dto"></param>
  3705. /// <returns></returns>
  3706. [HttpPost]
  3707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3708. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3709. {
  3710. #region 参数验证
  3711. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3712. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3713. #endregion
  3714. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3715. }
  3716. /// <summary>
  3717. /// 团组增减款项操作(Status:1.新增,2.修改)
  3718. /// </summary>
  3719. /// <param name="dto"></param>
  3720. /// <returns></returns>
  3721. [HttpPost]
  3722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3723. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3724. {
  3725. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3726. if (groupData.Code != 200)
  3727. {
  3728. return Ok(JsonView(false, groupData.Msg));
  3729. }
  3730. #region 应用推送
  3731. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3732. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3733. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3734. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  3735. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  3736. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  3737. //自动审核
  3738. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3739. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3740. //2024-10-21 新增LZ UID
  3741. var userIds = new List<int>() { 21 };
  3742. string title = $"系统通知";
  3743. string content = "";
  3744. var diId = dto.DiId;
  3745. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3746. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3747. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3748. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3749. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3750. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3751. #endregion
  3752. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3753. }
  3754. /// <summary>
  3755. /// 团组增减款项操作 删除
  3756. /// </summary>
  3757. /// <param name="dto"></param>
  3758. /// <returns></returns>
  3759. [HttpPost]
  3760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3761. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3762. {
  3763. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3764. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3765. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3766. if (res.Code == 0)
  3767. {
  3768. return Ok(JsonView(true, "删除成功!"));
  3769. }
  3770. return Ok(JsonView(false, "删除失败!"));
  3771. }
  3772. /// <summary>
  3773. /// 根据团组增减款项Id查询
  3774. /// </summary>
  3775. /// <param name="dto"></param>
  3776. /// <returns></returns>
  3777. [HttpPost]
  3778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3779. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3780. {
  3781. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3782. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3783. }
  3784. /// <summary>
  3785. /// 查询供应商名称
  3786. /// </summary>
  3787. /// <param name="dto"></param>
  3788. /// <returns></returns>
  3789. [HttpPost]
  3790. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3791. {
  3792. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3793. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3794. ?? new List<Grp_DecreasePayments>();
  3795. dbResult = dbResult.Distinct(new
  3796. ProductComparer()).ToList();
  3797. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3798. {
  3799. x.Id,
  3800. x.SupplierAddress,
  3801. x.SupplierArea,
  3802. x.SupplierContact,
  3803. x.SupplierContactNumber,
  3804. x.SupplierEmail,
  3805. x.SupplierName,
  3806. x.SupplierSocialAccount,
  3807. x.SupplierTypeId,
  3808. }).ToList());
  3809. return Ok(jw);
  3810. }
  3811. /// <summary>
  3812. /// 团组增减款项 OTA匹配
  3813. /// </summary>
  3814. /// <param name="file"></param>
  3815. /// <returns></returns>
  3816. [HttpPost]
  3817. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3818. {
  3819. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3820. string fileName = file.FileName;
  3821. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3822. {
  3823. return Ok(JsonView(false, "请上传Excel文件!"));
  3824. }
  3825. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3826. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3827. if (!Directory.Exists(path))
  3828. {
  3829. Directory.CreateDirectory(path);
  3830. }
  3831. var filePath = @$"{path}/{fileName}";
  3832. //保存文件
  3833. using (FileStream fs = System.IO.File.Create(filePath))
  3834. {
  3835. file.CopyTo(fs);
  3836. fs.Flush();
  3837. }
  3838. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3839. //读取ExcelFile
  3840. DataTable dt = ConvertExcelToDataTable(filePath);
  3841. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3842. dt.TableName = "TB";
  3843. //修改table列名
  3844. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3845. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3846. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3847. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3848. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3849. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3850. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3851. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3852. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3853. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3854. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3855. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3856. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3857. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3858. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3859. var otaOrderNos = new List<string>();
  3860. foreach (DataRow item in dt.Rows)
  3861. {
  3862. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3863. }
  3864. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3865. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3866. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3867. .Select((dp, di) => new
  3868. {
  3869. dp.PriceName,
  3870. dp.OTAOrderNo,
  3871. dp.FeeTotal,
  3872. di.TeamName,
  3873. })
  3874. .ToListAsync();
  3875. foreach (DataRow item in dt.Rows)
  3876. {
  3877. var otaOrderNo = item["OTAOrderNo"].ToString();
  3878. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3879. if (oaData == null) continue;
  3880. item["GroupName"] = oaData.TeamName;
  3881. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3882. }
  3883. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3884. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3885. List<DataTable> datas = new List<DataTable>();
  3886. datas.Add(dt);
  3887. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3888. return Ok(JsonView(true, "操作成功", new { url = url }));
  3889. }
  3890. #region
  3891. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3892. {
  3893. // 创建Workbook对象
  3894. Workbook workbook = new Workbook(excelFilePath);
  3895. // 获取第一个工作表
  3896. Worksheet worksheet = workbook.Worksheets[0];
  3897. // 将工作表转换为DataTable
  3898. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3899. return dataTable;
  3900. }
  3901. #endregion
  3902. #endregion
  3903. #region 文件上传、删除
  3904. /// <summary>
  3905. /// region 文件上传 可以带参数
  3906. /// </summary>
  3907. /// <param name="file"></param>
  3908. /// <returns></returns>
  3909. [HttpPost]
  3910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3911. public async Task<IActionResult> UploadProject(IFormFile file)
  3912. {
  3913. //var TypeName = Request.Headers["TypeName"].ToString();
  3914. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3915. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3916. ////文件名称
  3917. //string projectFileName = file.FileName;
  3918. ////上传的文件的路径
  3919. //string filePath = $"{fileDir}/{projectFileName}";
  3920. //if (TypeName == "A")//A代表团组增减款项
  3921. //{
  3922. // filePath = fileDir + $@"\团组增减款项相关文件";
  3923. // if (!Directory.Exists(filePath))
  3924. // {
  3925. // Directory.CreateDirectory(filePath);
  3926. // }
  3927. // //上传的文件的路径
  3928. // filePath += $@"\{projectFileName}";
  3929. //}
  3930. //else if (TypeName == "B")//B代表商邀相关文件
  3931. //{
  3932. // //上传的文件的路径
  3933. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3934. // if (!Directory.Exists(filePath))
  3935. // {
  3936. // Directory.CreateDirectory(filePath);
  3937. // }
  3938. // //上传的文件的路径
  3939. // filePath = $@"\{projectFileName}";
  3940. //}
  3941. //try
  3942. //{
  3943. // using (FileStream fs = System.IO.File.Create(filePath))
  3944. // {
  3945. // file.CopyTo(fs);
  3946. // fs.Flush();
  3947. // }
  3948. //}
  3949. //catch (Exception ex)
  3950. //{
  3951. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3952. //}
  3953. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3954. try
  3955. {
  3956. var TypeName = Request.Headers["TypeName"].ToString();
  3957. if (file != null)
  3958. {
  3959. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3960. //文件名称
  3961. string projectFileName = file.FileName;
  3962. //上传的文件的路径
  3963. string filePath = $"{fileDir}/{projectFileName}";
  3964. if (TypeName == "A")//A代表团组增减款项
  3965. {
  3966. if (!Directory.Exists(fileDir))
  3967. {
  3968. Directory.CreateDirectory(fileDir);
  3969. }
  3970. //上传的文件的路径
  3971. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3972. }
  3973. else if (TypeName == "B")//B代表商邀相关文件
  3974. {
  3975. if (!Directory.Exists(fileDir))
  3976. {
  3977. Directory.CreateDirectory(fileDir);
  3978. }
  3979. //上传的文件的路径
  3980. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3981. }
  3982. using (FileStream fs = System.IO.File.Create(filePath))
  3983. {
  3984. file.CopyTo(fs);
  3985. fs.Flush();
  3986. }
  3987. return Ok(JsonView(true, "上传成功!", projectFileName));
  3988. }
  3989. else
  3990. {
  3991. return Ok(JsonView(false, "上传失败!"));
  3992. }
  3993. }
  3994. catch (Exception ex)
  3995. {
  3996. return Ok(JsonView(false, "程序错误!"));
  3997. }
  3998. }
  3999. /// <summary>
  4000. /// 删除指定文件
  4001. /// </summary>
  4002. /// <param name="dto"></param>
  4003. /// <returns></returns>
  4004. [HttpPost]
  4005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4006. public async Task<IActionResult> DelFile(DelFileDto dto)
  4007. {
  4008. try
  4009. {
  4010. var TypeName = Request.Headers["TypeName"].ToString();
  4011. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4012. string filePath = "";
  4013. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4014. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4015. int id = 0;
  4016. if (TypeName == "A")
  4017. {
  4018. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  4019. // 删除该文件
  4020. System.IO.File.Delete(filePath);
  4021. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  4022. .Where(a => a.Id == dto.Id)
  4023. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  4024. .ExecuteCommandAsync();
  4025. }
  4026. else if (TypeName == "B")
  4027. {
  4028. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  4029. // 删除该文件
  4030. System.IO.File.Delete(filePath);
  4031. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  4032. if (info != null)
  4033. {
  4034. string[] files = new string[] { };
  4035. if (!string.IsNullOrEmpty(info.Attachment))
  4036. {
  4037. try
  4038. {
  4039. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  4040. }
  4041. catch (Exception)
  4042. {
  4043. files = new List<string>() { info.Attachment }.ToArray();
  4044. }
  4045. }
  4046. if (files.Length > 0)
  4047. {
  4048. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  4049. string filePath2 = string.Empty;
  4050. if (files1.Length > 0)
  4051. {
  4052. filePath2 = JsonConvert.SerializeObject(files1);
  4053. }
  4054. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4055. .Where(a => a.Id == dto.Id)
  4056. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  4057. .ExecuteCommandAsync();
  4058. }
  4059. }
  4060. }
  4061. if (id != 0)
  4062. {
  4063. return Ok(JsonView(true, "成功!"));
  4064. }
  4065. else
  4066. {
  4067. return Ok(JsonView(false, "失败!"));
  4068. }
  4069. }
  4070. catch (Exception ex)
  4071. {
  4072. return Ok(JsonView(false, "程序错误!"));
  4073. throw;
  4074. }
  4075. }
  4076. /// <summary>
  4077. /// 文件上传多个文件 可以带参数
  4078. /// </summary>
  4079. /// <param name="files"></param>
  4080. /// <returns></returns>
  4081. [HttpPost]
  4082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4083. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  4084. {
  4085. try
  4086. {
  4087. var TypeName = Request.Headers["TypeName"].ToString();
  4088. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4089. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  4090. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4091. var filePahts = new List<string>();
  4092. foreach (var file in files)
  4093. {
  4094. //文件名称
  4095. string projectFileName = file.FileName;
  4096. //上传的文件的路径
  4097. string filePath = $"{fileDir}/{projectFileName}";
  4098. if (TypeName == "A")//A代表团组增减款项
  4099. {
  4100. if (!Directory.Exists(fileDir))
  4101. {
  4102. Directory.CreateDirectory(fileDir);
  4103. }
  4104. //上传的文件的路径
  4105. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4106. }
  4107. else if (TypeName == "B")//B代表商邀相关文件
  4108. {
  4109. if (!Directory.Exists(fileDir))
  4110. {
  4111. Directory.CreateDirectory(fileDir);
  4112. }
  4113. //上传的文件的路径
  4114. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4115. }
  4116. using (FileStream fs = System.IO.File.Create(filePath))
  4117. {
  4118. file.CopyTo(fs);
  4119. fs.Flush();
  4120. }
  4121. filePahts.Add(projectFileName);
  4122. }
  4123. return Ok(JsonView(true, "上传成功!", filePahts));
  4124. }
  4125. catch (Exception ex)
  4126. {
  4127. return Ok(JsonView(false, "程序错误!"));
  4128. }
  4129. }
  4130. #endregion
  4131. #region 商邀费用录入
  4132. /// <summary>
  4133. /// 根据团组Id查询商邀费用列表
  4134. /// </summary>
  4135. /// <param name="dto"></param>
  4136. /// <returns></returns>
  4137. [HttpPost]
  4138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4139. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  4140. {
  4141. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  4142. if (groupData.Code != 0)
  4143. {
  4144. return Ok(JsonView(false, groupData.Msg));
  4145. }
  4146. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4147. }
  4148. /// <summary>
  4149. /// 商邀费用列表
  4150. /// 下载文件
  4151. /// </summary>
  4152. /// <param name="id"></param>
  4153. /// <returns></returns>
  4154. [HttpGet("{id}")]
  4155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4156. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  4157. {
  4158. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  4159. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  4160. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  4161. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  4162. var filePaths = new List<string>();
  4163. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  4164. try
  4165. {
  4166. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  4167. }
  4168. catch (Exception ex)
  4169. {
  4170. filePaths.Add(info.Attachment);
  4171. }
  4172. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  4173. for (int i = 0; i < filePaths.Count; i++)
  4174. {
  4175. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  4176. }
  4177. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  4178. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  4179. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4180. {
  4181. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4182. {
  4183. foreach (string filePath in filePaths)
  4184. {
  4185. if (System.IO.File.Exists(filePath))
  4186. {
  4187. // 获取文件名
  4188. string fileName = Path.GetFileName(filePath);
  4189. // 将文件添加到ZIP归档中
  4190. zipArchive.CreateEntryFromFile(filePath, fileName);
  4191. }
  4192. }
  4193. }
  4194. }
  4195. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  4196. }
  4197. /// <summary>
  4198. /// 商邀费用 Info Page 基础数据源
  4199. /// </summary>
  4200. /// <returns></returns>
  4201. [HttpPost]
  4202. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4203. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  4204. {
  4205. try
  4206. {
  4207. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  4208. if (groupData.Code != 0)
  4209. {
  4210. return Ok(JsonView(false, groupData.Msg));
  4211. }
  4212. return Ok(JsonView(true, "操作成功", groupData.Data));
  4213. }
  4214. catch (Exception ex)
  4215. {
  4216. return Ok(JsonView(false, ex.Message));
  4217. throw;
  4218. }
  4219. }
  4220. /// <summary>
  4221. /// 根据商邀费用ID查询C表和商邀费用数据
  4222. /// </summary>
  4223. /// <param name="dto"></param>
  4224. /// <returns></returns>
  4225. [HttpPost]
  4226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4227. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  4228. {
  4229. try
  4230. {
  4231. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  4232. if (groupData.Code != 0)
  4233. {
  4234. return Ok(JsonView(false, groupData.Msg));
  4235. }
  4236. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4237. }
  4238. catch (Exception ex)
  4239. {
  4240. return Ok(JsonView(false, ex.Message));
  4241. throw;
  4242. }
  4243. }
  4244. /// <summary>
  4245. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4246. /// </summary>
  4247. /// <param name="dto"></param>
  4248. /// <returns></returns>
  4249. [HttpPost]
  4250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4251. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4252. {
  4253. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4254. if (groupData.Code != 0)
  4255. {
  4256. return Ok(JsonView(false, groupData.Msg));
  4257. }
  4258. #region 应用推送
  4259. try
  4260. {
  4261. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4262. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4263. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4264. //2024-10-21 新增LZ UID
  4265. var userIds = new List<int>() { 21 };
  4266. string title = $"系统通知";
  4267. string content = "";
  4268. var diId = dto.DiId;
  4269. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4270. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4271. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4272. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4273. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4274. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4275. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4276. }
  4277. catch (Exception ex)
  4278. {
  4279. }
  4280. #endregion
  4281. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4282. }
  4283. /// <summary>
  4284. /// 商邀删除
  4285. /// </summary>
  4286. /// <param name="dto"></param>
  4287. /// <returns></returns>
  4288. [HttpPost]
  4289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4290. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4291. {
  4292. try
  4293. {
  4294. _sqlSugar.BeginTran();
  4295. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4296. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4297. {
  4298. IsDel = 1,
  4299. DeleteUserId = dto.DeleteUserId,
  4300. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4301. })
  4302. .Where(it => it.Id == dto.Id)
  4303. .ExecuteCommand();
  4304. if (res1 > 0)
  4305. {
  4306. int _diId = 0;
  4307. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4308. if (_ioaInfo != null)
  4309. {
  4310. _diId = _ioaInfo.DiId;
  4311. }
  4312. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4313. .SetColumns(a => new Grp_CreditCardPayment()
  4314. {
  4315. IsDel = 1,
  4316. DeleteUserId = dto.DeleteUserId,
  4317. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4318. })
  4319. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4320. .ExecuteCommand();
  4321. if (res2 > 0)
  4322. {
  4323. _sqlSugar.CommitTran();
  4324. return Ok(JsonView(true, "删除成功!"));
  4325. }
  4326. }
  4327. _sqlSugar.RollbackTran();
  4328. return Ok(JsonView(false, "删除失败"));
  4329. }
  4330. catch (Exception ex)
  4331. {
  4332. _sqlSugar.RollbackTran();
  4333. return Ok(JsonView(false, ex.Message));
  4334. }
  4335. }
  4336. /// <summary>
  4337. /// 团组模块文件上传
  4338. /// </summary>
  4339. /// <param name="dto"></param>
  4340. /// <returns></returns>
  4341. [HttpPost]
  4342. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4343. {
  4344. var jw = JsonView(false);
  4345. long M = 1024 * 1024;
  4346. if (dto.Files == null || dto.Files.Count == 0)
  4347. {
  4348. jw.Msg = "无文件信息!";
  4349. return Ok(jw);
  4350. }
  4351. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4352. {
  4353. jw.Msg = "文件大小超过20M!";
  4354. return Ok(jw);
  4355. }
  4356. //var nameSp = dto.File.FileName.Split(".");
  4357. //if (nameSp.Length < 2)
  4358. //{
  4359. // jw.Msg = "拓展名称有误!";
  4360. // return Ok(jw);
  4361. //}
  4362. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4363. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4364. //{
  4365. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4366. // return Ok(jw);
  4367. //}
  4368. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4369. if (Ctable == null)
  4370. {
  4371. jw.Msg = "Ctable指向有误!";
  4372. return Ok(jw);
  4373. }
  4374. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4375. if (groupInfo == null)
  4376. {
  4377. jw.Msg = "团组信息不存在!";
  4378. return Ok(jw);
  4379. }
  4380. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4381. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4382. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4383. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4384. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4385. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4386. try
  4387. {
  4388. if (!Directory.Exists(fileBase))
  4389. {
  4390. Directory.CreateDirectory(fileBase);
  4391. }
  4392. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4393. foreach (var fileStream in dto.Files)
  4394. {
  4395. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4396. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4397. {
  4398. Cid = dto.Cid,
  4399. CreateTime = DateTime.Now,
  4400. CreateUserId = dto.Userid,
  4401. Ctable = dto.Ctable,
  4402. Diid = dto.Diid,
  4403. IsDel = 0,
  4404. FilePath = saveFilePath,
  4405. FileName = fileStream.FileName
  4406. };
  4407. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4408. {
  4409. fileStream.CopyTo(fs);
  4410. fs.Flush();
  4411. }
  4412. saveArr.Add(file);
  4413. }
  4414. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4415. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4416. jw = JsonView(true, "保存成功!", new
  4417. {
  4418. count = addResult,
  4419. filesName = saveArr.Select(x => x.FileName)
  4420. });
  4421. }
  4422. catch (Exception ex)
  4423. {
  4424. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4425. {
  4426. count = 0,
  4427. filesName = new string[0],
  4428. });
  4429. }
  4430. return Ok(jw);
  4431. }
  4432. /// <summary>
  4433. /// 查询各模块已保存文件
  4434. /// </summary>
  4435. /// <param name="dto"></param>
  4436. /// <returns></returns>
  4437. [HttpPost]
  4438. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4439. {
  4440. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4441. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4442. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4443. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4444. {
  4445. expression = Expressionable.Create<Grp_GroupModelFile>()
  4446. .And(x => visaIds.Contains(x.CreateUserId));
  4447. }
  4448. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4449. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4450. .Where(expression.ToExpression())
  4451. .ToList();
  4452. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4453. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4454. {
  4455. x.FileName,
  4456. x.Id,
  4457. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4458. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4459. })));
  4460. }
  4461. /// <summary>
  4462. /// 下载该团组下的所有文件
  4463. /// </summary>
  4464. /// <param name="dto"></param>
  4465. /// <returns></returns>
  4466. [HttpPost]
  4467. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4468. {
  4469. var jw = JsonView(false);
  4470. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4471. if (groupInfo == null)
  4472. {
  4473. jw.Msg = "团组信息不存在!";
  4474. return Ok(jw);
  4475. }
  4476. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4477. var isModule = Convert.ToBoolean(dto.isModule);
  4478. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4479. IOOperatorHelper io = new IOOperatorHelper();
  4480. if (isModule)
  4481. {
  4482. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4483. foreach (var moduleArr in moduleGroup)
  4484. {
  4485. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4486. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4487. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4488. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4489. foreach (var item in moduleArr)
  4490. {
  4491. if (System.IO.File.Exists(item.FilePath))
  4492. {
  4493. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4494. {
  4495. byte[] bytes = new byte[fileStream.Length];
  4496. fileStream.Read(bytes, 0, bytes.Length);
  4497. fileStream.Close();
  4498. Stream stream = new MemoryStream(bytes);
  4499. chiZips.Add(item.FileName, stream);
  4500. }
  4501. }
  4502. }
  4503. if (chiZips.Count > 0)
  4504. {
  4505. var byts = io.ConvertZipStream(chiZips);
  4506. Stream stream = new MemoryStream(byts);
  4507. Zips.Add(key.Name + "_.zip", stream);
  4508. }
  4509. }
  4510. }
  4511. else
  4512. {
  4513. foreach (var item in dbQuery)
  4514. {
  4515. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4516. {
  4517. byte[] bytes = new byte[fileStream.Length];
  4518. fileStream.Read(bytes, 0, bytes.Length);
  4519. fileStream.Close();
  4520. Stream stream = new MemoryStream(bytes);
  4521. while (Zips.Keys.Contains(item.FileName))
  4522. {
  4523. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4524. }
  4525. Zips.Add(item.FileName, stream);
  4526. }
  4527. }
  4528. }
  4529. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4530. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4531. if (Zips.Count > 0)
  4532. {
  4533. var byts = io.ConvertZipStream(Zips);
  4534. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4535. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4536. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4537. }
  4538. else
  4539. {
  4540. jw.Msg = "暂无生成文件!";
  4541. }
  4542. return Ok(jw);
  4543. }
  4544. /// <summary>
  4545. /// 下载该团组下此模块的所有文件
  4546. /// </summary>
  4547. /// <param name="dto"></param>
  4548. /// <returns></returns>
  4549. [HttpPost]
  4550. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4551. {
  4552. var jw = JsonView(false);
  4553. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4554. if (groupInfo == null)
  4555. {
  4556. jw.Msg = "团组信息不存在!";
  4557. return Ok(jw);
  4558. }
  4559. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4560. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4561. && x.IsDel == 0);
  4562. if (key == null)
  4563. {
  4564. jw.Msg = "Ctable指向错误!";
  4565. return Ok(jw);
  4566. }
  4567. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4568. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4569. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4570. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4571. IOOperatorHelper io = new IOOperatorHelper();
  4572. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4573. foreach (var item in dbQuery)
  4574. {
  4575. if (System.IO.File.Exists(item.FilePath))
  4576. {
  4577. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4578. {
  4579. byte[] bytes = new byte[fileStream.Length];
  4580. fileStream.Read(bytes, 0, bytes.Length);
  4581. fileStream.Close();
  4582. Stream stream = new MemoryStream(bytes);
  4583. while (Zips.Keys.Contains(item.FileName))
  4584. {
  4585. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4586. }
  4587. Zips.Add(item.FileName, stream);
  4588. }
  4589. }
  4590. }
  4591. if (Zips.Count > 0)
  4592. {
  4593. var byts = io.ConvertZipStream(Zips);
  4594. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4595. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4596. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4597. }
  4598. else
  4599. {
  4600. jw.Msg = "暂无生成文件!";
  4601. }
  4602. return Ok(jw);
  4603. }
  4604. /// <summary>
  4605. /// 删除该团组下的指定文件
  4606. /// </summary>
  4607. /// <param name="dto"></param>
  4608. /// <returns></returns>
  4609. [HttpPost]
  4610. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4611. {
  4612. var jw = JsonView(false);
  4613. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4614. if (sing == null)
  4615. {
  4616. jw.Msg = "暂无";
  4617. return Ok(jw);
  4618. }
  4619. if (System.IO.File.Exists(sing.FilePath))
  4620. {
  4621. try
  4622. {
  4623. System.IO.File.Delete(sing.FilePath);
  4624. }
  4625. catch (Exception ex)
  4626. {
  4627. jw.Msg = "删除失败!" + ex.Message;
  4628. return Ok(jw);
  4629. }
  4630. }
  4631. sing.IsDel = 1;
  4632. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4633. sing.DeleteUserId = dto.UserId;
  4634. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4635. jw = JsonView(true, "删除成功!");
  4636. return Ok(jw);
  4637. }
  4638. #endregion
  4639. #region 团组英文资料
  4640. /// <summary>
  4641. /// 查询团组英文所有资料
  4642. /// </summary>
  4643. /// <param name="dto"></param>
  4644. /// <returns></returns>
  4645. [HttpPost]
  4646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4647. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4648. {
  4649. try
  4650. {
  4651. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4652. if (groupData.Code != 0)
  4653. {
  4654. return Ok(JsonView(false, groupData.Msg));
  4655. }
  4656. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4657. }
  4658. catch (Exception ex)
  4659. {
  4660. return Ok(JsonView(false, "程序错误!"));
  4661. throw;
  4662. }
  4663. }
  4664. /// <summary>
  4665. /// 团组英文资料操作(Status:1.新增,2.修改)
  4666. /// </summary>
  4667. /// <param name="dto"></param>
  4668. /// <returns></returns>
  4669. [HttpPost]
  4670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4671. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4672. {
  4673. try
  4674. {
  4675. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4676. if (groupData.Code != 0)
  4677. {
  4678. return Ok(JsonView(false, groupData.Msg));
  4679. }
  4680. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4681. }
  4682. catch (Exception ex)
  4683. {
  4684. return Ok(JsonView(false, "程序错误!"));
  4685. throw;
  4686. }
  4687. }
  4688. /// <summary>
  4689. /// 团组英文资料Id查询数据
  4690. /// </summary>
  4691. /// <param name="dto"></param>
  4692. /// <returns></returns>
  4693. [HttpPost]
  4694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4695. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4696. {
  4697. try
  4698. {
  4699. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4700. if (_DelegationEnData != null)
  4701. {
  4702. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4703. }
  4704. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4705. }
  4706. catch (Exception ex)
  4707. {
  4708. return Ok(JsonView(false, "程序错误!"));
  4709. throw;
  4710. }
  4711. }
  4712. /// <summary>
  4713. /// 团组英文资料删除
  4714. /// </summary>
  4715. /// <param name="dto"></param>
  4716. /// <returns></returns>
  4717. [HttpPost]
  4718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4719. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4720. {
  4721. try
  4722. {
  4723. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4724. if (!res)
  4725. {
  4726. return Ok(JsonView(false, "删除失败"));
  4727. }
  4728. return Ok(JsonView(true, "删除成功!"));
  4729. }
  4730. catch (Exception ex)
  4731. {
  4732. return Ok(JsonView(false, "程序错误!"));
  4733. throw;
  4734. }
  4735. }
  4736. #endregion
  4737. #region 导出邀请函
  4738. /// <summary>
  4739. /// 导出邀请函页面初始化
  4740. /// </summary>
  4741. /// <param name="dto"></param>
  4742. /// <returns></returns>
  4743. [HttpPost]
  4744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4745. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4746. {
  4747. try
  4748. {
  4749. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  4750. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4751. if (dto.DiId == 0)
  4752. {
  4753. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4754. }
  4755. else
  4756. {
  4757. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4758. }
  4759. return Ok(JsonView(true, "查询成功!", new
  4760. {
  4761. deleClient = crm_Deles,
  4762. delegations = grp_Delegations
  4763. }));
  4764. }
  4765. catch (Exception ex)
  4766. {
  4767. return Ok(JsonView(false, "程序错误!"));
  4768. throw;
  4769. }
  4770. }
  4771. /// <summary>
  4772. /// 导出邀请函
  4773. /// </summary>
  4774. /// <param name="dto"></param>
  4775. /// <returns></returns>
  4776. [HttpPost]
  4777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4778. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4779. {
  4780. #region 参数验证
  4781. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4782. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4783. #endregion
  4784. try
  4785. {
  4786. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4787. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4788. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4789. From Grp_TourClientList tcl
  4790. Left Join
  4791. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4792. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4793. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4794. From Crm_DeleClient dc
  4795. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4796. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4797. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4798. Where dc.IsDel = 0) temp
  4799. On temp.DcId =tcl.ClientId
  4800. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4801. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4802. List<string> texts = new List<string>();
  4803. if (datas.Count != 0)
  4804. {
  4805. foreach (TourClientListDetailsView item in datas)
  4806. {
  4807. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4808. {
  4809. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4810. }
  4811. else
  4812. {
  4813. string name = item.LastName + item.FirstName;
  4814. texts.Add(name);
  4815. }
  4816. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4817. {
  4818. if (!transDic.ContainsKey(item.Job))
  4819. {
  4820. texts.Add(item.Job);
  4821. }
  4822. }
  4823. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4824. {
  4825. texts.Add(item.CompanyFullName);
  4826. }
  4827. }
  4828. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4829. if (transData.Count > 0)
  4830. {
  4831. foreach (TranslateResult item in transData)
  4832. {
  4833. if (!transDic.ContainsKey(item.Query))
  4834. {
  4835. transDic.Add(item.Query, item.Translation);
  4836. }
  4837. }
  4838. }
  4839. List<GuestList> list = new List<GuestList>();
  4840. foreach (TourClientListDetailsView dele in datas)
  4841. {
  4842. GuestList guestList = new GuestList();
  4843. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4844. {
  4845. guestList.Name = dele.Pinyin;
  4846. }
  4847. else
  4848. {
  4849. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4850. guestList.Name = Name;
  4851. }
  4852. if (dele.Sex == 0)
  4853. {
  4854. guestList.Sex = "Male";
  4855. }
  4856. else if (dele.Sex == 1)
  4857. {
  4858. guestList.Sex = "Female";
  4859. }
  4860. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4861. if (!string.IsNullOrEmpty(dele.Job))
  4862. {
  4863. guestList.Job = dele.Job;
  4864. }
  4865. list.Add(guestList);
  4866. }
  4867. //载入模板
  4868. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4869. DocumentBuilder builder = new DocumentBuilder(doc);
  4870. //获取word里所有表格
  4871. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4872. //获取所填表格的序数
  4873. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4874. var rowStart = tableOne.Rows[0]; //获取第1行
  4875. //循环赋值
  4876. for (int i = 0; i < list.Count; i++)
  4877. {
  4878. builder.MoveToCell(0, i + 1, 0, 0);
  4879. builder.Write(list[i].Name.ToString());
  4880. builder.MoveToCell(0, i + 1, 1, 0);
  4881. builder.Write(list[i].Sex.ToString());
  4882. builder.MoveToCell(0, i + 1, 2, 0);
  4883. builder.Write(list[i].DOB.ToString());
  4884. builder.MoveToCell(0, i + 1, 3, 0);
  4885. builder.Write(list[i].Job.ToString());
  4886. }
  4887. //删除多余行
  4888. while (tableOne.Rows.Count > list.Count + 1)
  4889. {
  4890. tableOne.Rows.RemoveAt(list.Count + 1);
  4891. }
  4892. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4893. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4894. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4895. doc.Save(filePath);
  4896. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4897. return Ok(JsonView(true, "操作成功!", Url));
  4898. }
  4899. else
  4900. {
  4901. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4902. }
  4903. }
  4904. catch (Exception ex)
  4905. {
  4906. return Ok(JsonView(false, ex.Message));
  4907. throw;
  4908. }
  4909. }
  4910. #endregion
  4911. #region 团组经理模块 出入境费用
  4912. /// <summary>
  4913. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4914. /// </summary>
  4915. /// <returns></returns>
  4916. [HttpPost]
  4917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4918. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4919. {
  4920. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4921. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4922. //SetDataInfoView
  4923. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4924. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4925. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4926. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4927. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4928. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4929. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4930. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  4931. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4932. return Ok(JsonView(true, "查询成功!", new
  4933. {
  4934. GroupNameData = groupNameData.Data,
  4935. CurrencyData = _CurrencyData,
  4936. WordTypeData = _WordTypeData,
  4937. ExcelTypeData = _ExcelTypeData,
  4938. CurrencyInit = _currencyInfos,
  4939. ViewPermissionData = viewPermissionData
  4940. }));
  4941. }
  4942. /// <summary>
  4943. /// 团组模块 - 出入境费用
  4944. /// 实时汇率 tips
  4945. /// 签证费用 tips
  4946. /// 机票费用 tips
  4947. /// </summary>
  4948. /// <returns></returns>
  4949. [HttpPost]
  4950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4951. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4952. {
  4953. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4954. //默认币种显示
  4955. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  4956. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  4957. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4958. return Ok(JsonView(true, "查询成功!", new
  4959. {
  4960. //GroupNameData = groupNameData.Data,
  4961. visaData = visaData.Data,
  4962. airData = airData.Data,
  4963. reteInfos = reteInfos
  4964. }));
  4965. }
  4966. /// <summary>
  4967. /// 团组模块 - 出入境费用 - Info
  4968. /// </summary>
  4969. /// <returns></returns>
  4970. [HttpPost]
  4971. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  4972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4973. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4974. {
  4975. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4976. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4977. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4978. }
  4979. /// <summary>
  4980. /// 团组模块 - 出入境费用 - 设置view权限
  4981. /// </summary>
  4982. /// <returns></returns>
  4983. [HttpPost]
  4984. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4985. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4986. {
  4987. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4988. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4989. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4990. var permissions = new List<Grp_EnterExitCostPermission>();
  4991. foreach (var userId in dto.UserIds)
  4992. {
  4993. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4994. }
  4995. if (permissions.Any())
  4996. {
  4997. _sqlSugar.BeginTran();
  4998. try
  4999. {
  5000. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  5001. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  5002. if (result < 1)
  5003. {
  5004. _sqlSugar.RollbackTran();
  5005. return Ok(JsonView(false));
  5006. }
  5007. }
  5008. catch (Exception ex)
  5009. {
  5010. _sqlSugar.RollbackTran();
  5011. return Ok(JsonView(false, ex.Message));
  5012. }
  5013. _sqlSugar.CommitTran();
  5014. return Ok(JsonView(true));
  5015. }
  5016. return Ok(JsonView(false));
  5017. }
  5018. /// <summary>
  5019. /// 团组模块 - 出入境费用 - Add And Update
  5020. /// </summary>
  5021. /// <returns></returns>
  5022. [HttpPost]
  5023. [ApiLog("Grp_EnterExitCost",OperationEnum.Add)]
  5024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5025. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  5026. {
  5027. try
  5028. {
  5029. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5030. if (dto.DayOtherPriceData.Any())
  5031. {
  5032. var inserList = dto.DayOtherPriceData
  5033. .Where(x => x.Id == 0)
  5034. .Select(x => new Grp_DayOtherPrice
  5035. {
  5036. Cost = x.Cost,
  5037. Id = x.Id,
  5038. CreateTime = DateTime.Now,
  5039. CreateUserId = dto.UserId,
  5040. Currency = x.Currency,
  5041. Diid = x.DiId,
  5042. Index = x.Index,
  5043. IsDel = 0,
  5044. SetDataId = x.SetDataId,
  5045. SubTotal = x.SubTotal,
  5046. Remark = x.Remark
  5047. })
  5048. .ToList();
  5049. var updateList = dto.DayOtherPriceData
  5050. .Where(x => x.Id != 0)
  5051. .Select(x => new Grp_DayOtherPrice
  5052. {
  5053. Cost = x.Cost,
  5054. Id = x.Id,
  5055. CreateTime = DateTime.Now,
  5056. CreateUserId = dto.UserId,
  5057. Currency = x.Currency,
  5058. Diid = x.DiId,
  5059. Index = x.Index,
  5060. IsDel = 0,
  5061. SetDataId = x.SetDataId,
  5062. SubTotal = x.SubTotal,
  5063. Remark = x.Remark
  5064. })
  5065. .ToList();
  5066. //添加
  5067. _sqlSugar.BeginTran();
  5068. if (inserList.Any())
  5069. {
  5070. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  5071. }
  5072. if (updateList.Any())
  5073. {
  5074. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  5075. }
  5076. _sqlSugar.CommitTran();
  5077. }
  5078. if (data.Code != 0)
  5079. {
  5080. return Ok(JsonView(false, data.Msg));
  5081. }
  5082. //生成默认文件pdf并且通知人员
  5083. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  5084. {
  5085. DiId = dto.DiId,
  5086. ExportType = 1,
  5087. SubTypeId = 1005
  5088. }, "pdf");
  5089. //发送通知
  5090. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  5091. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  5092. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  5093. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  5094. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  5095. //汇率信息记录
  5096. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  5097. return Ok(JsonView(true, data.Msg, data.Data));
  5098. }
  5099. catch (Exception ex)
  5100. {
  5101. return Ok(JsonView(false, ex.Message));
  5102. }
  5103. }
  5104. /// <summary>
  5105. /// 团组模块 - 出入境费用 - Confirm 费用
  5106. /// </summary>
  5107. /// <returns></returns>
  5108. [HttpPost]
  5109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5110. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  5111. {
  5112. //TODO:测试完毕需把对应的用户ID更改
  5113. //1、数据表添加字段
  5114. //2、更改字段接口()
  5115. var _view = await _enterExitCostRep.ConfirmCost(dto);
  5116. //3、确认成功 给财务发送消息
  5117. if (_view.Code == 200)
  5118. {
  5119. if (dto.Type == 1)
  5120. {
  5121. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  5122. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  5123. }
  5124. }
  5125. return Ok(_view);
  5126. }
  5127. /// <summary>
  5128. /// 团组模块 - 出入境费用 - File download
  5129. /// </summary>
  5130. /// <param name="dto"></param>
  5131. /// <returns></returns>
  5132. [HttpPost]
  5133. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  5134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5135. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  5136. {
  5137. try
  5138. {
  5139. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  5140. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  5141. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  5142. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  5143. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  5144. 3 团组成员名单 1 团组成员名单", ""));
  5145. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  5146. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  5147. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  5148. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  5149. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  5150. //数据源
  5151. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  5152. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  5153. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  5154. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  5155. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  5156. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  5157. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  5158. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  5159. .Select((x, a, b) => new
  5160. {
  5161. x.Index,
  5162. itemName = a.Name,
  5163. CurrencyStr = b.Name,
  5164. x.Cost,
  5165. x.SubTotal,
  5166. x.Remark
  5167. })
  5168. .OrderBy((x) => x.Index)
  5169. .ToList(); //其他款项费用
  5170. var peiceItemCurrencys = new List<string>();
  5171. if (_DayAndCosts.Any())
  5172. {
  5173. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  5174. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  5175. }
  5176. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  5177. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  5178. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  5179. {
  5180. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  5181. }
  5182. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5183. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5184. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5185. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5186. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5187. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5188. .Select((tcl, dc, cc) => new ClientInfo
  5189. {
  5190. LastName = dc.LastName,
  5191. FirstName = dc.FirstName,
  5192. Sex = dc.Sex,
  5193. Birthday = dc.BirthDay,
  5194. Company = cc.CompanyFullName,
  5195. Job = dc.Job
  5196. })
  5197. .ToList();
  5198. foreach (var item in DeleClientList)
  5199. {
  5200. EncryptionProcessor.DecryptProperties(item);
  5201. }
  5202. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5203. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5204. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5205. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5206. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5207. if (dto.ExportType == 1) //明细表
  5208. {
  5209. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5210. {
  5211. //获取模板
  5212. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5213. //载入模板
  5214. Document doc = new Document(tempPath);
  5215. DocumentBuilder builder = new DocumentBuilder(doc);
  5216. //利用键值对存放数据
  5217. Dictionary<string, string> dic = new Dictionary<string, string>();
  5218. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5219. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5220. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5221. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5222. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5223. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5224. //境内费用(其他费用)
  5225. if (_EnterExitCosts.ChoiceOne == 1)
  5226. {
  5227. string row1_1 = "";
  5228. if (_EnterExitCosts.Visa > 0)
  5229. {
  5230. //insidePayTotal += _EnterExitCosts.Visa;
  5231. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5232. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5233. {
  5234. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5235. }
  5236. }
  5237. string row1_2 = "";
  5238. if (_EnterExitCosts.YiMiao > 0)
  5239. {
  5240. //insidePayTotal += _EnterExitCosts.YiMiao;
  5241. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5242. }
  5243. if (_EnterExitCosts.HeSuan > 0)
  5244. {
  5245. //insidePayTotal += _EnterExitCosts.HeSuan;
  5246. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5247. }
  5248. if (_EnterExitCosts.Service > 0)
  5249. {
  5250. //insidePayTotal += _EnterExitCosts.Service;
  5251. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5252. }
  5253. string row1_3 = "";
  5254. if (_EnterExitCosts.Safe > 0)
  5255. {
  5256. //insidePayTotal += _EnterExitCosts.Safe;
  5257. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5258. }
  5259. if (_EnterExitCosts.Ticket > 0)
  5260. {
  5261. //insidePayTotal += _EnterExitCosts.Ticket;
  5262. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5263. }
  5264. string row1 = "";
  5265. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5266. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5267. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5268. row1 += $"备注:{_EnterExitCosts.Remark}";
  5269. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5270. dic.Add("Row1Str", row1);
  5271. }
  5272. string airTotalStr = string.Empty,
  5273. airPriceStr = string.Empty;
  5274. //经济舱
  5275. if (_EnterExitCosts.SumJJC == 1)
  5276. {
  5277. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5278. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5279. }
  5280. //公务舱
  5281. if (_EnterExitCosts.SumGWC == 1)
  5282. {
  5283. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5284. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5285. }
  5286. //头等舱
  5287. if (_EnterExitCosts.SumTDC == 1)
  5288. {
  5289. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5290. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5291. }
  5292. //汇率描述
  5293. string rateStr = "";
  5294. if (peiceItemCurrencyInfos.Any())
  5295. {
  5296. rateStr = "\r\n汇率描述:";
  5297. foreach (var item in peiceItemCurrencyInfos)
  5298. {
  5299. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  5300. }
  5301. }
  5302. string twoItemRemark = "备注:";
  5303. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  5304. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  5305. dic.Add("AirTotalStr", airTotalStr);
  5306. dic.Add("AirPriceStr", airPriceStr);
  5307. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5308. dic.Add("TwoItemRemark", twoItemRemark);
  5309. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5310. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5311. int table1Row = 0,
  5312. table2Row = 0,
  5313. table3Row = 0,
  5314. table4Row = 0,
  5315. table5Row = 0;
  5316. //住宿费
  5317. if (_EnterExitCosts.ChoiceThree == 1)
  5318. {
  5319. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5320. table1Row = dac1.Count;
  5321. #region 填充word表格内容
  5322. for (int i = 0; i < dac1.Count; i++)
  5323. {
  5324. Grp_DayAndCost dac = dac1[i];
  5325. if (dac == null) continue;
  5326. builder.MoveToCell(0, i, 0, 0);
  5327. builder.Write("第" + dac.Days.ToString() + "晚:");
  5328. builder.MoveToCell(0, i, 1, 0);
  5329. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5330. //builder.Write(dac.Place == null ? "" : dac.Place);
  5331. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5332. builder.MoveToCell(0, i, 2, 0);
  5333. builder.Write("费用标准:");
  5334. string curr = "";
  5335. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5336. if (currData != null)
  5337. {
  5338. curr = currData.Name;
  5339. }
  5340. builder.MoveToCell(0, i, 3, 0);
  5341. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5342. builder.MoveToCell(0, i, 4, 0);
  5343. builder.Write("费用小计:");
  5344. builder.MoveToCell(0, i, 5, 0);
  5345. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5346. }
  5347. #endregion
  5348. }
  5349. else dic.Add("SubZS", "0.00");
  5350. //删除多余行
  5351. while (table1.Rows.Count > table1Row)
  5352. {
  5353. table1.Rows.RemoveAt(table1Row);
  5354. }
  5355. //伙食费
  5356. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5357. if (_EnterExitCosts.ChoiceFour == 1)
  5358. {
  5359. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5360. table2Row = dac2.Count;
  5361. #region 填充word表格内容
  5362. for (int i = 0; i < dac2.Count; i++)
  5363. {
  5364. Grp_DayAndCost dac = dac2[i];
  5365. if (dac == null) continue;
  5366. builder.MoveToCell(1, i, 0, 0);
  5367. builder.Write("第" + dac.Days.ToString() + "天:");
  5368. builder.MoveToCell(1, i, 1, 0);
  5369. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5370. builder.MoveToCell(1, i, 2, 0);
  5371. builder.Write("费用标准:");
  5372. string curr = "";
  5373. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5374. if (currData != null)
  5375. {
  5376. curr = currData.Name;
  5377. }
  5378. builder.MoveToCell(1, i, 3, 0);
  5379. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5380. builder.MoveToCell(1, i, 4, 0);
  5381. builder.Write("费用小计:");
  5382. builder.MoveToCell(1, i, 5, 0);
  5383. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5384. }
  5385. #endregion
  5386. }
  5387. else dic.Add("SubHS", "0.00");
  5388. //删除多余行
  5389. while (table2.Rows.Count > table2Row)
  5390. {
  5391. table2.Rows.RemoveAt(table2Row);
  5392. }
  5393. //公杂费
  5394. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5395. if (_EnterExitCosts.ChoiceFive == 1)
  5396. {
  5397. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5398. table3Row = dac3.Count;
  5399. #region 填充word表格内容
  5400. for (int i = 0; i < dac3.Count; i++)
  5401. {
  5402. Grp_DayAndCost dac = dac3[i];
  5403. if (dac == null) continue;
  5404. builder.MoveToCell(2, i, 0, 0);
  5405. builder.Write("第" + dac.Days.ToString() + "天:");
  5406. builder.MoveToCell(2, i, 1, 0);
  5407. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5408. builder.MoveToCell(2, i, 2, 0);
  5409. builder.Write("费用标准:");
  5410. string curr = "";
  5411. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5412. if (currData != null)
  5413. {
  5414. curr = currData.Name;
  5415. }
  5416. builder.MoveToCell(2, i, 3, 0);
  5417. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5418. builder.MoveToCell(2, i, 4, 0);
  5419. builder.Write("费用小计:");
  5420. builder.MoveToCell(2, i, 5, 0);
  5421. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5422. }
  5423. //删除多余行
  5424. while (table3.Rows.Count > table3Row)
  5425. {
  5426. table3.Rows.RemoveAt(table3Row);
  5427. }
  5428. #endregion
  5429. }
  5430. else dic.Add("SubGZF", "0.00");
  5431. //删除多余行
  5432. while (table3.Rows.Count > table3Row)
  5433. {
  5434. table3.Rows.RemoveAt(table3Row);
  5435. }
  5436. //培训费
  5437. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5438. if (_EnterExitCosts.ChoiceSix == 1)
  5439. {
  5440. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5441. dic.Add("SubPX", pxStr);
  5442. table4Row = dac4.Count;
  5443. #region 填充word表格内容
  5444. for (int i = 0; i < dac4.Count; i++)
  5445. {
  5446. Grp_DayAndCost dac = dac4[i];
  5447. if (dac == null) continue;
  5448. builder.MoveToCell(3, i, 0, 0);
  5449. builder.Write("第" + dac.Days.ToString() + "天:");
  5450. builder.MoveToCell(3, i, 1, 0);
  5451. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5452. builder.MoveToCell(3, i, 2, 0);
  5453. builder.Write("费用标准:");
  5454. string curr = "";
  5455. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5456. if (currData != null)
  5457. {
  5458. curr = currData.Name;
  5459. }
  5460. builder.MoveToCell(3, i, 3, 0);
  5461. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5462. builder.MoveToCell(3, i, 4, 0);
  5463. builder.Write("费用小计:");
  5464. builder.MoveToCell(3, i, 5, 0);
  5465. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5466. }
  5467. #endregion
  5468. }
  5469. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  5470. //删除多余行
  5471. while (table4.Rows.Count > table4Row)
  5472. {
  5473. table4.Rows.RemoveAt(table4Row);
  5474. }
  5475. //其他费用
  5476. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5477. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5478. {
  5479. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5480. dic.Add("titleQi", qtStr);
  5481. table5Row = dac5.Count;
  5482. #region 填充word表格内容
  5483. for (int i = 0; i < dac5.Count; i++)
  5484. {
  5485. var dac = dac5[i];
  5486. if (dac == null) continue;
  5487. builder.MoveToCell(4, i, 0, 0);
  5488. builder.Write("第" + dac.Index.ToString() + "项:");
  5489. builder.MoveToCell(4, i, 1, 0);
  5490. builder.Write(dac.itemName);
  5491. builder.MoveToCell(4, i, 2, 0);
  5492. builder.Write("费用标准:");
  5493. builder.MoveToCell(4, i, 3, 0);
  5494. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5495. builder.MoveToCell(4, i, 4, 0);
  5496. builder.Write("费用小计:");
  5497. builder.MoveToCell(4, i, 5, 0);
  5498. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5499. builder.MoveToCell(4, i, 6, 0);
  5500. builder.Write("备注:");
  5501. builder.MoveToCell(4, i, 7, 0);
  5502. builder.Write(dac.Remark);
  5503. }
  5504. #endregion
  5505. }
  5506. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5507. //删除多余行
  5508. while (table5.Rows.Count > table5Row)
  5509. {
  5510. table5.Rows.RemoveAt(table5Row);
  5511. }
  5512. //加上其他费用
  5513. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5514. decimal subJJC = 0.00M,
  5515. subGWC = 0.00M,
  5516. subTDC = 0.00M;
  5517. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  5518. string totalLabel = string.Format("全部费用总计:");
  5519. //经济舱
  5520. if (_EnterExitCosts.SumJJC == 1)
  5521. {
  5522. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5523. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  5524. }
  5525. //公务舱
  5526. if (_EnterExitCosts.SumGWC == 1) {
  5527. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5528. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  5529. }
  5530. //头等舱
  5531. if (_EnterExitCosts.SumTDC == 1)
  5532. {
  5533. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5534. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  5535. }
  5536. //TotalLabel
  5537. dic.Add("TotalLabel", totalLabel);
  5538. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5539. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5540. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5541. #region 填充word模板书签内容
  5542. foreach (var key in dic.Keys)
  5543. {
  5544. Bookmark bookmark = doc.Range.Bookmarks[key];
  5545. if (bookmark != null)
  5546. {
  5547. builder.MoveToBookmark(key);
  5548. builder.Write(dic[key]);
  5549. }
  5550. }
  5551. #endregion
  5552. #region 设置页眉
  5553. string userLabel = string.Empty;
  5554. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5555. if (currUserInfo != null)
  5556. {
  5557. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5558. if (userInfo != null)
  5559. {
  5560. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5561. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5562. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5563. }
  5564. }
  5565. //设置页脚
  5566. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5567. #endregion
  5568. //文件名
  5569. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5570. AsposeHelper.removewatermark_v2180();
  5571. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5572. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5573. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5574. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5575. }
  5576. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5577. {
  5578. //获取模板
  5579. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5580. //载入模板
  5581. Document doc = new Document(tempPath);
  5582. DocumentBuilder builder = new DocumentBuilder(doc);
  5583. Dictionary<string, string> dic = new Dictionary<string, string>();
  5584. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5585. {
  5586. List<string> list = new List<string>();
  5587. try
  5588. {
  5589. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5590. foreach (var item in spilitArr)
  5591. {
  5592. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5593. var depCode = spDotandEmpty[2].Substring(0, 3);
  5594. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5595. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5596. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5597. list.Add(depName);
  5598. list.Add(arrName);
  5599. }
  5600. list = list.Distinct().ToList();
  5601. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5602. }
  5603. catch (Exception)
  5604. {
  5605. dic.Add("ReturnCode", "行程录入不正确!");
  5606. }
  5607. }
  5608. else
  5609. {
  5610. dic.Add("ReturnCode", "未录入行程!");
  5611. }
  5612. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5613. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5614. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5615. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5616. {
  5617. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5618. dic.Add("Day", sp.Days.ToString());
  5619. }
  5620. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5621. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5622. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5623. //dic.Add("Names", Names);
  5624. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5625. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5626. decimal dac1totalPrice = 0.00M;
  5627. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5628. foreach (var dac in dac1)
  5629. {
  5630. if (dac.SubTotal == 0.00M)
  5631. {
  5632. continue;
  5633. }
  5634. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5635. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5636. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5637. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5638. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5639. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5640. builder.Write(currency);//币种
  5641. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5642. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5643. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5644. builder.Write("");//人数
  5645. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5646. builder.Write("");//天数
  5647. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5648. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5649. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5650. decimal rate = 0.00M;
  5651. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5652. builder.Write(rate.ToString("#0.0000"));//汇率
  5653. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5654. decimal rbmPrice = dac.SubTotal;
  5655. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5656. accommodationStartIndex++;
  5657. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5658. }
  5659. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5660. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5661. {
  5662. table1.Rows.RemoveAt(i - 1);
  5663. foodandotherStartIndex--;
  5664. }
  5665. if (dac2.Count == dac3.Count)//国家 币种 金额
  5666. {
  5667. for (int i = 0; i < dac2.Count; i++)
  5668. {
  5669. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5670. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5671. }
  5672. }
  5673. decimal dac2totalPrice = 0.00M;
  5674. foreach (var dac in dac2)
  5675. {
  5676. if (dac.SubTotal == 0)
  5677. {
  5678. continue;
  5679. }
  5680. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5681. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5682. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5683. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5684. builder.Write(currency);//币种
  5685. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5686. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5687. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5688. builder.Write("");//人数
  5689. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5690. builder.Write("");//天数
  5691. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5692. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5693. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5694. decimal rate = 0.00M;
  5695. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5696. builder.Write(rate.ToString("#0.0000"));//汇率
  5697. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5698. decimal rbmPrice = dac.SubTotal;
  5699. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5700. foodandotherStartIndex++;
  5701. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5702. }
  5703. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5704. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5705. {
  5706. table1.Rows.RemoveAt(i - 1);
  5707. }
  5708. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5709. string otherFeeStr = "";
  5710. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5711. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5712. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5713. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5714. foreach (var otherInfo in dac5)
  5715. {
  5716. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5717. }
  5718. #endregion
  5719. if (otherFeeStr.Length > 0)
  5720. {
  5721. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5722. otherFeeStr = $"({otherFeeStr})";
  5723. dic.Add("OtherFeeStr", otherFeeStr);
  5724. }
  5725. //总计
  5726. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5727. //国际旅费
  5728. string outsideAir = string.Empty;
  5729. string allPriceAir = string.Empty;
  5730. if (_EnterExitCosts.SumJJC == 1)
  5731. {
  5732. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5733. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5734. }
  5735. if (_EnterExitCosts.SumGWC == 1)
  5736. {
  5737. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5738. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5739. }
  5740. if (_EnterExitCosts.SumTDC == 1)
  5741. {
  5742. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5743. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5744. }
  5745. dic.Add("InTravelPrice", $"({outsideAir})");
  5746. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5747. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5748. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5749. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5750. foreach (var key in dic.Keys)
  5751. {
  5752. builder.MoveToBookmark(key);
  5753. builder.Write(dic[key]);
  5754. }
  5755. //模板文件名
  5756. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5757. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5758. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5759. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5760. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5761. }
  5762. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5763. {
  5764. //获取模板
  5765. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5766. //载入模板
  5767. WorkbookDesigner designer = new WorkbookDesigner();
  5768. designer.Workbook = new Workbook(tempPath);
  5769. Dictionary<string, string> dic = new Dictionary<string, string>();
  5770. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5771. {
  5772. List<string> list = new List<string>();
  5773. try
  5774. {
  5775. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5776. foreach (var item in spilitArr)
  5777. {
  5778. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5779. var depCode = spDotandEmpty[2].Substring(0, 3);
  5780. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5781. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5782. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5783. list.Add(depName);
  5784. list.Add(arrName);
  5785. }
  5786. list = list.Distinct().ToList();
  5787. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5788. }
  5789. catch (Exception)
  5790. {
  5791. dic.Add("ReturnCode", "行程录入不正确!");
  5792. }
  5793. }
  5794. else
  5795. {
  5796. dic.Add("ReturnCode", "未录入行程!");
  5797. }
  5798. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5799. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5800. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5801. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5802. {
  5803. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5804. dic.Add("Day", sp.Days.ToString());
  5805. }
  5806. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5807. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5808. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5809. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5810. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5811. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5812. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5813. designer.SetDataSource("Name", Names);
  5814. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5815. designer.SetDataSource("Day", dic["Day"] + "天");
  5816. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5817. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5818. int startIndex = 10;
  5819. const int startIndexcopy = 10;
  5820. if (dac2.Count == dac3.Count)//国家 币种 金额
  5821. {
  5822. for (int i = 0; i < dac2.Count; i++)
  5823. {
  5824. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5825. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5826. }
  5827. }
  5828. DataTable dtdac1 = new DataTable();
  5829. List<string> place = new List<string>();
  5830. dtdac1.Columns.AddRange(new DataColumn[] {
  5831. new DataColumn(){ ColumnName = "city"},
  5832. new DataColumn(){ ColumnName = "curr"},
  5833. new DataColumn(){ ColumnName = "criterion"},
  5834. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5835. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5836. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5837. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5838. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5839. });
  5840. DataTable dtdac2 = new DataTable();
  5841. dtdac2.Columns.AddRange(new DataColumn[] {
  5842. new DataColumn(){ ColumnName = "city"},
  5843. new DataColumn(){ ColumnName = "curr"},
  5844. new DataColumn(){ ColumnName = "criterion"},
  5845. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5846. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5847. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5848. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5849. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5850. });
  5851. dtdac1.TableName = "tb1";
  5852. dtdac2.TableName = "tb2";
  5853. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5854. foreach (var item in dac1)
  5855. {
  5856. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5857. if (place.Contains(item.Place))
  5858. {
  5859. continue;
  5860. }
  5861. DataRow row = dtdac1.NewRow();
  5862. row["city"] = item.Place;
  5863. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5864. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5865. row["curr"] = currency;
  5866. row["rate"] = rate.ToString("#0.0000");
  5867. row["criterion"] = item.Cost.ToString("#0.00");
  5868. row["number"] = 1;
  5869. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5870. //row["costRMB"] = rbmPrice;
  5871. dtdac1.Rows.Add(row);
  5872. place.Add(item.Place);
  5873. }
  5874. place = new List<string>();
  5875. foreach (var item in dac2)
  5876. {
  5877. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5878. if (place.Contains(item.Place))
  5879. {
  5880. continue;
  5881. }
  5882. DataRow row = dtdac2.NewRow();
  5883. row["city"] = item.Place;
  5884. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5885. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5886. row["curr"] = currency;
  5887. row["rate"] = rate.ToString("#0.0000");
  5888. row["criterion"] = item.Cost.ToString("#0.00");
  5889. row["number"] = 1;
  5890. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5891. //row["cost"] = item.SubTotal;
  5892. //row["costRMB"] = rbmPrice;
  5893. dtdac2.Rows.Add(row);
  5894. place.Add(item.Place);
  5895. //dac2totalPrice += rbmPrice;
  5896. }
  5897. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5898. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5899. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5900. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5901. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5902. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5903. string cell4Str1 = string.Empty;
  5904. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5905. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5906. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5907. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5908. string cellStr = $" 5.其他费用(";
  5909. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5910. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5911. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5912. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5913. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5914. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5915. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5916. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5917. foreach (var otherInfo in dac5)
  5918. {
  5919. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5920. }
  5921. #endregion
  5922. if (cellStr.Length > 8)
  5923. {
  5924. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5925. }
  5926. cellStr += ")";
  5927. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5928. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5929. decimal pxFee = dac4.Sum(it => it.Cost);
  5930. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5931. string celllastStr1 = "";
  5932. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5933. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5934. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5935. celllastStr1 += $",国际旅费 元";
  5936. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5937. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5938. designer.SetDataSource("cell4Str", cell4Str);
  5939. designer.SetDataSource("cellStr", cellStr);
  5940. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5941. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5942. designer.SetDataSource("celllastStr", celllastStr);
  5943. Workbook wb = designer.Workbook;
  5944. var sheet = wb.Worksheets[0];
  5945. //绑定datatable数据集
  5946. designer.SetDataSource(dtdac1);
  5947. designer.SetDataSource(dtdac2);
  5948. designer.Process();
  5949. var rowStart = dtdac1.Rows.Count;
  5950. while (rowStart > 0)
  5951. {
  5952. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5953. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5954. startIndex++;
  5955. rowStart--;
  5956. }
  5957. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5958. startIndex += 1; //总计行
  5959. rowStart = dtdac2.Rows.Count;
  5960. while (rowStart > 0)
  5961. {
  5962. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5963. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5964. startIndex++;
  5965. rowStart--;
  5966. }
  5967. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5968. wb.CalculateFormula(true);
  5969. //模板文件名
  5970. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5971. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5972. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5973. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5974. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5975. }
  5976. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5977. {
  5978. //获取模板
  5979. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5980. //载入模板
  5981. Document doc = new Document(tempPath);
  5982. DocumentBuilder builder = new DocumentBuilder(doc);
  5983. Dictionary<string, string> dic = new Dictionary<string, string>();
  5984. dic.Add("GroupName", _DelegationInfo.TeamName);
  5985. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5986. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5987. string missionLeaderJob = "";//负责人job
  5988. //int groupNumber = 0; //团人数
  5989. if (DeleClientList.Count > 0)
  5990. {
  5991. missionLeader = DeleClientList[0]?.Name ?? "";
  5992. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5993. }
  5994. dic.Add("MissionLeader", missionLeader); //团负责人
  5995. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5996. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5997. #region MyRegion
  5998. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5999. //{
  6000. // List<string> list = new List<string>();
  6001. // try
  6002. // {
  6003. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6004. // foreach (var item in spilitArr)
  6005. // {
  6006. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6007. // var depCode = spDotandEmpty[2].Substring(0, 3);
  6008. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  6009. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6010. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6011. // list.Add(depName);
  6012. // list.Add(arrName);
  6013. // }
  6014. // list = list.Distinct().ToList();
  6015. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6016. // }
  6017. // catch (Exception)
  6018. // {
  6019. // dic.Add("ReturnCode", "行程录入不正确!");
  6020. // }
  6021. //}
  6022. //else
  6023. //{
  6024. // dic.Add("ReturnCode", "未录入行程!");
  6025. //}
  6026. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  6027. dic.Add("ReturnCode", string.Join("、", countrys));
  6028. #endregion
  6029. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6030. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6031. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6032. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6033. //{
  6034. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6035. // dic.Add("Day", sp.Days.ToString());
  6036. //}
  6037. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  6038. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  6039. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6040. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6041. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6042. //培训人员名单
  6043. int cultivateRowIndex = 7;
  6044. foreach (var item in DeleClientList)
  6045. {
  6046. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  6047. builder.Write(item.Name);
  6048. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  6049. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  6050. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  6051. string birthDay = "";
  6052. if (item.Birthday != null)
  6053. {
  6054. DateTime dt = Convert.ToDateTime(item.Birthday);
  6055. birthDay = $"{dt.Year}.{dt.Month}";
  6056. }
  6057. builder.Write(birthDay);
  6058. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  6059. builder.Write(item.Company);
  6060. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  6061. builder.Write(item.Job);
  6062. cultivateRowIndex++;
  6063. }
  6064. //删除多余行
  6065. //cultivateRowIndex -= 2;
  6066. int delRows = 10 + 7 - cultivateRowIndex;
  6067. if (delRows > 0)
  6068. {
  6069. for (int i = 0; i < delRows; i++)
  6070. {
  6071. table1.Rows.RemoveAt(cultivateRowIndex);
  6072. //cultivateRowIndex++;
  6073. }
  6074. }
  6075. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  6076. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  6077. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  6078. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  6079. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  6080. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  6081. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  6082. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  6083. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  6084. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  6085. //其他费用
  6086. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  6087. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  6088. //其他费用合计
  6089. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  6090. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  6091. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  6092. //公务舱合计
  6093. //国际旅费
  6094. //string outsideJJ = "";
  6095. //string allPriceJJ = "";
  6096. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  6097. {
  6098. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6099. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  6100. }
  6101. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  6102. {
  6103. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  6104. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  6105. }
  6106. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  6107. {
  6108. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  6109. dic.Add("AirFeeTotal", airFeeTotalStr);
  6110. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  6111. dic.Add("FeeTotal", feeTotalStr);
  6112. }
  6113. foreach (var key in dic.Keys)
  6114. {
  6115. builder.MoveToBookmark(key);
  6116. builder.Write(dic[key]);
  6117. }
  6118. //模板文件名
  6119. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  6120. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6121. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6122. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6123. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6124. }
  6125. }
  6126. else if (dto.ExportType == 2) //表格
  6127. {
  6128. //利用键值对存放数据
  6129. Dictionary<string, string> dic = new Dictionary<string, string>();
  6130. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6131. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6132. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6133. dic.Add("Day", sp.Days.ToString());
  6134. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6135. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  6136. {
  6137. //获取模板
  6138. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  6139. //载入模板
  6140. Document doc = new Document(tempPath);
  6141. DocumentBuilder builder = new DocumentBuilder(doc);
  6142. dic.Add("TeamName", _DelegationInfo.TeamName);
  6143. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6144. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  6145. string missionLeaderName = "",
  6146. missionLeaderJob = "";
  6147. if (DeleClientList.Count > 0)
  6148. {
  6149. missionLeaderName = DeleClientList[0].Name;
  6150. missionLeaderJob = DeleClientList[0].Job;
  6151. }
  6152. dic.Add("MissionLeaderName", missionLeaderName);
  6153. dic.Add("MissionLeaderJob", missionLeaderJob);
  6154. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  6155. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  6156. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6157. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6158. int rowCount = 10;//总人数行
  6159. int startRowIndex = 7; //起始行
  6160. for (int i = 0; i < DeleClientList.Count; i++)
  6161. {
  6162. builder.MoveToCell(0, startRowIndex, 0, 0);
  6163. builder.Write(DeleClientList[i].Name); //出国人员姓名
  6164. builder.MoveToCell(0, startRowIndex, 1, 0);
  6165. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6166. builder.Write(sex);//性别
  6167. builder.MoveToCell(0, startRowIndex, 2, 0);
  6168. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  6169. builder.MoveToCell(0, startRowIndex, 3, 0);
  6170. builder.Write(DeleClientList[i].Company);//工作单位
  6171. builder.MoveToCell(0, startRowIndex, 4, 0);
  6172. builder.Write(DeleClientList[i].Job);//职务及级别
  6173. builder.MoveToCell(0, startRowIndex, 5, 0);
  6174. builder.Write("");//人员属性
  6175. builder.MoveToCell(0, startRowIndex, 6, 0);
  6176. builder.Write("");//上次出国时间
  6177. startRowIndex++;
  6178. }
  6179. int nullRow = rowCount - DeleClientList.Count;//空行
  6180. for (int i = 0; i < nullRow; i++)
  6181. {
  6182. table1.Rows.Remove(table1.Rows[startRowIndex]);
  6183. }
  6184. foreach (var key in dic.Keys)
  6185. {
  6186. builder.MoveToBookmark(key);
  6187. builder.Write(dic[key]);
  6188. }
  6189. //模板文件名
  6190. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  6191. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6192. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6193. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  6194. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  6195. }
  6196. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  6197. {
  6198. //获取模板
  6199. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  6200. //载入模板
  6201. Document doc = new Document(tempPath);
  6202. DocumentBuilder builder = new DocumentBuilder(doc);
  6203. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6204. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6205. dic.Add("Names", Names);
  6206. int accommodationRows = 12;
  6207. //int foodandotherRows = 12;
  6208. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6209. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6210. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6211. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6212. int accommodationStartIndex = 6;
  6213. decimal dac1totalPrice = 0.00M;
  6214. foreach (var dac in dac1)
  6215. {
  6216. if (dac.SubTotal == 0)
  6217. {
  6218. continue;
  6219. }
  6220. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6221. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6222. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6223. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6224. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6225. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6226. builder.Write(currency);//币种
  6227. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6228. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6229. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6230. builder.Write("");//人数
  6231. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6232. builder.Write("");//天数
  6233. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6234. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6235. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6236. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6237. builder.Write(rate.ToString("#0.0000"));//汇率
  6238. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6239. decimal rbmPrice = rate * dac.SubTotal;
  6240. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6241. accommodationStartIndex++;
  6242. dac1totalPrice += rbmPrice;
  6243. }
  6244. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6245. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6246. builder.Write("小计");
  6247. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6248. builder.Write(dac1totalPrice.ToString("#0.00"));
  6249. accommodationStartIndex++;
  6250. int nullRow = accommodationRows - dac1.Count;
  6251. //删除空行
  6252. //if (nullRow > 0)
  6253. //{
  6254. // int rowIndex = accommodationStartIndex;
  6255. // for (int i = 0; i < nullRow; i++)
  6256. // {
  6257. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6258. // row.Remove();
  6259. // rowIndex++;
  6260. // }
  6261. //}
  6262. if (dac2.Count == dac3.Count)//国家 币种 金额
  6263. {
  6264. for (int i = 0; i < dac2.Count; i++)
  6265. {
  6266. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6267. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6268. }
  6269. }
  6270. int foodandotherStartIndex = 19;//
  6271. decimal dac2totalPrice = 0.00M;
  6272. foreach (var dac in dac2)
  6273. {
  6274. if (dac.SubTotal == 0)
  6275. {
  6276. continue;
  6277. }
  6278. //foodandotherStartIndex = 12;
  6279. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6280. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6281. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6282. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6283. builder.Write(currency);//币种
  6284. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6285. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6286. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6287. builder.Write("");//人数
  6288. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6289. builder.Write("");//天数
  6290. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6291. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6292. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6293. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6294. builder.Write(rate.ToString("#0.0000"));//汇率
  6295. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6296. decimal rbmPrice = rate * dac.SubTotal;
  6297. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6298. foodandotherStartIndex++;
  6299. dac2totalPrice += rbmPrice;
  6300. }
  6301. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6302. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6303. //删除空行
  6304. //if (dac2.Count < foodandotherRows)
  6305. //{
  6306. // while (table2.Rows.Count > dac2.Count)
  6307. // {
  6308. // table2.Rows.RemoveAt(dac2.Count);
  6309. // }
  6310. //}
  6311. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6312. string otherFeeStr = "";
  6313. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6314. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6315. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6316. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6317. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6318. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6319. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6320. foreach (var otherInfo in dac5)
  6321. {
  6322. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6323. }
  6324. #endregion
  6325. if (otherFeeStr.Length > 0)
  6326. {
  6327. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6328. otherFeeStr = $"({otherFeeStr})";
  6329. dic.Add("OtherFeeStr", otherFeeStr);
  6330. }
  6331. foreach (var key in dic.Keys)
  6332. {
  6333. builder.MoveToBookmark(key);
  6334. builder.Write(dic[key]);
  6335. }
  6336. //模板文件名
  6337. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6338. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6339. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6340. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6341. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6342. }
  6343. }
  6344. else if (dto.ExportType == 3)
  6345. {
  6346. if (dto.SubTypeId == 1) //团组成员名单
  6347. {
  6348. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6349. //获取模板
  6350. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6351. //载入模板
  6352. Document doc = new Document(tempPath);
  6353. DocumentBuilder builder = new DocumentBuilder(doc);
  6354. //获取word里所有表格
  6355. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6356. //获取所填表格的序数
  6357. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6358. var rowStart = tableOne.Rows[0]; //获取第1行
  6359. //循环赋值
  6360. for (int i = 0; i < DeleClientList.Count; i++)
  6361. {
  6362. builder.MoveToCell(0, i + 1, 0, 0);
  6363. builder.Write(DeleClientList[i].Name);
  6364. builder.MoveToCell(0, i + 1, 1, 0);
  6365. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6366. builder.Write(sex);
  6367. builder.MoveToCell(0, i + 1, 2, 0);
  6368. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6369. builder.MoveToCell(0, i + 1, 3, 0);
  6370. builder.Write(DeleClientList[i].Company);
  6371. builder.MoveToCell(0, i + 1, 4, 0);
  6372. builder.Write(DeleClientList[i].Job);
  6373. }
  6374. //删除多余行
  6375. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6376. {
  6377. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6378. }
  6379. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6380. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6381. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6382. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6383. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6384. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6385. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6386. }
  6387. }
  6388. return Ok(JsonView(400, "操作失败!", ""));
  6389. }
  6390. catch (Exception ex)
  6391. {
  6392. return Ok(JsonView(400, ex.Message, ""));
  6393. }
  6394. }
  6395. /// <summary>
  6396. /// 获取三公费用标准city
  6397. /// </summary>
  6398. /// <param name="placeData"></param>
  6399. /// <param name="nationalTravelFeeId"></param>
  6400. /// <returns></returns>
  6401. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6402. {
  6403. string _city = string.Empty;
  6404. if (placeData.Count < 1) return _city;
  6405. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6406. if (data == null) return _city;
  6407. string country = data.Country;
  6408. string city = data.City;
  6409. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6410. else _city = city;
  6411. return _city;
  6412. }
  6413. /// <summary>
  6414. /// 团组模块 - 出入境费用 - 明细表导出
  6415. /// </summary>
  6416. /// <returns></returns>
  6417. [HttpPost]
  6418. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6419. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6420. {
  6421. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6422. if (data.Code != 0)
  6423. {
  6424. return Ok(JsonView(false, data.Msg));
  6425. }
  6426. return Ok(JsonView(true, data.Msg, data.Data));
  6427. }
  6428. /// <summary>
  6429. /// 团组模块 - 出入境费用 - 一键清空
  6430. /// </summary>
  6431. /// <returns></returns>
  6432. [HttpPost]
  6433. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6435. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6436. {
  6437. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6438. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6439. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6440. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6441. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6442. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6443. .SetColumns(x => new Grp_DayOtherPrice
  6444. {
  6445. IsDel = 1,
  6446. DeleteUserId = dto.UserId,
  6447. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6448. })
  6449. .ExecuteCommandAsync();
  6450. if (_view.Code == 0)
  6451. {
  6452. return Ok(JsonView(true, "操作成功"));
  6453. }
  6454. return Ok(JsonView(false, "操作失败"));
  6455. }
  6456. /// <summary>
  6457. /// 团组模块 - 出入境费用 - 子项删除
  6458. /// </summary>
  6459. /// <returns></returns>
  6460. [HttpPost]
  6461. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6462. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6463. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6464. {
  6465. try
  6466. {
  6467. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6468. if (data.Code != 0)
  6469. {
  6470. return Ok(JsonView(false, data.Msg));
  6471. }
  6472. return Ok(JsonView(true, "操作成功!", data.Data));
  6473. }
  6474. catch (Exception ex)
  6475. {
  6476. return Ok(JsonView(false, ex.Message));
  6477. }
  6478. }
  6479. /// <summary>
  6480. /// 删除三公其他费用
  6481. /// </summary>
  6482. /// <param name="dto"></param>
  6483. /// <returns></returns>
  6484. [HttpPost]
  6485. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  6486. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6487. {
  6488. var jw = JsonView(false, "删除失败!");
  6489. var data = new Grp_DayOtherPrice()
  6490. {
  6491. Id = dto.Id,
  6492. IsDel = 1,
  6493. DeleteUserId = dto.DeleteUserId,
  6494. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6495. };
  6496. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6497. if (del > 0)
  6498. {
  6499. jw.Code = 200;
  6500. jw.Msg = "删除成功!";
  6501. }
  6502. return Ok(jw);
  6503. }
  6504. /// <summary>
  6505. /// 团组模块 - 出入境国家费用标准 List
  6506. /// </summary>
  6507. /// <returns></returns>
  6508. [HttpPost]
  6509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6510. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6511. {
  6512. try
  6513. {
  6514. Stopwatch sw = new Stopwatch();
  6515. sw.Start();
  6516. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6517. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6518. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6519. Where gntf.Isdel = 0");
  6520. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6521. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6522. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6523. //foreach (var item in nationalTravel)
  6524. //{
  6525. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6526. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6527. // if (otherData != null)
  6528. // {
  6529. // cityData.Remove(otherData);
  6530. // cityData.Add(otherData);
  6531. // }
  6532. // nationalTravelFeeData1.Add(new
  6533. // {
  6534. // Country = item.Country,
  6535. // CityData = cityData
  6536. // });
  6537. //}
  6538. sw.Stop();
  6539. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6540. }
  6541. catch (Exception ex)
  6542. {
  6543. return Ok(JsonView(false, ex.Message));
  6544. throw;
  6545. }
  6546. }
  6547. /// <summary>
  6548. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6549. /// </summary>
  6550. /// <returns></returns>
  6551. [HttpPost]
  6552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6553. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6554. {
  6555. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6556. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6557. List<string> countryData = new List<string>();
  6558. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  6559. countryData = countryData.Distinct().ToList();
  6560. List<dynamic> dataSource = new List<dynamic>();
  6561. foreach (var item in countryData)
  6562. {
  6563. var cityData1 = new List<string>();
  6564. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  6565. var countryData2 = new
  6566. {
  6567. CountryName = item,
  6568. CityData = cityData1
  6569. };
  6570. dataSource.Add(countryData2);
  6571. }
  6572. return Ok(JsonView(true, "查询成功!", dataSource));
  6573. }
  6574. /// <summary>
  6575. /// 团组模块 - 出入境国家费用标准 Page List
  6576. /// </summary>
  6577. /// <returns></returns>
  6578. [HttpPost]
  6579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6580. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6581. {
  6582. int portId = dto.PortType;
  6583. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6584. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6585. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6586. string whereSql = string.Empty;
  6587. if (!string.IsNullOrEmpty(dto.Country))
  6588. {
  6589. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6590. }
  6591. if (!string.IsNullOrEmpty(dto.City))
  6592. {
  6593. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6594. }
  6595. string pageSql = string.Format(@"Select * From (
  6596. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6597. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6598. From Grp_NationalTravelFee gntf
  6599. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6600. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6601. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6602. RefAsync<int> total = 0;
  6603. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6604. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6605. }
  6606. /// <summary>
  6607. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6608. /// </summary>
  6609. /// <returns></returns>
  6610. [HttpPost]
  6611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6612. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6613. {
  6614. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6615. int portId = dto.PortType;
  6616. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6617. string whereSql = string.Empty;
  6618. if (!string.IsNullOrEmpty(dto.Country))
  6619. {
  6620. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6621. }
  6622. if (!string.IsNullOrEmpty(dto.City))
  6623. {
  6624. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6625. }
  6626. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6627. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6628. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6629. From Grp_NationalTravelFee gntf
  6630. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6631. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6632. Where gntf.Isdel = 0 {0} ", whereSql);
  6633. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6634. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6635. }
  6636. /// <summary>
  6637. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6638. /// </summary>
  6639. /// <returns></returns>
  6640. [HttpPost]
  6641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6642. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6643. {
  6644. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6645. if (data.Code != 0)
  6646. {
  6647. return Ok(JsonView(false, data.Msg));
  6648. }
  6649. return Ok(JsonView(true, "操作成功!", data.Data));
  6650. }
  6651. /// <summary>
  6652. /// 团组模块 - 出入境国家费用标准 - Del
  6653. /// </summary>
  6654. /// <returns></returns>
  6655. [HttpPost]
  6656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6657. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6658. {
  6659. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6660. {
  6661. Id = dto.Id,
  6662. DeleteUserId = dto.DeleteUserId,
  6663. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6664. IsDel = 1
  6665. };
  6666. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6667. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6668. .WhereColumns(it => new { it.Id })
  6669. .ExecuteCommandAsync();
  6670. if (delStatus <= 0)
  6671. {
  6672. return Ok(JsonView(false, "删除失败!"));
  6673. }
  6674. return Ok(JsonView(true, "操作成功!"));
  6675. }
  6676. /// <summary>
  6677. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6678. /// 注:Get 请求Headers 加 Token
  6679. /// </summary>
  6680. /// <param name="groupId"></param>
  6681. /// <returns></returns>
  6682. [HttpGet("{groupId}")]
  6683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6684. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6685. {
  6686. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6687. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6688. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6689. data.ForEach(x =>
  6690. {
  6691. x.CreateUserId = _currUserInfo.UserId;
  6692. });
  6693. if (data.Any())
  6694. {
  6695. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6696. if (add > 0)
  6697. {
  6698. return Ok(JsonView(true, "操作成功!"));
  6699. }
  6700. }
  6701. return Ok(JsonView(false, "未操作!"));
  6702. }
  6703. #endregion
  6704. #region 团组经理模块 出入境费用-草稿
  6705. /// <summary>
  6706. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6707. /// </summary>
  6708. /// <returns></returns>
  6709. [HttpPost]
  6710. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6711. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6712. {
  6713. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6714. .Where(x => x.IsDel == 0)
  6715. .OrderByDescending(x => x.CreateTime)
  6716. .Select(x => new { x.Id, x.DraftName })
  6717. .ToListAsync();
  6718. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6719. //SetDataInfoView
  6720. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6721. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6722. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6723. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6724. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6725. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6726. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6727. //默认币种显示
  6728. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6729. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6730. return Ok(JsonView(true, "查询成功!", new
  6731. {
  6732. DraftNameDatas = draftNameDatas,
  6733. CurrencyData = _CurrencyData,
  6734. WordTypeData = _WordTypeData,
  6735. ExcelTypeData = _ExcelTypeData,
  6736. CurrencyInit = _currencyInfos,
  6737. ViewPermissionData = viewPermissionData
  6738. }));
  6739. }
  6740. /// <summary>
  6741. /// 团组模块 - 出入境费用-草稿
  6742. /// 实时汇率 tips
  6743. /// 机票费用 tips
  6744. /// </summary>
  6745. /// <returns></returns>
  6746. [HttpPost]
  6747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6748. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6749. {
  6750. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6751. return Ok(JsonView(true, "查询成功!", new
  6752. {
  6753. //GroupNameData = groupNameData.Data,
  6754. //visaData = visaData.Data,
  6755. //airData = airData.Data,
  6756. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  6757. }));
  6758. }
  6759. /// <summary>
  6760. /// 团组模块 - 出入境费用-草稿
  6761. /// 签证费用 tips
  6762. /// </summary>
  6763. /// <returns></returns>
  6764. [HttpPost]
  6765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6766. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  6767. {
  6768. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  6769. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  6770. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  6771. .Select(x => x.NationalTravelFeeId)
  6772. .Distinct()
  6773. .ToListAsync();
  6774. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6775. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6776. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  6777. .Select(x => x.Country)
  6778. .Distinct()
  6779. .ToArrayAsync();
  6780. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  6781. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  6782. return Ok(JsonView(true, "查询成功!", new
  6783. {
  6784. totalAmt = totalAmt,
  6785. remark = remark
  6786. }));
  6787. }
  6788. /// <summary>
  6789. /// 团组模块 - 出入境费用-草稿 - Info
  6790. /// </summary>
  6791. /// <returns></returns>
  6792. [HttpPost]
  6793. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  6794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6795. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6796. {
  6797. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6798. }
  6799. /// <summary>
  6800. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6801. /// </summary>
  6802. /// <returns></returns>
  6803. [HttpPost]
  6804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6805. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6806. {
  6807. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6808. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6809. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6810. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6811. foreach (var userId in dto.UserIds)
  6812. {
  6813. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6814. }
  6815. if (permissions.Any())
  6816. {
  6817. _sqlSugar.BeginTran();
  6818. try
  6819. {
  6820. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6821. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6822. if (result < 1)
  6823. {
  6824. _sqlSugar.RollbackTran();
  6825. return Ok(JsonView(false));
  6826. }
  6827. }
  6828. catch (Exception ex)
  6829. {
  6830. _sqlSugar.RollbackTran();
  6831. return Ok(JsonView(false, ex.Message));
  6832. }
  6833. _sqlSugar.CommitTran();
  6834. return Ok(JsonView(true));
  6835. }
  6836. return Ok(JsonView(false));
  6837. }
  6838. /// <summary>
  6839. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6840. /// </summary>
  6841. /// <returns></returns>
  6842. [HttpPost]
  6843. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  6844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6845. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6846. {
  6847. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6848. if (data.Code != 0)
  6849. {
  6850. return Ok(JsonView(false, data.Msg));
  6851. }
  6852. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6853. //汇率信息记录
  6854. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6855. return Ok(JsonView(true, data.Msg, data.Data));
  6856. }
  6857. /// <summary>
  6858. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6859. /// </summary>
  6860. /// <param name="dto"></param>
  6861. /// <returns></returns>
  6862. [HttpPost]
  6863. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  6864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6865. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6866. {
  6867. try
  6868. {
  6869. var id = dto.Id;
  6870. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6871. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6872. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6873. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6874. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6875. 3 团组成员名单 1 团组成员名单", ""));
  6876. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6877. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6878. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6879. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6880. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6881. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6882. //数据源
  6883. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6884. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6885. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6886. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6887. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6888. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6889. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6890. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6891. .Select((x, a, b) => new
  6892. {
  6893. x.Index,
  6894. itemName = a.Name,
  6895. CurrencyStr = b.Name,
  6896. x.Cost,
  6897. x.SubTotal,
  6898. x.Remark
  6899. })
  6900. .OrderBy((x) => x.Index)
  6901. .ToList(); //其他款项费用
  6902. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6903. var peiceItemCurrencys = new List<string>();
  6904. if (_DayAndCosts.Any())
  6905. {
  6906. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6907. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6908. }
  6909. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6910. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6911. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6912. {
  6913. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6914. }
  6915. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6916. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6917. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6918. if (dto.ExportType == 1) //明细表
  6919. {
  6920. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6921. {
  6922. //获取模板
  6923. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6924. //载入模板
  6925. Document doc = new Document(tempPath);
  6926. DocumentBuilder builder = new DocumentBuilder(doc);
  6927. //利用键值对存放数据
  6928. Dictionary<string, string> dic = new Dictionary<string, string>();
  6929. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6930. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6931. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6932. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6933. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6934. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6935. //境内费用(其他费用)
  6936. if (_EnterExitCosts.ChoiceOne == 1)
  6937. {
  6938. string row1_1 = "";
  6939. if (_EnterExitCosts.Visa > 0)
  6940. {
  6941. //insidePayTotal += _EnterExitCosts.Visa;
  6942. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6943. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6944. {
  6945. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6946. }
  6947. }
  6948. string row1_2 = "";
  6949. if (_EnterExitCosts.YiMiao > 0)
  6950. {
  6951. //insidePayTotal += _EnterExitCosts.YiMiao;
  6952. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6953. }
  6954. if (_EnterExitCosts.HeSuan > 0)
  6955. {
  6956. //insidePayTotal += _EnterExitCosts.HeSuan;
  6957. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6958. }
  6959. if (_EnterExitCosts.Service > 0)
  6960. {
  6961. //insidePayTotal += _EnterExitCosts.Service;
  6962. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6963. }
  6964. string row1_3 = "";
  6965. if (_EnterExitCosts.Safe > 0)
  6966. {
  6967. //insidePayTotal += _EnterExitCosts.Safe;
  6968. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6969. }
  6970. if (_EnterExitCosts.Ticket > 0)
  6971. {
  6972. //insidePayTotal += _EnterExitCosts.Ticket;
  6973. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6974. }
  6975. string row1 = "";
  6976. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6977. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6978. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6979. row1 += $"备注:{_EnterExitCosts.Remark}";
  6980. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6981. dic.Add("Row1Str", row1);
  6982. }
  6983. string airTotalStr = string.Empty,
  6984. airPriceStr = string.Empty;
  6985. //经济舱
  6986. if (_EnterExitCosts.SumJJC == 1)
  6987. {
  6988. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6989. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6990. }
  6991. //公务舱
  6992. if (_EnterExitCosts.SumGWC == 1)
  6993. {
  6994. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6995. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6996. }
  6997. //头等舱
  6998. if (_EnterExitCosts.SumTDC == 1)
  6999. {
  7000. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  7001. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  7002. }
  7003. //汇率描述
  7004. string rateStr = "";
  7005. if (peiceItemCurrencyInfos.Any())
  7006. {
  7007. rateStr = "\r\n汇率描述:";
  7008. foreach (var item in peiceItemCurrencyInfos)
  7009. {
  7010. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  7011. }
  7012. }
  7013. string twoItemRemark = "备注:";
  7014. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7015. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7016. dic.Add("AirTotalStr", airTotalStr);
  7017. dic.Add("AirPriceStr", airPriceStr);
  7018. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7019. dic.Add("TwoItemRemark", twoItemRemark);
  7020. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7021. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7022. int table1Row = 0,
  7023. table2Row = 0,
  7024. table3Row = 0,
  7025. table4Row = 0,
  7026. table5Row = 0;
  7027. //住宿费
  7028. if (_EnterExitCosts.ChoiceThree == 1)
  7029. {
  7030. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  7031. table1Row = dac1.Count;
  7032. #region 填充word表格内容
  7033. for (int i = 0; i < dac1.Count; i++)
  7034. {
  7035. var dac = dac1[i];
  7036. if (dac == null) continue;
  7037. builder.MoveToCell(0, i, 0, 0);
  7038. builder.Write("第" + dac.Days.ToString() + "晚:");
  7039. builder.MoveToCell(0, i, 1, 0);
  7040. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  7041. //builder.Write(dac.Place == null ? "" : dac.Place);
  7042. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7043. builder.MoveToCell(0, i, 2, 0);
  7044. builder.Write("费用标准:");
  7045. string curr = "";
  7046. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7047. if (currData != null)
  7048. {
  7049. curr = currData.Name;
  7050. }
  7051. builder.MoveToCell(0, i, 3, 0);
  7052. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7053. builder.MoveToCell(0, i, 4, 0);
  7054. builder.Write("费用小计:");
  7055. builder.MoveToCell(0, i, 5, 0);
  7056. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7057. }
  7058. #endregion
  7059. }
  7060. else dic.Add("SubZS", "0.00");
  7061. //删除多余行
  7062. while (table1.Rows.Count > table1Row)
  7063. {
  7064. table1.Rows.RemoveAt(table1Row);
  7065. }
  7066. //伙食费
  7067. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7068. if (_EnterExitCosts.ChoiceFour == 1)
  7069. {
  7070. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7071. table2Row = dac2.Count;
  7072. #region 填充word表格内容
  7073. for (int i = 0; i < dac2.Count; i++)
  7074. {
  7075. var dac = dac2[i];
  7076. if (dac == null) continue;
  7077. builder.MoveToCell(1, i, 0, 0);
  7078. builder.Write("第" + dac.Days.ToString() + "天:");
  7079. builder.MoveToCell(1, i, 1, 0);
  7080. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7081. builder.MoveToCell(1, i, 2, 0);
  7082. builder.Write("费用标准:");
  7083. string curr = "";
  7084. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7085. if (currData != null)
  7086. {
  7087. curr = currData.Name;
  7088. }
  7089. builder.MoveToCell(1, i, 3, 0);
  7090. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7091. builder.MoveToCell(1, i, 4, 0);
  7092. builder.Write("费用小计:");
  7093. builder.MoveToCell(1, i, 5, 0);
  7094. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7095. }
  7096. #endregion
  7097. }
  7098. else dic.Add("SubHS", "0.00");
  7099. //删除多余行
  7100. while (table2.Rows.Count > table2Row)
  7101. {
  7102. table2.Rows.RemoveAt(table2Row);
  7103. }
  7104. //公杂费
  7105. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7106. if (_EnterExitCosts.ChoiceFive == 1)
  7107. {
  7108. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7109. table3Row = dac3.Count;
  7110. #region 填充word表格内容
  7111. for (int i = 0; i < dac3.Count; i++)
  7112. {
  7113. var dac = dac3[i];
  7114. if (dac == null) continue;
  7115. builder.MoveToCell(2, i, 0, 0);
  7116. builder.Write("第" + dac.Days.ToString() + "天:");
  7117. builder.MoveToCell(2, i, 1, 0);
  7118. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7119. builder.MoveToCell(2, i, 2, 0);
  7120. builder.Write("费用标准:");
  7121. string curr = "";
  7122. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7123. if (currData != null)
  7124. {
  7125. curr = currData.Name;
  7126. }
  7127. builder.MoveToCell(2, i, 3, 0);
  7128. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7129. builder.MoveToCell(2, i, 4, 0);
  7130. builder.Write("费用小计:");
  7131. builder.MoveToCell(2, i, 5, 0);
  7132. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7133. }
  7134. //删除多余行
  7135. while (table3.Rows.Count > table3Row)
  7136. {
  7137. table3.Rows.RemoveAt(table3Row);
  7138. }
  7139. #endregion
  7140. }
  7141. else dic.Add("SubGZF", "0.00");
  7142. //删除多余行
  7143. while (table3.Rows.Count > table3Row)
  7144. {
  7145. table3.Rows.RemoveAt(table3Row);
  7146. }
  7147. //培训费
  7148. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7149. if (_EnterExitCosts.ChoiceSix == 1)
  7150. {
  7151. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  7152. dic.Add("SubPX", pxStr);
  7153. table4Row = dac4.Count;
  7154. #region 填充word表格内容
  7155. for (int i = 0; i < dac4.Count; i++)
  7156. {
  7157. var dac = dac4[i];
  7158. if (dac == null) continue;
  7159. builder.MoveToCell(3, i, 0, 0);
  7160. builder.Write("第" + dac.Days.ToString() + "天:");
  7161. builder.MoveToCell(3, i, 1, 0);
  7162. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7163. builder.MoveToCell(3, i, 2, 0);
  7164. builder.Write("费用标准:");
  7165. string curr = "";
  7166. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7167. if (currData != null)
  7168. {
  7169. curr = currData.Name;
  7170. }
  7171. builder.MoveToCell(3, i, 3, 0);
  7172. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7173. builder.MoveToCell(3, i, 4, 0);
  7174. builder.Write("费用小计:");
  7175. builder.MoveToCell(3, i, 5, 0);
  7176. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7177. }
  7178. #endregion
  7179. }
  7180. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  7181. //删除多余行
  7182. while (table4.Rows.Count > table4Row)
  7183. {
  7184. table4.Rows.RemoveAt(table4Row);
  7185. }
  7186. //其他费用
  7187. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7188. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7189. {
  7190. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  7191. dic.Add("titleQi", qtStr);
  7192. table5Row = dac5.Count;
  7193. #region 填充word表格内容
  7194. for (int i = 0; i < dac5.Count; i++)
  7195. {
  7196. var dac = dac5[i];
  7197. if (dac == null) continue;
  7198. builder.MoveToCell(4, i, 0, 0);
  7199. builder.Write("第" + dac.Index.ToString() + "项:");
  7200. builder.MoveToCell(4, i, 1, 0);
  7201. builder.Write(dac.itemName);
  7202. builder.MoveToCell(4, i, 2, 0);
  7203. builder.Write("费用标准:");
  7204. builder.MoveToCell(4, i, 3, 0);
  7205. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7206. builder.MoveToCell(4, i, 4, 0);
  7207. builder.Write("费用小计:");
  7208. builder.MoveToCell(4, i, 5, 0);
  7209. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7210. builder.MoveToCell(4, i, 6, 0);
  7211. builder.Write("备注:");
  7212. builder.MoveToCell(4, i, 7, 0);
  7213. builder.Write(dac.Remark);
  7214. }
  7215. #endregion
  7216. }
  7217. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7218. //删除多余行
  7219. while (table5.Rows.Count > table5Row)
  7220. {
  7221. table5.Rows.RemoveAt(table5Row);
  7222. }
  7223. //加上其他费用
  7224. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7225. decimal subJJC = 0.00M,
  7226. subGWC = 0.00M,
  7227. subTDC = 0.00M;
  7228. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  7229. string totalLabel = string.Format("全部费用总计:");
  7230. //经济舱
  7231. if (_EnterExitCosts.SumJJC == 1)
  7232. {
  7233. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7234. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  7235. }
  7236. //公务舱
  7237. if (_EnterExitCosts.SumGWC == 1)
  7238. {
  7239. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7240. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  7241. }
  7242. //头等舱
  7243. if (_EnterExitCosts.SumTDC == 1)
  7244. {
  7245. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7246. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  7247. }
  7248. //TotalLabel
  7249. dic.Add("TotalLabel", totalLabel);
  7250. #region 填充word模板书签内容
  7251. foreach (var key in dic.Keys)
  7252. {
  7253. Bookmark bookmark = doc.Range.Bookmarks[key];
  7254. if (bookmark != null)
  7255. {
  7256. builder.MoveToBookmark(key);
  7257. builder.Write(dic[key]);
  7258. }
  7259. }
  7260. #endregion
  7261. //文件名
  7262. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7263. strFileName = CommonFun.ValidFileName(strFileName);
  7264. AsposeHelper.removewatermark_v2180();
  7265. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7266. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7267. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7268. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7269. }
  7270. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7271. {
  7272. //获取模板
  7273. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7274. //载入模板
  7275. Document doc = new Document(tempPath);
  7276. DocumentBuilder builder = new DocumentBuilder(doc);
  7277. Dictionary<string, string> dic = new Dictionary<string, string>();
  7278. string returnCodeLabel = string.Empty;
  7279. if (nationalTravelFeeData.Any())
  7280. {
  7281. List<string> list = new List<string>();
  7282. foreach (var item in nationalTravelFeeData)
  7283. {
  7284. list.Add($"{item.Country}({item.City})");
  7285. }
  7286. list = list.Distinct().ToList();
  7287. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7288. }
  7289. var countryLabel = string.Empty;
  7290. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7291. if (countryData.Any())
  7292. {
  7293. countryLabel = string.Join("、", countryData);
  7294. }
  7295. dic.Add("ReturnCodeAir", returnCodeLabel);
  7296. dic.Add("VisitStartDate", "-");
  7297. dic.Add("VisitEndDate", "-");
  7298. dic.Add("Day", "-");
  7299. dic.Add("VisitCountry", countryLabel);
  7300. dic.Add("ClientUnit", "-");
  7301. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7302. //dic.Add("Names", Names);
  7303. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7304. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7305. decimal dac1totalPrice = 0.00M;
  7306. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7307. foreach (var dac in dac1)
  7308. {
  7309. if (dac.SubTotal == 0.00M)
  7310. {
  7311. continue;
  7312. }
  7313. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7314. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7315. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7316. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7317. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7318. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7319. builder.Write(currency);//币种
  7320. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7321. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7322. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7323. builder.Write("");//人数
  7324. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7325. builder.Write("");//天数
  7326. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7327. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7328. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7329. decimal rate = 0.00M;
  7330. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7331. builder.Write(rate.ToString("#0.0000"));//汇率
  7332. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7333. decimal rbmPrice = dac.SubTotal;
  7334. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7335. accommodationStartIndex++;
  7336. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7337. }
  7338. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7339. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7340. {
  7341. table1.Rows.RemoveAt(i - 1);
  7342. foodandotherStartIndex--;
  7343. }
  7344. if (dac2.Count == dac3.Count)//国家 币种 金额
  7345. {
  7346. for (int i = 0; i < dac2.Count; i++)
  7347. {
  7348. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7349. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7350. }
  7351. }
  7352. decimal dac2totalPrice = 0.00M;
  7353. foreach (var dac in dac2)
  7354. {
  7355. if (dac.SubTotal == 0)
  7356. {
  7357. continue;
  7358. }
  7359. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7360. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7361. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7362. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7363. builder.Write(currency);//币种
  7364. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7365. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7366. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7367. builder.Write("");//人数
  7368. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7369. builder.Write("");//天数
  7370. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7371. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7372. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7373. decimal rate = 0.00M;
  7374. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7375. builder.Write(rate.ToString("#0.0000"));//汇率
  7376. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7377. decimal rbmPrice = dac.SubTotal;
  7378. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7379. foodandotherStartIndex++;
  7380. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7381. }
  7382. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7383. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7384. {
  7385. table1.Rows.RemoveAt(i - 1);
  7386. }
  7387. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7388. string otherFeeStr = "";
  7389. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7390. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7391. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7392. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7393. foreach (var otherInfo in dac5)
  7394. {
  7395. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7396. }
  7397. #endregion
  7398. if (otherFeeStr.Length > 0)
  7399. {
  7400. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7401. otherFeeStr = $"({otherFeeStr})";
  7402. dic.Add("OtherFeeStr", otherFeeStr);
  7403. }
  7404. //总计
  7405. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7406. //国际旅费
  7407. string outsideAir = string.Empty;
  7408. string allPriceAir = string.Empty;
  7409. if (_EnterExitCosts.SumJJC == 1)
  7410. {
  7411. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7412. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7413. }
  7414. if (_EnterExitCosts.SumGWC == 1)
  7415. {
  7416. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7417. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7418. }
  7419. if (_EnterExitCosts.SumTDC == 1)
  7420. {
  7421. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7422. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7423. }
  7424. dic.Add("InTravelPrice", $"({outsideAir})");
  7425. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7426. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7427. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7428. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7429. foreach (var key in dic.Keys)
  7430. {
  7431. builder.MoveToBookmark(key);
  7432. builder.Write(dic[key]);
  7433. }
  7434. //模板文件名
  7435. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7436. strFileName = CommonFun.ValidFileName(strFileName);
  7437. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7438. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7439. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7440. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7441. }
  7442. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7443. {
  7444. //获取模板
  7445. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7446. //载入模板
  7447. WorkbookDesigner designer = new WorkbookDesigner();
  7448. designer.Workbook = new Workbook(tempPath);
  7449. Dictionary<string, string> dic = new Dictionary<string, string>();
  7450. string returnCodeLabel = string.Empty;
  7451. if (nationalTravelFeeData.Any())
  7452. {
  7453. List<string> list = new List<string>();
  7454. foreach (var item in nationalTravelFeeData)
  7455. {
  7456. list.Add($"{item.Country}({item.City})");
  7457. }
  7458. list = list.Distinct().ToList();
  7459. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7460. }
  7461. var countryLabel = string.Empty;
  7462. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7463. if (countryData.Any())
  7464. {
  7465. countryLabel = string.Join("、", countryData);
  7466. }
  7467. dic.Add("ReturnCodeAir", returnCodeLabel);
  7468. dic.Add("VisitStartDate", "-");
  7469. dic.Add("VisitEndDate", "-");
  7470. dic.Add("Day", "0");
  7471. dic.Add("VisitCountry", countryLabel);
  7472. dic.Add("ClientUnit", "-");
  7473. designer.SetDataSource("ClientUnit", "-");
  7474. designer.SetDataSource("VisitCountry", countryLabel);
  7475. designer.SetDataSource("Group", "-");
  7476. designer.SetDataSource("ClientUnitTitle", "-");
  7477. designer.SetDataSource("Name", "-");
  7478. designer.SetDataSource("VisitStartDate", "-");
  7479. designer.SetDataSource("Day", "0");
  7480. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7481. designer.SetDataSource("ReturnCodeAir", "-");
  7482. int startIndex = 10;
  7483. const int startIndexcopy = 10;
  7484. if (dac2.Count == dac3.Count)//国家 币种 金额
  7485. {
  7486. for (int i = 0; i < dac2.Count; i++)
  7487. {
  7488. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7489. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7490. }
  7491. }
  7492. DataTable dtdac1 = new DataTable();
  7493. List<string> place = new List<string>();
  7494. dtdac1.Columns.AddRange(new DataColumn[] {
  7495. new DataColumn(){ ColumnName = "city"},
  7496. new DataColumn(){ ColumnName = "curr"},
  7497. new DataColumn(){ ColumnName = "criterion"},
  7498. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7499. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7500. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7501. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7502. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7503. });
  7504. DataTable dtdac2 = new DataTable();
  7505. dtdac2.Columns.AddRange(new DataColumn[] {
  7506. new DataColumn(){ ColumnName = "city"},
  7507. new DataColumn(){ ColumnName = "curr"},
  7508. new DataColumn(){ ColumnName = "criterion"},
  7509. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7510. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7511. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7512. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7513. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7514. });
  7515. dtdac1.TableName = "tb1";
  7516. dtdac2.TableName = "tb2";
  7517. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7518. foreach (var item in dac1)
  7519. {
  7520. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7521. if (place.Contains(item.Place))
  7522. {
  7523. continue;
  7524. }
  7525. DataRow row = dtdac1.NewRow();
  7526. row["city"] = item.Place;
  7527. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7528. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7529. row["curr"] = currency;
  7530. row["rate"] = rate.ToString("#0.0000");
  7531. row["criterion"] = item.Cost.ToString("#0.00");
  7532. row["number"] = 1;
  7533. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7534. //row["costRMB"] = rbmPrice;
  7535. dtdac1.Rows.Add(row);
  7536. place.Add(item.Place);
  7537. }
  7538. place = new List<string>();
  7539. foreach (var item in dac2)
  7540. {
  7541. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7542. if (place.Contains(item.Place))
  7543. {
  7544. continue;
  7545. }
  7546. DataRow row = dtdac2.NewRow();
  7547. row["city"] = item.Place;
  7548. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7549. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7550. row["curr"] = currency;
  7551. row["rate"] = rate.ToString("#0.0000");
  7552. row["criterion"] = item.Cost.ToString("#0.00");
  7553. row["number"] = 1;
  7554. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7555. //row["cost"] = item.SubTotal;
  7556. //row["costRMB"] = rbmPrice;
  7557. dtdac2.Rows.Add(row);
  7558. place.Add(item.Place);
  7559. //dac2totalPrice += rbmPrice;
  7560. }
  7561. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7562. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7563. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7564. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7565. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  7566. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  7567. string cell4Str1 = string.Empty;
  7568. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  7569. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  7570. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  7571. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7572. string cellStr = $" 5.其他费用(";
  7573. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  7574. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  7575. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  7576. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  7577. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  7578. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  7579. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7580. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7581. foreach (var otherInfo in dac5)
  7582. {
  7583. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  7584. }
  7585. #endregion
  7586. if (cellStr.Length > 8)
  7587. {
  7588. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7589. }
  7590. cellStr += ")";
  7591. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7592. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7593. decimal pxFee = dac4.Sum(it => it.Cost);
  7594. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7595. string celllastStr1 = "";
  7596. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  7597. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  7598. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  7599. celllastStr1 += $",国际旅费 元";
  7600. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  7601. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7602. designer.SetDataSource("cell4Str", cell4Str);
  7603. designer.SetDataSource("cellStr", cellStr);
  7604. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7605. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7606. designer.SetDataSource("celllastStr", celllastStr);
  7607. Workbook wb = designer.Workbook;
  7608. var sheet = wb.Worksheets[0];
  7609. //绑定datatable数据集
  7610. designer.SetDataSource(dtdac1);
  7611. designer.SetDataSource(dtdac2);
  7612. designer.Process();
  7613. var rowStart = dtdac1.Rows.Count;
  7614. while (rowStart > 0)
  7615. {
  7616. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7617. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7618. startIndex++;
  7619. rowStart--;
  7620. }
  7621. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7622. startIndex += 1; //总计行
  7623. rowStart = dtdac2.Rows.Count;
  7624. while (rowStart > 0)
  7625. {
  7626. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7627. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7628. startIndex++;
  7629. rowStart--;
  7630. }
  7631. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7632. wb.CalculateFormula(true);
  7633. //模板文件名
  7634. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7635. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7636. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7637. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7638. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7639. }
  7640. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7641. {
  7642. //获取模板
  7643. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7644. //载入模板
  7645. Document doc = new Document(tempPath);
  7646. DocumentBuilder builder = new DocumentBuilder(doc);
  7647. Dictionary<string, string> dic = new Dictionary<string, string>();
  7648. dic.Add("GroupName", "-");
  7649. dic.Add("ClientUnit", "-");
  7650. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7651. //string missionLeaderJob = "";//负责人job
  7652. //int groupNumber = 0; //团人数
  7653. dic.Add("MissionLeader", "-"); //团负责人
  7654. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7655. dic.Add("GroupNumber", "0"); //团人数
  7656. dic.Add("Day", "0");
  7657. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7658. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7659. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7660. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7661. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7662. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7663. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7664. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7665. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7666. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7667. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7668. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7669. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7670. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7671. //其他费用
  7672. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7673. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7674. //其他费用合计
  7675. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7676. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7677. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7678. //公务舱合计
  7679. //国际旅费
  7680. //string outsideJJ = "";
  7681. //string allPriceJJ = "";
  7682. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7683. {
  7684. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7685. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7686. }
  7687. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7688. {
  7689. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7690. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7691. }
  7692. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7693. {
  7694. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  7695. dic.Add("AirFeeTotal", airFeeTotalStr);
  7696. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  7697. dic.Add("FeeTotal", feeTotalStr);
  7698. }
  7699. foreach (var key in dic.Keys)
  7700. {
  7701. builder.MoveToBookmark(key);
  7702. builder.Write(dic[key]);
  7703. }
  7704. //模板文件名
  7705. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7706. strFileName = CommonFun.ValidFileName(strFileName);
  7707. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7708. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7709. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7710. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7711. }
  7712. }
  7713. else if (dto.ExportType == 2) //表格
  7714. {
  7715. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7716. }
  7717. else if (dto.ExportType == 3)
  7718. {
  7719. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7720. }
  7721. return Ok(JsonView(400, "只可导出明细表!", ""));
  7722. }
  7723. catch (Exception ex)
  7724. {
  7725. return Ok(JsonView(400, ex.Message, ""));
  7726. }
  7727. }
  7728. /// <summary>
  7729. /// 获取三公费用标准city
  7730. /// </summary>
  7731. /// <param name="placeData"></param>
  7732. /// <param name="nationalTravelFeeId"></param>
  7733. /// <returns></returns>
  7734. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7735. {
  7736. string _city = string.Empty;
  7737. if (!placeData.Any()) return _city;
  7738. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7739. if (data == null) return _city;
  7740. string country = data.Country;
  7741. string city = data.City;
  7742. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7743. else _city = city;
  7744. return _city;
  7745. }
  7746. /// <summary>
  7747. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7748. /// </summary>
  7749. /// <returns></returns>
  7750. [HttpPost]
  7751. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7753. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7754. {
  7755. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7756. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7757. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7758. if (_view.Code == 0)
  7759. {
  7760. return Ok(JsonView(true, "操作成功"));
  7761. }
  7762. return Ok(JsonView(false, "操作失败"));
  7763. }
  7764. /// <summary>
  7765. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7766. /// </summary>
  7767. /// <returns></returns>
  7768. [HttpPost]
  7769. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7771. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7772. {
  7773. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7774. if (data.Code != 0)
  7775. {
  7776. return Ok(JsonView(false, data.Msg));
  7777. }
  7778. return Ok(JsonView(true, "操作成功!", data.Data));
  7779. }
  7780. /// <summary>
  7781. /// 三公其他费用草稿 删除
  7782. /// </summary>
  7783. /// <param name="dto"></param>
  7784. /// <returns></returns>
  7785. [HttpPost]
  7786. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  7787. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7788. {
  7789. var jw = JsonView(false, "删除失败!");
  7790. var data = new Grp_DayOtherPriceDraft()
  7791. {
  7792. Id = dto.Id,
  7793. IsDel = 1,
  7794. DeleteUserId = dto.DeleteUserId,
  7795. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7796. };
  7797. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7798. if (del > 0)
  7799. {
  7800. jw.Code = 200;
  7801. jw.Msg = "删除成功!";
  7802. }
  7803. return Ok(jw);
  7804. }
  7805. /// <summary>
  7806. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7807. /// </summary>
  7808. /// <returns></returns>
  7809. [HttpPost]
  7810. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7811. {
  7812. var jw = JsonView(false);
  7813. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7814. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  7815. jw.Code = StatusCodes.Status200OK;
  7816. jw.Msg = "操作成功!";
  7817. jw.Data = new { groupNameDatas = groupNameDatas.Data, draftNames = draftDatas };
  7818. return Ok(jw);
  7819. }
  7820. /// <summary>
  7821. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7822. /// </summary>
  7823. /// <param name="dto"></param>
  7824. /// <returns></returns>
  7825. [HttpPost]
  7826. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7827. {
  7828. int userId = dto.UserId,
  7829. portId = dto.PortType,
  7830. groupId = dto.GroupId,
  7831. draftId = dto.DraftId;
  7832. _portTypeData.Add(1);
  7833. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7834. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7835. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7836. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7837. _sqlSugar.BeginTran();
  7838. try
  7839. {
  7840. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7841. if (draftDatas == null)
  7842. {
  7843. _sqlSugar.RollbackTran();
  7844. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7845. }
  7846. //验证可覆盖已有数据 两边创建人需为同一人;
  7847. int draftCreateUserId = draftDatas.CreateUserId,
  7848. formalCreateUserId = 0;
  7849. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7850. if (formalData != null)
  7851. {
  7852. formalCreateUserId = formalData.CreateUserId;
  7853. if (draftCreateUserId != formalCreateUserId)
  7854. {
  7855. _sqlSugar.RollbackTran();
  7856. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7857. }
  7858. }
  7859. //默认添加查看、编辑权限(创建人、自己)
  7860. await _enterExitCostRep.InitPerm(dto.GroupId,dto.UserId);
  7861. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7862. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7863. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7864. newExterData.DiId = groupId;
  7865. newExterData.CreateUserId = userId;
  7866. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7867. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7868. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7869. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7870. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7871. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7872. //数据如果存在执行删除
  7873. if (enterExitCostInfo != null)
  7874. {
  7875. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7876. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7877. .Where(x => x.Id == enterExitCostInfo.Id)
  7878. .ExecuteCommand();
  7879. _sqlSugar.Updateable<Grp_DayAndCost>()
  7880. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7881. .Where(x => x.DiId == groupId)
  7882. .ExecuteCommand();
  7883. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7884. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7885. .Where(x => x.Diid == groupId)
  7886. .ExecuteCommand();
  7887. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7888. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7889. .Where(x => x.GroupId == groupId)
  7890. .ExecuteCommand();
  7891. }
  7892. //执行insert
  7893. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7894. if (insertId < 1)
  7895. {
  7896. _sqlSugar.RollbackTran();
  7897. return Ok(JsonView(false, "草稿数据导入失败!"));
  7898. }
  7899. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7900. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7901. #region 默认添加权限
  7902. #endregion
  7903. _sqlSugar.CommitTran();
  7904. //执行操作之后
  7905. //生成默认文件pdf并且通知人员
  7906. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7907. {
  7908. DiId = groupId,
  7909. ExportType = 1,
  7910. SubTypeId = 1005
  7911. }, "pdf");
  7912. //发送通知
  7913. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7914. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7915. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7916. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7917. //汇率信息记录
  7918. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7919. return Ok(JsonView(true));
  7920. }
  7921. catch (Exception ex)
  7922. {
  7923. _sqlSugar.RollbackTran();
  7924. return Ok(JsonView(false, ex.Message));
  7925. }
  7926. }
  7927. #endregion
  7928. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7929. /// <summary>
  7930. /// 获取币种基础数据(含逻辑处理)
  7931. /// </summary>
  7932. /// <returns></returns>
  7933. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7934. {
  7935. return await GeneralMethod.EnterExitCostInitRate();
  7936. }
  7937. /// <summary>
  7938. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7939. /// </summary>
  7940. /// <returns></returns>
  7941. [HttpPost]
  7942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7943. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7944. {
  7945. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7946. //SetDataInfoView
  7947. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7948. var fileTypes = new List<EecSetDataInfoView>();
  7949. var wordTypeData = dataSource.Where(it => it.STid == 72).Select(x => new EecSetDataInfoView() {
  7950. ParentId = 1,
  7951. Id = x.Id,
  7952. Name = x.Name
  7953. }) .ToList(); //三公费用-Word明细类型
  7954. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  7955. var excelTypeData = dataSource.Where(it => it.STid == 73)
  7956. .Select(x => new EecSetDataInfoView()
  7957. {
  7958. ParentId = 2,
  7959. Id = x.Id,
  7960. Name = x.Name
  7961. }).ToList(); //三公费用-Excel明细类型
  7962. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  7963. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  7964. fileTypes.Add(groupNameList);
  7965. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  7966. //默认币种显示
  7967. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7968. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7969. return Ok(JsonView(true, "查询成功!", new
  7970. {
  7971. FileTypeData = fileTypes,
  7972. CurrencyInit = _currencyInfos,
  7973. viewPermissionData = viewPermissionData
  7974. }));
  7975. }
  7976. /// <summary>
  7977. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7978. /// </summary>
  7979. /// <returns></returns>
  7980. [HttpPost]
  7981. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7982. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7983. {
  7984. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7985. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7986. RefAsync<int> total = 0;
  7987. int diId = 0;
  7988. var status = int.TryParse(dto.GroupName, out diId);
  7989. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  7990. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  7991. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  7992. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7993. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  7994. .OrderByDescending(x => x.VisitStartDate)
  7995. .Select(x => new EnterExitCostMobileGroupView()
  7996. {
  7997. Id = x.Id,
  7998. GroupName = x.TeamName,
  7999. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  8000. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  8001. })
  8002. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8003. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  8004. {
  8005. foreach (var item in data)
  8006. {
  8007. item.IsView = true;
  8008. }
  8009. }
  8010. return Ok(JsonView(true, "查询成功!", data, total));
  8011. }
  8012. /// <summary>
  8013. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  8014. /// </summary>
  8015. /// <returns></returns>
  8016. [HttpPost]
  8017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8018. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  8019. {
  8020. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8021. RefAsync<int> total = 0;
  8022. var data = await _sqlSugar.Queryable<Sys_SetData>()
  8023. .Where(x => x.IsDel == 0 && x.STid == 66)
  8024. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  8025. .Select(x => new
  8026. {
  8027. id = x.Id,
  8028. name = x.Name,
  8029. remark = x.Remark,
  8030. })
  8031. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8032. return Ok(JsonView(true, "查询成功!", data, total));
  8033. }
  8034. /// <summary>
  8035. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  8036. /// </summary>
  8037. /// <returns></returns>
  8038. [HttpPost]
  8039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8040. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  8041. {
  8042. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8043. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8044. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  8045. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  8046. var groupOtherRateData = groupRateData.TeamRates;
  8047. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8048. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  8049. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  8050. groupOtherRateData = groupOtherRateData
  8051. .Select(x => new TeamRateDescAddCurrencyIdView
  8052. {
  8053. CurrencyId = x.CurrencyId,
  8054. CurrencyName = x.CurrencyName,
  8055. CurrencyCode = x.CurrencyCode,
  8056. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  8057. }).ToList();
  8058. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  8059. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  8060. }
  8061. /// <summary>
  8062. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  8063. /// </summary>
  8064. /// <returns></returns>
  8065. [HttpPost]
  8066. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8067. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  8068. {
  8069. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8070. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8071. var tipsData = new List<int>() { 1, 2, 3 };
  8072. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  8073. if (dto.TipsType == 1)
  8074. {
  8075. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  8076. }
  8077. else if (dto.TipsType == 2)
  8078. {
  8079. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  8080. return Ok(JsonView(true, "查询成功!", visaData.Data));
  8081. }
  8082. else if (dto.TipsType == 3)
  8083. {
  8084. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  8085. return Ok(JsonView(true, "查询成功!", airData.Data));
  8086. }
  8087. return Ok(JsonView(false));
  8088. }
  8089. /// <summary>
  8090. /// 团组模块 - 出入境国家费用标准-移动端 List
  8091. /// </summary>
  8092. /// <returns></returns>
  8093. [HttpPost]
  8094. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8095. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  8096. {
  8097. Stopwatch sw = new Stopwatch();
  8098. sw.Start();
  8099. RefAsync<int> total = 0;
  8100. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8101. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  8102. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  8103. .Where((ntf, sd, u) => ntf.IsDel == 0)
  8104. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  8105. .Select((ntf, sd, u) => new
  8106. {
  8107. Id = ntf.Id,
  8108. Area = $"{ntf.Country}-{ntf.City}",
  8109. Currency = ntf.Currency,
  8110. CurrencyCode = sd.Name,
  8111. CurrencyName = sd.Remark,
  8112. RoomCost = ntf.RoomCost,
  8113. FoodCost = ntf.FoodCost,
  8114. PublicCost = ntf.PublicCost,
  8115. LastUpdateUserId = ntf.LastUpdateUserId,
  8116. LastUpdateUserName = u.CnName,
  8117. LastUpdateTime = ntf.LastUpdateTime,
  8118. })
  8119. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8120. sw.Stop();
  8121. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  8122. }
  8123. /// <summary>
  8124. /// 团组模块 - 出入境费用-移动端 - Info
  8125. /// </summary>
  8126. /// <returns></returns>
  8127. [HttpPost]
  8128. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8129. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  8130. {
  8131. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8132. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8133. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  8134. return Ok(data);
  8135. }
  8136. /// <summary>
  8137. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  8138. /// </summary>
  8139. /// <returns></returns>
  8140. [HttpPost]
  8141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8142. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8143. {
  8144. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8145. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8146. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8147. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8148. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8149. mobileInfo.DiId = dto.DiId;
  8150. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8151. if (eecInfo == null) return Ok(mobileInfo);
  8152. //验证查看权限
  8153. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  8154. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  8155. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8156. mobileInfo.IsAssignPerm = isSet;
  8157. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8158. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8159. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8160. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8161. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8162. {
  8163. SubId = dac.Id,
  8164. DiId = dac.DiId,
  8165. Type = dac.Type,
  8166. Days = dac.Days,
  8167. NationalTravelFeeId = dac.NationalTravelFeeId,
  8168. Arae = $"{ntf.Country}-{ntf.City}",
  8169. Cost = dac.Cost,
  8170. Currency = dac.Currency,
  8171. CurrencyName = sd.Name,
  8172. SubTotal = dac.SubTotal,
  8173. })
  8174. .ToList();
  8175. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8176. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8177. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8178. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8179. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8180. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8181. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8182. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8183. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8184. //其他款项
  8185. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8186. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8187. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8188. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8189. .OrderBy((dop, sd1, sd2) => dop.Index)
  8190. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8191. {
  8192. SubId = dop.Id,
  8193. DiId = dop.Diid,
  8194. Index = dop.Index,
  8195. SetDataId = dop.SetDataId,
  8196. SetDataName = sd1.Name,
  8197. Cost = dop.Cost,
  8198. Currency = dop.Currency,
  8199. CurrencyName = sd2.Remark,
  8200. SubTotal = dop.SubTotal,
  8201. Remark = dop.Remark,
  8202. })
  8203. .ToArray();
  8204. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8205. return Ok(mobileInfo);
  8206. }
  8207. /// <summary>
  8208. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8209. /// </summary>
  8210. /// <returns></returns>
  8211. [HttpPost]
  8212. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8213. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8214. {
  8215. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8216. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8217. //验证查看权限
  8218. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  8219. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  8220. var userIds = await _sqlSugar
  8221. .Queryable<Grp_EnterExitCostPermission>()
  8222. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8223. .Select(x => x.UserId)
  8224. .ToArrayAsync();
  8225. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  8226. var perUsersView = new List<dynamic>();
  8227. foreach (var item in perUsers)
  8228. {
  8229. bool isView1 = false;
  8230. if (userIds.Any(x => x == item.Id)) isView1 = true;
  8231. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  8232. }
  8233. return Ok(JsonView(perUsersView));
  8234. }
  8235. /// <summary>
  8236. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8237. /// </summary>
  8238. /// <returns></returns>
  8239. [HttpPost]
  8240. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8241. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8242. {
  8243. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8244. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8245. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8246. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8247. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8248. //验证查看权限
  8249. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8250. //if (!isView) return Ok(JsonView(false, msg));
  8251. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8252. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8253. var subType = dto.SubType;
  8254. if (subType == 1) //1:境内费用
  8255. {
  8256. var oneData = new ChoiceOneMobileSubInfoView()
  8257. {
  8258. Id = eecInfo.Id,
  8259. ChoiceOne = eecInfo.ChoiceOne,
  8260. ChoiceOneTotalCost = eecInfo.InsidePay,
  8261. Visa = eecInfo.Visa,
  8262. VisaRemark = eecInfo.VisaRemark,
  8263. YiMiao = eecInfo.YiMiao,
  8264. HeSuan = eecInfo.HeSuan,
  8265. Service = eecInfo.Service,
  8266. Ticket = eecInfo.Ticket,
  8267. Safe = eecInfo.Safe,
  8268. FirstItemRemark = eecInfo.FirstItemRemark
  8269. };
  8270. return Ok(JsonView(oneData));
  8271. }
  8272. else if (subType == 2) //2:国际旅费
  8273. {
  8274. var twoData = new ChoiceTwoMobileSubInfoView()
  8275. {
  8276. Id = eecInfo.Id,
  8277. ChoiceTwoJJ = eecInfo.SumJJC,
  8278. OutsideJJPay = eecInfo.OutsideJJPay,
  8279. ChoiceTwoGW = eecInfo.SumGWC,
  8280. OutsideGWPay = eecInfo.OutsideGWPay,
  8281. ChoiceTwoTD = eecInfo.SumTDC,
  8282. OutsideTDPay = eecInfo.OutsideTDPay,
  8283. AirJJ = eecInfo.AirJJ,
  8284. AirGW = eecInfo.AirGW,
  8285. AirTD = eecInfo.AirTD,
  8286. CityTranffic = eecInfo.CityTranffic,
  8287. TwoItemRemark = eecInfo.TwoItemRemark
  8288. };
  8289. return Ok(JsonView(twoData));
  8290. }
  8291. else if (subType == 3) //3:住宿费
  8292. {
  8293. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8294. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8295. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8296. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8297. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8298. {
  8299. SubId = dac.Id,
  8300. DiId = dac.DiId,
  8301. Type = dac.Type,
  8302. Days = dac.Days,
  8303. NationalTravelFeeId = dac.NationalTravelFeeId,
  8304. Arae = $"{ntf.Country}-{ntf.City}",
  8305. Cost = dac.Cost,
  8306. Currency = dac.Currency,
  8307. CurrencyName = sd.Name,
  8308. SubTotal = dac.SubTotal,
  8309. })
  8310. .ToArray();
  8311. var data = new ChoiceMobileSubInfo3To6View()
  8312. {
  8313. ParentId = eecInfo.Id,
  8314. Choice = eecInfo.ChoiceThree,
  8315. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8316. Details = dayAndCostDatas
  8317. };
  8318. return Ok(JsonView(data));
  8319. }
  8320. else if (subType == 4) //4:伙食费
  8321. {
  8322. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8323. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8324. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8325. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8326. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8327. {
  8328. SubId = dac.Id,
  8329. DiId = dac.DiId,
  8330. Type = dac.Type,
  8331. Days = dac.Days,
  8332. NationalTravelFeeId = dac.NationalTravelFeeId,
  8333. Arae = $"{ntf.Country}-{ntf.City}",
  8334. Cost = dac.Cost,
  8335. Currency = dac.Currency,
  8336. CurrencyName = sd.Name,
  8337. SubTotal = dac.SubTotal,
  8338. })
  8339. .ToArray();
  8340. var data = new ChoiceMobileSubInfo3To6View()
  8341. {
  8342. ParentId = eecInfo.Id,
  8343. Choice = eecInfo.ChoiceFour,
  8344. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8345. Details = dayAndCostDatas
  8346. };
  8347. return Ok(JsonView(data));
  8348. }
  8349. else if (subType == 5) //5:公杂费
  8350. {
  8351. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8352. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8353. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8354. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8355. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8356. {
  8357. SubId = dac.Id,
  8358. DiId = dac.DiId,
  8359. Type = dac.Type,
  8360. Days = dac.Days,
  8361. NationalTravelFeeId = dac.NationalTravelFeeId,
  8362. Arae = $"{ntf.Country}-{ntf.City}",
  8363. Cost = dac.Cost,
  8364. Currency = dac.Currency,
  8365. CurrencyName = sd.Name,
  8366. SubTotal = dac.SubTotal,
  8367. })
  8368. .ToArray();
  8369. var data = new ChoiceMobileSubInfo3To6View()
  8370. {
  8371. ParentId = eecInfo.Id,
  8372. Choice = eecInfo.ChoiceFive,
  8373. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8374. Details = dayAndCostDatas
  8375. };
  8376. return Ok(JsonView(data));
  8377. }
  8378. else if (subType == 6) //6:培训费
  8379. {
  8380. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8381. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8382. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8383. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8384. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8385. {
  8386. SubId = dac.Id,
  8387. DiId = dac.DiId,
  8388. Type = dac.Type,
  8389. Days = dac.Days,
  8390. NationalTravelFeeId = dac.NationalTravelFeeId,
  8391. Arae = $"{ntf.Country}-{ntf.City}",
  8392. Cost = dac.Cost,
  8393. Currency = dac.Currency,
  8394. CurrencyName = sd.Name,
  8395. SubTotal = dac.SubTotal,
  8396. })
  8397. .ToArray();
  8398. var data = new ChoiceMobileSubInfo3To6View()
  8399. {
  8400. ParentId = eecInfo.Id,
  8401. Choice = eecInfo.ChoiceSix,
  8402. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8403. Details = dayAndCostDatas
  8404. };
  8405. return Ok(JsonView(data));
  8406. }
  8407. else if (subType == 7) //7:其他
  8408. {
  8409. //其他款项
  8410. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8411. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8412. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8413. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8414. .OrderBy((dop, sd1, sd2) => dop.Index)
  8415. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8416. {
  8417. SubId = dop.Id,
  8418. DiId = dop.Diid,
  8419. Index = dop.Index,
  8420. SetDataId = dop.SetDataId,
  8421. SetDataName = sd1.Name,
  8422. Cost = dop.Cost,
  8423. Currency = dop.Currency,
  8424. CurrencyName = sd2.Name,
  8425. SubTotal = dop.SubTotal,
  8426. Remark = dop.Remark,
  8427. })
  8428. .ToArray();
  8429. var data = new ChoiceSevenMobileSubInfoView()
  8430. {
  8431. ParentId = eecInfo.Id,
  8432. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8433. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8434. Details = otherData
  8435. };
  8436. return Ok(JsonView(data));
  8437. }
  8438. return Ok(JsonView(false));
  8439. }
  8440. #region op
  8441. /// <summary>
  8442. /// 移动端更新费用消息通知
  8443. /// </summary>
  8444. /// <param name="diid"></param>
  8445. /// <param name="id"></param>
  8446. /// <param name="currUserId"></param>
  8447. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  8448. {
  8449. try
  8450. {
  8451. ////生成默认文件pdf并且通知人员
  8452. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8453. //{
  8454. // DiId = diid,
  8455. // ExportType = 1,
  8456. // SubTypeId = 1005
  8457. //}, "pdf");
  8458. ////发送通知
  8459. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8460. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8461. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8462. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8463. ////汇率信息记录
  8464. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8465. }
  8466. catch (Exception ex)
  8467. {
  8468. //记录日志
  8469. throw;
  8470. }
  8471. }
  8472. /// <summary>
  8473. /// 验证出入境费用数据是否存在
  8474. /// 不存在添加
  8475. /// </summary>
  8476. /// <param name="diId"></param>
  8477. /// <param name="currUserId"></param>
  8478. /// <returns></returns>
  8479. /// <exception cref="CustomException"></exception>
  8480. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  8481. {
  8482. var parentId = 0;
  8483. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8484. if (info != null)
  8485. {
  8486. parentId = info.Id;
  8487. }
  8488. else
  8489. {
  8490. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8491. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8492. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8493. parentId = addId;
  8494. }
  8495. return parentId;
  8496. }
  8497. /// <summary>
  8498. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8499. /// </summary>
  8500. /// <returns></returns>
  8501. [HttpPost]
  8502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8503. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8504. {
  8505. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8506. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8507. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8508. //验证编辑权限
  8509. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8510. //if (!isEdit) return Ok(JsonView(false, msg));
  8511. var permissions = new List<Grp_EnterExitCostPermission>();
  8512. foreach (var userId in dto.UserIds)
  8513. {
  8514. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8515. }
  8516. if (permissions.Any())
  8517. {
  8518. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  8519. {
  8520. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  8521. }
  8522. _sqlSugar.BeginTran();
  8523. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8524. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8525. if (result < 1)
  8526. {
  8527. _sqlSugar.RollbackTran();
  8528. return Ok(JsonView(false));
  8529. }
  8530. _sqlSugar.CommitTran();
  8531. return Ok(JsonView(true));
  8532. }
  8533. return Ok(JsonView(false));
  8534. }
  8535. /// <summary>
  8536. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8537. /// </summary>
  8538. /// <returns></returns>
  8539. [HttpPost]
  8540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8541. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8542. {
  8543. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8544. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8545. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8546. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8547. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8548. int id = dto.Id;
  8549. if (id <= 0) //add
  8550. {
  8551. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8552. if (add < 1) return Ok(JsonView(false));
  8553. id = add;
  8554. }
  8555. else //update
  8556. {
  8557. ////验证编辑权限
  8558. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8559. //if (!isEdit) return Ok(JsonView(false, msg));
  8560. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8561. if (upd < 1) return Ok(JsonView(false));
  8562. }
  8563. #region 汇率变更时更改币种相关费用
  8564. var opDayCosts = new List<Grp_DayAndCost>();
  8565. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8566. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8567. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8568. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  8569. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8570. .Select((dac, sd) => new
  8571. {
  8572. dac.Id,
  8573. dac.DiId,
  8574. CurrencyCode = sd.Name,
  8575. dac.Cost
  8576. })
  8577. .ToList();
  8578. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8579. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8580. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8581. .Select((dop, sd) => new
  8582. {
  8583. dop.Id,
  8584. dop.Diid,
  8585. CurrencyCode = sd.Name,
  8586. dop.Cost
  8587. })
  8588. .ToList();
  8589. if (dayCosts.Count > 0)
  8590. {
  8591. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8592. foreach (var dc in new_dayCosts)
  8593. {
  8594. var thisCurrency = dc.Key.ToUpper();
  8595. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8596. if (thisRate == 0.00M) continue;
  8597. foreach (var dcSub in dc)
  8598. {
  8599. opDayCosts.Add(new Grp_DayAndCost()
  8600. {
  8601. Id = dcSub.Id,
  8602. DiId = dcSub.DiId,
  8603. Cost = dcSub.Cost,
  8604. SubTotal = dcSub.Cost * thisRate,
  8605. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8606. });
  8607. }
  8608. }
  8609. if (opDayCosts.Count > 0)
  8610. {
  8611. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8612. }
  8613. }
  8614. if (dayOtherCosts.Count > 0)
  8615. {
  8616. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8617. foreach (var dc in new_dayOtherCosts)
  8618. {
  8619. var thisCurrency = dc.Key.ToUpper();
  8620. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8621. if (thisRate == 0.00M) continue;
  8622. foreach (var dcSub in dc)
  8623. {
  8624. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8625. {
  8626. Id = dcSub.Id,
  8627. Diid = dcSub.Diid,
  8628. Cost = dcSub.Cost,
  8629. SubTotal = dcSub.Cost * thisRate,
  8630. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8631. });
  8632. }
  8633. }
  8634. if (opDayOtherCosts.Count > 0)
  8635. {
  8636. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8637. }
  8638. }
  8639. #endregion
  8640. //消息通知
  8641. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8642. //汇率信息记录
  8643. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8644. return Ok(JsonView(new { parentId = id }));
  8645. }
  8646. /// <summary>
  8647. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8648. /// </summary>
  8649. /// <returns></returns>
  8650. [HttpPost]
  8651. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8652. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8653. {
  8654. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8655. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8656. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8657. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8658. int id = dto.Id;
  8659. if (id <= 0) //add
  8660. {
  8661. checkboxInfo.CreateUserId = dto.CurrUserId;
  8662. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8663. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8664. if (add < 1) return Ok(JsonView(false));
  8665. }
  8666. else //update
  8667. {
  8668. ////验证编辑权限
  8669. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8670. //if (!isEdit) return Ok(JsonView(false, msg));
  8671. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8672. .UpdateColumns(x => new
  8673. {
  8674. x.ChoiceOne,
  8675. x.ChoiceTwo,
  8676. x.SumJJC,
  8677. x.SumGWC,
  8678. x.SumTDC,
  8679. x.ChoiceThree,
  8680. x.ChoiceFour,
  8681. x.ChoiceFive,
  8682. x.ChoiceSix,
  8683. x.OtherExpenses_Checked
  8684. })
  8685. .Where(x => x.Id == id)
  8686. .ExecuteCommandAsync();
  8687. if (upd < 1) return Ok(JsonView(false));
  8688. }
  8689. return Ok(JsonView(new { parentId = id }));
  8690. }
  8691. /// <summary>
  8692. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8693. /// </summary>
  8694. /// <returns></returns>
  8695. [HttpPost]
  8696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8697. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8698. {
  8699. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  8700. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8701. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8702. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8703. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8704. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8705. var checkboxInfo = new Grp_EnterExitCost()
  8706. {
  8707. Id = id,
  8708. DiId = diId,
  8709. CreateUserId = currUserId
  8710. };
  8711. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8712. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8713. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8714. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8715. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8716. if (id <= 0) //add
  8717. {
  8718. checkboxInfo.CreateUserId = dto.CurrUserId;
  8719. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8720. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8721. if (add < 1) return Ok(JsonView(false));
  8722. }
  8723. else //update
  8724. {
  8725. ////验证编辑权限
  8726. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8727. //if (!isEdit) return Ok(JsonView(false, msg));
  8728. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8729. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8730. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8731. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8732. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8733. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8734. .Where(x => x.Id == id)
  8735. .ExecuteCommandAsync();
  8736. if (upd < 1) return Ok(JsonView(false));
  8737. }
  8738. return Ok(JsonView(new { parentId = id }));
  8739. }
  8740. /// <summary>
  8741. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8742. /// </summary>
  8743. /// <returns></returns>
  8744. [HttpPost]
  8745. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8746. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8747. {
  8748. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8749. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8750. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8751. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8752. info.FirstItemRemark = dto.FirstItemRemark;
  8753. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8754. int id = dto.Id;
  8755. if (id <= 0) //add
  8756. {
  8757. info.CreateUserId = dto.CurrUserId;
  8758. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8759. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8760. if (add < 1) return Ok(JsonView(false));
  8761. id = add;
  8762. }
  8763. else //update
  8764. {
  8765. ////验证编辑权限
  8766. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8767. //if (!isEdit) return Ok(JsonView(false, msg));
  8768. var upd = await _sqlSugar.Updateable(info)
  8769. .UpdateColumns(x => new
  8770. {
  8771. x.ChoiceOne,
  8772. x.InsidePay,
  8773. x.VisaRemark,
  8774. x.Visa,
  8775. x.Service,
  8776. x.Safe,
  8777. x.Ticket,
  8778. x.HeSuan,
  8779. x.YiMiao,
  8780. x.FirstItemRemark
  8781. })
  8782. .Where(x => x.Id == id)
  8783. .ExecuteCommandAsync();
  8784. if (upd < 1) return Ok(JsonView(false));
  8785. }
  8786. //消息通知
  8787. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8788. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8789. }
  8790. /// <summary>
  8791. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8792. /// </summary>
  8793. /// <returns></returns>
  8794. [HttpPost]
  8795. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8796. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8797. {
  8798. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8799. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8800. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8801. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8802. info.OutsideJJPay = dto.OutsideJJPay;
  8803. info.OutsideGWPay = dto.OutsideGWPay;
  8804. info.OutsideTDPay = dto.OutsideTDPay;
  8805. info.AirJJ = dto.AirJJ;
  8806. info.AirGW = dto.AirGW;
  8807. info.AirTD = dto.AirTD;
  8808. info.CityTranffic = dto.CityTranffic;
  8809. info.TwoItemRemark = dto.TwoItemRemark;
  8810. info.SumJJC = dto.ChoiceTwoJJ;
  8811. info.SumGWC = dto.ChoiceTwoGW;
  8812. info.SumTDC = dto.ChoiceTwoTD;
  8813. int id = dto.Id;
  8814. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8815. if (id <= 0) //add
  8816. {
  8817. info.CreateUserId = dto.CurrUserId;
  8818. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8819. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8820. if (addId <= 0) return Ok(JsonView(false));
  8821. id = addId;
  8822. }
  8823. else //update
  8824. {
  8825. ////验证编辑权限
  8826. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8827. //if (!isEdit) return Ok(JsonView(false, msg));
  8828. var upd = await _sqlSugar.Updateable(info)
  8829. .UpdateColumns(x => new
  8830. {
  8831. x.SumJJC,
  8832. x.OutsideJJPay,
  8833. x.SumGWC,
  8834. x.OutsideGWPay,
  8835. x.SumTDC,
  8836. x.OutsideTDPay,
  8837. x.AirJJ,
  8838. x.AirGW,
  8839. x.AirTD,
  8840. x.CityTranffic,
  8841. x.TwoItemRemark
  8842. })
  8843. .Where(x => x.Id == id)
  8844. .ExecuteCommandAsync();
  8845. if (upd < 1) return Ok(JsonView(false));
  8846. }
  8847. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8848. gwcItemTotal = info.AirGW + info.CityTranffic;
  8849. tdcItemTotal = info.AirTD + info.CityTranffic;
  8850. //消息通知
  8851. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8852. return Ok(JsonView(new
  8853. {
  8854. parentId = id,
  8855. choiceTwoJJ = dto.ChoiceTwoJJ,
  8856. jjcItemTotal = jjcItemTotal,
  8857. choiceTwoGW = dto.ChoiceTwoGW,
  8858. gwcItemTotal = gwcItemTotal,
  8859. choiceTwoTD = dto.ChoiceTwoTD,
  8860. tdcItemTotal = tdcItemTotal
  8861. }));
  8862. }
  8863. /// <summary>
  8864. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8865. /// </summary>
  8866. /// <returns></returns>
  8867. [HttpPost]
  8868. [ApiExplorerSettings(IgnoreApi = true)]
  8869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8870. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8871. {
  8872. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8873. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8874. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8875. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8876. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8877. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8878. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8879. var infos = infos1.Select(x => new Grp_DayAndCost
  8880. {
  8881. Id = x.Id,
  8882. DiId = dto.DiId,
  8883. Type = dto.FeeType,
  8884. Days = x.Days,
  8885. NationalTravelFeeId = x.NationalTravelFeeId,
  8886. Cost = x.Cost,
  8887. Currency = x.Currency,
  8888. SubTotal = x.SubTotal,
  8889. CreateUserId = dto.CurrUserId
  8890. })
  8891. .ToList();
  8892. var adds = infos.Where(x => x.Id <= 0).ToList();
  8893. var upds = infos.Where(x => x.Id > 0).ToList();
  8894. if (adds.Count > 0)
  8895. {
  8896. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8897. if (add < 1) return Ok(JsonView(false));
  8898. }
  8899. if (upds.Count > 0)
  8900. {
  8901. var upd = await _sqlSugar.Updateable(adds)
  8902. .UpdateColumns(x => new
  8903. {
  8904. x.Days,
  8905. x.NationalTravelFeeId,
  8906. x.Cost,
  8907. x.Currency,
  8908. x.SubTotal
  8909. })
  8910. .WhereColumns(x => new { x.Id })
  8911. .ExecuteCommandAsync();
  8912. if (upd < 1) return Ok(JsonView(false));
  8913. }
  8914. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8915. //消息通知
  8916. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8917. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8918. return Ok(JsonView(new { itemTotal = itemTotal }));
  8919. }
  8920. /// <summary>
  8921. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8922. /// </summary>
  8923. /// <returns></returns>
  8924. [HttpPost]
  8925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8926. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8927. {
  8928. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8929. int subId = dto.SubId, feeType = dto.FeeType;
  8930. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8931. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8932. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8933. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8934. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8935. subInfo.Id = subId;
  8936. subInfo.DiId = dto.DiId;
  8937. if (feeType == 3) subInfo.Type = 1;
  8938. else if (feeType == 4) subInfo.Type = 2;
  8939. else if (feeType == 5) subInfo.Type = 3;
  8940. else if (feeType == 6) subInfo.Type = 4;
  8941. subInfo.CreateUserId = dto.CurrUserId;
  8942. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8943. if (parentId < 1) return Ok(JsonView(false));
  8944. //子表op
  8945. if (subId < 1)
  8946. {
  8947. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8948. if (subAdd < 1) return Ok(JsonView(false));
  8949. }
  8950. else
  8951. {
  8952. ////验证编辑权限
  8953. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8954. //if (!isEdit) return Ok(JsonView(false, msg));
  8955. var subUpd = await _sqlSugar.Updateable(subInfo)
  8956. .UpdateColumns(x => new
  8957. {
  8958. x.Days,
  8959. x.NationalTravelFeeId,
  8960. x.Cost,
  8961. x.Currency,
  8962. x.SubTotal
  8963. })
  8964. .WhereColumns(x => new { x.Id })
  8965. .ExecuteCommandAsync();
  8966. if (subUpd < 1) return Ok(JsonView(false));
  8967. }
  8968. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8969. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8970. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8971. }
  8972. /// <summary>
  8973. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8974. /// </summary>
  8975. /// <returns></returns>
  8976. [HttpPost]
  8977. [ApiExplorerSettings(IgnoreApi = true)]
  8978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8979. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8980. {
  8981. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8982. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8983. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8984. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8985. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8986. {
  8987. Id = x.Id,
  8988. Diid = dto.DiId,
  8989. SetDataId = x.SetDataId,
  8990. Index = x.Index,
  8991. Cost = x.Cost,
  8992. Currency = x.Currency,
  8993. SubTotal = x.SubTotal,
  8994. CreateUserId = dto.CurrUserId,
  8995. Remark = x.Remark
  8996. }).ToList();
  8997. var adds = infos.Where(x => x.Id <= 0).ToList();
  8998. var upds = infos.Where(x => x.Id > 0).ToList();
  8999. if (adds.Count > 0)
  9000. {
  9001. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9002. if (add < 1) return Ok(JsonView(false));
  9003. }
  9004. if (upds.Count > 0)
  9005. {
  9006. var upd = await _sqlSugar.Updateable(adds)
  9007. .UpdateColumns(x => new
  9008. {
  9009. x.Index,
  9010. x.SetDataId,
  9011. x.Cost,
  9012. x.Currency,
  9013. x.SubTotal,
  9014. x.Remark
  9015. })
  9016. .WhereColumns(x => new { x.Id })
  9017. .ExecuteCommandAsync();
  9018. if (upd < 1) return Ok(JsonView(false));
  9019. }
  9020. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  9021. //消息通知
  9022. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  9023. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9024. return Ok(JsonView(new { itemTotal = itemTotal }));
  9025. }
  9026. /// <summary>
  9027. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  9028. /// </summary>
  9029. /// <returns></returns>
  9030. [HttpPost]
  9031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9032. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  9033. {
  9034. int subId = dto.SubId;
  9035. int diId = dto.Diid;
  9036. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9037. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9038. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9039. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  9040. subInfo.Id = subId;
  9041. subInfo.Diid = dto.Diid;
  9042. subInfo.CreateUserId = dto.CurrUserId;
  9043. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  9044. if (parentId < 1) return Ok(JsonView(false));
  9045. #region 子表op
  9046. if (subId < 1)//add
  9047. {
  9048. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9049. if (subAdd < 1) return Ok(JsonView(false));
  9050. }
  9051. else //upd
  9052. {
  9053. ////验证编辑权限
  9054. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  9055. //if (!isEdit) return Ok(JsonView(false, msg));
  9056. var subUpd = await _sqlSugar.Updateable(subInfo)
  9057. .UpdateColumns(x => new
  9058. {
  9059. x.Index,
  9060. x.SetDataId,
  9061. x.Cost,
  9062. x.Currency,
  9063. x.SubTotal,
  9064. x.Remark
  9065. })
  9066. .WhereColumns(x => new { x.Id })
  9067. .ExecuteCommandAsync();
  9068. if (subUpd < 1) return Ok(JsonView(false));
  9069. }
  9070. #endregion
  9071. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  9072. //消息通知
  9073. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  9074. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9075. }
  9076. /// <summary>
  9077. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  9078. /// </summary>
  9079. /// <returns></returns>
  9080. [HttpPost]
  9081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9082. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  9083. {
  9084. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  9085. if (data.Code != 0)
  9086. {
  9087. return Ok(JsonView(false, data.Msg));
  9088. }
  9089. return Ok(JsonView(true, "操作成功!", data.Data));
  9090. }
  9091. /// <summary>
  9092. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  9093. /// </summary>
  9094. /// <param name="dto"></param>
  9095. /// <returns></returns>
  9096. [HttpPost]
  9097. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  9098. {
  9099. var data = new Grp_DayOtherPrice()
  9100. {
  9101. Id = dto.Id,
  9102. IsDel = 1,
  9103. DeleteUserId = dto.DeleteUserId,
  9104. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9105. };
  9106. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9107. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  9108. return Ok(JsonView(false, "删除失败!"));
  9109. }
  9110. #endregion
  9111. #endregion
  9112. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  9113. /// <summary>
  9114. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  9115. /// </summary>
  9116. /// <returns></returns>
  9117. [HttpPost]
  9118. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9119. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  9120. {
  9121. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9122. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9123. RefAsync<int> total = 0;
  9124. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  9125. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  9126. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  9127. .Select(x => new
  9128. {
  9129. Id = x.Id,
  9130. DraftName = x.DraftName,
  9131. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  9132. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  9133. .Any()
  9134. })
  9135. .OrderByDescending(x => x.Id)
  9136. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9137. return Ok(JsonView(true, "查询成功!", data, total));
  9138. }
  9139. /// <summary>
  9140. /// 出入境费用-草稿 移动端
  9141. /// 获取币种基础数据(含逻辑处理)
  9142. /// </summary>
  9143. /// <returns></returns>
  9144. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  9145. {
  9146. return await GeneralMethod.EnterExitCostInitRate();
  9147. }
  9148. /// <summary>
  9149. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9150. /// </summary>
  9151. /// <returns></returns>
  9152. [HttpPost]
  9153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9154. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  9155. {
  9156. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9157. //SetDataInfoView
  9158. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  9159. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  9160. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  9161. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  9162. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  9163. //默认币种显示
  9164. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9165. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9166. return Ok(JsonView(true, "查询成功!", new
  9167. {
  9168. WordTypeData = _WordTypeData,
  9169. ExcelTypeData = _ExcelTypeData,
  9170. CurrencyInit = _currencyInfos,
  9171. viewPermissionData = viewPermissionData
  9172. }));
  9173. }
  9174. /// <summary>
  9175. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9176. /// </summary>
  9177. /// <returns></returns>
  9178. [HttpPost]
  9179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9180. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9181. {
  9182. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9183. RefAsync<int> total = 0;
  9184. int diId = 0;
  9185. var status = int.TryParse(dto.GroupName, out diId);
  9186. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9187. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9188. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9189. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9190. .OrderByDescending(x => x.VisitStartDate)
  9191. .Select(x => new
  9192. {
  9193. Id = x.Id,
  9194. GroupName = x.TeamName
  9195. })
  9196. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9197. return Ok(JsonView(true, "查询成功!", data, total));
  9198. }
  9199. /// <summary>
  9200. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9201. /// </summary>
  9202. /// <returns></returns>
  9203. [HttpPost]
  9204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9205. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9206. {
  9207. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9208. RefAsync<int> total = 0;
  9209. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9210. .Where(x => x.IsDel == 0 && x.STid == 66)
  9211. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9212. .Select(x => new
  9213. {
  9214. id = x.Id,
  9215. name = x.Name,
  9216. remark = x.Remark,
  9217. })
  9218. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9219. return Ok(JsonView(true, "查询成功!", data, total));
  9220. }
  9221. /// <summary>
  9222. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9223. /// </summary>
  9224. /// <returns></returns>
  9225. [HttpPost]
  9226. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9227. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9228. {
  9229. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9230. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9231. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  9232. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9233. var groupOtherRateData = groupRateData.TeamRates;
  9234. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9235. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9236. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9237. groupOtherRateData = groupOtherRateData
  9238. .Select(x => new TeamRateDescAddCurrencyIdView
  9239. {
  9240. CurrencyId = x.CurrencyId,
  9241. CurrencyName = x.CurrencyName,
  9242. CurrencyCode = x.CurrencyCode,
  9243. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9244. }).ToList();
  9245. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9246. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9247. }
  9248. /// <summary>
  9249. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9250. /// </summary>
  9251. /// <returns></returns>
  9252. [HttpPost]
  9253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9254. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9255. {
  9256. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9257. var tipsData = new List<int>() { 1, 2, 3 };
  9258. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9259. if (dto.TipsType == 1)
  9260. {
  9261. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9262. }
  9263. else if (dto.TipsType == 2)
  9264. {
  9265. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  9266. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9267. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9268. .Select(x => x.NationalTravelFeeId)
  9269. .Distinct()
  9270. .ToListAsync();
  9271. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9272. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9273. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9274. .Select(x => x.Country)
  9275. .Distinct()
  9276. .ToArrayAsync();
  9277. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9278. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9279. return Ok(JsonView(true, "查询成功!", new
  9280. {
  9281. totalAmt = totalAmt,
  9282. remark = remark
  9283. }));
  9284. }
  9285. else if (dto.TipsType == 3)
  9286. {
  9287. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  9288. }
  9289. return Ok(JsonView(false));
  9290. }
  9291. /// <summary>
  9292. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  9293. /// </summary>
  9294. /// <returns></returns>
  9295. [HttpPost]
  9296. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9297. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  9298. {
  9299. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  9300. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9301. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  9302. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  9303. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  9304. var info = new Grp_EnterExitCostDraft() {
  9305. DraftName = dto.DraftName,
  9306. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  9307. CreateUserId = dto.CurrUserId
  9308. };
  9309. _sqlSugar.BeginTran();
  9310. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9311. if (draftId < 1) {
  9312. _sqlSugar.RollbackTran();
  9313. return Ok(JsonView(false, "草稿创建失败!"));
  9314. }
  9315. //添加默认权限
  9316. await _enterExitCostDraftRep.InitPerm(draftId,dto.CurrUserId);
  9317. _sqlSugar.CommitTran();
  9318. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  9319. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9320. mobileInfo.Id = draftId;
  9321. mobileInfo.DraftName = dto.DraftName;
  9322. mobileInfo.Currencys = rateInfos;
  9323. mobileInfo.IsAssignPerm = assignPerm;
  9324. return Ok(JsonView(mobileInfo));
  9325. }
  9326. /// <summary>
  9327. /// 出入境费用-草稿-移动端 查看编辑提示消息
  9328. /// </summary>
  9329. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  9330. /// <summary>
  9331. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9332. /// </summary>
  9333. /// <returns></returns>
  9334. [HttpPost]
  9335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9336. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9337. {
  9338. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9339. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9340. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9341. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9342. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9343. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  9344. //验证查看编辑权限
  9345. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9346. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9347. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9348. mobileInfo.IsAssignPerm = assignPerm;
  9349. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9350. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9351. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9352. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9353. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9354. {
  9355. ParentId = dac.ParentId,
  9356. SubId = dac.Id,
  9357. Type = dac.Type,
  9358. Days = dac.Days,
  9359. NationalTravelFeeId = dac.NationalTravelFeeId,
  9360. Arae = $"{ntf.Country}-{ntf.City}",
  9361. Cost = dac.Cost,
  9362. Currency = dac.Currency,
  9363. CurrencyName = sd.Name,
  9364. SubTotal = dac.SubTotal,
  9365. })
  9366. .ToList();
  9367. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9368. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9369. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9370. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9371. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9372. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9373. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9374. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9375. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9376. //其他款项
  9377. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9378. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9379. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9380. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9381. .OrderBy((dop, sd1, sd2) => dop.Index)
  9382. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9383. {
  9384. ParentId = dop.ParentId,
  9385. SubId = dop.Id,
  9386. Index = dop.Index,
  9387. SetDataId = dop.SetDataId,
  9388. SetDataName = sd1.Name,
  9389. Cost = dop.Cost,
  9390. Currency = dop.Currency,
  9391. CurrencyName = sd2.Remark,
  9392. SubTotal = dop.SubTotal,
  9393. Remark = dop.Remark,
  9394. })
  9395. .ToArray();
  9396. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9397. return Ok(mobileInfo);
  9398. }
  9399. /// <summary>
  9400. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9401. /// </summary>
  9402. /// <returns></returns>
  9403. [HttpPost]
  9404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9405. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9406. {
  9407. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9408. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9409. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9410. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9411. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9412. //验证查看编辑权限
  9413. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9414. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9415. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9416. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9417. var subType = dto.SubType;
  9418. if (subType == 1) //1:境内费用
  9419. {
  9420. var oneData = new ChoiceOneMobileSubInfoView()
  9421. {
  9422. Id = eecInfo.Id,
  9423. ChoiceOne = eecInfo.ChoiceOne,
  9424. ChoiceOneTotalCost = eecInfo.InsidePay,
  9425. Visa = eecInfo.Visa,
  9426. VisaRemark = eecInfo.VisaRemark,
  9427. YiMiao = eecInfo.YiMiao,
  9428. HeSuan = eecInfo.HeSuan,
  9429. Service = eecInfo.Service,
  9430. Ticket = eecInfo.Ticket,
  9431. Safe = eecInfo.Safe,
  9432. FirstItemRemark = eecInfo.FirstItemRemark
  9433. };
  9434. return Ok(JsonView(oneData));
  9435. }
  9436. else if (subType == 2) //2:国际旅费
  9437. {
  9438. var twoData = new ChoiceTwoMobileSubInfoView()
  9439. {
  9440. Id = eecInfo.Id,
  9441. ChoiceTwoJJ = eecInfo.SumJJC,
  9442. OutsideJJPay = eecInfo.OutsideJJPay,
  9443. ChoiceTwoGW = eecInfo.SumGWC,
  9444. OutsideGWPay = eecInfo.OutsideGWPay,
  9445. ChoiceTwoTD = eecInfo.SumTDC,
  9446. OutsideTDPay = eecInfo.OutsideTDPay,
  9447. AirJJ = eecInfo.AirJJ,
  9448. AirGW = eecInfo.AirGW,
  9449. AirTD = eecInfo.AirTD,
  9450. CityTranffic = eecInfo.CityTranffic,
  9451. TwoItemRemark = eecInfo.TwoItemRemark
  9452. };
  9453. return Ok(JsonView(twoData));
  9454. }
  9455. else if (subType == 3) //3:住宿费
  9456. {
  9457. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9458. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9459. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9460. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9461. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9462. {
  9463. ParentId = dac.ParentId,
  9464. SubId = dac.Id,
  9465. Type = dac.Type,
  9466. Days = dac.Days,
  9467. NationalTravelFeeId = dac.NationalTravelFeeId,
  9468. Arae = $"{ntf.Country}-{ntf.City}",
  9469. Cost = dac.Cost,
  9470. Currency = dac.Currency,
  9471. CurrencyName = sd.Name,
  9472. SubTotal = dac.SubTotal,
  9473. })
  9474. .ToArray();
  9475. var data = new ChoiceDraftMobileSubInfo3To6View()
  9476. {
  9477. ParentId = eecInfo.Id,
  9478. Choice = eecInfo.ChoiceThree,
  9479. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9480. Details = dayAndCostDatas
  9481. };
  9482. return Ok(JsonView(data));
  9483. }
  9484. else if (subType == 4) //4:伙食费
  9485. {
  9486. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9487. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9488. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9489. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9490. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9491. {
  9492. ParentId = dac.ParentId,
  9493. SubId = dac.Id,
  9494. Type = dac.Type,
  9495. Days = dac.Days,
  9496. NationalTravelFeeId = dac.NationalTravelFeeId,
  9497. Arae = $"{ntf.Country}-{ntf.City}",
  9498. Cost = dac.Cost,
  9499. Currency = dac.Currency,
  9500. CurrencyName = sd.Name,
  9501. SubTotal = dac.SubTotal,
  9502. })
  9503. .ToArray();
  9504. var data = new ChoiceDraftMobileSubInfo3To6View()
  9505. {
  9506. ParentId = eecInfo.Id,
  9507. Choice = eecInfo.ChoiceFour,
  9508. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9509. Details = dayAndCostDatas
  9510. };
  9511. return Ok(JsonView(data));
  9512. }
  9513. else if (subType == 5) //5:公杂费
  9514. {
  9515. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9516. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9517. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9518. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9519. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9520. {
  9521. ParentId = dac.ParentId,
  9522. SubId = dac.Id,
  9523. Type = dac.Type,
  9524. Days = dac.Days,
  9525. NationalTravelFeeId = dac.NationalTravelFeeId,
  9526. Arae = $"{ntf.Country}-{ntf.City}",
  9527. Cost = dac.Cost,
  9528. Currency = dac.Currency,
  9529. CurrencyName = sd.Name,
  9530. SubTotal = dac.SubTotal,
  9531. })
  9532. .ToArray();
  9533. var data = new ChoiceDraftMobileSubInfo3To6View()
  9534. {
  9535. ParentId = eecInfo.Id,
  9536. Choice = eecInfo.ChoiceFive,
  9537. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9538. Details = dayAndCostDatas
  9539. };
  9540. return Ok(JsonView(data));
  9541. }
  9542. else if (subType == 6) //6:培训费
  9543. {
  9544. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9545. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9546. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9547. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9548. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9549. {
  9550. ParentId = dac.ParentId,
  9551. SubId = dac.Id,
  9552. Type = dac.Type,
  9553. Days = dac.Days,
  9554. NationalTravelFeeId = dac.NationalTravelFeeId,
  9555. Arae = $"{ntf.Country}-{ntf.City}",
  9556. Cost = dac.Cost,
  9557. Currency = dac.Currency,
  9558. CurrencyName = sd.Name,
  9559. SubTotal = dac.SubTotal,
  9560. })
  9561. .ToArray();
  9562. var data = new ChoiceDraftMobileSubInfo3To6View()
  9563. {
  9564. ParentId = eecInfo.Id,
  9565. Choice = eecInfo.ChoiceSix,
  9566. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9567. Details = dayAndCostDatas
  9568. };
  9569. return Ok(JsonView(data));
  9570. }
  9571. else if (subType == 7) //7:其他
  9572. {
  9573. //其他款项
  9574. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9575. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9576. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9577. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9578. .OrderBy((dop, sd1, sd2) => dop.Index)
  9579. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9580. {
  9581. ParentId = dop.ParentId,
  9582. SubId = dop.Id,
  9583. Index = dop.Index,
  9584. SetDataId = dop.SetDataId,
  9585. SetDataName = sd1.Name,
  9586. Cost = dop.Cost,
  9587. Currency = dop.Currency,
  9588. CurrencyName = sd2.Name,
  9589. SubTotal = dop.SubTotal,
  9590. Remark = dop.Remark,
  9591. })
  9592. .ToArray();
  9593. var data = new ChoiceSevenDraftMobileSubInfoView()
  9594. {
  9595. ParentId = eecInfo.Id,
  9596. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9597. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9598. Details = otherData
  9599. };
  9600. return Ok(JsonView(data));
  9601. }
  9602. return Ok(JsonView(false));
  9603. }
  9604. #region op
  9605. /// <summary>
  9606. /// 移动端更新费用消息通知
  9607. /// </summary>
  9608. /// <param name="draftId"></param>
  9609. /// <param name="id"></param>
  9610. /// <param name="currUserId"></param>
  9611. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9612. {
  9613. try
  9614. {
  9615. ////生成默认文件pdf并且通知人员
  9616. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9617. //{
  9618. // DiId = draftId,
  9619. // ExportType = 1,
  9620. // SubTypeId = 1005
  9621. //}, "pdf");
  9622. ////发送通知
  9623. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9624. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9625. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9626. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9627. ////汇率信息记录
  9628. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9629. }
  9630. catch (Exception ex)
  9631. {
  9632. //记录日志
  9633. throw;
  9634. }
  9635. }
  9636. /// <summary>
  9637. /// 验证出入境费用数据是否存在
  9638. /// 不存在添加
  9639. /// </summary>
  9640. /// <param name="draftId"></param>
  9641. /// <param name="currUserId"></param>
  9642. /// <returns></returns>
  9643. /// <exception cref="CustomException"></exception>
  9644. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9645. {
  9646. var parentId = 0;
  9647. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9648. if (info != null) parentId = info.Id;
  9649. else
  9650. {
  9651. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9652. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9653. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9654. parentId = addId;
  9655. }
  9656. return parentId;
  9657. }
  9658. /// <summary>
  9659. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  9660. /// </summary>
  9661. /// <returns></returns>
  9662. [HttpPost]
  9663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9664. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  9665. {
  9666. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9667. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9668. //验证查看权限
  9669. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9670. if (!isView) return Ok(JsonView(false, _viewPermStr));
  9671. var userIds = await _sqlSugar
  9672. .Queryable<Grp_EnterExitCostDraftPermission>()
  9673. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  9674. .Select(x => x.UserId)
  9675. .ToArrayAsync();
  9676. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  9677. var perUsersView = new List<dynamic>();
  9678. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  9679. var viewPermissionData = new List<PermissionViewUserview>();
  9680. if (feeBasePerm.Any())
  9681. {
  9682. foreach (var item in feeBasePerm)
  9683. {
  9684. if (item.Users.Any())
  9685. {
  9686. viewPermissionData.AddRange(item.Users);
  9687. }
  9688. }
  9689. }
  9690. foreach (var item in perUsers)
  9691. {
  9692. bool isView1 = false;
  9693. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9694. else if (viewPermissionData.Any(x => x.Id ==dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  9695. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9696. }
  9697. return Ok(JsonView(perUsersView));
  9698. }
  9699. /// <summary>
  9700. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9701. /// </summary>
  9702. /// <returns></returns>
  9703. [HttpPost]
  9704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9705. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9706. {
  9707. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9708. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9709. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9710. //验证查看编辑权限
  9711. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9712. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9713. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  9714. foreach (var userId in dto.UserIds)
  9715. {
  9716. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9717. }
  9718. if (permissions.Any())
  9719. {
  9720. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9721. {
  9722. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9723. }
  9724. _sqlSugar.BeginTran();
  9725. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9726. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9727. if (result < 1)
  9728. {
  9729. _sqlSugar.RollbackTran();
  9730. return Ok(JsonView(false));
  9731. }
  9732. _sqlSugar.CommitTran();
  9733. return Ok(JsonView(true));
  9734. }
  9735. return Ok(JsonView(false));
  9736. }
  9737. /// <summary>
  9738. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9739. /// </summary>
  9740. /// <returns></returns>
  9741. [HttpPost]
  9742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9743. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9744. {
  9745. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9746. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9747. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9748. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9749. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9750. int id = dto.DraftId;
  9751. if (id <= 0) //add
  9752. {
  9753. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9754. if (add < 1) return Ok(JsonView(false));
  9755. id = add;
  9756. }
  9757. else //update
  9758. {
  9759. //验证查看编辑权限
  9760. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  9761. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  9762. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9763. if (upd < 1) return Ok(JsonView(false));
  9764. }
  9765. #region 汇率变更时更改币种相关费用
  9766. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9767. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9768. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9769. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9770. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9771. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9772. .Select((dac, sd) => new
  9773. {
  9774. dac.Id,
  9775. dac.ParentId,
  9776. CurrencyCode = sd.Name,
  9777. dac.Cost
  9778. })
  9779. .ToList();
  9780. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9781. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9782. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9783. .Select((dop, sd) => new
  9784. {
  9785. dop.Id,
  9786. dop.ParentId,
  9787. CurrencyCode = sd.Name,
  9788. dop.Cost
  9789. })
  9790. .ToList();
  9791. if (dayCosts.Count > 0)
  9792. {
  9793. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9794. foreach (var dc in new_dayCosts)
  9795. {
  9796. var thisCurrency = dc.Key.ToUpper();
  9797. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9798. if (thisRate == 0.00M) continue;
  9799. foreach (var dcSub in dc)
  9800. {
  9801. opDayCosts.Add(new Grp_DayAndCostDraft()
  9802. {
  9803. Id = dcSub.Id,
  9804. ParentId = dcSub.ParentId,
  9805. Cost = dcSub.Cost,
  9806. SubTotal = dcSub.Cost * thisRate,
  9807. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  9808. });
  9809. }
  9810. }
  9811. if (opDayCosts.Count > 0)
  9812. {
  9813. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9814. }
  9815. }
  9816. if (dayOtherCosts.Count > 0)
  9817. {
  9818. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9819. foreach (var dc in new_dayOtherCosts)
  9820. {
  9821. var thisCurrency = dc.Key.ToUpper();
  9822. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9823. if (thisRate == 0.00M) continue;
  9824. foreach (var dcSub in dc)
  9825. {
  9826. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  9827. {
  9828. Id = dcSub.Id,
  9829. ParentId = dcSub.ParentId,
  9830. Cost = dcSub.Cost,
  9831. SubTotal = dcSub.Cost * thisRate,
  9832. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9833. });
  9834. }
  9835. }
  9836. if (opDayOtherCosts.Count > 0)
  9837. {
  9838. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9839. }
  9840. }
  9841. #endregion
  9842. ////消息通知
  9843. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9844. ////汇率信息记录
  9845. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9846. return Ok(JsonView(new { parentId = id }));
  9847. }
  9848. /// <summary>
  9849. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9850. /// </summary>
  9851. /// <returns></returns>
  9852. [HttpPost]
  9853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9854. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9855. {
  9856. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9857. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9858. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9859. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9860. int id = dto.DraftId;
  9861. if (id <= 0) //add
  9862. {
  9863. checkboxInfo.CreateUserId = dto.CurrUserId;
  9864. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9865. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9866. if (add < 1) return Ok(JsonView(false));
  9867. }
  9868. else //update
  9869. {
  9870. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9871. .UpdateColumns(x => new
  9872. {
  9873. x.ChoiceOne,
  9874. x.ChoiceTwo,
  9875. x.SumJJC,
  9876. x.SumGWC,
  9877. x.SumTDC,
  9878. x.ChoiceThree,
  9879. x.ChoiceFour,
  9880. x.ChoiceFive,
  9881. x.ChoiceSix,
  9882. x.OtherExpenses_Checked
  9883. })
  9884. .Where(x => x.Id == id)
  9885. .ExecuteCommandAsync();
  9886. if (upd < 1) return Ok(JsonView(false));
  9887. }
  9888. return Ok(JsonView(new { parentId = id }));
  9889. }
  9890. /// <summary>
  9891. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9892. /// </summary>
  9893. /// <returns></returns>
  9894. [HttpPost]
  9895. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9896. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9897. {
  9898. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9899. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9900. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9901. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9902. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9903. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9904. var checkboxInfo = new Grp_EnterExitCostDraft()
  9905. {
  9906. Id = draftId,
  9907. CreateUserId = currUserId
  9908. };
  9909. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9910. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9911. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9912. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9913. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9914. if (draftId <= 0) //add
  9915. {
  9916. checkboxInfo.CreateUserId = dto.CurrUserId;
  9917. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9918. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9919. if (add < 1) return Ok(JsonView(false));
  9920. }
  9921. else //update
  9922. {
  9923. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9924. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9925. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9926. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9927. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9928. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9929. .Where(x => x.Id == draftId)
  9930. .ExecuteCommandAsync();
  9931. if (upd < 1) return Ok(JsonView(false));
  9932. }
  9933. return Ok(JsonView(new { parentId = draftId }));
  9934. }
  9935. /// <summary>
  9936. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9937. /// </summary>
  9938. /// <returns></returns>
  9939. [HttpPost]
  9940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9941. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9942. {
  9943. int id = dto.DraftId, currUserId = dto.CurrUserId;
  9944. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9945. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9946. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9947. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9948. info.FirstItemRemark = dto.FirstItemRemark;
  9949. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9950. if (id <= 0) //add
  9951. {
  9952. info.CreateUserId = dto.CurrUserId;
  9953. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9954. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9955. if (add < 1) return Ok(JsonView(false));
  9956. id = add;
  9957. }
  9958. else //update
  9959. {
  9960. var upd = await _sqlSugar.Updateable(info)
  9961. .UpdateColumns(x => new
  9962. {
  9963. x.ChoiceOne,
  9964. x.InsidePay,
  9965. x.VisaRemark,
  9966. x.Visa,
  9967. x.Service,
  9968. x.Safe,
  9969. x.Ticket,
  9970. x.HeSuan,
  9971. x.YiMiao,
  9972. x.FirstItemRemark
  9973. })
  9974. .Where(x => x.Id == id)
  9975. .ExecuteCommandAsync();
  9976. if (upd < 1) return Ok(JsonView(false));
  9977. }
  9978. ////消息通知
  9979. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9980. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9981. }
  9982. /// <summary>
  9983. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9984. /// </summary>
  9985. /// <returns></returns>
  9986. [HttpPost]
  9987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9988. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9989. {
  9990. int id = dto.DraftId;
  9991. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9992. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9993. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9994. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9995. info.OutsideJJPay = dto.OutsideJJPay;
  9996. info.OutsideGWPay = dto.OutsideGWPay;
  9997. info.OutsideTDPay = dto.OutsideTDPay;
  9998. info.AirJJ = dto.AirJJ;
  9999. info.AirGW = dto.AirGW;
  10000. info.AirTD = dto.AirTD;
  10001. info.CityTranffic = dto.CityTranffic;
  10002. info.TwoItemRemark = dto.TwoItemRemark;
  10003. info.SumJJC = dto.ChoiceTwoJJ;
  10004. info.SumGWC = dto.ChoiceTwoGW;
  10005. info.SumTDC = dto.ChoiceTwoTD;
  10006. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10007. if (id <= 0) //add
  10008. {
  10009. info.CreateUserId = dto.CurrUserId;
  10010. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10011. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10012. if (addId <= 0) return Ok(JsonView(false));
  10013. id = addId;
  10014. }
  10015. else //update
  10016. {
  10017. var upd = await _sqlSugar.Updateable(info)
  10018. .UpdateColumns(x => new
  10019. {
  10020. x.SumJJC,
  10021. x.OutsideJJPay,
  10022. x.SumGWC,
  10023. x.OutsideGWPay,
  10024. x.SumTDC,
  10025. x.OutsideTDPay,
  10026. x.AirJJ,
  10027. x.AirGW,
  10028. x.AirTD,
  10029. x.CityTranffic,
  10030. x.TwoItemRemark
  10031. })
  10032. .Where(x => x.Id == id)
  10033. .ExecuteCommandAsync();
  10034. if (upd < 1) return Ok(JsonView(false));
  10035. }
  10036. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10037. gwcItemTotal = info.AirGW + info.CityTranffic;
  10038. tdcItemTotal = info.AirTD + info.CityTranffic;
  10039. ////消息通知
  10040. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10041. return Ok(JsonView(new
  10042. {
  10043. parentId = id,
  10044. choiceTwoJJ = dto.ChoiceTwoJJ,
  10045. jjcItemTotal = jjcItemTotal,
  10046. choiceTwoGW = dto.ChoiceTwoGW,
  10047. gwcItemTotal = gwcItemTotal,
  10048. choiceTwoTD = dto.ChoiceTwoTD,
  10049. tdcItemTotal = tdcItemTotal
  10050. }));
  10051. }
  10052. /// <summary>
  10053. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10054. /// </summary>
  10055. /// <returns></returns>
  10056. [HttpPost]
  10057. [ApiExplorerSettings(IgnoreApi = true)]
  10058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10059. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  10060. {
  10061. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10062. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10063. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10064. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10065. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10066. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10067. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  10068. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  10069. {
  10070. Id = x.Id,
  10071. ParentId = dto.DraftId,
  10072. Type = dto.FeeType,
  10073. Days = x.Days,
  10074. NationalTravelFeeId = x.NationalTravelFeeId,
  10075. Cost = x.Cost,
  10076. Currency = x.Currency,
  10077. SubTotal = x.SubTotal,
  10078. CreateUserId = dto.CurrUserId
  10079. })
  10080. .ToList();
  10081. var adds = infos.Where(x => x.Id <= 0).ToList();
  10082. var upds = infos.Where(x => x.Id > 0).ToList();
  10083. if (adds.Count > 0)
  10084. {
  10085. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10086. if (add < 1) return Ok(JsonView(false));
  10087. }
  10088. if (upds.Count > 0)
  10089. {
  10090. var upd = await _sqlSugar.Updateable(adds)
  10091. .UpdateColumns(x => new
  10092. {
  10093. x.Days,
  10094. x.NationalTravelFeeId,
  10095. x.Cost,
  10096. x.Currency,
  10097. x.SubTotal
  10098. })
  10099. .WhereColumns(x => new { x.Id })
  10100. .ExecuteCommandAsync();
  10101. if (upd < 1) return Ok(JsonView(false));
  10102. }
  10103. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10104. ////消息通知
  10105. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  10106. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10107. return Ok(JsonView(new { itemTotal = itemTotal }));
  10108. }
  10109. /// <summary>
  10110. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10111. /// </summary>
  10112. /// <returns></returns>
  10113. [HttpPost]
  10114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10115. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  10116. {
  10117. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10118. int subId = dto.SubId, feeType = dto.FeeType;
  10119. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10120. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10121. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10122. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10123. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  10124. subInfo.Id = subId;
  10125. subInfo.ParentId = dto.DraftId;
  10126. if (feeType == 3) subInfo.Type = 1;
  10127. else if (feeType == 4) subInfo.Type = 2;
  10128. else if (feeType == 5) subInfo.Type = 3;
  10129. else if (feeType == 6) subInfo.Type = 4;
  10130. subInfo.CreateUserId = dto.CurrUserId;
  10131. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  10132. if (parentId < 1) return Ok(JsonView(false));
  10133. //子表op
  10134. if (subId < 1)
  10135. {
  10136. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10137. if (subAdd < 1) return Ok(JsonView(false));
  10138. }
  10139. else
  10140. {
  10141. var subUpd = await _sqlSugar.Updateable(subInfo)
  10142. .UpdateColumns(x => new
  10143. {
  10144. x.Days,
  10145. x.NationalTravelFeeId,
  10146. x.Cost,
  10147. x.Currency,
  10148. x.SubTotal
  10149. })
  10150. .WhereColumns(x => new { x.Id })
  10151. .ExecuteCommandAsync();
  10152. if (subUpd < 1) return Ok(JsonView(false));
  10153. }
  10154. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  10155. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10156. }
  10157. /// <summary>
  10158. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  10159. /// </summary>
  10160. /// <returns></returns>
  10161. [HttpPost]
  10162. [ApiExplorerSettings(IgnoreApi = true)]
  10163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10164. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  10165. {
  10166. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10167. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10168. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10169. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  10170. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  10171. {
  10172. Id = x.Id,
  10173. ParentId = dto.DraftId,
  10174. SetDataId = x.SetDataId,
  10175. Index = x.Index,
  10176. Cost = x.Cost,
  10177. Currency = x.Currency,
  10178. SubTotal = x.SubTotal,
  10179. CreateUserId = dto.CurrUserId,
  10180. Remark = x.Remark
  10181. }).ToList();
  10182. var adds = infos.Where(x => x.Id <= 0).ToList();
  10183. var upds = infos.Where(x => x.Id > 0).ToList();
  10184. if (adds.Count > 0)
  10185. {
  10186. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10187. if (add < 1) return Ok(JsonView(false));
  10188. }
  10189. if (upds.Count > 0)
  10190. {
  10191. var upd = await _sqlSugar.Updateable(adds)
  10192. .UpdateColumns(x => new
  10193. {
  10194. x.Index,
  10195. x.SetDataId,
  10196. x.Cost,
  10197. x.Currency,
  10198. x.SubTotal,
  10199. x.Remark
  10200. })
  10201. .WhereColumns(x => new { x.Id })
  10202. .ExecuteCommandAsync();
  10203. if (upd < 1) return Ok(JsonView(false));
  10204. }
  10205. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  10206. //消息通知
  10207. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  10208. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10209. return Ok(JsonView(new { itemTotal = itemTotal }));
  10210. }
  10211. /// <summary>
  10212. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  10213. /// </summary>
  10214. /// <returns></returns>
  10215. [HttpPost]
  10216. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10217. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  10218. {
  10219. int subId = dto.SubId, id = dto.DraftId;
  10220. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10221. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  10222. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10223. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  10224. subInfo.Id = subId;
  10225. subInfo.ParentId = id;
  10226. subInfo.CreateUserId = dto.CurrUserId;
  10227. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  10228. if (parentId < 1) return Ok(JsonView(false));
  10229. #region 子表op
  10230. if (subId < 1)//add
  10231. {
  10232. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10233. if (subAdd < 1) return Ok(JsonView(false));
  10234. }
  10235. else //upd
  10236. {
  10237. var subUpd = await _sqlSugar.Updateable(subInfo)
  10238. .UpdateColumns(x => new
  10239. {
  10240. x.Index,
  10241. x.SetDataId,
  10242. x.Cost,
  10243. x.Currency,
  10244. x.SubTotal,
  10245. x.Remark
  10246. })
  10247. .WhereColumns(x => new { x.Id })
  10248. .ExecuteCommandAsync();
  10249. if (subUpd < 1) return Ok(JsonView(false));
  10250. }
  10251. #endregion
  10252. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10253. ////消息通知
  10254. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10255. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10256. }
  10257. /// <summary>
  10258. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10259. /// </summary>
  10260. /// <returns></returns>
  10261. [HttpPost]
  10262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10263. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10264. {
  10265. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10266. if (data.Code != 0)
  10267. {
  10268. return Ok(JsonView(false, data.Msg));
  10269. }
  10270. return Ok(JsonView(true, "操作成功!", data.Data));
  10271. }
  10272. /// <summary>
  10273. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10274. /// </summary>
  10275. /// <param name="dto"></param>
  10276. /// <returns></returns>
  10277. [HttpPost]
  10278. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10279. {
  10280. var data = new Grp_DayOtherPriceDraft()
  10281. {
  10282. Id = dto.Id,
  10283. IsDel = 1,
  10284. DeleteUserId = dto.DeleteUserId,
  10285. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10286. };
  10287. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10288. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10289. return Ok(JsonView(false, "删除失败!"));
  10290. }
  10291. #endregion
  10292. #endregion
  10293. #region 团组经理模块 出入境费用报价表
  10294. /// <summary>
  10295. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  10296. /// </summary>
  10297. /// <returns></returns>
  10298. [HttpPost]
  10299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10300. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  10301. {
  10302. var initRates = await GeneralMethod.EnterExitCostInitRate();
  10303. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  10304. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  10305. initRates.Insert(0, cnyInfo);
  10306. liveRates.Insert(0, cnyInfo);
  10307. return Ok(JsonView(true, "查询成功!", new
  10308. {
  10309. InitRates = initRates,
  10310. LiveRates = liveRates
  10311. }));
  10312. }
  10313. /// <summary>
  10314. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  10315. /// </summary>
  10316. /// <returns></returns>
  10317. [HttpPost]
  10318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10319. public async Task<IActionResult> EnterExitCostQuoteNameListDto(EnterExitCostQuoteNameListDto dto)
  10320. {
  10321. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  10322. }
  10323. /// <summary>
  10324. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  10325. /// </summary>
  10326. /// <returns></returns>
  10327. [HttpPost]
  10328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10329. public async Task<IActionResult> EnterExitCostQuoteGroupNameListDto(EnterExitCostQuoteGroupNameListDto dto)
  10330. {
  10331. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  10332. }
  10333. /// <summary>
  10334. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  10335. /// </summary>
  10336. /// <returns></returns>
  10337. [HttpPost]
  10338. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10339. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  10340. {
  10341. int groupId = dto.DiId,
  10342. currUserId = dto.CurrUserId;
  10343. if (groupId < 1) return Ok(JsonView(false,"请传入有效的GroupId;"));
  10344. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  10345. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10346. if (info.Code != StatusCodes.Status200OK) return Ok(info);
  10347. var infoView = info.Data as EnterExitCostInfoView;
  10348. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  10349. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  10350. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  10351. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  10352. var eecRates = infoView.Currencys;
  10353. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  10354. int pplNum = 1;
  10355. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  10356. var views = new List<QuoteSubItemInfo>();
  10357. #region 数据填充
  10358. var intTravelCosts = new List<QuoteSubItemInfo>();
  10359. #region 机票费用 1354
  10360. int intTravelIndex = 1;
  10361. if (infoView.SumJJC == 1)
  10362. {
  10363. intTravelCosts.Add(new QuoteSubItemInfo
  10364. {
  10365. ItemId = 1354,
  10366. Index = intTravelIndex,
  10367. FeeName = "经济舱",
  10368. UnitPrice = infoView.AirJJ,
  10369. Currency = "CNY",
  10370. Quantity = 1,
  10371. PplNum = 1,
  10372. TotalAmt = infoView.AirJJ,
  10373. Remark = "",
  10374. });
  10375. intTravelIndex++;
  10376. }
  10377. if (infoView.SumGWC == 1)
  10378. {
  10379. intTravelCosts.Add(new QuoteSubItemInfo
  10380. {
  10381. ItemId = 1354,
  10382. Index = intTravelIndex,
  10383. FeeName = "公务舱",
  10384. UnitPrice = infoView.AirGW,
  10385. Currency = "CNY",
  10386. Quantity = 1,
  10387. PplNum = 1,
  10388. TotalAmt = infoView.AirGW,
  10389. Remark = "",
  10390. });
  10391. intTravelIndex++;
  10392. }
  10393. if (infoView.SumTDC == 1)
  10394. {
  10395. intTravelCosts.Add(new QuoteSubItemInfo
  10396. {
  10397. ItemId = 1354,
  10398. Index = intTravelIndex,
  10399. FeeName = "头等舱",
  10400. UnitPrice = infoView.AirTD,
  10401. Currency = "CNY",
  10402. Quantity = 1,
  10403. PplNum = 1,
  10404. TotalAmt = infoView.AirTD,
  10405. Remark = "",
  10406. });
  10407. intTravelIndex++;
  10408. }
  10409. intTravelCosts.Add(new QuoteSubItemInfo
  10410. {
  10411. ItemId = 1354,
  10412. Index = intTravelIndex,
  10413. FeeName = "城市间交通费用",
  10414. UnitPrice = infoView.CityTranffic,
  10415. Currency = "CNY",
  10416. Quantity = 1,
  10417. PplNum = pplNum,
  10418. TotalAmt = infoView.CityTranffic * pplNum,
  10419. Remark = "",
  10420. });
  10421. views.AddRange(intTravelCosts);
  10422. #endregion
  10423. var accomCosts = new List<QuoteSubItemInfo>();
  10424. #region 住宿费 1355
  10425. if (infoView.QuarterageData.Any())
  10426. {
  10427. int accomIndex = 1;
  10428. int accomItemTypeId = 1355;
  10429. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  10430. foreach (var item in groupData)
  10431. {
  10432. string feeName = string.Empty;
  10433. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10434. if (countryInfo != null)
  10435. {
  10436. feeName = countryInfo.Country;
  10437. var city = countryInfo.City;
  10438. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10439. {
  10440. feeName += $"-{city}";
  10441. }
  10442. }
  10443. var hotelInfo = item.FirstOrDefault();
  10444. if (hotelInfo == null) continue;
  10445. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  10446. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10447. int quantity = item.ToList().Count;
  10448. accomCosts.Add(new QuoteSubItemInfo
  10449. {
  10450. ItemId = accomItemTypeId,
  10451. Index = accomIndex,
  10452. FeeName = feeName,
  10453. UnitPrice = hotelInfo.Cost,
  10454. Currency = thisCurrency,
  10455. Quantity = quantity,
  10456. PplNum = pplNum,
  10457. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  10458. Remark = "",
  10459. });
  10460. accomIndex++;
  10461. }
  10462. views.AddRange(accomCosts);
  10463. }
  10464. #endregion
  10465. var mealCosts = new List<QuoteSubItemInfo>();
  10466. #region 餐饮费 1356
  10467. if (infoView.BoardWagesData.Any())
  10468. {
  10469. var mealIndex = 1;
  10470. int mealItemTypeId = 1356;
  10471. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  10472. foreach (var item in groupData)
  10473. {
  10474. string feeName = string.Empty;
  10475. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10476. if (countryInfo != null)
  10477. {
  10478. feeName = countryInfo.Country;
  10479. var city = countryInfo.City;
  10480. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10481. {
  10482. feeName += $"-{city}";
  10483. }
  10484. }
  10485. var mealInfo = item.FirstOrDefault();
  10486. if (mealInfo == null) continue;
  10487. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  10488. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10489. int quantity = item.ToList().Count;
  10490. mealCosts.Add(new QuoteSubItemInfo
  10491. {
  10492. ItemId = mealItemTypeId,
  10493. Index = mealIndex,
  10494. FeeName = feeName,
  10495. UnitPrice = mealInfo.Cost,
  10496. Currency = thisCurrency,
  10497. Quantity = quantity,
  10498. PplNum = pplNum,
  10499. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  10500. Remark = "",
  10501. });
  10502. mealIndex++;
  10503. }
  10504. views.AddRange(mealCosts);
  10505. }
  10506. #endregion
  10507. var miscCosts = new List<QuoteSubItemInfo>();
  10508. #region 公杂费 1364
  10509. if (infoView.MiscellaneousFeeData.Any())
  10510. {
  10511. var miscIndex = 1;
  10512. int miscItemTypeId = 1364;
  10513. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  10514. foreach (var item in groupData)
  10515. {
  10516. string feeName = string.Empty;
  10517. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  10518. if (countryInfo != null)
  10519. {
  10520. feeName = countryInfo.Country;
  10521. var city = countryInfo.City;
  10522. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  10523. {
  10524. feeName += $"-{city}";
  10525. }
  10526. }
  10527. var miscInfo = item.FirstOrDefault();
  10528. if (miscInfo == null) continue;
  10529. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  10530. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  10531. int quantity = item.ToList().Count;
  10532. mealCosts.Add(new QuoteSubItemInfo
  10533. {
  10534. ItemId = miscItemTypeId,
  10535. Index = miscIndex,
  10536. FeeName = feeName,
  10537. UnitPrice = miscInfo.Cost,
  10538. Currency = thisCurrency,
  10539. Quantity = quantity,
  10540. PplNum = pplNum,
  10541. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  10542. Remark = "",
  10543. });
  10544. miscIndex++;
  10545. }
  10546. views.AddRange(mealCosts);
  10547. }
  10548. #endregion
  10549. #region 签证+保险 1362
  10550. int visaInsIndex = 1;
  10551. int visaInsItemTypeId = 1362;
  10552. if (infoView.Visa > 0)
  10553. {
  10554. views.Add(new QuoteSubItemInfo() {
  10555. ItemId = visaInsItemTypeId,
  10556. Index = visaInsIndex,
  10557. FeeName = $"签证",
  10558. UnitPrice = infoView.Visa,
  10559. Currency = $"CNY",
  10560. Quantity = 1,
  10561. PplNum = pplNum,
  10562. TotalAmt = infoView.Visa * pplNum,
  10563. Remark = "",
  10564. });
  10565. visaInsIndex++;
  10566. }
  10567. if (infoView.Safe > 0)
  10568. {
  10569. views.Add(new QuoteSubItemInfo()
  10570. {
  10571. ItemId = visaInsItemTypeId,
  10572. Index = visaInsIndex,
  10573. FeeName = $"保险",
  10574. UnitPrice = infoView.Safe,
  10575. Currency = $"CNY",
  10576. Quantity = 1,
  10577. PplNum = pplNum,
  10578. TotalAmt = infoView.Safe * pplNum,
  10579. Remark = "",
  10580. });
  10581. }
  10582. #endregion
  10583. #region 服务费 1363
  10584. int serviceFeeIndex = 1;
  10585. int serviceFeeItemTypeId = 1363;
  10586. if (infoView.Service > 0)
  10587. {
  10588. views.Add(new QuoteSubItemInfo()
  10589. {
  10590. ItemId = serviceFeeItemTypeId,
  10591. Index = serviceFeeIndex,
  10592. FeeName = $"服务费",
  10593. UnitPrice = infoView.Service,
  10594. Currency = $"CNY",
  10595. Quantity = 1,
  10596. PplNum = pplNum,
  10597. TotalAmt = infoView.Service * pplNum,
  10598. Remark = "",
  10599. });
  10600. }
  10601. #endregion
  10602. #endregion
  10603. var result = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { });
  10604. result.Rates = eecRates.ToArray();
  10605. if (result.FeeItems.Any())
  10606. {
  10607. result.FeeItems.Select(x =>
  10608. {
  10609. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  10610. if (feeInfos.Any()) x.Infos = feeInfos;
  10611. return x;
  10612. }
  10613. )
  10614. .OrderBy(x => x.Index)
  10615. .ToList();
  10616. }
  10617. return Ok(JsonView(result));
  10618. }
  10619. /// <summary>
  10620. /// 团组模块 - 出入境费用报价表 - Info
  10621. /// </summary>
  10622. /// <returns></returns>
  10623. [HttpPost]
  10624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10625. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  10626. {
  10627. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  10628. if (!info.Rates.Any())
  10629. {
  10630. var rates = await GeneralMethod.EnterExitCostInitRate();
  10631. info.Rates = rates.ToArray();
  10632. }
  10633. return Ok(JsonView(info));
  10634. }
  10635. /// <summary>
  10636. /// 团组模块 - 出入境费用报价表 - OP
  10637. /// </summary>
  10638. /// <returns></returns>
  10639. [HttpPost]
  10640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10641. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  10642. {
  10643. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  10644. }
  10645. /// <summary>
  10646. /// 团组模块 - 出入境费用报价表 - 删除 项
  10647. /// </summary>
  10648. /// <returns></returns>
  10649. [HttpPost]
  10650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10651. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  10652. {
  10653. if (dto.Id < 1) return Ok(JsonView(false,MsgTips.Id));
  10654. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10655. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  10656. }
  10657. /// <summary>
  10658. /// 团组模块 - 出入境费用报价表 - 导出
  10659. /// </summary>
  10660. /// <returns></returns>
  10661. [HttpPost]
  10662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10663. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  10664. {
  10665. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  10666. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10667. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id= dto.Id });
  10668. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  10669. var rates = info.Rates;
  10670. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  10671. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  10672. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  10673. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  10674. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  10675. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  10676. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1560); //邀请函发放时间
  10677. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1561); //公务活动
  10678. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1562); //签证+保险
  10679. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1563); //服务费
  10680. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1564); //公杂费
  10681. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1565); //税费
  10682. //获取模板
  10683. string tempPath = (AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx");
  10684. var designer = new WorkbookDesigner();
  10685. designer.Workbook = new Workbook(tempPath);
  10686. designer.SetDataSource("QuoteName", info.Name);
  10687. designer.SetDataSource("CompanyTitle", "公司名称");
  10688. designer.SetDataSource("CompanyLabel", "");
  10689. #region 国际旅费
  10690. designer.SetDataSource("IntTravelTitle", intTravelCosts.ItemName);
  10691. if (intTravelCosts.Infos.Any())
  10692. {
  10693. var cabClassFilter = new string[] {"经济舱","公务舱","头等舱" };
  10694. string label = string.Empty;
  10695. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  10696. if (infos.Any())
  10697. {
  10698. label = $"{infos.Sum(x => x.PplNum)}人全程机票:{infos.Sum(x => x.TotalAmt).TruncDecimals(2)}元\r\n";
  10699. }
  10700. foreach (var item in intTravelCosts.Infos)
  10701. {
  10702. label += $"{item.FeeName}:{item.UnitPrice.TruncDecimals(2)}元/人*{item.PplNum}人\r\n";
  10703. }
  10704. label += $"\r\n以上小计:{intTravelCosts.TotalAmt.TruncDecimals(2)}元";
  10705. designer.SetDataSource("IntTravelLabel", label);
  10706. }
  10707. #endregion
  10708. #region 住宿费
  10709. designer.SetDataSource("AccomTitle", accomCosts.ItemName);
  10710. if (accomCosts.Infos.Any())
  10711. {
  10712. string currencyName = string.Empty;
  10713. decimal rate = 1.0000M;
  10714. string label = "全程五星酒店,每人1间房\r\n";
  10715. foreach (var item in accomCosts.Infos)
  10716. {
  10717. string hotelName = string.Empty;
  10718. if (item.FeeName.Contains("-"))
  10719. {
  10720. var feeName = item.FeeName.Split('-');
  10721. hotelName = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  10722. }
  10723. else hotelName = $"\r\n{item.FeeName}:";
  10724. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  10725. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  10726. rate = rateInfo?.Rate ?? 1.0000M;
  10727. label += $"{hotelName}{item.UnitPrice.TruncDecimals(2)}{currencyName}/间/晚*{item.Quantity.ToString("#0")}*{item.PplNum}人\r\n";
  10728. }
  10729. label += $"\r\n以上小计:{accomCosts.TotalAmt.TruncDecimals(2)}元({currencyName}汇率:{rate.TruncDecimals(4)})";
  10730. designer.SetDataSource("AccomLabel", label);
  10731. }
  10732. #endregion
  10733. #region 餐饮费
  10734. designer.SetDataSource("MealTitle", mealCosts.ItemName);
  10735. if (mealCosts.Infos.Any())
  10736. {
  10737. string currencyName = string.Empty;
  10738. decimal rate = 1.0000M;
  10739. string label = "全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n";
  10740. foreach (var item in mealCosts.Infos)
  10741. {
  10742. string name = string.Empty;
  10743. if (item.FeeName.Contains("-"))
  10744. {
  10745. var feeName = item.FeeName.Split('-');
  10746. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  10747. }
  10748. else name = $"\r\n{item.FeeName}:";
  10749. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  10750. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  10751. rate = rateInfo?.Rate ?? 1.0000M;
  10752. label += $"{name}{item.UnitPrice.TruncDecimals(2)}{currencyName}/天*{item.Quantity.ToString("#0")}*{item.PplNum}人\r\n";
  10753. }
  10754. label += $"\r\n以上小计:{accomCosts.TotalAmt.TruncDecimals(2)}元\r\n({currencyName}汇率:{rate.TruncDecimals(4)})";
  10755. designer.SetDataSource("MealLabel", label);
  10756. }
  10757. #endregion
  10758. #region 车辆安排
  10759. designer.SetDataSource("VehArrangeTitle", vehArranges.ItemName);
  10760. if (vehArranges.Infos.Any())
  10761. {
  10762. string currencyName = string.Empty;
  10763. decimal rate = 1.0000M;
  10764. string label = $"";
  10765. foreach (var item in vehArranges.Infos)
  10766. {
  10767. label += $"{item.Remark}\r\n\r\n{item.FeeName}\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元";
  10768. }
  10769. designer.SetDataSource("VehArrangeLabel", label);
  10770. }
  10771. #endregion
  10772. #region 邀请函发放对象
  10773. designer.SetDataSource("InviteToTitle", inviteTo.ItemName);
  10774. #endregion
  10775. designer.Process();
  10776. //文件名
  10777. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10778. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  10779. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  10780. return Ok(JsonView(true, "成功", url));
  10781. }
  10782. #endregion
  10783. #region 签证费用录入
  10784. /// <summary>
  10785. /// 根据diid查询签证费用列表
  10786. /// </summary>
  10787. /// <param name="dto"></param>
  10788. /// <returns></returns>
  10789. [HttpPost]
  10790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10791. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10792. {
  10793. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10794. if (groupData.Code != 0)
  10795. {
  10796. return Ok(JsonView(false, groupData.Msg));
  10797. }
  10798. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10799. }
  10800. /// <summary>
  10801. /// 根据签证费用Id查询单条数据及c表数据
  10802. /// </summary>
  10803. /// <param name="dto"></param>
  10804. /// <returns></returns>
  10805. [HttpPost]
  10806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10807. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10808. {
  10809. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10810. if (groupData.Code != 0)
  10811. {
  10812. return Ok(JsonView(false, groupData.Msg));
  10813. }
  10814. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10815. }
  10816. /// <summary>
  10817. /// 签证费用删除
  10818. /// </summary>
  10819. /// <param name="dto"></param>
  10820. /// <returns></returns>
  10821. [HttpPost]
  10822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10823. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10824. {
  10825. _sqlSugar.BeginTran();
  10826. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10827. if (!res)
  10828. {
  10829. _sqlSugar.RollbackTran();
  10830. return Ok(JsonView(false, "删除失败"));
  10831. }
  10832. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10833. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10834. .SetColumns(a => new Grp_CreditCardPayment()
  10835. {
  10836. IsDel = 1,
  10837. DeleteUserId = dto.DeleteUserId,
  10838. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10839. })
  10840. .ExecuteCommand();
  10841. if (resSub < 1)
  10842. {
  10843. _sqlSugar.RollbackTran();
  10844. return Ok(JsonView(false, "删除失败"));
  10845. }
  10846. _sqlSugar.CommitTran();
  10847. return Ok(JsonView(true, "删除成功!"));
  10848. }
  10849. /// <summary>
  10850. /// 签证费用录入下拉框初始化
  10851. /// </summary>
  10852. /// <returns></returns>
  10853. [HttpPost]
  10854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10855. public async Task<IActionResult> VisaPriceAddSelect()
  10856. {
  10857. //支付方式
  10858. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10859. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10860. //币种
  10861. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10862. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10863. //乘客类型
  10864. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10865. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10866. //卡类型
  10867. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10868. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10869. //代办费类型
  10870. var agencyFeeTypeData = new List<dynamic>() {
  10871. new { id = 0 , Text = "未选择" },
  10872. new { id = 1 , Text = "小公务" },
  10873. new { id = 2 , Text = "大公务" },
  10874. };
  10875. //签证费用标准国家Data
  10876. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10877. var data = new
  10878. {
  10879. Payment = _Payment,
  10880. CurrencyList = _CurrencyList,
  10881. PassengerType = _PassengerType,
  10882. BankCard = _BankCard,
  10883. AgencyFeeType = agencyFeeTypeData,
  10884. CountryFeeData = visaCountryFeeData
  10885. };
  10886. return Ok(JsonView(true, "查询成功!", data));
  10887. }
  10888. /// <summary>
  10889. /// 签证费用录入操作(Status:1.新增,2.修改)
  10890. /// </summary>
  10891. /// <param name="dto"></param>
  10892. /// <returns></returns>
  10893. [HttpPost]
  10894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10895. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10896. {
  10897. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10898. if (groupData.Code != 0)
  10899. {
  10900. return Ok(JsonView(false, groupData.Msg));
  10901. }
  10902. #region 应用推送
  10903. try
  10904. {
  10905. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10906. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10907. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10908. //2024-10-21 新增LZ UID
  10909. var userIds = new List<int>() { 21 };
  10910. string title = $"系统通知";
  10911. string content = "";
  10912. var diId = dto.DiId;
  10913. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10914. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10915. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10916. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  10917. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10918. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10919. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10920. }
  10921. catch (Exception ex)
  10922. {
  10923. }
  10924. #endregion
  10925. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10926. }
  10927. #endregion
  10928. #region 签证提成录入
  10929. /// <summary>
  10930. /// 签证提成录入
  10931. /// 基础数据
  10932. /// </summary>
  10933. /// <returns></returns>
  10934. [HttpGet]
  10935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10936. public async Task<IActionResult> VisaCommissionInit()
  10937. {
  10938. return Ok(await _visaCommissionRep.Init());
  10939. }
  10940. /// <summary>
  10941. /// 签证提成录入
  10942. /// Item
  10943. /// </summary>
  10944. /// <param name="_dto"></param>
  10945. /// <returns></returns>
  10946. [HttpPost]
  10947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10948. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10949. {
  10950. var validator = new VisaCommissionItemDtoValidator();
  10951. var validatorRes = await validator.ValidateAsync(_dto);
  10952. if (!validatorRes.IsValid)
  10953. {
  10954. StringBuilder sb = new StringBuilder();
  10955. foreach (var item in validatorRes.Errors)
  10956. {
  10957. sb.AppendLine(item.ErrorMessage);
  10958. }
  10959. return Ok(JsonView(false, sb.ToString()));
  10960. }
  10961. return Ok(await _visaCommissionRep.Item(_dto));
  10962. }
  10963. /// <summary>
  10964. /// 签证提成录入
  10965. /// Save
  10966. /// </summary>
  10967. /// <param name="_dto"></param>
  10968. /// <returns></returns>
  10969. [HttpPost]
  10970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10971. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10972. {
  10973. //参数验证
  10974. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10975. foreach (var item in _dto.Items)
  10976. {
  10977. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10978. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10979. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10980. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10981. }
  10982. return Ok(await _visaCommissionRep.Save(_dto));
  10983. }
  10984. /// <summary>
  10985. /// 签证提成录入
  10986. /// Create
  10987. /// </summary>
  10988. /// <param name="_dto"></param>
  10989. /// <returns></returns>
  10990. [HttpPost]
  10991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10992. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10993. {
  10994. var validator = new VisaCommissionCreateDtoValidator();
  10995. var validatorRes = await validator.ValidateAsync(_dto);
  10996. if (!validatorRes.IsValid)
  10997. {
  10998. StringBuilder sb = new StringBuilder();
  10999. foreach (var item in validatorRes.Errors)
  11000. {
  11001. sb.AppendLine(item.ErrorMessage);
  11002. }
  11003. return Ok(JsonView(false, sb.ToString()));
  11004. }
  11005. return Ok(await _visaCommissionRep.Create(_dto));
  11006. }
  11007. /// <summary>
  11008. /// 签证提成录入
  11009. /// Put(编辑)
  11010. /// </summary>
  11011. /// <param name="id"></param>
  11012. /// <param name="_dto"></param>
  11013. /// <returns></returns>
  11014. [HttpPut]
  11015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11016. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  11017. {
  11018. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  11019. var validator = new VisaCommissionCreateDtoValidator();
  11020. var validatorRes = await validator.ValidateAsync(_dto);
  11021. if (!validatorRes.IsValid)
  11022. {
  11023. StringBuilder sb = new StringBuilder();
  11024. foreach (var item in validatorRes.Errors)
  11025. {
  11026. sb.AppendLine(item.ErrorMessage);
  11027. }
  11028. return Ok(JsonView(false, sb.ToString()));
  11029. }
  11030. return Ok(await _visaCommissionRep.Edit(id, _dto));
  11031. }
  11032. /// <summary>
  11033. /// 签证提成录入
  11034. /// Del
  11035. /// </summary>
  11036. /// <param name="id"></param>
  11037. /// <param name="currUserId"></param>
  11038. /// <returns></returns>
  11039. [HttpPost]
  11040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11041. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  11042. {
  11043. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  11044. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  11045. return Ok(await _visaCommissionRep.Del(id, currUserId));
  11046. }
  11047. #endregion
  11048. #region op费用录入
  11049. /// <summary>
  11050. /// 根据diid查询op费用列表
  11051. /// </summary>
  11052. /// <param name="dto"></param>
  11053. /// <returns></returns>
  11054. [HttpPost]
  11055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11056. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  11057. {
  11058. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  11059. if (groupData.Code != 0)
  11060. {
  11061. return Ok(JsonView(false, groupData.Msg));
  11062. }
  11063. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11064. }
  11065. /// <summary>
  11066. /// 根据op费用Id查询单条数据及c表数据
  11067. /// </summary>
  11068. /// <param name="dto"></param>
  11069. /// <returns></returns>
  11070. [HttpPost]
  11071. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11072. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  11073. {
  11074. try
  11075. {
  11076. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  11077. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  11078. var data = new
  11079. {
  11080. CarTouristGuideGround = _groupData,
  11081. CreditCardPayment = _creditCardPayment
  11082. };
  11083. return Ok(JsonView(true, "查询成功!", data));
  11084. }
  11085. catch (Exception ex)
  11086. {
  11087. return Ok(JsonView(false, "程序错误!"));
  11088. }
  11089. }
  11090. /// <summary>
  11091. /// op费用删除
  11092. /// </summary>
  11093. /// <param name="dto"></param>
  11094. /// <returns></returns>
  11095. [HttpPost]
  11096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11097. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  11098. {
  11099. try
  11100. {
  11101. _sqlSugar.BeginTran();
  11102. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  11103. if (!res)
  11104. {
  11105. return Ok(JsonView(false, "删除失败"));
  11106. }
  11107. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  11108. {
  11109. IsDel = 1,
  11110. DeleteUserId = dto.DeleteUserId,
  11111. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11112. }).ExecuteCommandAsync();
  11113. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  11114. {
  11115. IsDel = 1,
  11116. DeleteUserId = dto.DeleteUserId,
  11117. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11118. }).ExecuteCommandAsync();
  11119. #region 删除超支相关数据
  11120. //删除导入的超支数据
  11121. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  11122. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  11123. {
  11124. IsDel = 1,
  11125. DeleteUserId = dto.DeleteUserId,
  11126. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11127. }).ExecuteCommand();
  11128. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  11129. {
  11130. IsDel = 1,
  11131. DeleteUserId = dto.DeleteUserId,
  11132. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11133. }).ExecuteCommand();
  11134. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  11135. {
  11136. IsDel = 1,
  11137. DeleteUserId = dto.DeleteUserId,
  11138. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11139. }).ExecuteCommand();
  11140. #endregion
  11141. _sqlSugar.CommitTran();
  11142. return Ok(JsonView(true, "删除成功!"));
  11143. }
  11144. catch (Exception ex)
  11145. {
  11146. _sqlSugar.RollbackTran();
  11147. return Ok(JsonView(false, "程序错误!" + ex.Message));
  11148. }
  11149. }
  11150. /// <summary>
  11151. /// op费用录入操作(Status:1.新增,2.修改)
  11152. /// </summary>
  11153. /// <param name="dto"></param>
  11154. /// <returns></returns>
  11155. [HttpPost]
  11156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11157. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  11158. {
  11159. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  11160. if (groupData.Code != 0)
  11161. {
  11162. return Ok(JsonView(false, groupData.Msg));
  11163. }
  11164. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11165. }
  11166. /// <summary>
  11167. /// 填写费用详细页面初始化绑定
  11168. /// </summary>
  11169. /// <param name="dto"></param>
  11170. /// <returns></returns>
  11171. [HttpPost]
  11172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11173. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  11174. {
  11175. try
  11176. {
  11177. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  11178. if (groupData.Code != 0)
  11179. {
  11180. return Ok(JsonView(false, groupData.Msg));
  11181. }
  11182. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11183. }
  11184. catch (Exception ex)
  11185. {
  11186. return Ok(JsonView(false, ex.Message));
  11187. }
  11188. }
  11189. /// <summary>
  11190. /// 根据op费用Id查询详细数据
  11191. /// </summary>
  11192. /// <param name="dto"></param>
  11193. /// <returns></returns>
  11194. [HttpPost]
  11195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11196. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  11197. {
  11198. try
  11199. {
  11200. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  11201. if (groupData.Code != 0)
  11202. {
  11203. return Ok(JsonView(false, groupData.Msg));
  11204. }
  11205. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11206. }
  11207. catch (Exception ex)
  11208. {
  11209. return Ok(JsonView(false, ex.Message));
  11210. }
  11211. }
  11212. /// <summary>
  11213. /// OP费用录入填写详情
  11214. /// </summary>
  11215. /// <param name="dto"></param>
  11216. /// <returns></returns>
  11217. [HttpPost]
  11218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11219. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  11220. {
  11221. try
  11222. {
  11223. #region 参数校验
  11224. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  11225. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  11226. if (di == null) return Ok(JsonView(false, "团组错误!"));
  11227. #endregion
  11228. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  11229. if (groupData.Code != 0)
  11230. {
  11231. return Ok(JsonView(false, groupData.Msg));
  11232. }
  11233. //自动审核
  11234. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  11235. #region 应用推送
  11236. try
  11237. {
  11238. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  11239. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  11240. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  11241. //2024-10-21 新增LZ UID
  11242. var userIds = new List<int>() { 21 };
  11243. string title = $"系统通知";
  11244. var diId = dto.DiId;
  11245. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  11246. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  11247. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  11248. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  11249. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  11250. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  11251. }
  11252. catch (Exception ex)
  11253. {
  11254. }
  11255. #endregion
  11256. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  11257. }
  11258. catch (Exception ex)
  11259. {
  11260. return Ok(JsonView(false, ex.Message));
  11261. }
  11262. }
  11263. /// <summary>
  11264. /// 获取三公详细所有城市
  11265. /// </summary>
  11266. /// <returns></returns>
  11267. [HttpGet]
  11268. public IActionResult OpCarCityResult()
  11269. {
  11270. var jw = JsonView(false);
  11271. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  11272. {
  11273. x.Id,
  11274. x.Country,
  11275. x.City,
  11276. }).ToList();
  11277. if (data.Count > 0)
  11278. {
  11279. jw = JsonView(true, "获取成功!", data);
  11280. }
  11281. else
  11282. {
  11283. jw.Msg = "城市数据为空!";
  11284. jw.Data = new string[0];
  11285. }
  11286. return Ok(jw);
  11287. }
  11288. /// <summary>
  11289. /// 导出地接费用明细
  11290. /// </summary>
  11291. /// <param name="dto"></param>
  11292. /// <returns></returns>
  11293. [HttpPost]
  11294. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  11295. {
  11296. var jw = JsonView(false);
  11297. if (dto.Diid < 1)
  11298. {
  11299. jw.Msg = "请输入正确的diid!";
  11300. return Ok(jw);
  11301. }
  11302. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11303. if (group == null)
  11304. {
  11305. jw.Msg = "未找到团组信息!";
  11306. return Ok(jw);
  11307. }
  11308. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11309. if (localGuideArr.Count == 0)
  11310. {
  11311. jw.Msg = "该团组暂无地接信息!";
  11312. return Ok(jw);
  11313. }
  11314. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  11315. var overspendSoure = new Dictionary<int, int>
  11316. {
  11317. { 91, 982 }, //车
  11318. { 92 , 1059} ,//导游
  11319. { 994 , 1073}, //翻译
  11320. { 988 , 1074 }, //早餐
  11321. { 93 , 1075 }, //午餐
  11322. { 989 , 1076 }, //晚餐
  11323. };
  11324. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  11325. foreach (var groupArr in localGroup)
  11326. {
  11327. var keyValue = groupArr.Key;
  11328. if (int.TryParse(keyValue, out int cityid))
  11329. {
  11330. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  11331. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  11332. }
  11333. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  11334. foreach (var item in groupArr)
  11335. {
  11336. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  11337. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  11338. new Grp_CarTouristGuideGroundReservationsContentExtend
  11339. {
  11340. Count = a.Count,
  11341. CreateTime = a.CreateTime,
  11342. CreateUserId = a.CreateUserId,
  11343. CTGGRId = a.CTGGRId,
  11344. Currency = a.Currency,
  11345. DatePrice = a.DatePrice,
  11346. DeleteTime = a.DeleteTime,
  11347. DeleteUserId = a.DeleteUserId,
  11348. DiId = a.DiId,
  11349. Id = a.Id,
  11350. IsDel = a.IsDel,
  11351. Price = a.Price,
  11352. PriceContent = a.PriceContent,
  11353. Remark = a.Remark,
  11354. SId = a.SId,
  11355. SidName = b.Name,
  11356. Units = a.Units,
  11357. }
  11358. ).ToList();
  11359. if (content.Count > 0)
  11360. {
  11361. contentArr.Add(content);
  11362. }
  11363. }
  11364. //open excel
  11365. //set excel
  11366. //save excel
  11367. try
  11368. {
  11369. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  11370. IWorkbook workbook;
  11371. if (Path.GetExtension(filePath).ToLower() == ".xls")
  11372. {
  11373. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11374. }
  11375. else
  11376. {
  11377. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  11378. }
  11379. ISheet sheet = workbook.GetSheetAt(0);
  11380. var rowStartIndex = 2;
  11381. var clounmCount = 10;
  11382. var initStyleRow = sheet.GetRow(2);
  11383. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  11384. //var overspendArrDetail =
  11385. var existsId = new List<CarCompare>();
  11386. var lastElem = arr.Last();
  11387. var thisSid = -1;
  11388. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  11389. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  11390. {
  11391. Name = "未知币种!",
  11392. Remark = "未知币种!",
  11393. };
  11394. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  11395. Action cloneRowFn = () =>
  11396. {
  11397. rowStartIndex++;
  11398. var cloneRow = sheet.CreateRow(rowStartIndex);
  11399. // 复制样式
  11400. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  11401. {
  11402. ICell sourceCell = initStyleRow.GetCell(i);
  11403. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  11404. // 确保单元格存在样式
  11405. if (sourceCell.CellStyle != null)
  11406. {
  11407. targetCell.CellStyle = sourceCell.CellStyle;
  11408. }
  11409. }
  11410. };
  11411. var mergeRow = () =>
  11412. {
  11413. for (int i = 2; i < sheet.LastRowNum; i++)
  11414. {
  11415. var row = sheet.GetRow(i);
  11416. var cellFirst = row.GetCell(0);
  11417. var thisIndex = i + 1;
  11418. while (thisIndex < sheet.LastRowNum)
  11419. {
  11420. var nextRow = sheet.GetRow(thisIndex);
  11421. var nextCellFirst = nextRow.GetCell(0);
  11422. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  11423. {
  11424. thisIndex++;
  11425. }
  11426. else
  11427. {
  11428. break;
  11429. }
  11430. }
  11431. thisIndex--;
  11432. if (thisIndex != i)
  11433. {
  11434. //合并row
  11435. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11436. i, // 起始行索引(0-based)
  11437. thisIndex, // 结束行索引(0-based)
  11438. 0, // 起始列索引(0-based)
  11439. 0 // 结束列索引(0-based)
  11440. );
  11441. sheet.AddMergedRegion(cellRangeAddress);
  11442. i = thisIndex;
  11443. }
  11444. }
  11445. };
  11446. var chaoshiNumber = 0;
  11447. var totalNumber = 0.00M;
  11448. string lastStr = "";
  11449. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  11450. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  11451. {
  11452. b.IsAuditGM,
  11453. x.Id,
  11454. x.Area,
  11455. b.PayPercentage,
  11456. b.PayMoney,
  11457. }).ToList();
  11458. string yesPayment = "", noPayment = "";
  11459. foreach (var item in queryCarArrByCityAndDiid)
  11460. {
  11461. if (item.IsAuditGM == 1)
  11462. {
  11463. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11464. }
  11465. else
  11466. {
  11467. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  11468. }
  11469. }
  11470. lastStr = yesPayment + noPayment;
  11471. foreach (var item in arr)
  11472. {
  11473. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  11474. {
  11475. if (thisSid != item.SId)
  11476. {
  11477. if (thisSid == -1)
  11478. {
  11479. thisSid = item.SId;
  11480. }
  11481. else
  11482. {
  11483. //合并小计行
  11484. //创建合并区域的实例
  11485. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11486. rowStartIndex, // 起始行索引(0-based)
  11487. rowStartIndex, // 结束行索引(0-based)
  11488. 0, // 起始列索引(0-based)
  11489. 3 // 结束列索引(0-based)
  11490. );
  11491. sheet.AddMergedRegion(cellRangeAddress);
  11492. var CellStyle = workbook.CreateCellStyle();
  11493. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11494. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11495. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11496. for (int i = 0; i <= clounmCount; i++)
  11497. {
  11498. if (i > 6)
  11499. {
  11500. var CellStyle1 = workbook.CreateCellStyle();
  11501. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11502. IFont Font = workbook.CreateFont(); // 创建字体
  11503. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11504. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11505. CellStyle1.SetFont(Font);
  11506. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11507. }
  11508. else
  11509. {
  11510. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11511. }
  11512. }
  11513. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11514. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11515. //超时合计
  11516. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11517. //超时数
  11518. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11519. //超时合计费用
  11520. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11521. thisSid = item.SId;
  11522. cloneRowFn();
  11523. chaoshiNumber = 0;
  11524. totalNumber = 0;
  11525. }
  11526. }
  11527. IRow row = sheet.GetRow(rowStartIndex);
  11528. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11529. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  11530. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  11531. if (isOpenOverspendSoure)
  11532. {
  11533. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11534. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  11535. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  11536. }
  11537. for (int i = 0; i <= clounmCount; i++)
  11538. {
  11539. var cell = row.GetCell(i);
  11540. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  11541. if (cell == null)
  11542. {
  11543. cell = row.CreateCell(i);
  11544. }
  11545. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  11546. fontRed.CloneStyleFrom(cell.CellStyle);
  11547. IFont Font = workbook.CreateFont(); // 创建字体
  11548. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  11549. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11550. fontRed.SetFont(Font);
  11551. byte[] rgb = new byte[3] { 255, 242, 204 };
  11552. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  11553. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  11554. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  11555. if (workbook is XSSFWorkbook)
  11556. {
  11557. BackgroundColor255_242_204.FillForegroundColor = 0;
  11558. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  11559. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  11560. }
  11561. else
  11562. {
  11563. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  11564. }
  11565. if (i == 1 || i > 6)
  11566. {
  11567. if (i > 6)
  11568. {
  11569. fontRed.FillForegroundColor = 0;
  11570. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  11571. fontRed.FillPattern = FillPattern.SolidForeground;
  11572. }
  11573. cell.CellStyle = fontRed;
  11574. }
  11575. if (i > 2 && i < 7)
  11576. {
  11577. cell.CellStyle = BackgroundColor255_242_204;
  11578. }
  11579. cell.SetCellValue(setCellValue); //写入单元格
  11580. }
  11581. if (overspendSoure.ContainsKey(thisSid))
  11582. {
  11583. var overspendId = overspendSoure[thisSid];
  11584. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  11585. }
  11586. cloneRowFn();
  11587. existsId.Add(new CarCompare
  11588. {
  11589. DataPrice = item.DatePrice.ObjToDate(),
  11590. Sid = item.SId
  11591. });
  11592. }
  11593. if (item.Equals(lastElem))
  11594. {
  11595. //合并小计行
  11596. //创建合并区域的实例
  11597. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  11598. rowStartIndex, // 起始行索引(0-based)
  11599. rowStartIndex, // 结束行索引(0-based)
  11600. 0, // 起始列索引(0-based)
  11601. 3 // 结束列索引(0-based)
  11602. );
  11603. sheet.AddMergedRegion(cellRangeAddress);
  11604. var CellStyle = workbook.CreateCellStyle();
  11605. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11606. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  11607. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  11608. for (int i = 0; i <= clounmCount; i++)
  11609. {
  11610. if (i > 6)
  11611. {
  11612. var CellStyle1 = workbook.CreateCellStyle();
  11613. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  11614. IFont Font = workbook.CreateFont(); // 创建字体
  11615. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  11616. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  11617. CellStyle1.SetFont(Font);
  11618. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  11619. }
  11620. else
  11621. {
  11622. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  11623. }
  11624. }
  11625. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  11626. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  11627. //超时合计
  11628. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  11629. //超时数
  11630. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  11631. //超时合计费用
  11632. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  11633. cloneRowFn();
  11634. // 创建合并区域的实例
  11635. cellRangeAddress = new CellRangeAddress(
  11636. rowStartIndex, // 起始行索引(0-based)
  11637. rowStartIndex, // 结束行索引(0-based)
  11638. 0, // 起始列索引(0-based)
  11639. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  11640. );
  11641. // 添加合并区域
  11642. sheet.AddMergedRegion(cellRangeAddress);
  11643. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  11644. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  11645. }
  11646. }
  11647. mergeRow();
  11648. // 保存修改后的Excel文件到新文件
  11649. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  11650. // new FileStream(newFilePath, FileMode.CreateNew)
  11651. using (var stream = new MemoryStream())
  11652. {
  11653. workbook.Write(stream, true);
  11654. stream.Flush();
  11655. stream.Seek(0, SeekOrigin.Begin);
  11656. MemoryStream memoryStream = new MemoryStream();
  11657. stream.CopyTo(memoryStream);
  11658. memoryStream.Seek(0, SeekOrigin.Begin);
  11659. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  11660. }
  11661. workbook.Close();
  11662. workbook.Dispose();
  11663. }
  11664. catch (Exception ex)
  11665. {
  11666. jw.Msg = "出现异常!" + ex.Message;
  11667. return Ok(jw);
  11668. }
  11669. }
  11670. if (Zips.Count > 0)
  11671. {
  11672. IOOperatorHelper io = new IOOperatorHelper();
  11673. var byts = io.ConvertZipStream(Zips);
  11674. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  11675. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  11676. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  11677. }
  11678. else
  11679. {
  11680. jw.Msg = "暂无生成文件!";
  11681. }
  11682. return Ok(jw);
  11683. }
  11684. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  11685. {
  11686. string outStr = string.Empty;
  11687. switch (i)
  11688. {
  11689. case 0:
  11690. outStr = arr[0].SidName;
  11691. break;
  11692. case 1:
  11693. outStr = arr[0].DataPriceStr;
  11694. break;
  11695. case 2:
  11696. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  11697. break;
  11698. case 4:
  11699. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  11700. break;
  11701. case 7:
  11702. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11703. {
  11704. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  11705. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  11706. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  11707. }
  11708. break;
  11709. case 8:
  11710. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11711. {
  11712. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  11713. }
  11714. break;
  11715. case 9:
  11716. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11717. {
  11718. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  11719. }
  11720. break;
  11721. case 10:
  11722. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11723. {
  11724. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  11725. }
  11726. break;
  11727. }
  11728. return outStr;
  11729. }
  11730. #region OP行程单
  11731. /// <summary>
  11732. /// OP行程单初始化
  11733. /// </summary>
  11734. /// <param name="dto"></param>
  11735. /// <returns></returns>
  11736. [HttpPost]
  11737. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11738. {
  11739. var jw = JsonView(false);
  11740. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  11741. var group = groupList.First();
  11742. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11743. if (group == null)
  11744. {
  11745. jw.Msg = "暂无团组!";
  11746. return Ok(jw);
  11747. }
  11748. group = groupList.Find(x => x.Id == diid);
  11749. if (group == null)
  11750. {
  11751. jw.Msg = "请输入正确的团组ID!";
  11752. return Ok(jw);
  11753. }
  11754. string city = string.Empty;
  11755. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11756. if (blackCode.Count > 0)
  11757. {
  11758. var black = blackCode.First();
  11759. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11760. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11761. if (blackSp.Length > 0)
  11762. {
  11763. try
  11764. {
  11765. var cityArrCode = new List<string>(20);
  11766. foreach (var item in blackSp)
  11767. {
  11768. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11769. var IndexSelect = itemSp[2];
  11770. var cityArrCodeLength = cityArrCode.Count - 1;
  11771. var startCity = IndexSelect.Substring(0, 3);
  11772. if (cityArrCodeLength > 0)
  11773. {
  11774. var arrEndCity = cityArrCode[cityArrCodeLength];
  11775. if (arrEndCity != startCity)
  11776. {
  11777. cityArrCode.Add(startCity.ToUpper());
  11778. }
  11779. }
  11780. else
  11781. {
  11782. cityArrCode.Add(startCity.ToUpper());
  11783. }
  11784. var endCity = IndexSelect.Substring(3, 3);
  11785. cityArrCode.Add(endCity.ToUpper());
  11786. }
  11787. var cityThree = string.Empty;
  11788. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11789. cityThree = cityThree.TrimEnd(',');
  11790. if (string.IsNullOrWhiteSpace(cityThree))
  11791. {
  11792. throw new
  11793. Exception("error");
  11794. }
  11795. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11796. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11797. foreach (var item in cityArrCode)
  11798. {
  11799. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11800. if (find != null)
  11801. {
  11802. city += find.City + "/";
  11803. }
  11804. else
  11805. {
  11806. city += item + "三字码未收入/";
  11807. }
  11808. }
  11809. city = city.TrimEnd('/');
  11810. }
  11811. catch (Exception e)
  11812. {
  11813. city = "黑屏代码格式不正确!";
  11814. }
  11815. }
  11816. }
  11817. else
  11818. {
  11819. city = "未录入黑屏代码";
  11820. }
  11821. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11822. {
  11823. Date = x.Date,
  11824. Days = x.Days,
  11825. Diffgroup = x.Diffgroup,
  11826. Diid = x.Diid,
  11827. Traffic_First = x.Traffic_First,
  11828. Traffic_Second = x.Traffic_Second,
  11829. Trip = x.Trip,
  11830. WeekDay = x.WeekDay,
  11831. Id = x.Id
  11832. }).ToList();
  11833. jw.Data = new
  11834. {
  11835. groupList = groupList.Select(x => new
  11836. {
  11837. x.Id,
  11838. x.TeamName,
  11839. x.TourCode
  11840. }).ToList(),
  11841. groupInfo = new
  11842. {
  11843. group.VisitDays,
  11844. group.TourCode,
  11845. group.VisitPNumber,
  11846. group.TeamName,
  11847. city
  11848. },
  11849. OpTravelList
  11850. };
  11851. jw.Code = 200;
  11852. jw.Msg = "操作成功!";
  11853. return Ok(jw);
  11854. }
  11855. /// <summary>
  11856. /// 删除团组行程单
  11857. /// </summary>
  11858. /// <returns></returns>
  11859. [HttpPost]
  11860. public IActionResult DelTravel(DelOpTravelDto dto)
  11861. {
  11862. var jw = JsonView(false);
  11863. if (dto.UserId <= 0 || dto.Diid <= 0)
  11864. {
  11865. jw.Msg = "请输入正确的参数!";
  11866. return Ok(jw);
  11867. }
  11868. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11869. .SetColumns(x => new Grp_TravelList
  11870. {
  11871. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11872. DeleteUserId = dto.UserId,
  11873. IsDel = 1,
  11874. }).ExecuteCommand();
  11875. jw = JsonView(true);
  11876. return Ok(jw);
  11877. }
  11878. /// <summary>
  11879. /// 行程单保存
  11880. /// </summary>
  11881. /// <returns></returns>
  11882. [HttpPost]
  11883. public IActionResult TravelSave(TravelSaveDto dto)
  11884. {
  11885. var jw = JsonView(false);
  11886. if (dto.Arr.Count > 0)
  11887. {
  11888. try
  11889. {
  11890. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11891. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  11892. .ToList();
  11893. _sqlSugar.BeginTran();
  11894. foreach (var item in dto.Arr)
  11895. {
  11896. if (item.Id == 0)
  11897. {
  11898. throw new Exception("请传入正确的Id");
  11899. }
  11900. //比较上一次的差异
  11901. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11902. if (findTravel != null)
  11903. {
  11904. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11905. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11906. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  11907. }
  11908. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11909. .SetColumns(x => new Grp_TravelList
  11910. {
  11911. Trip = item.Trip
  11912. }).ExecuteCommand();
  11913. }
  11914. _sqlSugar.CommitTran();
  11915. jw = JsonView(true);
  11916. }
  11917. catch (Exception ex)
  11918. {
  11919. _sqlSugar.RollbackTran();
  11920. jw.Msg = "程序异常!" + ex.Message;
  11921. }
  11922. }
  11923. else
  11924. {
  11925. jw.Msg = "请传入正确的参数!";
  11926. }
  11927. return Ok(jw);
  11928. }
  11929. private string CheckStr(string original, string changed)
  11930. {
  11931. // 创建diff_match_patch对象
  11932. var dmp = new diff_match_patch();
  11933. // 计算差异
  11934. List<Diff> diffs = dmp.diff_main(original, changed);
  11935. // 清理和合并差异
  11936. dmp.diff_cleanupSemantic(diffs);
  11937. // 使用StringBuilder构建最终的字符串
  11938. StringBuilder finalString = new StringBuilder();
  11939. // 输出差异结果,并构建变动后的字符串
  11940. foreach (Diff diff in diffs)
  11941. {
  11942. switch (diff.operation)
  11943. {
  11944. case Operation.EQUAL:
  11945. // 相等的部分,直接添加到最终字符串
  11946. finalString.Append(diff.text);
  11947. break;
  11948. case Operation.INSERT:
  11949. // 插入的部分,添加标记并添加到最终字符串
  11950. finalString.Append("[++]" + diff.text + "[++]");
  11951. break;
  11952. case Operation.DELETE:
  11953. // 删除的部分,不添加到最终字符串
  11954. //finalString.Append("[++]" + diff.text + "[++]");
  11955. break;
  11956. }
  11957. }
  11958. // 输出变动后的字符串
  11959. return finalString.ToString();
  11960. }
  11961. private class tagContent
  11962. {
  11963. public DateTime Date { get; set; }
  11964. public string StartTag { get; set; }
  11965. public string EndTag { get; set; }
  11966. public string Content { get; set; }
  11967. public static int tagLength { get { return 3; } }
  11968. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11969. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11970. public bool IsFinally { get; set; }
  11971. }
  11972. private List<string> ExtractContentBetweenTags(string input, string tag)
  11973. {
  11974. List<string> results = new List<string>();
  11975. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11976. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11977. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11978. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11979. string[] strValueArr = new string[1];
  11980. foreach (System.Text.RegularExpressions.Match match in matches)
  11981. {
  11982. var strValue = match.Groups[1].Value;
  11983. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11984. }
  11985. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11986. return results;
  11987. }
  11988. /// <summary>
  11989. /// 导出行程单
  11990. /// </summary>
  11991. /// <param name="dto"></param>
  11992. /// <returns></returns>
  11993. [HttpPost]
  11994. public IActionResult ExportTravel(ExportTravelDto dto)
  11995. {
  11996. var jw = JsonView(false);
  11997. jw.Data = "";
  11998. int diid = 0;
  11999. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  12000. if (Find == null)
  12001. {
  12002. jw.Msg = "请选择正确的团组!";
  12003. return Ok(jw);
  12004. }
  12005. else
  12006. {
  12007. diid = Find.Id;
  12008. }
  12009. //数据源
  12010. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  12011. DataTable dtBlack = null;
  12012. try
  12013. {
  12014. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  12015. }
  12016. catch (Exception)
  12017. {
  12018. jw.Msg = "机票黑屏代码有误!";
  12019. return Ok(jw);
  12020. }
  12021. string CityStr = string.Empty;
  12022. if (dtBlack.Rows.Count == 0)
  12023. {
  12024. jw.Msg = "机票黑屏代码有误!";
  12025. return Ok(jw);
  12026. }
  12027. else
  12028. {
  12029. foreach (DataRow row in dtBlack.Rows)
  12030. {
  12031. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12032. {
  12033. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  12034. return Ok(jw);
  12035. }
  12036. }
  12037. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  12038. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  12039. }
  12040. // 指定的文字
  12041. var targetTextDic = new Dictionary<string, List<string>>();
  12042. //创建数据源Table
  12043. DataTable dtSource = new DataTable();
  12044. dtSource.Columns.Add("Days", typeof(string));
  12045. dtSource.Columns.Add("Date", typeof(string));
  12046. dtSource.Columns.Add("Week", typeof(string));
  12047. dtSource.Columns.Add("Traffic", typeof(string));
  12048. dtSource.Columns.Add("Trip", typeof(string));
  12049. //获取数据,放到datatable
  12050. foreach (var item in _travelList)
  12051. {
  12052. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  12053. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  12054. .Replace(tagContent.TagFormat.Item2, string.Empty)
  12055. .Replace("[++]", string.Empty);
  12056. DataRow dr = dtSource.NewRow();
  12057. dr["Days"] = item.Days;
  12058. dr["Date"] = item.Date;
  12059. dr["Week"] = item.WeekDay;
  12060. dr["Traffic"] = item.Traffic_First
  12061. + "\r\n"
  12062. + item.Traffic_Second;
  12063. dr["Trip"] = item.Trip;
  12064. dtSource.Rows.Add(dr);
  12065. }
  12066. Dictionary<string, string> dic = new Dictionary<string, string>();
  12067. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  12068. dic.Add("City", CityStr);
  12069. dic.Add("Days", Find.VisitDays.ToString());
  12070. dic.Add("DeleCode", Find.TourCode);
  12071. dic.Add("Pnum", Find.VisitPNumber.ToString());
  12072. //模板路径
  12073. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  12074. //载入模板
  12075. Document doc = null;
  12076. DocumentBuilder builder = null;
  12077. try
  12078. {
  12079. //载入模板
  12080. doc = new Document(tempPath);
  12081. builder = new DocumentBuilder(doc);
  12082. }
  12083. catch (Exception)
  12084. {
  12085. jw.Msg = "模板位置不存在!";
  12086. return Ok(jw);
  12087. }
  12088. foreach (var key in dic.Keys)
  12089. {
  12090. Bookmark bookmark = doc.Range.Bookmarks[key];
  12091. if (bookmark != null)
  12092. {
  12093. builder.MoveToBookmark(key);
  12094. builder.Write(dic[key]);
  12095. }
  12096. }
  12097. //获取word里所有表格
  12098. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12099. //获取所填表格的序数
  12100. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12101. try
  12102. {
  12103. //循环赋值
  12104. for (int i = 0; i < dtSource.Rows.Count; i++)
  12105. {
  12106. builder.MoveToCell(0, i + 1, 0, 0);
  12107. builder.Write(dtSource.Rows[i]["Days"].ToString());
  12108. builder.MoveToCell(0, i + 1, 1, 0);
  12109. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  12110. builder.MoveToCell(0, i + 1, 2, 0);
  12111. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  12112. var trip = dtSource.Rows[i]["Trip"].ToString();
  12113. builder.MoveToCell(0, i + 1, 3, 0);
  12114. builder.Write(trip);
  12115. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  12116. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12117. // 获取特定索引的段落
  12118. Paragraph paragraph = (Paragraph)paragraphs[0];
  12119. Run run = paragraph.Runs[0];
  12120. Aspose.Words.Font font = run.Font;
  12121. font.Name = "黑体";
  12122. //设置双休红色
  12123. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  12124. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  12125. paragraph = (Paragraph)paragraphs[1];
  12126. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  12127. {
  12128. run = paragraph.Runs[0];
  12129. font = run.Font;
  12130. font.Color = Color.Red;
  12131. }
  12132. }
  12133. }
  12134. catch (Exception ex)
  12135. {
  12136. }
  12137. //删除多余行
  12138. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  12139. {
  12140. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  12141. }
  12142. var targetTextList = new List<string>();
  12143. // 遍历文档中的表格
  12144. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  12145. {
  12146. foreach (Aspose.Words.Tables.Row row in table.Rows)
  12147. {
  12148. var cellIndex = 0;
  12149. foreach (Cell cell in row.Cells)
  12150. {
  12151. if (cellIndex == 1 && row.Cells.Count == 4)
  12152. {
  12153. foreach (var target in targetTextDic.Keys)
  12154. {
  12155. if (cell.GetText().Contains(target))
  12156. {
  12157. targetTextList = targetTextDic[target];
  12158. break;
  12159. }
  12160. }
  12161. }
  12162. // 遍历单元格中的所有段落
  12163. foreach (Paragraph paragraph in cell.Paragraphs)
  12164. {
  12165. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  12166. List<Run> runs = new List<Run>();
  12167. foreach (Run run in paragraph.Runs)
  12168. {
  12169. runs.Add(run);
  12170. }
  12171. foreach (Run run in runs)
  12172. {
  12173. foreach (var targetText in targetTextList)
  12174. {
  12175. // 检查文字是否包含指定文字
  12176. if (run.Text.Contains(targetText))
  12177. {
  12178. // 将包含的部分设置为红色
  12179. HighlightText(run, targetText, Color.Red);
  12180. }
  12181. }
  12182. }
  12183. }
  12184. cellIndex++;
  12185. }
  12186. }
  12187. }
  12188. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  12189. if (!Directory.Exists(savePath))
  12190. {
  12191. try
  12192. {
  12193. Directory.CreateDirectory(savePath);
  12194. }
  12195. catch
  12196. {
  12197. }
  12198. }
  12199. string path = savePath + Find.TeamName + "出访日程";
  12200. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  12201. try
  12202. {
  12203. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  12204. string postfix = ".docx";
  12205. if (dto.IsPDF == 1)
  12206. {
  12207. saveFormat = Aspose.Words.SaveFormat.Pdf;
  12208. postfix = ".pdf";
  12209. }
  12210. doc.Save(path + postfix, saveFormat);
  12211. jw = JsonView(true, "导出成功", ftpPath + postfix);
  12212. }
  12213. catch (Exception)
  12214. {
  12215. jw = JsonView(false);
  12216. }
  12217. return Ok(jw);
  12218. }
  12219. /// <summary>
  12220. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  12221. /// </summary>
  12222. /// <param name="num"></param>
  12223. /// <returns></returns>
  12224. string GetNum(string num)
  12225. {
  12226. string str = "";
  12227. switch (num)
  12228. {
  12229. case "1":
  12230. str = "一";
  12231. break;
  12232. case "2":
  12233. str = "二";
  12234. break;
  12235. case "3":
  12236. str = "三";
  12237. break;
  12238. case "4":
  12239. str = "四";
  12240. break;
  12241. case "5":
  12242. str = "五";
  12243. break;
  12244. case "6":
  12245. str = "六";
  12246. break;
  12247. case "7":
  12248. str = "七";
  12249. break;
  12250. case "8":
  12251. str = "八";
  12252. break;
  12253. case "9":
  12254. str = "九";
  12255. break;
  12256. case "10":
  12257. str = "十";
  12258. break;
  12259. case "11":
  12260. str = "十一";
  12261. break;
  12262. case "12":
  12263. str = "十二";
  12264. break;
  12265. case "一":
  12266. str = "1";
  12267. break;
  12268. case "二":
  12269. str = "2";
  12270. break;
  12271. case "三":
  12272. str = "3";
  12273. break;
  12274. case "四":
  12275. str = "4";
  12276. break;
  12277. case "五":
  12278. str = "5";
  12279. break;
  12280. case "六":
  12281. str = "6";
  12282. break;
  12283. case "七":
  12284. str = "7";
  12285. break;
  12286. case "八":
  12287. str = "8";
  12288. break;
  12289. case "九":
  12290. str = "9";
  12291. break;
  12292. case "十":
  12293. str = "10";
  12294. break;
  12295. case "十一":
  12296. str = "11";
  12297. break;
  12298. case "十二":
  12299. str = "12";
  12300. break;
  12301. }
  12302. return str;
  12303. }
  12304. // 高亮包含指定文字的部分
  12305. void HighlightText(Run run, string targetText, Color color)
  12306. {
  12307. string text = run.Text;
  12308. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  12309. if (startIndex >= 0)
  12310. {
  12311. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  12312. // 前部分
  12313. if (startIndex > 0)
  12314. {
  12315. Run beforeRun = (Run)run.Clone(true);
  12316. beforeRun.Text = text.Substring(0, startIndex);
  12317. parentParagraph.InsertBefore(beforeRun, run);
  12318. }
  12319. // 匹配部分
  12320. Run matchRun = (Run)run.Clone(true);
  12321. matchRun.Text = text.Substring(startIndex, targetText.Length);
  12322. matchRun.Font.Color = color;
  12323. parentParagraph.InsertBefore(matchRun, run);
  12324. // 后部分
  12325. if (startIndex + targetText.Length < text.Length)
  12326. {
  12327. Run afterRun = (Run)run.Clone(true);
  12328. afterRun.Text = text.Substring(startIndex + targetText.Length);
  12329. parentParagraph.InsertBefore(afterRun, run);
  12330. }
  12331. // 删除原始Run
  12332. run.Remove();
  12333. }
  12334. }
  12335. #endregion
  12336. #endregion
  12337. #region 团组成本
  12338. /// <summary>
  12339. /// 团组成本数据初始化
  12340. /// </summary>
  12341. /// <param name="dto"></param>
  12342. /// <returns></returns>
  12343. [HttpPost]
  12344. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  12345. {
  12346. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  12347. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  12348. WHEN COUNT(*) >= 0 THEN 'True'
  12349. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  12350. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  12351. ").ToList(); //团组列表
  12352. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  12353. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  12354. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  12355. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  12356. if (groupinfoValue != null)
  12357. {
  12358. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  12359. var spArr = new string[1] { countryArr };
  12360. if (countryArr.Contains("|"))
  12361. {
  12362. spArr = countryArr.Split("|");
  12363. }
  12364. else if (countryArr.Contains("、"))
  12365. {
  12366. spArr = countryArr.Split("、");
  12367. }
  12368. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  12369. {
  12370. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  12371. if (dbQueryCountry != null)
  12372. {
  12373. visaCountryInfoArr.Add(dbQueryCountry);
  12374. }
  12375. }
  12376. }
  12377. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  12378. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  12379. var create = _GroupCostRepository.
  12380. CreateGroupCostByBlackCode(dto.Diid);
  12381. if (groupCost.Count == 0 && create.Code == 0)
  12382. {
  12383. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  12384. }
  12385. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  12386. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  12387. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  12388. groupCostMap = groupCostMap.Select(x =>
  12389. {
  12390. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  12391. {
  12392. x.Date = dataForamt.ToString("yyyy-MM-dd");
  12393. }
  12394. return x;
  12395. }).ToList();
  12396. //GroupCostParameter.Add(new
  12397. // Grp_GroupCostParameter());
  12398. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  12399. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  12400. return Ok(JsonView(new
  12401. {
  12402. groupList,
  12403. groupInfo,
  12404. groupChecks,
  12405. groupCost = groupCostMap,
  12406. hotelNumber,
  12407. GroupCostParameter = GroupCostParameterMap,
  12408. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  12409. {
  12410. x.VisaCountry,
  12411. x.VisaPrice,
  12412. x.Id,
  12413. }).ToList(),
  12414. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  12415. blackCodeIsTrue = create.Code == 0 ? true : false,
  12416. hotelIsTrue = hotelIsTrue,
  12417. }));
  12418. }
  12419. /// <summary>
  12420. /// 团组成本信息保存
  12421. /// </summary>
  12422. /// <param name="dto"></param>
  12423. /// <returns></returns>
  12424. [HttpPost]
  12425. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  12426. {
  12427. if (dto.Diid <= 0 || dto.Userid <= 0)
  12428. {
  12429. return Ok(JsonView(false));
  12430. }
  12431. JsonView jw = null;
  12432. bool isTrue = false;
  12433. #region 复制团组成本
  12434. //if (dto.Diid == 2581)
  12435. //{
  12436. // dto.Diid = 2599;
  12437. // dto.CheckBoxs.ForEach(x =>
  12438. // {
  12439. // x.Diid = 2599;
  12440. // });
  12441. // dto.GroupCosts.ForEach(x =>
  12442. // {
  12443. // x.Diid = 2599;
  12444. // });
  12445. // dto.CostTypeHotelNumbers.ForEach(x =>
  12446. // {
  12447. // x.Diid = 2599;
  12448. // });
  12449. // dto.GroupCostParameters.ForEach(x =>
  12450. // {
  12451. // x.DiId = 2599;
  12452. // });
  12453. //}
  12454. #endregion
  12455. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  12456. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  12457. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  12458. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  12459. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  12460. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  12461. try
  12462. {
  12463. _sqlSugar.BeginTran();
  12464. isTrue = await _GroupCostRepository.
  12465. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  12466. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  12467. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  12468. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  12469. _sqlSugar.CommitTran();
  12470. jw = JsonView(true, "保存成功!", isTrue);
  12471. }
  12472. catch (Exception)
  12473. {
  12474. _sqlSugar.RollbackTran();
  12475. jw = JsonView(false);
  12476. }
  12477. return Ok(jw);
  12478. }
  12479. /// <summary>
  12480. /// 司兼导数据
  12481. /// </summary>
  12482. /// <param name="dto"></param>
  12483. /// <returns></returns>
  12484. [HttpPost]
  12485. public IActionResult GetCarGuides(CarGuidesDto dto)
  12486. {
  12487. JsonView jw = null;
  12488. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  12489. jw = JsonView(true, "获取成功!", Data);
  12490. return Ok(jw);
  12491. }
  12492. /// <summary>
  12493. /// 导游数据
  12494. /// </summary>
  12495. /// <param name="dto"></param>
  12496. /// <returns></returns>
  12497. [HttpPost]
  12498. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  12499. {
  12500. JsonView jw = null;
  12501. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  12502. // 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
  12503. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  12504. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  12505. jw = JsonView(true, "获取成功!", Data);
  12506. return Ok(jw);
  12507. }
  12508. /// <summary>
  12509. /// 成本车数据
  12510. /// </summary>
  12511. /// <param name="dto"></param>
  12512. /// <returns></returns>
  12513. [HttpPost]
  12514. public IActionResult GetCarInfo(CarGuidesDto dto)
  12515. {
  12516. JsonView jw = null;
  12517. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  12518. jw = JsonView(true, "获取成功!", Data);
  12519. return Ok(jw);
  12520. }
  12521. /// <summary>
  12522. /// 景点数据
  12523. /// </summary>
  12524. /// <param name="dto"></param>
  12525. /// <returns></returns>
  12526. [HttpPost]
  12527. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  12528. {
  12529. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  12530. return Ok(JsonView(true, "获取成功!", Data));
  12531. }
  12532. /// <summary>
  12533. /// 成本通知
  12534. /// </summary>
  12535. /// <param name="dto"></param>
  12536. /// <returns></returns>
  12537. [HttpPost]
  12538. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  12539. {
  12540. if (dto.Diid < 0)
  12541. {
  12542. return Ok(JsonView(false));
  12543. }
  12544. JsonView jw = null;
  12545. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  12546. if (GroupCostParameter != null)
  12547. {
  12548. int IsShare = 0;
  12549. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  12550. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  12551. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  12552. string msg = string.Empty;
  12553. if (isTrue)
  12554. {
  12555. if (IsShare == 0)
  12556. {
  12557. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  12558. }
  12559. else
  12560. {
  12561. #region 企微通知对应岗位用户
  12562. try
  12563. {
  12564. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  12565. }
  12566. catch (Exception ex)
  12567. {
  12568. }
  12569. #endregion
  12570. msg = "通知成功,其他模块操作人员可见此成本信息!";
  12571. }
  12572. jw = JsonView(isTrue, msg, new { IsShare });
  12573. }
  12574. else
  12575. {
  12576. msg = "修改失败!";
  12577. jw = JsonView(isTrue, msg);
  12578. }
  12579. }
  12580. else
  12581. {
  12582. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  12583. }
  12584. return Ok(jw);
  12585. }
  12586. /// <summary>
  12587. /// 导出报价单
  12588. /// </summary>
  12589. /// <param name="dto"></param>
  12590. /// <returns></returns>
  12591. [HttpPost]
  12592. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  12593. {
  12594. if (dto.Diid == 0)
  12595. {
  12596. return Ok(JsonView(false, "请传递团组id"));
  12597. }
  12598. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12599. if (deleInfo.Code != 0)
  12600. {
  12601. return Ok(JsonView(false, "团组信息查询失败!"));
  12602. }
  12603. var di = deleInfo.Data as DelegationInfoWebView;
  12604. if (di != null)
  12605. {
  12606. di.TeamName = di.TeamName.Replace("|", "、");
  12607. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  12608. //文件名
  12609. string strFileName = di.TeamName + "-收款账单.doc";
  12610. //获取模板
  12611. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  12612. //载入模板
  12613. Document doc = new Document(tmppath);
  12614. decimal TotalPrice = 0.00M;
  12615. string itemStr = string.Empty;
  12616. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  12617. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12618. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  12619. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  12620. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  12621. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  12622. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  12623. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  12624. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  12625. foreach (var cost in groupCostType)
  12626. {
  12627. var List = cost.ToList();
  12628. if (cost.Key == "A")
  12629. {
  12630. foreach (var ListItem in List)
  12631. {
  12632. if (ListItem.number > 0)
  12633. {
  12634. if (ListItem.code.Contains("TBR"))
  12635. {
  12636. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12637. }
  12638. else
  12639. {
  12640. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12641. }
  12642. TotalPrice += (ListItem.number * ListItem.price);
  12643. }
  12644. }
  12645. }
  12646. else
  12647. {
  12648. itemStr = itemStr.Insert(0, "A段\r\n");
  12649. itemStr += "B段\r\n";
  12650. foreach (var ListItem in List)
  12651. {
  12652. if (ListItem.number > 0)
  12653. {
  12654. if (ListItem.code.Contains("TBR"))
  12655. {
  12656. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12657. }
  12658. else
  12659. {
  12660. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  12661. }
  12662. TotalPrice += (ListItem.number * ListItem.price);
  12663. }
  12664. }
  12665. }
  12666. }
  12667. #region 替换Word模板书签内容
  12668. Dictionary<string, string> marks = new Dictionary<string, string>();
  12669. marks.Add("To", di.ClientUnit);//付款方
  12670. marks.Add("ToTel", di.TellPhone);//付款方电话
  12671. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  12672. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  12673. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  12674. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  12675. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  12676. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  12677. marks.Add("PayItemContent", itemStr);//详细信息
  12678. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  12679. #endregion
  12680. ////注
  12681. //if (doc.Range.Bookmarks["Attention"] != null)
  12682. //{
  12683. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  12684. // mark.Text = frList[0].Attention;
  12685. //}
  12686. foreach (var item in marks.Keys)
  12687. {
  12688. if (doc.Range.Bookmarks[item] != null)
  12689. {
  12690. Bookmark mark = doc.Range.Bookmarks[item];
  12691. mark.Text = marks[item];
  12692. }
  12693. }
  12694. byte[] bytes = null;
  12695. using (MemoryStream stream = new MemoryStream())
  12696. {
  12697. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  12698. bytes = stream.ToArray();
  12699. }
  12700. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  12701. return Ok(JsonView(true, "", new
  12702. {
  12703. Data = bytes,
  12704. strFileName,
  12705. }));
  12706. }
  12707. else
  12708. {
  12709. return Ok(JsonView(false, "团组信息不存在!"));
  12710. }
  12711. }
  12712. /// <summary>
  12713. /// 导出团组成本
  12714. /// </summary>
  12715. /// <param name="dto"></param>
  12716. /// <returns></returns>
  12717. [HttpPost]
  12718. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  12719. {
  12720. var jw = JsonView(false);
  12721. if (dto.Diid == 0)
  12722. {
  12723. return Ok(JsonView(false, "请传递团组id"));
  12724. }
  12725. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12726. if (deleInfo.Code != 0)
  12727. {
  12728. return Ok(JsonView(false, "团组信息查询失败!"));
  12729. }
  12730. var di = deleInfo.Data as DelegationInfoWebView;
  12731. if (di == null)
  12732. {
  12733. return Ok(JsonView(false, "团组信息查询失败!"));
  12734. }
  12735. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12736. WorkbookDesigner designer = new WorkbookDesigner();
  12737. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12738. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12739. for (int i = 0; i < List_GC.Count; i++)
  12740. {
  12741. GroupCost_Excel gc = new GroupCost_Excel();
  12742. gc.Id = List_GC[i].Id;
  12743. gc.Diid = List_GC[i].Diid.ToString();
  12744. gc.DAY = List_GC[i].DAY;
  12745. string week = "";
  12746. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12747. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12748. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12749. gc.ITIN = List_GC[i].ITIN;
  12750. gc.CarType = List_GC[i].CarType;
  12751. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12752. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12753. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12754. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12755. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12756. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12757. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12758. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12759. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12760. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12761. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12762. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12763. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12764. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12765. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12766. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12767. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12768. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12769. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12770. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12771. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12772. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12773. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12774. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12775. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12776. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12777. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12778. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12779. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12780. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12781. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12782. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12783. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12784. List_GC1.Add(gc);
  12785. }
  12786. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12787. dt.TableName = "TB";
  12788. //报表标题等不用dt的值
  12789. designer.SetDataSource("TeamName", dto.title.TeamName);
  12790. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12791. designer.SetDataSource("Tax", dto.title.Tax);
  12792. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12793. designer.SetDataSource("Currency", dto.title.Currency);
  12794. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12795. designer.SetDataSource("Rate", dto.title.Rate);
  12796. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12797. var Aparams = hotels.Find(x => x.Type == "Default");
  12798. if (Aparams == null)
  12799. {
  12800. return Ok(jw);
  12801. }
  12802. //酒店数量
  12803. var txtSGRNumber = Aparams.SGR.ToString();
  12804. var txtTBRNumber = Aparams.TBR.ToString();
  12805. var txtJSESNumber = Aparams.JSES.ToString();
  12806. var txtSUITENumbe = Aparams.SUITE.ToString();
  12807. if (dto.costType == "B")
  12808. {
  12809. Aparams = hotels.Find(x => x.Type == "A");
  12810. var Bparams = hotels.Find(x => x.Type == "B");
  12811. if (Aparams == null || Bparams == null)
  12812. {
  12813. return Ok(jw);
  12814. }
  12815. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12816. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12817. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12818. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12819. }
  12820. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12821. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12822. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12823. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12824. var ws = designer.Workbook.Worksheets[0];
  12825. int Row = List_GC.Count;
  12826. int startIndex = 11;
  12827. int HideRows = 0;
  12828. List<int> hideRowsList = new List<int>();
  12829. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12830. #region A段left数据
  12831. var left = dto.leftInfo.Find(x => x.Type == "A");
  12832. if (left == null)
  12833. {
  12834. return Ok(jw);
  12835. }
  12836. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12837. if (leftBindData != null)
  12838. {
  12839. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12840. designer.SetDataSource("VisaRS", leftBindData.rs);
  12841. designer.SetDataSource("VisaXS", leftBindData.xs);
  12842. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12843. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12844. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12845. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12846. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12847. }
  12848. else
  12849. {
  12850. hideRowsList.Add(Row + startIndex + HideRows);
  12851. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12852. }
  12853. HideRows += 2;
  12854. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12855. if (leftBindData != null)
  12856. {
  12857. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12858. designer.SetDataSource("BXRS", leftBindData.rs);
  12859. designer.SetDataSource("BXXS", leftBindData.xs);
  12860. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12861. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12862. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12863. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12864. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12865. }
  12866. else
  12867. {
  12868. hideRowsList.Add(Row + startIndex + HideRows);
  12869. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12870. }
  12871. HideRows += 2;
  12872. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12873. if (leftBindData != null)
  12874. {
  12875. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12876. designer.SetDataSource("HSRS", leftBindData.rs);
  12877. designer.SetDataSource("HSXS", leftBindData.xs);
  12878. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12879. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12880. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12881. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12882. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12883. }
  12884. else
  12885. {
  12886. hideRowsList.Add(Row + startIndex + HideRows);
  12887. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12888. }
  12889. HideRows += 2;
  12890. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12891. if (leftBindData != null)
  12892. {
  12893. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12894. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12895. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12896. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12897. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12898. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12899. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12900. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12901. }
  12902. else
  12903. {
  12904. hideRowsList.Add(Row + startIndex + HideRows);
  12905. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12906. }
  12907. HideRows += 2;
  12908. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12909. if (leftBindData != null)
  12910. {
  12911. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12912. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12913. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12914. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12915. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12916. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12917. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12918. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12919. }
  12920. else
  12921. {
  12922. hideRowsList.Add(Row + startIndex + HideRows);
  12923. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12924. }
  12925. HideRows += 2;
  12926. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12927. if (leftBindData != null)
  12928. {
  12929. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12930. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12931. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12932. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12933. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12934. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12935. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12936. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12937. }
  12938. else
  12939. {
  12940. hideRowsList.Add(Row + startIndex + HideRows);
  12941. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12942. }
  12943. HideRows += 2;
  12944. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12945. if (leftBindData != null)
  12946. {
  12947. ////TBR
  12948. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12949. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12950. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12951. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12952. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12953. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12954. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12955. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12956. }
  12957. else
  12958. {
  12959. hideRowsList.Add(Row + startIndex + HideRows);
  12960. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12961. }
  12962. HideRows += 2;
  12963. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12964. if (leftBindData != null)
  12965. {
  12966. ////SGR
  12967. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12968. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12969. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12970. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12971. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12972. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12973. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12974. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12975. }
  12976. else
  12977. {
  12978. hideRowsList.Add(Row + startIndex + HideRows);
  12979. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12980. }
  12981. HideRows += 2;
  12982. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12983. if (leftBindData != null)
  12984. {
  12985. ////JS/ES
  12986. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12987. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12988. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12989. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12990. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12991. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12992. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12993. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12994. }
  12995. else
  12996. {
  12997. hideRowsList.Add(Row + startIndex + HideRows);
  12998. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12999. }
  13000. HideRows += 2;
  13001. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  13002. if (leftBindData != null)
  13003. {
  13004. ////SUITE
  13005. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  13006. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  13007. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  13008. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13009. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13010. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13011. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13012. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13013. }
  13014. else
  13015. {
  13016. hideRowsList.Add(Row + startIndex + HideRows);
  13017. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13018. }
  13019. HideRows += 2;
  13020. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  13021. if (leftBindData != null)
  13022. {
  13023. designer.SetDataSource("DJDRCB", leftBindData.cb);
  13024. designer.SetDataSource("DJRS", leftBindData.rs);
  13025. designer.SetDataSource("DJXS", leftBindData.xs);
  13026. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13027. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13028. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13029. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13030. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13031. }
  13032. else
  13033. {
  13034. hideRowsList.Add(Row + startIndex + HideRows);
  13035. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13036. }
  13037. HideRows += 2;
  13038. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13039. if (leftBindData != null)
  13040. {
  13041. designer.SetDataSource("HCPCB", leftBindData.cb);
  13042. designer.SetDataSource("HCPRS", leftBindData.rs);
  13043. designer.SetDataSource("HCPXS", leftBindData.xs);
  13044. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13045. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13046. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13047. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13048. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13049. }
  13050. else
  13051. {
  13052. hideRowsList.Add(Row + startIndex + HideRows);
  13053. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13054. }
  13055. HideRows += 2;
  13056. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13057. if (leftBindData != null)
  13058. {
  13059. designer.SetDataSource("CPCB", leftBindData.cb);
  13060. designer.SetDataSource("CPRS", leftBindData.rs);
  13061. designer.SetDataSource("CPXS", leftBindData.xs);
  13062. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13063. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13064. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13065. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13066. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13067. }
  13068. else
  13069. {
  13070. hideRowsList.Add(Row + startIndex + HideRows);
  13071. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13072. }
  13073. HideRows += 2;
  13074. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13075. if (leftBindData != null)
  13076. {
  13077. designer.SetDataSource("GWDRCD", leftBindData.cb);
  13078. designer.SetDataSource("GWRS", leftBindData.rs);
  13079. designer.SetDataSource("GWXS", leftBindData.xs);
  13080. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13081. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13082. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13083. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13084. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13085. }
  13086. else
  13087. {
  13088. hideRowsList.Add(Row + startIndex + HideRows);
  13089. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13090. }
  13091. HideRows += 2;
  13092. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13093. if (leftBindData != null)
  13094. {
  13095. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  13096. designer.SetDataSource("LYJRS", leftBindData.rs);
  13097. designer.SetDataSource("LYJXS", leftBindData.xs);
  13098. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13099. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13100. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13101. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13102. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13103. }
  13104. else
  13105. {
  13106. hideRowsList.Add(Row + startIndex + HideRows);
  13107. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  13108. }
  13109. #endregion
  13110. #region A段Right信息
  13111. var right = dto.rightInfo.Find(x => x.Type == "A");
  13112. if (right == null)
  13113. {
  13114. return Ok(jw);
  13115. }
  13116. HideRows += 4;
  13117. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13118. if (rightBindData != null)
  13119. {
  13120. //经济舱 + 双人间 TBR
  13121. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  13122. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  13123. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13124. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  13125. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13126. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13127. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13128. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13129. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13130. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13131. }
  13132. else
  13133. {
  13134. hideRowsList.Add(Row + startIndex + HideRows);
  13135. }
  13136. HideRows += 2;
  13137. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13138. if (rightBindData != null)
  13139. {
  13140. //经济舱 + 单人间 SGR
  13141. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  13142. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  13143. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13144. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  13145. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13146. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13147. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13148. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13149. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13150. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13151. }
  13152. else
  13153. {
  13154. hideRowsList.Add(Row + startIndex + HideRows);
  13155. }
  13156. HideRows += 2;
  13157. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13158. if (rightBindData != null)
  13159. {
  13160. //公务舱 + 单人间 SGR
  13161. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  13162. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  13163. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13164. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  13165. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13166. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13167. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13168. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13169. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13170. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13171. }
  13172. else
  13173. {
  13174. hideRowsList.Add(Row + startIndex + HideRows);
  13175. }
  13176. HideRows += 2;
  13177. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13178. if (rightBindData != null)
  13179. {
  13180. //公务舱 + 小套房 JSES
  13181. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  13182. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  13183. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13184. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  13185. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13186. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13187. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13188. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13189. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13190. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13191. }
  13192. else
  13193. {
  13194. hideRowsList.Add(Row + startIndex + HideRows);
  13195. }
  13196. HideRows += 2;
  13197. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13198. if (rightBindData != null)
  13199. {
  13200. //公务舱 + 小套房 JSES
  13201. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  13202. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  13203. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13204. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  13205. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13206. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13207. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13208. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13209. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13210. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13211. }
  13212. else
  13213. {
  13214. hideRowsList.Add(Row + startIndex + HideRows);
  13215. }
  13216. HideRows += 2;
  13217. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13218. if (rightBindData != null)
  13219. {
  13220. //经济舱 + 大套房
  13221. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  13222. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  13223. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13224. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  13225. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13226. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13227. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13228. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13229. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13230. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13231. }
  13232. else
  13233. {
  13234. hideRowsList.Add(Row + startIndex + HideRows);
  13235. }
  13236. HideRows += 2;
  13237. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13238. if (rightBindData != null)
  13239. {
  13240. //头等舱 + 小套房 JSES
  13241. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  13242. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  13243. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13244. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  13245. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13246. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13247. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13248. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13249. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13250. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13251. }
  13252. else
  13253. {
  13254. hideRowsList.Add(Row + startIndex + HideRows);
  13255. }
  13256. HideRows += 2;
  13257. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13258. if (rightBindData != null)
  13259. {
  13260. //头等舱 + 大套房
  13261. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  13262. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  13263. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13264. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  13265. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13266. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13267. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13268. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13269. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13270. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13271. }
  13272. else
  13273. {
  13274. hideRowsList.Add(Row + startIndex + HideRows);
  13275. }
  13276. #endregion
  13277. #region B段标题清空
  13278. designer.SetDataSource("CostBDRCB", "");
  13279. designer.SetDataSource("CostBRS", "");
  13280. designer.SetDataSource("CostBXS", "");
  13281. designer.SetDataSource("CostBZCB", "");
  13282. designer.SetDataSource("CostBDRBJ", "");
  13283. designer.SetDataSource("CostBZBJ", "");
  13284. designer.SetDataSource("CostBDRLR", "");
  13285. designer.SetDataSource("CostBZLR", "");
  13286. designer.SetDataSource("CostBDRCBOM", "");
  13287. designer.SetDataSource("CostBRSOM", "");
  13288. designer.SetDataSource("CostBZCBOM", "");
  13289. designer.SetDataSource("CostBDRBJOM", "");
  13290. designer.SetDataSource("CostBZBJOM", "");
  13291. designer.SetDataSource("CostBDRLROM", "");
  13292. designer.SetDataSource("CostBZLROM", "");
  13293. #endregion
  13294. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  13295. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  13296. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  13297. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  13298. designer.SetDataSource("DJName", "地接(CNY)");
  13299. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  13300. designer.SetDataSource("CPName", "地接-船票(CNY)");
  13301. designer.SetDataSource("GWName", "公务(CNY)");
  13302. designer.SetDataSource("YQHName", "邀请函(CNY)");
  13303. designer.SetDataSource("LYJName", "零用金(CNY)");
  13304. designer.SetDataSource("HSName", "核酸检测(CNY)");
  13305. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  13306. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  13307. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  13308. designer.SetDataSource("BXName", "保险(CNY)");
  13309. designer.SetDataSource("VisaName", "签证(CNY)");
  13310. #region B段基本数据
  13311. if (dto.costType == "B")
  13312. {
  13313. left = dto.leftInfo.Find(x => x.Type == "B");
  13314. if (left == null)
  13315. {
  13316. return Ok(jw);
  13317. }
  13318. #region B段left数据
  13319. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  13320. if (leftBindData != null)
  13321. {
  13322. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  13323. designer.SetDataSource("BHSRS", leftBindData.rs);
  13324. designer.SetDataSource("BHSXS", leftBindData.xs);
  13325. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13326. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13327. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13328. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13329. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13330. }
  13331. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  13332. if (leftBindData != null)
  13333. {
  13334. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  13335. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  13336. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  13337. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13338. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13339. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13340. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13341. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13342. }
  13343. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  13344. if (leftBindData != null)
  13345. {
  13346. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  13347. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  13348. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  13349. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13350. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13351. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13352. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13353. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13354. }
  13355. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  13356. if (leftBindData != null)
  13357. {
  13358. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  13359. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  13360. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  13361. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13362. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13363. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13364. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13365. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13366. }
  13367. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  13368. if (leftBindData != null)
  13369. {
  13370. designer.SetDataSource("BHCPCB", leftBindData.cb);
  13371. designer.SetDataSource("BHCPRS", leftBindData.rs);
  13372. designer.SetDataSource("BHCPXS", leftBindData.xs);
  13373. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13374. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13375. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13376. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13377. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13378. }
  13379. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  13380. if (leftBindData != null)
  13381. {
  13382. designer.SetDataSource("BCPCB", leftBindData.cb);
  13383. designer.SetDataSource("BCPRS", leftBindData.rs);
  13384. designer.SetDataSource("BCPXS", leftBindData.xs);
  13385. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13386. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13387. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13388. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13389. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13390. }
  13391. //TBR
  13392. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  13393. if (leftBindData != null)
  13394. {
  13395. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  13396. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  13397. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  13398. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13399. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13400. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13401. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13402. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13403. }
  13404. //SGR
  13405. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  13406. if (leftBindData != null)
  13407. {
  13408. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  13409. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  13410. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  13411. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13412. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13413. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13414. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13415. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13416. }
  13417. //JS/ES
  13418. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  13419. if (leftBindData != null)
  13420. {
  13421. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  13422. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  13423. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  13424. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13425. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13426. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13427. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13428. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13429. }
  13430. //SUITE
  13431. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  13432. if (leftBindData != null)
  13433. {
  13434. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  13435. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  13436. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  13437. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13438. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13439. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13440. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13441. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13442. }
  13443. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  13444. if (leftBindData != null)
  13445. {
  13446. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  13447. designer.SetDataSource("BDJRS", leftBindData.rs);
  13448. designer.SetDataSource("BDJXS", leftBindData.xs);
  13449. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13450. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13451. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13452. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13453. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13454. }
  13455. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  13456. if (leftBindData != null)
  13457. {
  13458. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  13459. designer.SetDataSource("BGWRS", leftBindData.rs);
  13460. designer.SetDataSource("BGWXS", leftBindData.xs);
  13461. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13462. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13463. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13464. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13465. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13466. }
  13467. #region 优化方案
  13468. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  13469. //excelBind.Add("零用金", new {
  13470. //cb="",
  13471. //rs="",
  13472. //xs ="",
  13473. //zcb = "",
  13474. //});
  13475. #endregion
  13476. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  13477. if (leftBindData != null)
  13478. {
  13479. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  13480. designer.SetDataSource("BLYJRS", leftBindData.rs);
  13481. designer.SetDataSource("BLYJXS", leftBindData.xs);
  13482. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  13483. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  13484. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  13485. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  13486. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  13487. }
  13488. #endregion
  13489. #region B段Right信息
  13490. right = dto.rightInfo.Find(x => x.Type == "B");
  13491. if (right == null)
  13492. {
  13493. return Ok(jw);
  13494. }
  13495. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  13496. if (rightBindData != null)
  13497. {
  13498. //经济舱 + 双人间 TBR
  13499. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  13500. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  13501. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13502. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  13503. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13504. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13505. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13506. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13507. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13508. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13509. }
  13510. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  13511. if (rightBindData != null)
  13512. {
  13513. //经济舱 + 单人间 SGR
  13514. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  13515. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  13516. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13517. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  13518. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13519. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13520. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13521. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13522. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13523. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13524. }
  13525. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  13526. if (rightBindData != null)
  13527. {
  13528. //公务舱 + 单人间 SGR
  13529. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  13530. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  13531. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13532. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  13533. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13534. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13535. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13536. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13537. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13538. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13539. }
  13540. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  13541. if (rightBindData != null)
  13542. {
  13543. //公务舱 + 小套房 JSES
  13544. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  13545. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  13546. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13547. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  13548. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13549. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13550. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13551. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13552. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13553. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13554. }
  13555. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  13556. if (rightBindData != null)
  13557. {
  13558. //公务舱 + 小套房 JSES
  13559. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  13560. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  13561. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13562. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  13563. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13564. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13565. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13566. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13567. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13568. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13569. }
  13570. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  13571. if (rightBindData != null)
  13572. {
  13573. //经济舱 + 大套房
  13574. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  13575. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  13576. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13577. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  13578. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13579. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13580. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13581. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13582. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13583. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13584. }
  13585. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  13586. if (rightBindData != null)
  13587. {
  13588. //头等舱 + 小套房 JSES
  13589. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  13590. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  13591. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13592. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  13593. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13594. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13595. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13596. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13597. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13598. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13599. }
  13600. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  13601. if (rightBindData != null)
  13602. {
  13603. //头等舱 + 大套房
  13604. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  13605. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  13606. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  13607. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  13608. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  13609. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  13610. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  13611. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  13612. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  13613. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  13614. }
  13615. #endregion
  13616. #region 标题
  13617. designer.SetDataSource("CostBDRCB", "单人成本");
  13618. designer.SetDataSource("CostBRS", "人数");
  13619. designer.SetDataSource("CostBXS", "系数");
  13620. designer.SetDataSource("CostBZCB", "总成本");
  13621. designer.SetDataSource("CostBDRBJ", "单人报价");
  13622. designer.SetDataSource("CostBZBJ", "总报价");
  13623. designer.SetDataSource("CostBDRLR", "单人利润");
  13624. designer.SetDataSource("CostBZLR", "总利润");
  13625. designer.SetDataSource("CostBDRCBOM", "单人成本");
  13626. designer.SetDataSource("CostBRSOM", "人数");
  13627. designer.SetDataSource("CostBZCBOM", "总成本");
  13628. designer.SetDataSource("CostBDRBJOM", "单人报价");
  13629. designer.SetDataSource("CostBZBJOM", "总报价");
  13630. designer.SetDataSource("CostBDRLROM", "单人利润");
  13631. designer.SetDataSource("CostBZLROM", "总利润");
  13632. #endregion
  13633. }
  13634. #endregion
  13635. designer.SetDataSource("TzZCB2", TzZCB2);
  13636. designer.SetDataSource("TzZBJ2", TzZBJ2);
  13637. designer.SetDataSource("TzZLR2", TzZLR2);
  13638. string[] dataSourceKeys = new string[]
  13639. {
  13640. "VF",
  13641. "TGS",
  13642. "TGOF",
  13643. "TGM",
  13644. "TGA",
  13645. "TGTF",
  13646. "TGEF",
  13647. "CFM",
  13648. "CFOF",
  13649. "B",
  13650. "L",
  13651. "D",
  13652. "TBR",
  13653. "SGR",
  13654. "JSES",
  13655. "Suite",
  13656. "TV",
  13657. "1L",
  13658. "IF",
  13659. "EF",
  13660. "BRF",
  13661. "TE",
  13662. "TGT",
  13663. "DRVT",
  13664. "PC",
  13665. "TLF",
  13666. "ECT"
  13667. };
  13668. foreach (var item in dataSourceKeys)
  13669. {
  13670. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  13671. if (find != null)
  13672. {
  13673. designer.SetDataSource(item, find.text);
  13674. }
  13675. else
  13676. {
  13677. designer.SetDataSource(item, 0);
  13678. }
  13679. }
  13680. designer.SetDataSource(dt);
  13681. //根据数据源处理生成报表内容
  13682. designer.Process();
  13683. designer.Workbook.Worksheets[0].Name = "清单";
  13684. Worksheet sheet = designer.Workbook.Worksheets[0];
  13685. foreach (var Rowindex in hideRowsList)
  13686. {
  13687. ws.Cells.HideRows(Rowindex, 2);
  13688. }
  13689. byte[] bytes = null;
  13690. string strFileName = di.TeamName + "-团组-成本.xls";
  13691. using (MemoryStream stream = new MemoryStream())
  13692. {
  13693. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  13694. bytes = stream.ToArray();
  13695. }
  13696. return Ok(JsonView(true, "", new
  13697. {
  13698. Data = bytes,
  13699. strFileName,
  13700. }));
  13701. }
  13702. /// <summary>
  13703. /// 导出客户报表
  13704. /// </summary>
  13705. /// <returns></returns>
  13706. [HttpPost]
  13707. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  13708. {
  13709. var jw = JsonView(false);
  13710. if (dto.Diid == 0)
  13711. {
  13712. return Ok(JsonView(false, "请传递团组id"));
  13713. }
  13714. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13715. if (deleInfo.Code != 0)
  13716. {
  13717. return Ok(JsonView(false, "团组信息查询失败!"));
  13718. }
  13719. var di = deleInfo.Data as DelegationInfoWebView;
  13720. if (di == null)
  13721. {
  13722. return Ok(JsonView(false, "团组信息查询失败!"));
  13723. }
  13724. //文件名
  13725. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  13726. //获取模板
  13727. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13728. //载入模板
  13729. Document doc = new Document(tmppath);
  13730. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13731. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13732. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13733. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13734. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13735. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13736. if (AParameter == null)
  13737. {
  13738. return Ok(JsonView(false, "系数不存在!"));
  13739. }
  13740. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13741. , TzAirDesc, TzZCost;
  13742. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13743. = TzAirDesc = TzZCost = string.Empty;
  13744. TzNumber = AParameter.CostTypenumber.ToString();
  13745. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13746. CarGuides1 = dto.CarGuides1;
  13747. Meal = dto.Meal;
  13748. SubsidizedMeals = dto.SubsidizedMeals;
  13749. NightRepair = dto.NightRepair;
  13750. AttractionsTickets = dto.AttractionsTickets;
  13751. MiscellaneousFees = dto.MiscellaneousFees;
  13752. ATip = dto.ATip;
  13753. TzHotelDesc = "";
  13754. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13755. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13756. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13757. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13758. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13759. TzAirDesc = "";
  13760. TzZCost = dto.TzZCost;
  13761. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13762. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13763. var index = 1;
  13764. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13765. foreach (var item in TzHotelDescArr)
  13766. {
  13767. if (AinfoArr != null)
  13768. {
  13769. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13770. if (Ainfo != null)
  13771. {
  13772. if (int.Parse(Ainfo.rs) <= 0)
  13773. {
  13774. continue;
  13775. }
  13776. var hotelText = string.Empty;
  13777. switch (item)
  13778. {
  13779. case "SGR":
  13780. hotelText = "单人间";
  13781. break;
  13782. case "JSES":
  13783. hotelText = "小套房";
  13784. break;
  13785. case "SUITE":
  13786. hotelText = "套房";
  13787. break;
  13788. case "TBR":
  13789. hotelText = "双人间";
  13790. break;
  13791. }
  13792. if (item != "TBR")
  13793. {
  13794. 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";
  13795. }
  13796. else
  13797. {
  13798. 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";
  13799. }
  13800. index++;
  13801. }
  13802. }
  13803. }
  13804. index = 1;
  13805. foreach (var item in TzAirDescArr)
  13806. {
  13807. if (AinfoArr != null)
  13808. {
  13809. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13810. if (Ainfo != null)
  13811. {
  13812. if (int.Parse(Ainfo.rs) <= 0)
  13813. {
  13814. continue;
  13815. }
  13816. 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";
  13817. index++;
  13818. }
  13819. }
  13820. }
  13821. if (dto.costType == "B")
  13822. {
  13823. if (BParameter == null)
  13824. {
  13825. return Ok(JsonView(false, "B段系数不存在!"));
  13826. }
  13827. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13828. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13829. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13830. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13831. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13832. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13833. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13834. foreach (var item in TzHotelDescArr)
  13835. {
  13836. if (AinfoArr != null)
  13837. {
  13838. TzHotelDesc += "B段信息 \r\n";
  13839. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13840. if (Ainfo != null)
  13841. {
  13842. if (int.Parse(Ainfo.rs) <= 0)
  13843. {
  13844. continue;
  13845. }
  13846. var hotelText = string.Empty;
  13847. switch (item)
  13848. {
  13849. case "SGR":
  13850. hotelText = "单人间";
  13851. break;
  13852. case "JSES":
  13853. hotelText = "小套房";
  13854. break;
  13855. case "SUITE":
  13856. hotelText = "套房";
  13857. break;
  13858. case "TBR":
  13859. hotelText = "双人间";
  13860. break;
  13861. }
  13862. if (item != "TBR")
  13863. {
  13864. 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";
  13865. }
  13866. else
  13867. {
  13868. 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";
  13869. }
  13870. index++;
  13871. }
  13872. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13873. }
  13874. }
  13875. index = 1;
  13876. foreach (var item in TzAirDescArr)
  13877. {
  13878. if (AinfoArr != null)
  13879. {
  13880. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13881. if (Ainfo != null)
  13882. {
  13883. if (int.Parse(Ainfo.rs) <= 0)
  13884. {
  13885. continue;
  13886. }
  13887. 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";
  13888. index++;
  13889. }
  13890. }
  13891. }
  13892. }
  13893. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13894. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13895. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13896. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13897. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13898. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13899. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13900. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13901. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13902. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13903. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13904. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13905. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13906. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13907. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13908. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13909. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13910. DickeyValue.Add("TzZCost", TzZCost);
  13911. foreach (var key in DickeyValue.Keys)
  13912. {
  13913. if (doc.Range.Bookmarks[key] != null)
  13914. {
  13915. Bookmark mark = doc.Range.Bookmarks[key];
  13916. mark.Text = DickeyValue[key];
  13917. }
  13918. }
  13919. byte[] bytes = null;
  13920. string strFileName = di.TeamName + "-客户报价.doc";
  13921. using (MemoryStream stream = new MemoryStream())
  13922. {
  13923. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13924. bytes = stream.ToArray();
  13925. }
  13926. return Ok(JsonView(true, "", new
  13927. {
  13928. Data = bytes,
  13929. strFileName,
  13930. }));
  13931. }
  13932. /// <summary>
  13933. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13934. /// </summary>
  13935. /// <param name="dto"></param>
  13936. /// <returns></returns>
  13937. [HttpPost]
  13938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13939. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13940. {
  13941. try
  13942. {
  13943. #region 参数验证
  13944. if (dto.DiId < 0)
  13945. {
  13946. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13947. }
  13948. List<int> cTableIds = new List<int>() {
  13949. 76 ,//酒店预订
  13950. 77 ,//行程
  13951. 79 ,//车/导游地接
  13952. 80 ,//签证
  13953. 81 ,//邀请/公务活
  13954. 82 ,//团组客户保险
  13955. 85 ,//机票预订
  13956. 98 ,//其他款项
  13957. 285 ,//收款退还
  13958. 751 ,//酒店早餐
  13959. 1015 // 超支费用
  13960. };
  13961. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13962. {
  13963. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13964. }
  13965. #endregion
  13966. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13967. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13968. if (_GroupCostParameters.Count <= 0)
  13969. {
  13970. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13971. }
  13972. if (_GroupCostParameters[0].IsShare == 0)
  13973. {
  13974. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13975. }
  13976. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13977. //处理date为空问题
  13978. if (_GroupCosts.Count > 0)
  13979. {
  13980. for (int i = 0; i < _GroupCosts.Count; i++)
  13981. {
  13982. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13983. {
  13984. if (i > 0)
  13985. {
  13986. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13987. }
  13988. }
  13989. }
  13990. }
  13991. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13992. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13993. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13994. string currCode = "";
  13995. #region currCode 验证
  13996. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13997. if (isInt)
  13998. {
  13999. var currData = currDatas.Find(it => it.Id == intCurrency);
  14000. if (currData != null)
  14001. {
  14002. currCode = currData.Name;
  14003. }
  14004. }
  14005. else
  14006. {
  14007. currCode = _GroupCostParameters[0].Currency.Trim();
  14008. }
  14009. #endregion
  14010. //op,酒店单段模式存储
  14011. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  14012. {
  14013. CurrencyCode = currCode,
  14014. Rate = _GroupCostParameters[0].Rate,
  14015. CostType = _GroupCostParameters[0].CostType,
  14016. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  14017. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  14018. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  14019. };
  14020. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  14021. if (_GroupCostParameters.Count == 2)
  14022. {
  14023. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  14024. }
  14025. foreach (var item in _GroupCostParameters)
  14026. {
  14027. decimal _rate = 1;
  14028. decimal _rate1 = item.Rate;
  14029. decimal _scale = 1;
  14030. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  14031. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  14032. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  14033. //if (userInfo != null)
  14034. //{
  14035. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  14036. // {
  14037. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  14038. // {
  14039. // _scale = 1.00M;
  14040. // }
  14041. // }
  14042. //}
  14043. #endregion
  14044. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  14045. {
  14046. CurrencyCode = currCode,
  14047. Rate = _rate1,
  14048. CostType = item.CostType,
  14049. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  14050. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  14051. CostTypeNumber = item.CostTypenumber
  14052. };
  14053. if (_GroupCostParameters.Count > 1)
  14054. {
  14055. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  14056. }
  14057. else
  14058. {
  14059. modulePromptInfo.CostTypeNumber = item.LYJRS;
  14060. }
  14061. if (dto.CTable == 79)//
  14062. {
  14063. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  14064. modulePromptInfo.TotalCost = item.DJCB;
  14065. }
  14066. List<string> costTypes = new List<string>() { "A", "B" };
  14067. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  14068. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  14069. if (_GroupCostsDuplicates.Count() == 1)
  14070. {
  14071. _GroupCostsTypeData = _GroupCosts;
  14072. }
  14073. else
  14074. {
  14075. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  14076. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  14077. }
  14078. /*
  14079. * 76 酒店预订
  14080. * 77 行程
  14081. * 79 车/导游地接
  14082. * 80 签证
  14083. * 81 邀请/公务活动
  14084. * 82 团组客户保险
  14085. * 85 机票预订
  14086. * 98 其他款项
  14087. * 285 收款退还
  14088. * 751 酒店早餐
  14089. * 1015 超支费用
  14090. */
  14091. switch (dto.CTable)
  14092. {
  14093. case 76: // 酒店预订
  14094. _ModuleSubPromptInfo.AddRange(
  14095. _GroupCostsTypeData.Select(it => new
  14096. {
  14097. it.DAY,
  14098. it.Date,
  14099. it.ACCON,
  14100. it.ITIN,
  14101. it.SGR,
  14102. it.TBR,
  14103. it.JS_ES,
  14104. it.Suite
  14105. })
  14106. );
  14107. break;
  14108. case 79: // 车/导游地接
  14109. _ModuleSubPromptInfo.AddRange(
  14110. _GroupCostsTypeData.Select(it => new
  14111. {
  14112. Date = it.Date, //日期
  14113. CarFee = it.CarCost * _rate * _scale, //车费用
  14114. CarType = it.CarType, //车型
  14115. DriverFee = it.CFS * _rate * _scale, //司机工资
  14116. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  14117. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  14118. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  14119. GuideFee = it.TGS * _rate * _scale, //导游费用
  14120. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  14121. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  14122. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  14123. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  14124. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  14125. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  14126. Breakfast = it.B * _rate * _scale, //早餐费
  14127. Lunch = it.L * _rate * _scale, //午餐费
  14128. Dinner = it.D * _rate * _scale, //晚餐费
  14129. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  14130. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  14131. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  14132. TicketFee = it.EF * _rate * _scale, //门票费
  14133. TicketRemark = it.EFR, //门票费描述
  14134. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  14135. TravelSupplies = it.TE * _rate * _scale, //出行物资
  14136. SpentCash = it.PC * _rate * _scale, //零用金
  14137. LeadersFee = it.TLF * _rate * _scale, //领队费
  14138. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  14139. })
  14140. );
  14141. break;
  14142. case 85: // 机票
  14143. List<dynamic> datas = new List<dynamic>();
  14144. datas.Add(
  14145. new
  14146. {
  14147. AirType = "经济舱",
  14148. AirNum = item.JJCRS,
  14149. AirDRCB = item.JJCCB,
  14150. AirZCB = (item.JJCRS * item.JJCCB)
  14151. }
  14152. );
  14153. datas.Add(
  14154. new
  14155. {
  14156. AirType = "公务舱",
  14157. AirNum = item.GWCRS,
  14158. AirDRCB = item.GWCCB,
  14159. AirZCB = (item.GWCRS * item.GWCCB)
  14160. }
  14161. );
  14162. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  14163. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  14164. modulePromptInfo.Data = new
  14165. {
  14166. airFeeData = datas,
  14167. airInitData = initDatas
  14168. };
  14169. _ModulePromptInfos.Add(modulePromptInfo);
  14170. break;
  14171. default:
  14172. break;
  14173. }
  14174. }
  14175. if (dto.CTable != 85)
  14176. {
  14177. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  14178. _ModulePromptInfos.Add(_ModulePromptInfo);
  14179. }
  14180. _view.ModulePromptInfos = _ModulePromptInfos;
  14181. return Ok(JsonView(true, "操作成功!", _view));
  14182. }
  14183. catch (Exception ex)
  14184. {
  14185. return Ok(JsonView(false, ex.Message));
  14186. }
  14187. }
  14188. /// <summary>
  14189. /// 根据黑屏代码重新生成行程
  14190. /// </summary>
  14191. /// <param name="dto"></param>
  14192. /// <returns></returns>
  14193. [HttpPost]
  14194. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  14195. {
  14196. var jw = JsonView(false);
  14197. var Create = _GroupCostRepository.
  14198. CreateGroupCostByBlackCode(dto.Diid);
  14199. jw.Msg = Create.Msg;
  14200. if (Create.Code == 0)
  14201. {
  14202. jw.Code = 200;
  14203. jw.Data = new
  14204. {
  14205. groupCost = Create.Data,
  14206. blackCodeIsTrue = true
  14207. };
  14208. }
  14209. else
  14210. {
  14211. jw.Code = 400;
  14212. jw.Data = new
  14213. {
  14214. groupCost = Create.Data,
  14215. blackCodeIsTrue = false,
  14216. };
  14217. }
  14218. return Ok(jw);
  14219. }
  14220. /// <summary>
  14221. /// 成本获取OP历史车费用
  14222. /// </summary>
  14223. /// <param name="dto"></param>
  14224. /// <returns></returns>
  14225. [HttpPost]
  14226. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  14227. {
  14228. var jw = JsonView(false);
  14229. try
  14230. {
  14231. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  14232. //获取现有所有车的数据
  14233. if (!dto.Param.IsNullOrWhiteSpace())
  14234. {
  14235. string sql = $@"
  14236. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  14237. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  14238. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  14239. 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
  14240. AND gctggr.ServiceEndTime is not NULL
  14241. ORDER by gctggrc.id DESC
  14242. ";
  14243. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  14244. var numeberResult = await Task.Run(() =>
  14245. {
  14246. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  14247. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  14248. return numberArr;
  14249. });
  14250. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  14251. foreach (var item in numeberResult)
  14252. {
  14253. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  14254. {
  14255. Country = "数据异常!",
  14256. City = string.Empty,
  14257. };
  14258. item.Area = find.Country + " " + find.City;
  14259. }
  14260. dbResult.AddRange(numeberResult);
  14261. if (dto.Param.Contains("、"))
  14262. {
  14263. var sp = dto.Param.Split("、");
  14264. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14265. .Where(x =>
  14266. {
  14267. return System.Array.Exists(sp, e =>
  14268. {
  14269. bool where = false;
  14270. if (x.Area != null)
  14271. {
  14272. where = x.Area.Contains(e);
  14273. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14274. {
  14275. return false;
  14276. }
  14277. }
  14278. if (x.PriceName != null && !where)
  14279. {
  14280. where = x.PriceName.Contains(e);
  14281. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14282. {
  14283. return false;
  14284. }
  14285. }
  14286. return where;
  14287. });
  14288. }).ToList();
  14289. }
  14290. else
  14291. {
  14292. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  14293. .Where(x =>
  14294. {
  14295. bool where = false;
  14296. if (x.Area != null)
  14297. {
  14298. where = x.Area.Contains(dto.Param);
  14299. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  14300. {
  14301. return false;
  14302. }
  14303. }
  14304. if (x.PriceName != null && !where)
  14305. {
  14306. where = x.PriceName.Contains(dto.Param);
  14307. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  14308. {
  14309. return false;
  14310. }
  14311. }
  14312. return where;
  14313. }
  14314. )
  14315. .ToList();
  14316. }
  14317. }
  14318. var view = dbResult.Select(x =>
  14319. {
  14320. decimal dp = 0.00M;
  14321. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  14322. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  14323. if (string.IsNullOrWhiteSpace(x.DatePrice))
  14324. {
  14325. if (startB && endB)
  14326. {
  14327. var timesp = endD.Subtract(startD);
  14328. if ((timesp.Days + 1) != 0)
  14329. {
  14330. dp = x.Price / (timesp.Days + 1);
  14331. }
  14332. }
  14333. }
  14334. else
  14335. {
  14336. dp = x.Price;
  14337. }
  14338. return new
  14339. {
  14340. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  14341. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  14342. x.Area,
  14343. x.id,
  14344. price = x.Price.ToString("F2"),
  14345. x.PriceName,
  14346. x.PriceContent,
  14347. x.TeamName,
  14348. x.DatePrice,
  14349. dayPrice = dp.ToString("F2"),
  14350. };
  14351. }).OrderByDescending(x => x.id).ToList();
  14352. jw = JsonView(true, "获取成功!", view);
  14353. }
  14354. catch (Exception e)
  14355. {
  14356. jw = JsonView(false, e.Message);
  14357. }
  14358. return Ok(jw);
  14359. }
  14360. #endregion
  14361. #region 酒店预订 新 雷怡 2023-12-28 17:45
  14362. /// <summary>
  14363. /// 酒店预订
  14364. /// 酒店费用列表 根据团组Id查询
  14365. /// </summary>
  14366. /// <param name="_dto"></param>
  14367. /// <returns></returns>
  14368. [HttpPost]
  14369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14370. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  14371. {
  14372. #region 参数验证
  14373. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14374. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14375. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14376. #region 团组操作权限验证 76 酒店预定模块
  14377. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14378. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14379. #endregion
  14380. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14381. #region 页面操作权限验证
  14382. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14383. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14384. #endregion
  14385. #endregion
  14386. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  14387. }
  14388. /// <summary>
  14389. /// 酒店预订
  14390. /// 基础数据
  14391. /// </summary>
  14392. /// <param name="_dto"></param>
  14393. /// <returns></returns>
  14394. [HttpPost]
  14395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14396. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  14397. {
  14398. #region 参数验证
  14399. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14400. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14401. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14402. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14403. #region 页面操作权限验证
  14404. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14405. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14406. #endregion
  14407. #region 团组操作权限验证 76 酒店预定模块
  14408. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14409. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14410. #endregion
  14411. #endregion
  14412. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  14413. }
  14414. /// <summary>
  14415. /// 酒店预订
  14416. /// 创建 入住卷号码
  14417. /// </summary>
  14418. /// <param name="_dto"></param>
  14419. /// <returns></returns>
  14420. [HttpPost]
  14421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14422. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  14423. {
  14424. #region 参数验证
  14425. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14426. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14427. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14428. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14429. #region 页面操作权限验证
  14430. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14431. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14432. #endregion
  14433. #region 团组操作权限验证 76 酒店预定模块
  14434. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14435. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14436. #endregion
  14437. #endregion
  14438. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  14439. if (data.Code != 0)
  14440. {
  14441. return Ok(JsonView(false, data.Msg));
  14442. }
  14443. return Ok(JsonView(true, data.Msg, data.Data));
  14444. }
  14445. /// <summary>
  14446. /// 酒店预订
  14447. /// 详情
  14448. /// </summary>
  14449. /// <param name="_dto"></param>
  14450. /// <returns></returns>
  14451. [HttpPost]
  14452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14453. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  14454. {
  14455. #region 参数验证
  14456. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  14457. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14458. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  14459. #region 团组操作权限验证 76 酒店预定模块
  14460. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14461. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14462. #endregion
  14463. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14464. #region 页面操作权限验证
  14465. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14466. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14467. #endregion
  14468. #endregion
  14469. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  14470. }
  14471. /// <summary>
  14472. /// 酒店预订
  14473. /// Add Or Edit
  14474. /// </summary>
  14475. /// <param name="_dto"></param>
  14476. /// <returns></returns>
  14477. [HttpPost]
  14478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14479. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  14480. {
  14481. #region 参数验证
  14482. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14483. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14484. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14485. #region 团组操作权限验证 76 酒店预定模块
  14486. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14487. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14488. #endregion
  14489. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14490. #region 页面操作权限验证
  14491. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14492. if (_dto.Id == 0) // Add
  14493. {
  14494. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14495. }
  14496. else if (_dto.Id > 1) // Edit
  14497. {
  14498. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  14499. }
  14500. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  14501. #endregion
  14502. #endregion
  14503. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  14504. if (_view.Code != 200)
  14505. {
  14506. return Ok(_view);
  14507. }
  14508. #region 成本无酒店价格数据进入超支
  14509. _sqlSugar.BeginTran();
  14510. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  14511. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  14512. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  14513. for (int i = 0; i < groupCost.Count; i++)
  14514. {
  14515. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  14516. {
  14517. groupCost[i].Date = groupCost[i - 1].Date;
  14518. }
  14519. }
  14520. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  14521. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  14522. List<Fin_GroupExtraCostDto_OP>();
  14523. if (start_Bool && end_Bool)
  14524. {
  14525. while (start_Time < end_Time)
  14526. {
  14527. foreach (var item in groupCost_Grp)
  14528. {
  14529. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  14530. {
  14531. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  14532. {
  14533. extraCostList.Add(new
  14534. Fin_GroupExtraCostDto_OP
  14535. {
  14536. Area = _dto.AreaId,
  14537. coefficient = 1.5M,
  14538. createUser = _dto.UserId,
  14539. currency = _dto.CardPriceCurrency,
  14540. diId = _dto.DiId,
  14541. ManagerConfirm = 0,
  14542. SupervisorConfirm = 0,
  14543. SYsupervisorConfirm = 0,
  14544. editType = 1,
  14545. PortType = 1,
  14546. price = _dto.CardPrice,
  14547. PriceCount = 1,
  14548. priceType = 1027,
  14549. priceDetailType = 1044,
  14550. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  14551. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  14552. });
  14553. }
  14554. }
  14555. }
  14556. start_Time = start_Time.AddDays(1);
  14557. }
  14558. }
  14559. if (extraCostList.Any())
  14560. {
  14561. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  14562. }
  14563. _sqlSugar.CommitTran();
  14564. #endregion
  14565. #region 应用推送
  14566. try
  14567. {
  14568. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14569. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14570. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14571. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14572. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14573. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14574. var diId = _dto.DiId;
  14575. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14576. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14577. #region 操作记录
  14578. var opInfo = new Crm_TableOperationRecord()
  14579. {
  14580. TableName = "Grp_HotelReservations",
  14581. PortType = _dto.PortType,
  14582. DataId = hotelId,
  14583. CreateUserId = _dto.UserId
  14584. };
  14585. //var opStatus = OperationEnum.NoOperation;
  14586. if (_dto.Id < 1) //添加操作
  14587. {
  14588. opInfo.OperationItem = OperationEnum.Add;
  14589. }
  14590. else if (_dto.Id > 0)
  14591. {
  14592. opInfo.OperationItem = OperationEnum.Edit;
  14593. }
  14594. string opRemark = string.Empty;
  14595. if (ccpInfo != null)
  14596. {
  14597. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  14598. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  14599. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  14600. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  14601. }
  14602. opInfo.Remark = opRemark;
  14603. await _tableorRep.AddAsync(opInfo);
  14604. #endregion
  14605. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  14606. //2024-10-21 新增LZ UID
  14607. var userIds = new List<int>() { 21 };
  14608. string title = $"费用审核";
  14609. string content = "";
  14610. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14611. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14612. try
  14613. {
  14614. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  14615. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  14616. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  14617. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  14618. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  14619. }
  14620. catch (Exception ex)
  14621. {
  14622. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  14623. }
  14624. }
  14625. catch (Exception ex)
  14626. {
  14627. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  14628. }
  14629. try
  14630. {
  14631. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  14632. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  14633. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  14634. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  14635. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  14636. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  14637. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14638. //自动审核
  14639. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  14640. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  14641. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  14642. //2024-10-21 新增LZ UID
  14643. var userIds = new List<int>() { 21 };
  14644. string title = $"系统通知";
  14645. var diId = _dto.DiId;
  14646. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14647. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14648. string content = "";
  14649. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14650. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14651. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14652. }
  14653. catch (Exception ex)
  14654. {
  14655. }
  14656. #endregion
  14657. return Ok(_view);
  14658. }
  14659. /// <summary>
  14660. /// 酒店自动审核测试
  14661. /// Add Or Edit
  14662. /// </summary>
  14663. /// <param name="diid"></param>
  14664. /// <param name="dataId"></param>
  14665. /// <returns></returns>
  14666. [HttpPost]
  14667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14668. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  14669. {
  14670. #region 应用推送
  14671. try
  14672. {
  14673. //自动审核
  14674. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  14675. }
  14676. catch (Exception ex)
  14677. {
  14678. return Ok(JsonView(false, "操作失败"));
  14679. }
  14680. #endregion
  14681. return Ok(JsonView(false, "操作成功"));
  14682. }
  14683. /// <summary>
  14684. /// 酒店预订
  14685. /// Del
  14686. /// </summary>
  14687. /// <param name="_dto"></param>
  14688. /// <returns></returns>
  14689. [HttpPost]
  14690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14691. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  14692. {
  14693. #region 参数验证
  14694. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14695. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14696. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14697. #region 团组操作权限验证 76 酒店预定模块
  14698. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14699. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14700. #endregion
  14701. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14702. #region 页面操作权限验证
  14703. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14704. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14705. #endregion
  14706. #endregion
  14707. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  14708. #region 操作记录
  14709. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  14710. {
  14711. TableName = "Grp_HotelReservations",
  14712. PortType = _dto.PortType,
  14713. OperationItem = OperationEnum.Del,
  14714. DataId = _dto.Id,
  14715. CreateUserId = _dto.UserId
  14716. });
  14717. #endregion
  14718. return Ok(data);
  14719. }
  14720. /// <summary>
  14721. /// 酒店预订
  14722. /// 生成VOUCHER
  14723. /// 2024.05.06 之前版本
  14724. /// </summary>
  14725. /// <param name="_dto"></param>
  14726. /// <returns></returns>
  14727. [HttpPost]
  14728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14729. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  14730. {
  14731. try
  14732. {
  14733. #region 参数验证
  14734. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14735. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14736. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14737. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14738. #region 团组操作权限验证 76 酒店预定模块
  14739. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14740. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14741. #endregion
  14742. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14743. #region 页面操作权限验证
  14744. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14745. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14746. #endregion
  14747. #endregion
  14748. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14749. //判断数据是否完整
  14750. if (hr != null)
  14751. {
  14752. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14753. {
  14754. string strFileName = "HotelStatement/";
  14755. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14756. if (dele != null)
  14757. strFileName += dele.TourCode;
  14758. //载入模板
  14759. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14760. Document doc = new Document(sss);
  14761. DocumentBuilder builder = new DocumentBuilder(doc);
  14762. #region 替换Word模板书签内容
  14763. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14764. //入住卷预定号码
  14765. if (doc.Range.Bookmarks["VNO"] != null)
  14766. {
  14767. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14768. mark.Text = hr.CheckNumber;
  14769. }
  14770. //酒店时间
  14771. if (doc.Range.Bookmarks["Date"] != null)
  14772. {
  14773. Bookmark mark = doc.Range.Bookmarks["Date"];
  14774. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14775. }
  14776. //团号
  14777. if (doc.Range.Bookmarks["TNo"] != null)
  14778. {
  14779. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14780. mark.Text = dele.TourCode;
  14781. }
  14782. //预定号码
  14783. if (doc.Range.Bookmarks["BookingId"] != null)
  14784. {
  14785. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14786. mark.Text = hr.ReservationsNo;
  14787. }
  14788. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14789. {
  14790. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14791. mark.Text = hr.DetermineNo;
  14792. }
  14793. //酒店城市
  14794. if (doc.Range.Bookmarks["City"] != null)
  14795. {
  14796. Bookmark mark = doc.Range.Bookmarks["City"];
  14797. mark.Text = hr.City;
  14798. }
  14799. //酒店名称
  14800. if (doc.Range.Bookmarks["HName"] != null)
  14801. {
  14802. Bookmark mark = doc.Range.Bookmarks["HName"];
  14803. mark.Text = hr.HotelName;
  14804. }
  14805. //酒店地址
  14806. if (doc.Range.Bookmarks["Address"] != null)
  14807. {
  14808. Bookmark mark = doc.Range.Bookmarks["Address"];
  14809. mark.Text = hr.HotelAddress;
  14810. }
  14811. //酒店电话
  14812. if (doc.Range.Bookmarks["Tel"] != null)
  14813. {
  14814. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14815. mark.Text = hr.HotelTel;
  14816. }
  14817. //酒店传真
  14818. if (doc.Range.Bookmarks["Fax"] != null)
  14819. {
  14820. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14821. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14822. {
  14823. mark.Text = hr.HotelFax;
  14824. }
  14825. }
  14826. //入住时间
  14827. if (doc.Range.Bookmarks["CIn"] != null)
  14828. {
  14829. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14830. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14831. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14832. }
  14833. //退房时间
  14834. if (doc.Range.Bookmarks["COut"] != null)
  14835. {
  14836. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14837. Bookmark mark = doc.Range.Bookmarks["COut"];
  14838. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14839. }
  14840. //客户名称
  14841. if (doc.Range.Bookmarks["GName"] != null)
  14842. {
  14843. string guestName = "";
  14844. string[] clients = new string[] { };
  14845. if (hr.GuestName.Contains(","))
  14846. {
  14847. clients = hr.GuestName.Split(",");
  14848. }
  14849. else
  14850. {
  14851. clients = new string[] { hr.GuestName };
  14852. }
  14853. List<int> clientIds_int = new List<int>();
  14854. if (clients.Length > 0)
  14855. {
  14856. foreach (var item in clients)
  14857. {
  14858. if (item.IsNumeric())
  14859. {
  14860. clientIds_int.Add(int.Parse(item));
  14861. }
  14862. }
  14863. }
  14864. if (clientIds_int.Count > 0)
  14865. {
  14866. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14867. foreach (var client in _clientDatas)
  14868. {
  14869. //男
  14870. if (client.Sex == 0) guestName += $"Mr.";
  14871. //女
  14872. else if (client.Sex == 1) guestName += $"Ms.";
  14873. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14874. {
  14875. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14876. }
  14877. //guestName += $"{client.Pinyin},";
  14878. }
  14879. if (guestName.Length > 0)
  14880. {
  14881. guestName = guestName.Substring(0, guestName.Length - 1);
  14882. }
  14883. }
  14884. else
  14885. {
  14886. guestName = hr.GuestName;
  14887. }
  14888. Bookmark mark = doc.Range.Bookmarks["GName"];
  14889. mark.Text = guestName;
  14890. }
  14891. //房间介绍
  14892. if (doc.Range.Bookmarks["ROOM"] != null)
  14893. {
  14894. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14895. mark.Text = hr.RoomExplanation;
  14896. }
  14897. //报价描述
  14898. if (doc.Range.Bookmarks["NOTE"] != null)
  14899. {
  14900. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14901. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14902. if (ss != null)
  14903. mark.Text = ss.Name;
  14904. }
  14905. //入住时间
  14906. if (doc.Range.Bookmarks["CheckIn"] != null)
  14907. {
  14908. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14909. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14910. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14911. }
  14912. //退房时间
  14913. if (doc.Range.Bookmarks["CheckOut"] != null)
  14914. {
  14915. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14916. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14917. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14918. }
  14919. //日期
  14920. if (doc.Range.Bookmarks["DT"] != null)
  14921. {
  14922. Bookmark mark = doc.Range.Bookmarks["DT"];
  14923. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14924. }
  14925. //名称
  14926. if (doc.Range.Bookmarks["VName"] != null)
  14927. {
  14928. Bookmark mark = doc.Range.Bookmarks["VName"];
  14929. mark.Text = hr.HotelName;
  14930. }
  14931. //号码
  14932. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14933. {
  14934. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14935. mark.Text = hr.CheckNumber;
  14936. }
  14937. #endregion
  14938. strFileName += "VOUCHER.doc";
  14939. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14940. doc.Save(fileDir);
  14941. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14942. return Ok(JsonView(true, "操作成功!", Url));
  14943. }
  14944. else
  14945. {
  14946. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14947. }
  14948. }
  14949. else
  14950. {
  14951. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14952. }
  14953. }
  14954. catch (Exception ex)
  14955. {
  14956. return Ok(JsonView(false, ex.Message));
  14957. }
  14958. }
  14959. /// <summary>
  14960. /// 酒店预订
  14961. /// 生成VOUCHER
  14962. /// 2024.05.06 之后版本
  14963. /// </summary>
  14964. /// <param name="_dto"></param>
  14965. /// <returns></returns>
  14966. [HttpPost]
  14967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14968. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14969. {
  14970. #region 参数验证
  14971. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14972. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14973. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14974. #region 团组操作权限验证 76 酒店预定模块
  14975. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14976. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14977. #endregion
  14978. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14979. #region 页面操作权限验证
  14980. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14981. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14982. #endregion
  14983. #endregion
  14984. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14985. //判断数据是否完整
  14986. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14987. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14988. string strFileName = "HotelStatement/";
  14989. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14990. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14991. #region 数据处理
  14992. List<int> guestIds = new List<int>();
  14993. //int index = 0;
  14994. foreach (var item in hrDtas)
  14995. {
  14996. if (item.GuestName.Contains(","))
  14997. {
  14998. string[] guestIdArr = item.GuestName.Split(',');
  14999. foreach (var guestIdStr in guestIdArr)
  15000. {
  15001. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  15002. if (guestBool)
  15003. {
  15004. guestIds.Add(guestId);
  15005. }
  15006. }
  15007. }
  15008. else guestNames += item.GuestName;
  15009. var voucherInfo = new HotelVoucherInfoView()
  15010. {
  15011. HotelName = item.HotelName,
  15012. CheckInDate = item.CheckInDate,
  15013. CheckOutDate = item.CheckOutDate,
  15014. ConfirmationNumber = item.DetermineNo.Trim(),
  15015. RoomType = item.RoomExplanation
  15016. };
  15017. vouchers.Add(voucherInfo);
  15018. }
  15019. if (guestIds.Count > 0)
  15020. {
  15021. guestIds = guestIds.Distinct().ToList();
  15022. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  15023. if (guestDatas.Count > 0)
  15024. {
  15025. guestNames = "";
  15026. foreach (var guest in guestDatas)
  15027. {
  15028. string guestName = "";
  15029. if (guest.Sex == 0) guestName += @"MR.";
  15030. else if (guest.Sex == 1) guestName += @"MS.";
  15031. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  15032. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  15033. guestNames += @$"{guestName.Trim()}、";
  15034. }
  15035. if (guestNames.Length > 0)
  15036. {
  15037. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  15038. }
  15039. }
  15040. }
  15041. #endregion
  15042. //载入模板
  15043. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  15044. Document doc = new Document(sss);
  15045. DocumentBuilder builder = new DocumentBuilder(doc);
  15046. if (doc.Range.Bookmarks["GuestName"] != null)
  15047. {
  15048. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  15049. mark.Text = guestNames;
  15050. }
  15051. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15052. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  15053. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  15054. for (int i = 1; i <= vouchers.Count; i++)
  15055. {
  15056. HotelVoucherInfoView hviv = vouchers[i - 1];
  15057. builder.MoveToCell(0, i, 0, 0);
  15058. builder.Write(hviv.HotelName);
  15059. builder.MoveToCell(0, i, 1, 0);
  15060. builder.Write(hviv.CheckInDate);
  15061. builder.MoveToCell(0, i, 2, 0);
  15062. builder.Write(hviv.CheckOutDate);
  15063. builder.MoveToCell(0, i, 3, 0);
  15064. builder.Write(hviv.RoomType);
  15065. builder.MoveToCell(0, i, 4, 0);
  15066. builder.Write(hviv.ConfirmationNumber);
  15067. }
  15068. //删除多余行
  15069. int currRowIndex = vouchers.Count + 1;
  15070. int delRows = 21 - currRowIndex;
  15071. if (delRows > 0)
  15072. {
  15073. for (int i = 0; i < delRows; i++)
  15074. {
  15075. table.Rows.RemoveAt(currRowIndex);
  15076. //cultivateRowIndex++;
  15077. }
  15078. }
  15079. strFileName += "VOUCHER.docx";
  15080. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15081. doc.Save(fileDir);
  15082. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15083. return Ok(JsonView(true, "操作成功!", Url));
  15084. }
  15085. /// <summary>
  15086. /// 酒店预订
  15087. /// 生成VOUCHER 批量生成
  15088. /// New
  15089. /// </summary>
  15090. /// <param name="_dto"></param>
  15091. /// <returns></returns>
  15092. [HttpPost]
  15093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15094. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  15095. {
  15096. #region 参数验证
  15097. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15098. if (_dto.PageId < 1) _dto.PageId = 28;
  15099. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15100. #region 团组操作权限验证 76 酒店预定模块
  15101. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15102. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15103. #endregion
  15104. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15105. #region 页面操作权限验证
  15106. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15107. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15108. #endregion
  15109. #endregion
  15110. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  15111. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  15112. .OrderBy(x => x.CheckInDate)
  15113. .ToListAsync();
  15114. //判断数据是否完整
  15115. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  15116. string strFileName = "HotelStatement/";
  15117. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  15118. if (dele != null)
  15119. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  15120. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  15121. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  15122. .Where(it => it.IsDel == 0)
  15123. .ToListAsync();
  15124. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  15125. for (int i = 0; i < hrDtas.Count; i++)
  15126. {
  15127. string guestNames = string.Empty;
  15128. List<int> guestIds = new List<int>();
  15129. var item = hrDtas[i];
  15130. //处理客户姓名
  15131. if (item.GuestName.Contains(","))
  15132. {
  15133. string[] guestIdArr = item.GuestName.Split(',');
  15134. foreach (var guestIdStr in guestIdArr)
  15135. if (int.TryParse(guestIdStr, out int guestId))
  15136. guestIds.Add(guestId);
  15137. }
  15138. else
  15139. {
  15140. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  15141. if (guestIdBool)
  15142. {
  15143. guestIds.Add(guestId);
  15144. }
  15145. //NaN
  15146. if (item.GuestName.Contains("NaN"))
  15147. {
  15148. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  15149. }
  15150. }
  15151. if (guestIds.Count > 0)
  15152. {
  15153. guestIds = guestIds.Distinct().ToList();
  15154. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  15155. if (guestDatas1.Count > 0)
  15156. {
  15157. guestNames = "";
  15158. foreach (var guest in guestDatas1)
  15159. {
  15160. string guestName = "";
  15161. if (guest.Sex == 0) guestName += @"MR.";
  15162. else if (guest.Sex == 1) guestName += @"MS.";
  15163. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  15164. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  15165. guestNames += @$"{guestName.Trim()}、";
  15166. }
  15167. if (guestNames.Length > 0)
  15168. {
  15169. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  15170. }
  15171. }
  15172. }
  15173. //if (!string.IsNullOrEmpty(guestNames))
  15174. //{
  15175. hrDtas[i].GuestName = guestNames;
  15176. //}
  15177. }
  15178. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  15179. Document doc = new Document();
  15180. DocumentBuilder builder = new DocumentBuilder(doc);
  15181. try
  15182. {
  15183. builder.MoveToDocumentStart();
  15184. foreach (var item in hrDtas)
  15185. {
  15186. //标题
  15187. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  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.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15193. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  15194. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  15195. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  15196. builder.ParagraphFormat.LineSpacing = 1;
  15197. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15198. builder.ParagraphFormat.Style.Font.Size = 9;
  15199. builder.ParagraphFormat.Style.Font.Bold = true;
  15200. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  15201. builder.StartTable();
  15202. // 设置边框颜色
  15203. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  15204. //设置边框样式
  15205. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  15206. //表格
  15207. #region 第一行
  15208. builder.InsertCell();
  15209. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15210. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15211. //builder.CellFormat.AllowAutoFit = false;
  15212. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15213. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15214. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15215. builder.CellFormat.WrapText = true; //自动换行
  15216. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15217. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  15218. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15219. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15220. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15221. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15222. builder.Write("TOUR NO:");
  15223. builder.InsertCell();
  15224. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15225. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15226. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15227. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15228. builder.ParagraphFormat.Style.Font.Bold = false;
  15229. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15230. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15231. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15232. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15233. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15234. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15235. builder.Write($"{dele?.TourCode ?? "-"}");
  15236. builder.InsertCell();
  15237. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15238. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15239. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15240. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15241. builder.ParagraphFormat.Style.Font.Bold = false;
  15242. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15243. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15244. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15245. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15246. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15247. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15248. builder.Write($"CITY:");
  15249. builder.InsertCell();
  15250. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15251. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15252. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15253. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15254. builder.ParagraphFormat.Style.Font.Bold = false;
  15255. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15256. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15257. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15258. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15259. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15260. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15261. builder.Write($"{item.City}");
  15262. builder.EndRow();
  15263. #endregion
  15264. #region 第二行
  15265. builder.InsertCell();
  15266. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15267. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15268. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15269. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15270. builder.ParagraphFormat.Style.Font.Bold = false;
  15271. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15272. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15273. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15274. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15275. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15276. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15277. builder.Write("CONFIRMATION NO:");
  15278. builder.InsertCell();
  15279. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15280. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15281. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15282. builder.ParagraphFormat.Style.Font.Bold = false;
  15283. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15284. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15285. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15286. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15287. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15288. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15289. builder.CellFormat.VerticalMerge = CellMerge.None;
  15290. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15291. builder.Write($"{item.DetermineNo}");
  15292. builder.InsertCell();
  15293. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15294. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15295. builder.InsertCell();
  15296. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15297. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15298. builder.EndRow();
  15299. #endregion
  15300. #region 第三行
  15301. builder.InsertCell();
  15302. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15303. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15304. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15305. builder.ParagraphFormat.Style.Font.Bold = false;
  15306. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15307. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15308. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15309. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15310. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15311. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15312. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15313. builder.Write($"HOTEL NAME:");
  15314. builder.InsertCell();
  15315. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15316. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15317. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15318. builder.ParagraphFormat.Style.Font.Bold = false;
  15319. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15320. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15321. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15322. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15323. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15324. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15325. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15326. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15327. builder.Write($"{item.HotelName}");
  15328. builder.InsertCell();
  15329. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15330. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15331. builder.InsertCell();
  15332. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15333. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15334. builder.EndRow();
  15335. #endregion
  15336. #region 第四行
  15337. builder.InsertCell();
  15338. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15339. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15340. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15341. builder.ParagraphFormat.Style.Font.Bold = false;
  15342. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15343. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15344. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15345. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15346. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15347. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15348. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15349. builder.Write($"HOTEL ADDRESS:");
  15350. builder.InsertCell();
  15351. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15352. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15353. builder.ParagraphFormat.Style.Font.Size = 8;
  15354. builder.ParagraphFormat.Style.Font.Bold = false;
  15355. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15356. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15357. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15358. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15359. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15360. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15361. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15362. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15363. builder.Write($"{item.HotelAddress}");
  15364. builder.InsertCell();
  15365. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15366. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15367. builder.InsertCell();
  15368. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15369. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15370. builder.EndRow();
  15371. #endregion
  15372. #region 第五行
  15373. builder.InsertCell();
  15374. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15375. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15376. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15377. builder.ParagraphFormat.Style.Font.Bold = false;
  15378. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15379. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15380. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15381. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15382. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15383. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15384. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15385. builder.Write("TEL:");
  15386. builder.InsertCell();
  15387. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15388. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15389. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15390. builder.ParagraphFormat.Style.Font.Bold = false;
  15391. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15392. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15393. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15394. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15395. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15396. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15397. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15398. builder.Write($"{item.HotelTel}");
  15399. builder.InsertCell();
  15400. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15401. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15402. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15403. builder.ParagraphFormat.Style.Font.Bold = false;
  15404. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15405. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15406. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15407. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15408. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15409. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15410. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15411. builder.Write($"FAX:");
  15412. builder.InsertCell();
  15413. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15414. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15415. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15416. builder.ParagraphFormat.Style.Font.Bold = false;
  15417. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15418. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15419. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15420. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15421. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15422. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15423. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15424. builder.Write($"{item.HotelFax}");
  15425. builder.EndRow();
  15426. #endregion
  15427. #region 第六行
  15428. builder.InsertCell();
  15429. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15430. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15431. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15432. builder.ParagraphFormat.Style.Font.Bold = false;
  15433. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15434. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15435. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15436. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15437. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15438. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15439. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15440. builder.Write("CHECK IN:");
  15441. builder.InsertCell();
  15442. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15443. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15444. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15445. builder.ParagraphFormat.Style.Font.Bold = false;
  15446. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15447. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15448. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15449. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15450. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15451. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15452. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15453. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  15454. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  15455. builder.Write($"{checkInStr}");
  15456. builder.InsertCell();
  15457. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15458. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15459. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15460. builder.ParagraphFormat.Style.Font.Bold = false;
  15461. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15462. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15463. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15464. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15465. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15466. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15467. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15468. builder.Write($"CHECK OUT:");
  15469. builder.InsertCell();
  15470. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15471. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15472. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15473. builder.ParagraphFormat.Style.Font.Bold = false;
  15474. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15475. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15476. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15477. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15478. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15479. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15480. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15481. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  15482. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  15483. builder.Write($"{checkOutStr}");
  15484. builder.EndRow();
  15485. #endregion
  15486. #region 第七行
  15487. builder.InsertCell();
  15488. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15489. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15490. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15491. builder.ParagraphFormat.Style.Font.Bold = false;
  15492. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15493. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15494. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15495. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15496. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15497. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15498. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15499. builder.Write($"GUEST NAME:");
  15500. builder.InsertCell();
  15501. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15502. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15503. builder.ParagraphFormat.Style.Font.Size = 8;
  15504. builder.ParagraphFormat.Style.Font.Bold = false;
  15505. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15506. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15507. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15508. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15509. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15510. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15511. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15512. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15513. builder.Write($"{item.GuestName}");
  15514. builder.InsertCell();
  15515. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15516. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15517. builder.InsertCell();
  15518. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15519. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15520. builder.EndRow();
  15521. #endregion
  15522. #region 第八行
  15523. builder.InsertCell();
  15524. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15525. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15526. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15527. builder.ParagraphFormat.Style.Font.Bold = false;
  15528. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15529. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15530. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15531. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15532. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15533. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15534. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15535. builder.Write($"ROOM TYPE:");
  15536. builder.InsertCell();
  15537. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15538. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15539. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15540. builder.ParagraphFormat.Style.Font.Bold = false;
  15541. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15542. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15543. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15544. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15545. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15546. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15547. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15548. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15549. builder.Write($"{item.RoomExplanation}");
  15550. builder.InsertCell();
  15551. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15552. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15553. builder.InsertCell();
  15554. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15555. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15556. builder.EndRow();
  15557. #endregion
  15558. #region 第九行
  15559. builder.InsertCell();
  15560. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15561. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15562. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15563. builder.ParagraphFormat.Style.Font.Bold = false;
  15564. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15565. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15566. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  15567. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  15568. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  15569. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  15570. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  15571. builder.Write($"NOTE:");
  15572. builder.InsertCell();
  15573. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15574. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  15575. builder.ParagraphFormat.Style.Font.Size = 7.5;
  15576. builder.ParagraphFormat.Style.Font.Bold = false;
  15577. builder.CellFormat.HorizontalMerge = CellMerge.None;
  15578. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  15579. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  15580. builder.CellFormat.HorizontalMerge = CellMerge.First;
  15581. 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.");
  15582. builder.InsertCell();
  15583. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  15584. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15585. builder.InsertCell();
  15586. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  15587. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  15588. builder.EndRow();
  15589. #endregion
  15590. builder.EndTable();
  15591. //换行
  15592. builder.Writeln("");
  15593. builder.Writeln("");
  15594. }
  15595. #region 获取文档中的所有表格 设置文字自适应
  15596. // 获取文档中的所有表格。
  15597. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  15598. {
  15599. // 遍历表格中的所有行。
  15600. foreach (Aspose.Words.Tables.Row row in table.Rows)
  15601. {
  15602. foreach (Cell cell in row.Cells)
  15603. {
  15604. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  15605. cellFormat.Width = 0;
  15606. }
  15607. }
  15608. }
  15609. #endregion
  15610. #region 设置页眉
  15611. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  15612. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  15613. if (System.IO.File.Exists(voucherHeaderPath))
  15614. {
  15615. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  15616. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  15617. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  15618. Shape shape = builder.InsertImage(imageBytes);
  15619. // 调整图片位置
  15620. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  15621. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  15622. shape.Top = 50; // 将图片距离页眉上边缘的距离
  15623. shape.Left = 0; // 将图片距离页面左边缘的距离
  15624. shape.Width = 81; // 设置图片宽度
  15625. shape.Height = 36; // 设置图片高度
  15626. }
  15627. //靠右
  15628. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  15629. //// 设置页脚上下边距
  15630. //builder.PageSetup.HeaderDistance = 42;
  15631. // 添加页眉线
  15632. Aspose.Words.Border borderHeader = null;
  15633. try
  15634. {
  15635. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  15636. }
  15637. catch (Exception e)
  15638. {
  15639. // TODO Auto-generated catch block
  15640. //e.printStackTrace();
  15641. }
  15642. borderHeader.Shadow = true;
  15643. borderHeader.DistanceFromText = 2;
  15644. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  15645. #endregion
  15646. }
  15647. catch (Exception ex)
  15648. {
  15649. }
  15650. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  15651. doc.Save(fileDir);
  15652. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  15653. return Ok(JsonView(true, "操作成功!", Url));
  15654. }
  15655. /// <summary>
  15656. /// 酒店预订
  15657. /// 生成 预定成本 Excel
  15658. /// </summary>
  15659. /// <param name="_dto"></param>
  15660. /// <returns></returns>
  15661. [HttpPost]
  15662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15663. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  15664. {
  15665. #region 参数验证
  15666. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  15667. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  15668. if (!vadalitorRes.IsValid)
  15669. {
  15670. var errors = new StringBuilder();
  15671. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  15672. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  15673. }
  15674. #region 团组操作权限验证 76 酒店预定模块
  15675. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15676. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  15677. #endregion
  15678. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15679. #region 页面操作权限验证
  15680. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15681. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15682. #endregion
  15683. #endregion
  15684. decimal _rate = 1.00M;
  15685. string _currency = string.Empty;
  15686. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  15687. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15688. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  15689. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15690. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  15691. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  15692. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  15693. if (_GroupCostParameter == null)
  15694. {
  15695. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  15696. bool isIntType = int.TryParse(_currency, out int currId);
  15697. if (isIntType)
  15698. {
  15699. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15700. }
  15701. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15702. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15703. if (currInfo == null)
  15704. {
  15705. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15706. }
  15707. else _rate = currInfo.Rate;
  15708. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  15709. {
  15710. _rate = _GroupCostParameter.Rate;
  15711. }
  15712. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15713. //string strFileName = "HotelStatement/";
  15714. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15715. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15716. var rateDatas = new List<dynamic>();
  15717. #region 数据处理
  15718. foreach (var item in hrDtas)
  15719. {
  15720. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15721. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15722. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15723. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15724. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15725. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  15726. {
  15727. continue;
  15728. }
  15729. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15730. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  15731. string singleRoomFeeStr = string.Empty,
  15732. doubleRoomFeeStr = string.Empty,
  15733. suiteRoomFeeStr = string.Empty,
  15734. otherRoomFeeStr = string.Empty,
  15735. payMoneyStr = string.Empty,
  15736. cardPriceStr = string.Empty;
  15737. if (roomCurr.Equals("CNY"))
  15738. {
  15739. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15740. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15741. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15742. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15743. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15744. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15745. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15746. }
  15747. else
  15748. {
  15749. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15750. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15751. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15752. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15753. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15754. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15755. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15756. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15757. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15758. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15759. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15760. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15761. if (ccpPaymentCurrency.Equals("CNY"))
  15762. {
  15763. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15764. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15765. }
  15766. else
  15767. {
  15768. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15769. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15770. }
  15771. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15772. if (hotelcardPriceCurrency.Equals("CNY"))
  15773. {
  15774. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15775. }
  15776. else
  15777. {
  15778. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15779. }
  15780. }
  15781. string breakfastPriceStr = string.Empty,
  15782. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15783. governmentRentStr = string.Empty,
  15784. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15785. cityTaxStr = string.Empty,
  15786. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15787. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15788. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15789. {
  15790. if (breakfastCurrency1.Equals("CNY"))
  15791. {
  15792. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15793. }
  15794. else
  15795. {
  15796. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15797. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15798. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15799. }
  15800. }
  15801. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15802. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15803. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15804. {
  15805. if (governmentRentCurrency.Equals("CNY"))
  15806. {
  15807. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15808. }
  15809. else
  15810. {
  15811. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15812. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15813. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15814. }
  15815. }
  15816. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15817. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15818. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15819. {
  15820. if (cityTaxStrCurrency1.Equals("CNY"))
  15821. {
  15822. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15823. }
  15824. else
  15825. {
  15826. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15827. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15828. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15829. }
  15830. }
  15831. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15832. int payDId = roomInfo?.PayDId ?? 0;
  15833. pcfds.Add(new HotelReservations_PCFD_View()
  15834. {
  15835. City = item.City,
  15836. HotelName = item.HotelName,
  15837. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15838. // SingleRoomCount = item.SingleRoomCount,
  15839. SingleRoomPrice = singleRoomFeeStr,
  15840. // DoubleRoomCount = item.DoubleRoomCount,
  15841. DoubleRoomPrice = doubleRoomFeeStr,
  15842. //SuiteRoomCount = item.SuiteRoomCount,
  15843. SuiteRoomPrice = suiteRoomFeeStr,
  15844. OtherRoomPrice = otherRoomFeeStr,
  15845. //OtherRoomCount = item.OtherRoomCount,
  15846. BreakfastPrice = breakfastPriceStr,
  15847. GovernmentRent = governmentRentStr,
  15848. CityTax = cityTaxStr,
  15849. RoomExplanation = item.RoomExplanation,
  15850. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15851. PayTime = roomInfo?.ConsumptionDate,
  15852. BankNo = roomInfo?.BankNo,
  15853. PayMoney = payMoneyStr,
  15854. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15855. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15856. CardPrice = cardPriceStr,
  15857. Remark = ccpInfo.Remark
  15858. });
  15859. }
  15860. #endregion
  15861. //载入模板
  15862. WorkbookDesigner designer = new WorkbookDesigner();
  15863. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15864. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15865. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15866. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15867. var rateDatas1 = rateDatas.Distinct();
  15868. var rateStr = string.Empty;
  15869. foreach (var item in rateDatas1)
  15870. {
  15871. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15872. }
  15873. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15874. designer.SetDataSource("Opertor", userInfo.CnName);
  15875. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15876. dt.TableName = "ViewMyHotelReservations";
  15877. designer.SetDataSource(dt);
  15878. designer.Process();
  15879. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15880. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15881. designer.Workbook.Save(serverPath);
  15882. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15883. #region 删除指定行
  15884. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15885. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15886. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15887. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15888. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15889. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15890. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15891. cssIndex = dt.Columns["CityTax"].Ordinal,
  15892. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15893. remarkIndex = dt.Columns["Remark"].Ordinal;
  15894. //删除指定列
  15895. foreach (DataRow item in dt.Rows)
  15896. {
  15897. string singleStr = item["SingleRoomPrice"].ToString();
  15898. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15899. if (containsDigitButNotZero1) singleDel = false;
  15900. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15901. string doubleStr = item["DoubleRoomPrice"].ToString();
  15902. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15903. if (containsDigitButNotZero2) doubleDel = false;
  15904. string suiteStr = item["SuiteRoomPrice"].ToString();
  15905. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15906. if (containsDigitButNotZero3) suiteDel = false;
  15907. string otherStr = item["OtherRoomPrice"].ToString();
  15908. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15909. if (containsDigitButNotZero4) otherDel = false;
  15910. string zcStr = item["BreakfastPrice"].ToString();
  15911. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15912. if (containsDigitButNotZero5) zcDel = false;
  15913. string dsStr = item["GovernmentRent"].ToString();
  15914. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15915. if (containsDigitButNotZero6) dsDel = false;
  15916. string cssStr = item["CityTax"].ToString();
  15917. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15918. if (containsDigitButNotZero7) cssDel = false;
  15919. string cpStr = item["ConsumptionPatterns"].ToString();
  15920. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15921. string remarkStr = item["Remark"].ToString();
  15922. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15923. }
  15924. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15925. DeleteColumn(serverPath, cpIndex, cpDel);
  15926. DeleteColumn(serverPath, dsIndex, dsDel);
  15927. DeleteColumn(serverPath, cssIndex, cssDel);
  15928. DeleteColumn(serverPath, zcIndex, zcDel);
  15929. DeleteColumn(serverPath, otherIndex, otherDel);
  15930. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15931. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15932. DeleteColumn(serverPath, singleIndex, singleDel);
  15933. #endregion
  15934. //只保留第一个表格
  15935. DeleteSheet(serverPath);
  15936. return Ok(JsonView(true, "操作成功", url = rst));
  15937. }
  15938. else
  15939. {
  15940. _currency = _GroupCostParameter.Currency;
  15941. bool isIntType = int.TryParse(_currency, out int currId);
  15942. if (isIntType)
  15943. {
  15944. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15945. }
  15946. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15947. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15948. if (currInfo == null)
  15949. {
  15950. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15951. }
  15952. if (!_currency.ToUpper().Equals("CNY"))
  15953. {
  15954. _rate = _GroupCostParameter.Rate;
  15955. }
  15956. _rate = currInfo.Rate;
  15957. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15958. //string strFileName = "HotelStatement/";
  15959. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15960. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15961. #region 数据处理
  15962. foreach (var item in hrDtas)
  15963. {
  15964. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15965. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15966. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15967. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15968. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15969. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15970. string singleRoomFeeStr = string.Empty,
  15971. doubleRoomFeeStr = string.Empty,
  15972. suiteRoomFeeStr = string.Empty,
  15973. otherRoomFeeStr = string.Empty,
  15974. payMoneyStr = string.Empty,
  15975. cardPriceStr = string.Empty;
  15976. if (roomCurr.Equals(_currency))
  15977. {
  15978. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15979. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15980. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15981. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15982. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15983. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15984. }
  15985. else
  15986. {
  15987. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15988. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15989. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15990. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15991. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15992. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15993. }
  15994. string breakfastPriceStr = string.Empty,
  15995. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15996. governmentRentStr = string.Empty,
  15997. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15998. cityTaxStrStr = string.Empty,
  15999. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  16000. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  16001. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  16002. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  16003. int payDId = roomInfo?.PayDId ?? 0;
  16004. pcfds.Add(new HotelReservations_PCFD_View()
  16005. {
  16006. City = item.City,
  16007. HotelName = item.HotelName,
  16008. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  16009. // SingleRoomCount = item.SingleRoomCount,
  16010. SingleRoomPrice = singleRoomFeeStr,
  16011. // DoubleRoomCount = item.DoubleRoomCount,
  16012. DoubleRoomPrice = doubleRoomFeeStr,
  16013. //SuiteRoomCount = item.SuiteRoomCount,
  16014. SuiteRoomPrice = suiteRoomFeeStr,
  16015. OtherRoomPrice = otherRoomFeeStr,
  16016. //OtherRoomCount = item.OtherRoomCount,
  16017. BreakfastPrice = breakfastPriceStr,
  16018. GovernmentRent = governmentRentStr,
  16019. CityTax = cityTaxStrStr,
  16020. RoomExplanation = item.RoomExplanation,
  16021. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  16022. PayTime = roomInfo?.ConsumptionDate,
  16023. BankNo = roomInfo?.BankNo,
  16024. PayMoney = payMoneyStr,
  16025. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  16026. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  16027. CardPrice = cardPriceStr,
  16028. Remark = ccpInfo.Remark
  16029. });
  16030. }
  16031. #endregion
  16032. //载入模板
  16033. WorkbookDesigner designer = new WorkbookDesigner();
  16034. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  16035. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  16036. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  16037. designer.SetDataSource("TourNo", groupInfo.TourCode);
  16038. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  16039. designer.SetDataSource("Opertor", userInfo.CnName);
  16040. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  16041. dt.TableName = "ViewMyHotelReservations";
  16042. designer.SetDataSource(dt);
  16043. designer.Process();
  16044. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  16045. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  16046. designer.Workbook.Save(serverPath);
  16047. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  16048. #region 删除指定行
  16049. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  16050. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  16051. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  16052. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  16053. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  16054. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  16055. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  16056. cssIndex = dt.Columns["CityTax"].Ordinal,
  16057. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  16058. remarkIndex = dt.Columns["Remark"].Ordinal;
  16059. //删除指定列
  16060. foreach (DataRow item in dt.Rows)
  16061. {
  16062. string singleStr = item["SingleRoomPrice"].ToString();
  16063. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  16064. if (containsDigitButNotZero1) singleDel = false;
  16065. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  16066. string doubleStr = item["DoubleRoomPrice"].ToString();
  16067. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16068. if (containsDigitButNotZero2) doubleDel = false;
  16069. string suiteStr = item["SuiteRoomPrice"].ToString();
  16070. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  16071. if (containsDigitButNotZero3) suiteDel = false;
  16072. string otherStr = item["OtherRoomPrice"].ToString();
  16073. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  16074. if (containsDigitButNotZero4) otherDel = false;
  16075. string zcStr = item["BreakfastPrice"].ToString();
  16076. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  16077. if (containsDigitButNotZero5) zcDel = false;
  16078. string dsStr = item["GovernmentRent"].ToString();
  16079. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  16080. if (containsDigitButNotZero6) dsDel = false;
  16081. string cssStr = item["CityTax"].ToString();
  16082. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  16083. if (containsDigitButNotZero7) cssDel = false;
  16084. string cpStr = item["ConsumptionPatterns"].ToString();
  16085. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  16086. string remarkStr = item["Remark"].ToString();
  16087. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  16088. }
  16089. DeleteColumn(serverPath, remarkIndex, remarkDel);
  16090. DeleteColumn(serverPath, cpIndex, cpDel);
  16091. DeleteColumn(serverPath, dsIndex, dsDel);
  16092. DeleteColumn(serverPath, cssIndex, cssDel);
  16093. DeleteColumn(serverPath, zcIndex, zcDel);
  16094. DeleteColumn(serverPath, otherIndex, otherDel);
  16095. DeleteColumn(serverPath, suiteIndex, suiteDel);
  16096. DeleteColumn(serverPath, doubleIndex, doubleDel);
  16097. DeleteColumn(serverPath, singleIndex, singleDel);
  16098. #endregion
  16099. //只保留第一个表格
  16100. DeleteSheet(serverPath);
  16101. return Ok(JsonView(true, "操作成功", url = rst));
  16102. }
  16103. //return Ok(JsonView(false));
  16104. }
  16105. /// <summary>
  16106. /// 删除指定列
  16107. /// </summary>
  16108. /// <param name="file"></param>
  16109. /// <param name="columnIndex"></param>
  16110. /// <param name="isDel"></param>
  16111. private void DeleteColumn(string file, int columnIndex, bool isDel)
  16112. {
  16113. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16114. //wb.Save(file);
  16115. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  16116. if (sheet1 != null)
  16117. {
  16118. if (isDel)
  16119. {
  16120. Cells cells = sheet1.Cells;
  16121. cells.DeleteColumn(columnIndex);
  16122. }
  16123. }
  16124. wb.Save(file);
  16125. }
  16126. /// <summary>
  16127. /// 删除sheet
  16128. /// </summary>
  16129. /// <param name="file"></param>
  16130. /// <param name="sheetName"></param>
  16131. private void DeleteSheet(string file, string sheetName = "")
  16132. {
  16133. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  16134. //wb.Save(file);
  16135. List<string> sheets = new List<string>();
  16136. foreach (var item in wb.Worksheets)
  16137. {
  16138. sheets.Add(item.Name);
  16139. }
  16140. if (sheets.Count > 0)
  16141. {
  16142. sheets.RemoveAt(0);//不删除第一个sheet
  16143. foreach (var item in sheets)
  16144. {
  16145. wb.Worksheets.RemoveAt(item);
  16146. }
  16147. }
  16148. wb.Save(file);
  16149. }
  16150. /// <summary>
  16151. /// 酒店预订
  16152. /// 确认单
  16153. /// </summary>
  16154. /// <param name="_dto"></param>
  16155. /// <returns></returns>
  16156. [HttpPost]
  16157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16158. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  16159. {
  16160. try
  16161. {
  16162. #region 参数验证
  16163. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  16164. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16165. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  16166. #region 团组操作权限验证 76 酒店预定模块
  16167. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16168. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  16169. #endregion
  16170. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16171. #region 页面操作权限验证
  16172. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16173. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16174. #endregion
  16175. #endregion
  16176. //团组信息
  16177. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  16178. //酒店数据
  16179. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  16180. if (listhoteldata.Count < 0)
  16181. {
  16182. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  16183. }
  16184. //利datatable存储
  16185. DataTable dt = new DataTable();
  16186. dt.Columns.Add("CheckInDate", typeof(string));
  16187. dt.Columns.Add("City", typeof(string));
  16188. dt.Columns.Add("Hotel", typeof(string));
  16189. dt.Columns.Add("Room", typeof(string));
  16190. for (int i = 0; i < listhoteldata.Count; i++)
  16191. {
  16192. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  16193. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  16194. while (dayStart < dayEnd)
  16195. {
  16196. string temp = "";
  16197. DataRow row = dt.NewRow();
  16198. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  16199. row["City"] = listhoteldata[i].City;
  16200. row["Hotel"] = listhoteldata[i].HotelName;
  16201. if (listhoteldata[i].SingleRoomCount > 0)
  16202. {
  16203. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  16204. }
  16205. if (listhoteldata[i].DoubleRoomCount > 0)
  16206. {
  16207. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  16208. }
  16209. if (listhoteldata[i].SuiteRoomCount > 0)
  16210. {
  16211. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  16212. }
  16213. if (listhoteldata[i].OtherRoomCount > 0)
  16214. {
  16215. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  16216. }
  16217. row["Room"] = temp;
  16218. dt.Rows.Add(row);
  16219. dayStart = dayStart.AddDays(1);
  16220. }
  16221. }
  16222. Dictionary<string, string> dic = new Dictionary<string, string>();
  16223. dic.Add("Dele", di.TeamName);
  16224. dic.Add("City", di.VisitCountry);
  16225. //模板路径
  16226. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  16227. //载入模板
  16228. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  16229. DocumentBuilder builder = new DocumentBuilder(doc);
  16230. foreach (var key in dic.Keys)
  16231. {
  16232. builder.MoveToBookmark(key);
  16233. builder.Write(dic[key]);
  16234. }
  16235. //获取word里所有表格
  16236. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16237. //获取所填表格的序数
  16238. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16239. var rowStart = tableOne.Rows[0]; //获取第1行
  16240. //循环赋值
  16241. for (int i = 0; i < dt.Rows.Count; i++)
  16242. {
  16243. builder.MoveToCell(0, i + 1, 0, 0);
  16244. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  16245. builder.MoveToCell(0, i + 1, 1, 0);
  16246. builder.Write(dt.Rows[i]["City"].ToString());
  16247. builder.MoveToCell(0, i + 1, 2, 0);
  16248. builder.Write(dt.Rows[i]["Hotel"].ToString());
  16249. builder.MoveToCell(0, i + 1, 3, 0);
  16250. builder.Write(dt.Rows[i]["Room"].ToString());
  16251. }
  16252. //删除多余行
  16253. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  16254. {
  16255. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  16256. }
  16257. string strFileName = di.TeamName + "酒店确认单.doc";
  16258. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  16259. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  16260. return Ok(JsonView(true, "成功", url));
  16261. }
  16262. catch (Exception ex)
  16263. {
  16264. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  16265. }
  16266. }
  16267. #endregion
  16268. #region 团组状态
  16269. /// <summary>
  16270. /// 团组状态列表 Page
  16271. /// </summary>
  16272. /// <param name="dto">团组列表请求dto</param>
  16273. /// <returns></returns>
  16274. [HttpPost]
  16275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16276. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  16277. {
  16278. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16279. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  16280. {
  16281. string sqlWhere = string.Empty;
  16282. if (dto.IsSure == 0) //未完成
  16283. {
  16284. sqlWhere += string.Format(@" And IsSure = 0");
  16285. }
  16286. else if (dto.IsSure == 1) //已完成
  16287. {
  16288. sqlWhere += string.Format(@" And IsSure = 1");
  16289. }
  16290. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  16291. {
  16292. string tj = dto.SearchCriteria;
  16293. 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}%')",
  16294. tj, tj, tj, tj, tj);
  16295. }
  16296. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  16297. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  16298. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  16299. From (
  16300. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  16301. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  16302. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  16303. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  16304. From Grp_DelegationInfo gdi
  16305. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  16306. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  16307. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  16308. Where gdi.IsDel = 0 {0}
  16309. ) temp ", sqlWhere);
  16310. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  16311. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  16312. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  16313. }
  16314. else
  16315. {
  16316. return Ok(JsonView(false, "查询失败"));
  16317. }
  16318. }
  16319. /// <summary>
  16320. /// 团组状态
  16321. /// 设置操作完成
  16322. /// </summary>
  16323. /// <param name="dto">团组列表请求dto</param>
  16324. /// <returns></returns>
  16325. [HttpPost]
  16326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16327. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  16328. {
  16329. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  16330. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  16331. {
  16332. Id = dto.Id,
  16333. IsSure = 1
  16334. };
  16335. var result = await _sqlSugar.Updateable(_DelegationInfo)
  16336. .UpdateColumns(it => new { it.IsSure })
  16337. .WhereColumns(it => new { it.Id })
  16338. .ExecuteCommandAsync();
  16339. if (result > 0)
  16340. {
  16341. return Ok(JsonView(true, "操作完成!"));
  16342. }
  16343. return Ok(JsonView(false, "操作失败!"));
  16344. }
  16345. #endregion
  16346. #region 保险费用录入
  16347. /// <summary>
  16348. /// 根据团组Id查询保险费用列表
  16349. /// </summary>
  16350. /// <param name="dto"></param>
  16351. /// <returns></returns>
  16352. [HttpPost]
  16353. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16354. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  16355. {
  16356. Result groupData = await _customersRep.CustomersByDiId(dto);
  16357. if (groupData.Code != 0)
  16358. {
  16359. return Ok(JsonView(false, groupData.Msg));
  16360. }
  16361. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16362. }
  16363. /// <summary>
  16364. /// 根据保险费用Id查询保险费用详细
  16365. /// </summary>
  16366. /// <param name="dto"></param>
  16367. /// <returns></returns>
  16368. [HttpPost]
  16369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16370. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  16371. {
  16372. try
  16373. {
  16374. Result groupData = await _customersRep.CustomersById(dto);
  16375. if (groupData.Code != 0)
  16376. {
  16377. return Ok(JsonView(false, groupData.Msg));
  16378. }
  16379. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16380. }
  16381. catch (Exception ex)
  16382. {
  16383. return Ok(JsonView(false, ex.Message));
  16384. }
  16385. }
  16386. /// <summary>
  16387. /// 保险费用录入页面初始化绑定
  16388. /// </summary>
  16389. /// <param name="dto"></param>
  16390. /// <returns></returns>
  16391. [HttpPost]
  16392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16393. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  16394. {
  16395. try
  16396. {
  16397. Result groupData = await _customersRep.CustomersInitialize(dto);
  16398. if (groupData.Code != 0)
  16399. {
  16400. return Ok(JsonView(false, groupData.Msg));
  16401. }
  16402. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16403. }
  16404. catch (Exception ex)
  16405. {
  16406. return Ok(JsonView(false, ex.Message));
  16407. }
  16408. }
  16409. /// <summary>
  16410. /// 保险费用操作(Status:1.新增,2.修改)
  16411. /// </summary>
  16412. /// <param name="dto"></param>
  16413. /// <returns></returns>
  16414. [HttpPost]
  16415. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16416. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  16417. {
  16418. Result groupData = await _customersRep.OpCustomers(dto);
  16419. if (groupData.Code != 0)
  16420. {
  16421. return Ok(JsonView(false, groupData.Msg));
  16422. }
  16423. #region 应用推送
  16424. try
  16425. {
  16426. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  16427. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  16428. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  16429. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16430. //自动审核
  16431. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  16432. //2024-10-21 新增LZ UID
  16433. var userIds = new List<int>() { 21 };
  16434. string title = $"系统通知";
  16435. var diId = dto.DiId;
  16436. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16437. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16438. string content = "";
  16439. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16440. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16441. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16442. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  16443. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  16444. }
  16445. catch (Exception ex)
  16446. {
  16447. }
  16448. #endregion
  16449. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16450. }
  16451. /// <summary>
  16452. /// 保险文件上传
  16453. /// </summary>
  16454. /// <param name="file"></param>
  16455. /// <returns></returns>
  16456. [HttpPost]
  16457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16458. public async Task<IActionResult> UploadCus(IFormFile file)
  16459. {
  16460. try
  16461. {
  16462. if (file != null)
  16463. {
  16464. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16465. //文件名称
  16466. string projectFileName = file.FileName;
  16467. //上传的文件的路径
  16468. string filePath = "";
  16469. if (!Directory.Exists(fileDir))
  16470. {
  16471. Directory.CreateDirectory(fileDir);
  16472. }
  16473. //上传的文件的路径
  16474. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  16475. using (FileStream fs = System.IO.File.Create(filePath))
  16476. {
  16477. file.CopyTo(fs);
  16478. fs.Flush();
  16479. }
  16480. return Ok(JsonView(true, "上传成功!", projectFileName));
  16481. }
  16482. else
  16483. {
  16484. return Ok(JsonView(false, "上传失败!"));
  16485. }
  16486. }
  16487. catch (Exception ex)
  16488. {
  16489. return Ok(JsonView(false, "程序错误!"));
  16490. throw;
  16491. }
  16492. }
  16493. /// <summary>
  16494. /// 保险删除指定文件
  16495. /// </summary>
  16496. /// <param name="dto"></param>
  16497. /// <returns></returns>
  16498. [HttpPost]
  16499. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16500. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  16501. {
  16502. try
  16503. {
  16504. string filePath = "";
  16505. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  16506. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  16507. //int id = 0;
  16508. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  16509. // 删除该文件
  16510. try
  16511. {
  16512. System.IO.File.Delete(filePath);
  16513. 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()
  16514. {
  16515. Attachment = "",
  16516. }).ExecuteCommandAsync();
  16517. if (result != 0)
  16518. {
  16519. return Ok(JsonView(true, "成功!"));
  16520. }
  16521. else
  16522. {
  16523. return Ok(JsonView(false, "失败!"));
  16524. }
  16525. }
  16526. catch (Exception)
  16527. {
  16528. 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()
  16529. {
  16530. Attachment = "",
  16531. }).ExecuteCommandAsync();
  16532. if (result != 0)
  16533. {
  16534. return Ok(JsonView(true, "成功!"));
  16535. }
  16536. else
  16537. {
  16538. return Ok(JsonView(false, "失败!"));
  16539. }
  16540. }
  16541. }
  16542. catch (Exception ex)
  16543. {
  16544. return Ok(JsonView(false, "程序错误!"));
  16545. throw;
  16546. }
  16547. }
  16548. /// <summary>
  16549. /// 保险费用操作(删除)
  16550. /// </summary>
  16551. /// <param name="dto"></param>
  16552. /// <returns></returns>
  16553. [HttpPost]
  16554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16555. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  16556. {
  16557. try
  16558. {
  16559. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  16560. if (!res)
  16561. {
  16562. return Ok(JsonView(false, "删除失败"));
  16563. }
  16564. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  16565. {
  16566. IsDel = 1,
  16567. DeleteUserId = dto.DeleteUserId,
  16568. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16569. }).ExecuteCommandAsync();
  16570. return Ok(JsonView(true, "删除成功!"));
  16571. }
  16572. catch (Exception ex)
  16573. {
  16574. return Ok(JsonView(false, "程序错误!"));
  16575. throw;
  16576. }
  16577. }
  16578. #endregion
  16579. #region 接团客户名单 PageId 104
  16580. /// <summary>
  16581. /// 接团客户名单
  16582. /// 迁移数据(慎用!)
  16583. /// </summary>
  16584. /// <returns></returns>
  16585. [HttpPost]
  16586. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16587. public async Task<IActionResult> PostTourClientListChange()
  16588. {
  16589. try
  16590. {
  16591. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  16592. //var groupClinetData1
  16593. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  16594. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  16595. int updateCount = 0;
  16596. if (oldOAClientList.Count > 0)
  16597. {
  16598. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  16599. _sqlSugar.BeginTran();
  16600. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  16601. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  16602. foreach (var item in oldOAClientList)
  16603. {
  16604. int comId = 0;
  16605. string format = "yyyy-MM-dd HH:mm:ss";
  16606. string data11 = "1990-01-01 00:00";
  16607. var data1 = IsValidDate(item.OPdate, format);
  16608. if (data1) data11 = item.OPdate;
  16609. //客户公司验证
  16610. if (!string.IsNullOrEmpty(item.Company))
  16611. {
  16612. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  16613. if (clientComInfo == null) // add
  16614. {
  16615. var addInfo = new Crm_CustomerCompany()
  16616. {
  16617. CompanyAbbreviation = "",
  16618. CompanyFullName = item.Company,
  16619. Address = "",
  16620. PostCodes = "",
  16621. LastedOpUserId = item.OPer,
  16622. LastedOpDt = Convert.ToDateTime(data11),
  16623. CreateUserId = item.OPer,
  16624. CreateTime = Convert.ToDateTime(data11),
  16625. IsDel = 0
  16626. };
  16627. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  16628. if (comId1 > 0) comId = comId1;
  16629. }
  16630. else comId = clientComInfo.Id;
  16631. }
  16632. //客户人员验证
  16633. int clientId = 0;
  16634. string name = item.LastName + item.Name;
  16635. if (!string.IsNullOrEmpty(name))
  16636. {
  16637. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  16638. if (clientInfo == null)
  16639. {
  16640. DateTime? dateTime = null;
  16641. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  16642. if (isDt) dateTime = birthDayDt;
  16643. var addInfo1 = new Crm_DeleClient()
  16644. {
  16645. CrmCompanyId = comId,
  16646. DiId = -1,
  16647. LastName = item.LastName,
  16648. FirstName = item.Name,
  16649. OldName = "",
  16650. Pinyin = item.Pinyin,
  16651. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  16652. Marriage = 0,
  16653. Phone = item.Phone,
  16654. Job = item.Job,
  16655. BirthDay = dateTime
  16656. };
  16657. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  16658. if (clientId1 > 0) clientId = clientId1;
  16659. }
  16660. else clientId = clientInfo.Id;
  16661. }
  16662. if (clientId < 1)
  16663. {
  16664. continue;
  16665. }
  16666. int airType = 0;
  16667. if (item.AirType == "超经舱") airType = 459;
  16668. else if (item.AirType == "公务舱") airType = 458;
  16669. else if (item.AirType == "经济舱") airType = 460;
  16670. else if (item.AirType == "其他") airType = 565;
  16671. else if (item.AirType == "头等舱") airType = 457;
  16672. var _TourClientListEntity = new Grp_TourClientList()
  16673. {
  16674. DiId = item.Diid,
  16675. ClientId = clientId,
  16676. CreateUserId = item.OPer,
  16677. CreateTime = Convert.ToDateTime(data11),
  16678. Remark = item.Remark,
  16679. IsDel = item.Isdel,
  16680. ShippingSpaceTypeId = airType,
  16681. ShippingSpaceSpecialNeeds = item.AirRemark,
  16682. HotelSpecialNeeds = item.RoomType
  16683. };
  16684. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  16685. if (_TourClientList > 0)
  16686. {
  16687. updateCount++;
  16688. }
  16689. }
  16690. _sqlSugar.CommitTran();
  16691. }
  16692. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  16693. }
  16694. catch (Exception ex)
  16695. {
  16696. _sqlSugar.RollbackTran();
  16697. return Ok(JsonView(false, ex.Message));
  16698. }
  16699. //return Ok(JsonView(true));
  16700. }
  16701. private bool IsValidDate(string dateString, string format)
  16702. {
  16703. DateTime dateValue;
  16704. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  16705. return valid;
  16706. }
  16707. /// <summary>
  16708. /// 接团客户名单
  16709. /// 根据团组Id查询List
  16710. /// </summary>
  16711. /// <param name="_dto"></param>
  16712. /// <returns></returns>
  16713. [HttpPost]
  16714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16715. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  16716. {
  16717. #region 参数验证
  16718. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  16719. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  16720. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  16721. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16722. #region 页面操作权限验证
  16723. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16724. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16725. #endregion
  16726. #endregion
  16727. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  16728. if (viewData.Code != 0)
  16729. {
  16730. return Ok(JsonView(false, viewData.Msg));
  16731. }
  16732. return Ok(JsonView(viewData.Data));
  16733. }
  16734. /// <summary>
  16735. /// 接团客户名单
  16736. /// 基础数据 Init
  16737. /// </summary>
  16738. /// <param name="_dto"></param>
  16739. /// <returns></returns>
  16740. [HttpPost]
  16741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16742. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16743. {
  16744. #region 参数验证
  16745. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16746. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16747. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16748. #region 页面操作权限验证
  16749. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16750. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16751. #endregion
  16752. #endregion
  16753. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16754. }
  16755. /// <summary>
  16756. /// 接团客户名单
  16757. /// 根据 Id查询 Details
  16758. /// </summary>
  16759. /// <param name="_dto"></param>
  16760. /// <returns></returns>
  16761. [HttpPost]
  16762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16763. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16764. {
  16765. #region 参数验证
  16766. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16767. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16768. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16769. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16770. #region 页面操作权限验证
  16771. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16772. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16773. #endregion
  16774. #endregion
  16775. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16776. if (viewData.Code != 0)
  16777. {
  16778. return Ok(JsonView(false, viewData.Msg));
  16779. }
  16780. return Ok(JsonView(viewData.Data));
  16781. }
  16782. /// <summary>
  16783. /// 接团客户名单
  16784. /// Add Or Edit
  16785. /// </summary>
  16786. /// <param name="_dto"></param>
  16787. /// <returns></returns>
  16788. [HttpPost]
  16789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16790. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16791. {
  16792. #region 参数验证
  16793. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16794. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16795. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16796. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16797. #region 页面操作权限验证
  16798. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16799. if (_dto.Id == 0) //添加
  16800. {
  16801. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16802. }
  16803. else if (_dto.Id >= 0) //修改
  16804. {
  16805. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16806. }
  16807. #endregion
  16808. #endregion
  16809. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16810. if (viewData.Code != 0)
  16811. {
  16812. return Ok(JsonView(false, viewData.Msg));
  16813. }
  16814. return Ok(JsonView(true));
  16815. }
  16816. /// <summary>
  16817. /// 接团客户名单
  16818. /// json字符串 AddMultiple(添加多个)
  16819. /// </summary>
  16820. /// <param name="_dto"></param>
  16821. /// <returns></returns>
  16822. [HttpPost]
  16823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16824. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16825. {
  16826. #region 参数验证
  16827. string jsonLabel = _dto.JsonLabel;
  16828. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16829. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16830. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16831. #region 页面操作权限验证
  16832. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16833. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16834. #endregion
  16835. #endregion
  16836. var request = new TourClientListAddMultipleDto();
  16837. request.DiId = _dto.DiId;
  16838. request.UserId = _dto.UserId;
  16839. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16840. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16841. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16842. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16843. var infos = new List<TourClientListInfo>();
  16844. foreach (var data in datas)
  16845. {
  16846. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16847. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16848. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16849. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16850. {
  16851. continue;
  16852. }
  16853. infos.Add(new TourClientListInfo()
  16854. {
  16855. IsAccompany = 1,
  16856. LastName = lastName,
  16857. FirstName = firstName,
  16858. Pinyin = lastNameEn + @"/" + firstNameEn,
  16859. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  16860. CompanyFullName = data.CompanyFullName,
  16861. Job = data.Job
  16862. });
  16863. }
  16864. if (infos.Any())
  16865. {
  16866. var viewData = await _tourClientListRep._AddMultiple(request);
  16867. if (viewData.Code != 0)
  16868. {
  16869. return Ok(JsonView(false, viewData.Msg));
  16870. }
  16871. return Ok(JsonView(true));
  16872. }
  16873. return Ok(JsonView(false));
  16874. }
  16875. /// <summary>
  16876. /// 接团客户名单
  16877. /// AddMultiple(添加多个)
  16878. /// </summary>
  16879. /// <param name="_dto"></param>
  16880. /// <returns></returns>
  16881. [HttpPost]
  16882. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16883. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16884. {
  16885. #region 参数验证
  16886. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16887. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16888. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16889. #region 页面操作权限验证
  16890. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16891. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16892. #endregion
  16893. #endregion
  16894. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16895. if (viewData.Code != 0)
  16896. {
  16897. return Ok(JsonView(false, viewData.Msg));
  16898. }
  16899. return Ok(JsonView(true));
  16900. }
  16901. /// <summary>
  16902. /// 接团客户名单
  16903. /// Del
  16904. /// </summary>
  16905. /// <param name="_dto"></param>
  16906. /// <returns></returns>
  16907. [HttpPost]
  16908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16909. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16910. {
  16911. #region 参数验证
  16912. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16913. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16914. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16915. #region 页面操作权限验证
  16916. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16917. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16918. #endregion
  16919. #endregion
  16920. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16921. if (viewData.Code != 0)
  16922. {
  16923. return Ok(JsonView(false, viewData.Msg));
  16924. }
  16925. return Ok(JsonView(true));
  16926. }
  16927. /// <summary>
  16928. /// 接团客户名单
  16929. /// 文件下载 客户名单
  16930. /// </summary>
  16931. /// <param name="_dto"></param>
  16932. /// <returns></returns>
  16933. [HttpPost]
  16934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16935. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16936. {
  16937. #region 参数验证
  16938. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16939. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16940. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16941. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16942. #region 页面操作权限验证
  16943. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16944. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16945. #endregion
  16946. #endregion
  16947. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16948. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16949. From Grp_TourClientList tcl
  16950. Left Join
  16951. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16952. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16953. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16954. From Crm_DeleClient dc
  16955. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16956. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16957. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16958. Where dc.IsDel = 0) temp
  16959. On temp.DcId =tcl.ClientId
  16960. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16961. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16962. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16963. //载入模板
  16964. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16965. if (_dto.Language == 1)
  16966. {
  16967. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16968. }
  16969. //载入模板
  16970. var doc = new Document(tempPath);
  16971. DocumentBuilder builder = new DocumentBuilder(doc);
  16972. //获取word里所有表格
  16973. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16974. //获取所填表格的序数
  16975. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16976. var rowStart = tableOne.Rows[0]; //获取第1行
  16977. if (_dto.Language == 0)
  16978. {
  16979. //循环赋值
  16980. for (int i = 0; i < DcList.Count; i++)
  16981. {
  16982. EncryptionProcessor.DecryptProperties(DcList[i]);
  16983. builder.MoveToCell(0, i + 1, 0, 0);
  16984. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16985. builder.MoveToCell(0, i + 1, 1, 0);
  16986. int sex = DcList[i].Sex;
  16987. string sexStr = string.Empty;
  16988. if (sex == 0) sexStr = "男";
  16989. else if (sex == 1) sexStr = "女";
  16990. else sexStr = "未设置";
  16991. builder.Write(sexStr);
  16992. builder.MoveToCell(0, i + 1, 2, 0);
  16993. string birthDay = DcList[i].BirthDay;
  16994. string birthDayStr = string.Empty;
  16995. if (!string.IsNullOrEmpty(birthDay))
  16996. {
  16997. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16998. }
  16999. builder.Write(birthDayStr);
  17000. builder.MoveToCell(0, i + 1, 3, 0);
  17001. string company = "";
  17002. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  17003. {
  17004. company = DcList[i].CompanyFullName.ToString();
  17005. }
  17006. builder.Write(company);
  17007. builder.MoveToCell(0, i + 1, 4, 0);
  17008. builder.Write(DcList[i].Job);
  17009. }
  17010. }
  17011. else if (_dto.Language == 1)
  17012. {
  17013. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  17014. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  17015. List<string> transArrayStr = new List<string>();
  17016. string transStrRes1 = "";
  17017. for (int i = 0; i < DcList.Count; i++)
  17018. {
  17019. var dc = DcList[i];
  17020. EncryptionProcessor.DecryptProperties(dc);
  17021. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  17022. if (dc.Job.Equals("暂无")) dc.Job = "-";
  17023. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  17024. if (DcList.Count - 1 == i) transStrRes1 += str1;
  17025. else transStrRes1 += $"{str1}|";
  17026. }
  17027. //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";
  17028. string transStrRes = "";
  17029. if (transStrRes1.Length > 0)
  17030. {
  17031. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  17032. }
  17033. //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
  17034. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  17035. //List<string> transArray = new List<string> { };
  17036. List<TranslateInfo> transArray = new List<TranslateInfo>();
  17037. if (transStrRes.Contains("|"))
  17038. {
  17039. string[] transArray1 = transStrRes.Split('|');
  17040. if (transArray1.Length > 0)
  17041. {
  17042. foreach (var item in transArray1)
  17043. {
  17044. if (item.Contains("&"))
  17045. {
  17046. string[] transArray2 = item.Split('&');
  17047. int index = 0;
  17048. string companyName = "", job = "";
  17049. if (transArray2.Length > 0)
  17050. {
  17051. bool success = int.TryParse(transArray2[0].Trim(), out index);
  17052. if (1 < transArray2.Length) companyName = transArray2[1];
  17053. if (2 < transArray2.Length) job = transArray2[2];
  17054. }
  17055. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  17056. }
  17057. }
  17058. }
  17059. }
  17060. //循环赋值
  17061. for (int i = 0; i < DcList.Count; i++)
  17062. {
  17063. string PYName = "";
  17064. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  17065. {
  17066. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  17067. string PY_First = DcList[i].Pinyin.Split('/')[1];
  17068. PYName = PY_First + " " + PY_Last;
  17069. }
  17070. else
  17071. {
  17072. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  17073. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  17074. PYName = PY_First + " " + PY_Last;
  17075. }
  17076. builder.MoveToCell(0, i + 1, 0, 0);
  17077. builder.Write(PYName);
  17078. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  17079. builder.MoveToCell(0, i + 1, 1, 0);
  17080. builder.Write(sex);
  17081. DateTime birthDt;
  17082. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  17083. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  17084. builder.MoveToCell(0, i + 1, 2, 0);
  17085. builder.Write(birthday);
  17086. string company = string.Empty, job = string.Empty;
  17087. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  17088. if (dcTransInfo != null)
  17089. {
  17090. company = dcTransInfo.CompanyName;
  17091. job = dcTransInfo.Job;
  17092. }
  17093. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  17094. {
  17095. //查询对照表
  17096. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  17097. if (tempCec != null)
  17098. {
  17099. company = tempCec.enName;
  17100. }
  17101. //翻译
  17102. else
  17103. {
  17104. }
  17105. }
  17106. builder.MoveToCell(0, i + 1, 3, 0);
  17107. builder.Write(company);
  17108. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  17109. {
  17110. //查询对照表
  17111. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  17112. if (tempPec != null)
  17113. {
  17114. job = tempPec.enName;
  17115. }
  17116. //翻译
  17117. else
  17118. {
  17119. }
  17120. }
  17121. builder.MoveToCell(0, i + 1, 4, 0);
  17122. builder.Write(job);
  17123. }
  17124. }
  17125. //删除多余行
  17126. while (tableOne.Rows.Count > DcList.Count + 1)
  17127. {
  17128. tableOne.Rows.RemoveAt(DcList.Count + 1);
  17129. }
  17130. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  17131. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  17132. doc.Save(fileDir);
  17133. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  17134. return Ok(JsonView(true, "操作成功!", Url));
  17135. }
  17136. private class TranslateInfo
  17137. {
  17138. public int Index { get; set; }
  17139. public string CompanyName { get; set; }
  17140. public string Job { get; set; }
  17141. }
  17142. #endregion
  17143. #region 团组倒推表
  17144. /// <summary>
  17145. /// 倒推表基础数据
  17146. /// Init
  17147. /// </summary>
  17148. /// <returns></returns>
  17149. [HttpPost]
  17150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17151. public async Task<IActionResult> PostInvertedListInit()
  17152. {
  17153. var viewData = await _invertedListRep._Init();
  17154. if (viewData.Code != 0)
  17155. {
  17156. return Ok(JsonView(false, viewData.Msg));
  17157. }
  17158. return Ok(JsonView(viewData.Data));
  17159. }
  17160. /// <summary>
  17161. /// 倒推表
  17162. /// Info
  17163. /// </summary>
  17164. /// <param name="dto"></param>
  17165. /// <returns></returns>
  17166. [HttpPost]
  17167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17168. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  17169. {
  17170. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  17171. if (viewData.Code != 0)
  17172. {
  17173. return Ok(JsonView(false, viewData.Msg));
  17174. }
  17175. return Ok(JsonView(viewData.Data));
  17176. }
  17177. /// <summary>
  17178. /// 倒推表
  17179. /// Create
  17180. /// </summary>
  17181. /// <param name="dto"></param>
  17182. /// <returns></returns>
  17183. [HttpPost]
  17184. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17185. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  17186. {
  17187. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  17188. if (viewData.Code != 0)
  17189. {
  17190. return Ok(JsonView(false, viewData.Msg));
  17191. }
  17192. return Ok(JsonView(viewData.Data));
  17193. }
  17194. /// <summary>
  17195. /// 倒推表
  17196. /// Update
  17197. /// </summary>
  17198. /// <param name="dto"></param>
  17199. /// <returns></returns>
  17200. [HttpPost]
  17201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17202. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  17203. {
  17204. var viewData = await _invertedListRep._Update(dto);
  17205. if (viewData.Code != 0)
  17206. {
  17207. return Ok(JsonView(false, viewData.Msg));
  17208. }
  17209. return Ok(JsonView(viewData.Data));
  17210. }
  17211. /// <summary>
  17212. /// 倒推表
  17213. /// File Download
  17214. /// </summary>
  17215. /// <param name="dto"></param>
  17216. /// <returns></returns>
  17217. [HttpPost]
  17218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17219. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  17220. {
  17221. var info2 = await _invertedListRep._Info(1, dto.DiId);
  17222. if (info2.Code != 0)
  17223. {
  17224. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  17225. }
  17226. var info1 = info2.Data as InvertedListInfoView;
  17227. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  17228. string teamName = "";
  17229. if (info != null) teamName = info.TeamName;
  17230. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  17231. var doc = new Document();
  17232. var builder = new DocumentBuilder(doc);
  17233. #region old insert
  17234. ////载入模板
  17235. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  17236. //Document doc = new Document(tempPath);
  17237. //DocumentBuilder builder = new DocumentBuilder(doc);
  17238. //利用键值对存放数据
  17239. //Dictionary<string, string> dic = new Dictionary<string, string>();
  17240. //dic.Add("TeamName", teamName);
  17241. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  17242. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  17243. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  17244. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  17245. //dic.Add("SQRemark", info1.ApprovalRemark);
  17246. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  17247. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  17248. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  17249. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  17250. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  17251. //dic.Add("QZRemark", info1.VisaInformationRemark);
  17252. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  17253. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  17254. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  17255. //dic.Add("CQRemark", info1.IssueVisaRemark);
  17256. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  17257. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  17258. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  17259. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  17260. //#region 填充word模板书签内容
  17261. //foreach (var key in dic.Keys)
  17262. //{
  17263. // builder.MoveToBookmark(key);
  17264. // builder.Write(dic[key]);
  17265. //}
  17266. //#endregion
  17267. #endregion
  17268. #region New Insert
  17269. string titleFont = $"仿宋",
  17270. contentFont = $"仿宋";
  17271. var fontColor = Color.FromArgb(64, 64, 64);
  17272. //设置标题 团组名称
  17273. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17274. builder.Font.Name = titleFont;
  17275. builder.Font.Color = fontColor;
  17276. builder.Font.Size = 12;
  17277. builder.Font.Bold = true;
  17278. builder.Writeln(teamName);
  17279. //设置副标题 团组出访时间
  17280. builder.Font.Size = 12;
  17281. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  17282. builder.Writeln();
  17283. var backgroundColor = Color.FromArgb(199, 199, 199);
  17284. var table = builder.StartTable();
  17285. builder.InsertCell();
  17286. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  17287. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  17288. builder.CellFormat.Borders.LineWidth = 1;
  17289. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  17290. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  17291. builder.RowFormat.Height = 40;
  17292. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17293. builder.Font.Name = contentFont;
  17294. builder.Font.Size = 12;
  17295. builder.Font.Bold = true;
  17296. builder.Font.Color = fontColor;
  17297. builder.Write("时间");
  17298. builder.InsertCell();
  17299. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  17300. builder.Write("流程");
  17301. builder.InsertCell();
  17302. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  17303. builder.Write("说明");
  17304. builder.EndRow();
  17305. //报批资料准备
  17306. if (info1.IsSelectedAirportd)
  17307. {
  17308. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  17309. }
  17310. //报批/提供送签资料
  17311. if (info1.IsSelectedApprovalData)
  17312. {
  17313. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  17314. }
  17315. //出批件护照办理
  17316. if (info1.IsSelectedIssueApproval)
  17317. {
  17318. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  17319. }
  17320. //签证资料准备
  17321. if (info1.IsSelectedVisaInfo)
  17322. {
  17323. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  17324. }
  17325. //送签
  17326. if (info1.IsSelectedSendVisa)
  17327. {
  17328. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  17329. }
  17330. //出签
  17331. if (info1.IsSelectedIssueVisa)
  17332. {
  17333. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  17334. }
  17335. //机票
  17336. if (info1.IsSelectedAirTicket)
  17337. {
  17338. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  17339. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  17340. }
  17341. //酒店
  17342. if (info1.IsSelectedHotel)
  17343. {
  17344. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  17345. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  17346. }
  17347. //开行前会
  17348. if (info1.IsSelectedPreTripMeeting)
  17349. {
  17350. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  17351. }
  17352. //送机
  17353. if (info1.IsSelectedAirportdDropOff)
  17354. {
  17355. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  17356. }
  17357. builder.EndTable();
  17358. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  17359. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  17360. for (int i = 0; i < table.Rows.Count; i++)
  17361. {
  17362. var row = table.Rows[i];
  17363. //设置宽度
  17364. row.Cells[0].CellFormat.Width = 20.00;
  17365. row.Cells[1].CellFormat.Width = 30.00;
  17366. row.Cells[2].CellFormat.Width = 50.00;
  17367. if (i != 0)
  17368. {
  17369. //边框设置
  17370. InvertedListFileDownloadSetBorders(row.Cells, 0);
  17371. InvertedListFileDownloadSetBorders(row.Cells, 1);
  17372. InvertedListFileDownloadSetBorders(row.Cells, 2);
  17373. }
  17374. }
  17375. #region 页脚插入图片
  17376. // 创建页脚
  17377. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  17378. doc.FirstSection.HeadersFooters.Add(footer);
  17379. Paragraph para = new Paragraph(doc);
  17380. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  17381. footer.AppendChild(para);
  17382. builder.MoveTo(para);
  17383. string imagePath = "./Images/FMGJ_Log.png";
  17384. builder.InsertImage(imagePath);
  17385. #endregion
  17386. #endregion
  17387. var fileDir = AppSettingsHelper.Get("WordBasePath");
  17388. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  17389. string filePath = fileDir + $@"InvertedList/{fileName}";
  17390. doc.Save(filePath);
  17391. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  17392. return Ok(JsonView(true, "操作成功!", Url));
  17393. }
  17394. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime,string content,string reamrk)
  17395. {
  17396. var fontColor = Color.FromArgb(64, 64, 64);
  17397. builder.InsertCell();
  17398. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  17399. builder.RowFormat.Height = 40;
  17400. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17401. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17402. builder.Font.Name = fontName;
  17403. builder.Font.Size = 8;
  17404. builder.Font.Bold = true;
  17405. builder.Font.Color = fontColor;
  17406. builder.Write(dateTime);
  17407. builder.InsertCell();
  17408. builder.Font.Size = 9;
  17409. builder.Font.Bold = true;
  17410. builder.Font.Color = fontColor;
  17411. builder.Write(content);
  17412. builder.InsertCell();
  17413. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  17414. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17415. builder.Font.Size = 9;
  17416. builder.Font.Bold = false;
  17417. builder.Font.Color = fontColor;
  17418. builder.Write(reamrk);
  17419. builder.EndRow();
  17420. }
  17421. private void InvertedListFileDownloadSetBorders(CellCollection cell,int index)
  17422. {
  17423. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  17424. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  17425. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  17426. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  17427. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  17428. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  17429. }
  17430. #endregion
  17431. #region 会务倒推表
  17432. /// <summary>
  17433. /// 会务倒推表
  17434. /// Init
  17435. /// </summary>
  17436. /// <returns></returns>
  17437. [HttpPost]
  17438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17439. public async Task<IActionResult> InforRetrogressTableInit()
  17440. {
  17441. var groupData = await _groupRepository.PostShareGroupInfos(1);
  17442. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  17443. return Ok(JsonView(false, groupData.Msg));
  17444. }
  17445. /// <summary>
  17446. /// 会务倒推表
  17447. /// ExcelDownload
  17448. /// </summary>
  17449. /// <param name="dto"></param>
  17450. /// <returns></returns>
  17451. [HttpPost]
  17452. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  17453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17454. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  17455. {
  17456. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  17457. var validatorRes = await validator.ValidateAsync(dto);
  17458. if (!validatorRes.IsValid)
  17459. {
  17460. StringBuilder sb = new StringBuilder();
  17461. foreach (var item in validatorRes.Errors)
  17462. {
  17463. sb.AppendLine(item.ErrorMessage);
  17464. }
  17465. return Ok(JsonView(false, sb.ToString()));
  17466. }
  17467. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  17468. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  17469. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  17470. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  17471. #region Excel
  17472. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  17473. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  17474. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  17475. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  17476. var fileNamePrefix = string.Empty;
  17477. if (days >= 30)
  17478. {
  17479. tempPath += $"会务工作倒推进度表(30天).xlsx";
  17480. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  17481. }
  17482. else if (days < 30 && days > 7)
  17483. {
  17484. tempPath += $"会务工作倒推进度表(15天).xlsx";
  17485. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  17486. }
  17487. else if (days <= 7)
  17488. {
  17489. tempPath += $"会务工作倒推进度表(7天).xlsx";
  17490. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  17491. }
  17492. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  17493. fileName = CommonFun.ValidFileName(fileName);
  17494. //载入模板
  17495. WorkbookDesigner designer = new WorkbookDesigner();
  17496. designer.Workbook = new Workbook(tempPath);
  17497. designer.Process();
  17498. if (!Directory.Exists(savePath))
  17499. {
  17500. Directory.CreateDirectory(savePath);
  17501. }
  17502. string serverPath = $"{savePath}{fileName}";
  17503. designer.Workbook.Save(serverPath);
  17504. string rst = $"{servicePath}{ftpPath}{fileName}";
  17505. #endregion
  17506. return Ok(JsonView(new { url = rst }));
  17507. }
  17508. #endregion
  17509. #region 三公签证费用(签证费、代办费)
  17510. /// <summary>
  17511. /// 三公签证费用(签证费、代办费)
  17512. /// List
  17513. /// </summary>
  17514. /// <returns></returns>
  17515. [HttpPost]
  17516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17517. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  17518. {
  17519. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  17520. if (_view.Code != 0)
  17521. {
  17522. return Ok(JsonView(false, _view.Msg));
  17523. }
  17524. return Ok(JsonView(true, "操作成功!", _view.Data));
  17525. }
  17526. /// <summary>
  17527. /// 三公签证费用(签证费、代办费)
  17528. /// Add Or Update
  17529. /// </summary>
  17530. /// <returns></returns>
  17531. [HttpPost]
  17532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17533. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  17534. {
  17535. var _view = await _visaFeeInfoRep._Update(_dto);
  17536. if (_view.Code != 0)
  17537. {
  17538. return Ok(JsonView(false, _view.Msg));
  17539. }
  17540. return Ok(JsonView(true, _view.Msg));
  17541. }
  17542. #endregion
  17543. #region 酒店询价
  17544. /// <summary>
  17545. /// 酒店询价
  17546. /// Init
  17547. /// </summary>
  17548. /// <returns></returns>
  17549. [HttpPost]
  17550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17551. public async Task<IActionResult> PostHotelInquiryInit()
  17552. {
  17553. var res = await _hotelInquiryRep._Init();
  17554. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17555. return Ok(JsonView(true, res.Msg, res.Data));
  17556. }
  17557. /// <summary>
  17558. /// 酒店询价
  17559. /// page Item
  17560. /// </summary>
  17561. /// <param name="_dto"></param>
  17562. /// <returns></returns>
  17563. [HttpPost]
  17564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17565. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  17566. {
  17567. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  17568. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17569. var view = res.Data as PageDataViewBase;
  17570. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  17571. }
  17572. /// <summary>
  17573. /// 酒店询价
  17574. /// info
  17575. /// </summary>
  17576. /// <param name="_dto"></param>
  17577. /// <returns></returns>
  17578. [HttpPost]
  17579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17580. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  17581. {
  17582. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  17583. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17584. return Ok(JsonView(true, res.Msg, res.Data));
  17585. }
  17586. /// <summary>
  17587. /// 酒店询价
  17588. /// Add Or Edit
  17589. /// </summary>
  17590. /// <param name="_dto"></param>
  17591. /// <returns></returns>
  17592. [HttpPost]
  17593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17594. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  17595. {
  17596. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  17597. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17598. return Ok(JsonView(true, res.Msg, res.Data));
  17599. }
  17600. /// <summary>
  17601. /// 酒店询价
  17602. /// Del
  17603. /// </summary>
  17604. /// <param name="_dto"></param>
  17605. /// <returns></returns>
  17606. [HttpPost]
  17607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17608. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  17609. {
  17610. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  17611. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  17612. return Ok(JsonView(true, res.Msg, res.Data));
  17613. }
  17614. #endregion
  17615. #region 下载匹配op行程单
  17616. /// <summary>
  17617. /// 匹配op行程单
  17618. /// Init
  17619. /// </summary>
  17620. /// <param name="dto">团组列表请求dto</param>
  17621. /// <returns></returns>
  17622. [HttpPost]
  17623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17624. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  17625. {
  17626. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17627. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  17628. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  17629. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  17630. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  17631. .Where(it => it.IsDel == 0)
  17632. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  17633. .OrderByDescending(it => it.VisitStartDate)
  17634. .ToList();
  17635. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  17636. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17637. var diids = groupInfos.Select(it => it.Id).ToList();
  17638. List<string> countrys = new List<string>();
  17639. foreach (var item in country)
  17640. {
  17641. var data = _groupRepository.FormartTeamName(item);
  17642. var dataArray = _groupRepository.GroupSplitCountry(data);
  17643. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17644. }
  17645. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  17646. List<string> areaArray = new List<string>(); //GetGroupCityLine
  17647. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  17648. foreach (var item in areaItem)
  17649. {
  17650. string areaStr = item.Value;
  17651. if (!string.IsNullOrEmpty(areaStr))
  17652. {
  17653. string[] str1 = areaStr.Split("-");
  17654. if (str1.Length > 0)
  17655. {
  17656. areaArray.AddRange(str1);
  17657. }
  17658. }
  17659. }
  17660. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  17661. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  17662. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  17663. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  17664. .ToList();
  17665. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  17666. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  17667. .Where(it => countriesIds.Contains(it.Id))
  17668. .Select(it => new { it.Id, Name = it.Name_CN })
  17669. .ToList();
  17670. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  17671. .Select(it => it.TeamName).ToList();
  17672. stopwatch.Stop();
  17673. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  17674. }
  17675. ///// <summary>
  17676. ///// 匹配op行程单
  17677. ///// Init 查询区域数据
  17678. ///// </summary>
  17679. ///// <param name="dto">团组列表请求dto</param>
  17680. ///// <returns></returns>
  17681. //[HttpPost]
  17682. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17683. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  17684. //{
  17685. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  17686. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  17687. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  17688. // if (string.IsNullOrEmpty(countriesDataStr))
  17689. // {
  17690. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  17691. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  17692. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  17693. // }
  17694. // else
  17695. // {
  17696. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  17697. // }
  17698. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  17699. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  17700. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  17701. // List<dynamic> childList = new List<dynamic>();
  17702. // int parentId = dto.CountriesId;
  17703. // if (provinceData.Count > 1)
  17704. // {
  17705. // foreach (var item1 in provinceData)
  17706. // {
  17707. // List<dynamic> childList1 = new List<dynamic>();
  17708. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  17709. // foreach (var item2 in citiesData1)
  17710. // {
  17711. // List<dynamic> childList2 = new List<dynamic>();
  17712. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17713. // foreach (var item3 in countiesData1)
  17714. // {
  17715. // childList2.Add(new
  17716. // {
  17717. // id = item3.Id,
  17718. // parentId = item2.Id,
  17719. // level = "district",
  17720. // name = item3.Name_CN,
  17721. // });
  17722. // }
  17723. // childList1.Add(new
  17724. // {
  17725. // id = item2.Id,
  17726. // parentId = item1.Id,
  17727. // level = "city",
  17728. // name = item2.Name_CN,
  17729. // childList = childList2
  17730. // });
  17731. // }
  17732. // childList.Add(new
  17733. // {
  17734. // id = item1.Id,
  17735. // parentId = parentId,
  17736. // level = "province",
  17737. // name = item1.Name_CN,
  17738. // childList = childList1
  17739. // });
  17740. // }
  17741. // //城市
  17742. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  17743. // foreach (var item2 in citiesData2)
  17744. // {
  17745. // List<dynamic> childList22 = new List<dynamic>();
  17746. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17747. // foreach (var item3 in countiesData1)
  17748. // {
  17749. // childList22.Add(new
  17750. // {
  17751. // id = item3.Id,
  17752. // parentId = item2.Id,
  17753. // level = "district",
  17754. // name = item3.Name_CN,
  17755. // });
  17756. // }
  17757. // childList.Add(new
  17758. // {
  17759. // id = item2.Id,
  17760. // parentId = parentId,
  17761. // level = "city",
  17762. // name = item2.Name_CN,
  17763. // childList = childList22
  17764. // });
  17765. // }
  17766. // }
  17767. // else
  17768. // {
  17769. // foreach (var item2 in citiesData)
  17770. // {
  17771. // string cname = item2.Name_CN;
  17772. // List<dynamic> childList1 = new List<dynamic>();
  17773. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  17774. // foreach (var item3 in countiesData1)
  17775. // {
  17776. // childList1.Add(new
  17777. // {
  17778. // Id = item3.Id,
  17779. // parentId = item2.Id,
  17780. // level = "district",
  17781. // name = item3.Name_CN
  17782. // });
  17783. // }
  17784. // childList.Add(new
  17785. // {
  17786. // id = item2.Id,
  17787. // parentId = parentId,
  17788. // level = "city",
  17789. // name = item2.Name_CN,
  17790. // childList = childList1
  17791. // });
  17792. // }
  17793. // }
  17794. // stopwatch.Stop();
  17795. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  17796. //}
  17797. /// <summary>
  17798. /// 匹配op行程单
  17799. /// 接团信息列表 Page
  17800. /// </summary>
  17801. /// <param name="dto">团组列表请求dto</param>
  17802. /// <returns></returns>
  17803. [HttpPost]
  17804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17805. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  17806. {
  17807. var swatch = new Stopwatch();
  17808. swatch.Start();
  17809. #region 参数验证
  17810. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17811. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17812. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17813. #region 页面操作权限验证
  17814. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17815. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  17816. #endregion
  17817. #endregion
  17818. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17819. {
  17820. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  17821. //string sqlWhere = "";
  17822. if (!string.IsNullOrEmpty(dto.Country))
  17823. {
  17824. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  17825. }
  17826. if (!string.IsNullOrEmpty(dto.Area))
  17827. {
  17828. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  17829. }
  17830. if (!string.IsNullOrEmpty(dto.TeamName))
  17831. {
  17832. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  17833. }
  17834. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  17835. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  17836. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  17837. swatch.Stop();
  17838. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  17839. }
  17840. else
  17841. {
  17842. return Ok(JsonView(false, "查询失败"));
  17843. }
  17844. }
  17845. /// <summary>
  17846. /// 匹配op行程单
  17847. /// 行程单下载
  17848. /// </summary>
  17849. /// <param name="dto">团组列表请求dto</param>
  17850. /// <returns></returns>
  17851. [HttpPost]
  17852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17853. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  17854. {
  17855. #region 参数验证
  17856. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17857. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  17858. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17859. #region 页面操作权限验证
  17860. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  17861. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  17862. #endregion
  17863. #endregion
  17864. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  17865. {
  17866. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  17867. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  17868. }
  17869. else
  17870. {
  17871. return Ok(JsonView(false, "下载失败!"));
  17872. }
  17873. }
  17874. #endregion
  17875. #region 国家信息 数据 注释
  17876. //[HttpPost]
  17877. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  17878. //{
  17879. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  17880. // foreach (var item in dto)
  17881. // {
  17882. // infos.Add(new Grp_GroupsTaskAssignment()
  17883. // {
  17884. // DIId = item,
  17885. // CTId = 82,
  17886. // UId = 248,
  17887. // IsEnable = 1,
  17888. // CreateUserId = 233,
  17889. // CreateTime = DateTime.Now,
  17890. // IsDel = 0
  17891. // });
  17892. // infos.Add(new Grp_GroupsTaskAssignment()
  17893. // {
  17894. // DIId = item,
  17895. // CTId = 82,
  17896. // UId = 286,
  17897. // IsEnable = 1,
  17898. // CreateUserId = 233,
  17899. // CreateTime = DateTime.Now,
  17900. // IsDel = 0
  17901. // });
  17902. // }
  17903. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  17904. // return Ok("操作成功");
  17905. //}
  17906. //public class paramJsonDto
  17907. //{
  17908. // public List<CountriesInfo> str { get; set; }
  17909. //}
  17910. //[HttpPost]
  17911. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  17912. //{
  17913. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  17914. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  17915. // List<Sys_Cities> cities = new List<Sys_Cities>();
  17916. // List<Sys_Cities> districts = new List<Sys_Cities>();
  17917. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17918. // _sqlSugar.BeginTran();
  17919. // int countitiesIndex = 0;
  17920. // foreach (var item in dto.str)
  17921. // {
  17922. // dynamic data = item.c;
  17923. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  17924. // if (data != null)
  17925. // {
  17926. // countitiesIndex++;
  17927. // foreach (var item1 in data)
  17928. // {
  17929. // string cnname = item1.cn;
  17930. // string enname = item1.en;
  17931. // Sys_Cities provinceInfo = new Sys_Cities()
  17932. // {
  17933. // CountriesId = countriesId,
  17934. // Name_CN = cnname,
  17935. // Name_EN = enname,
  17936. // ParentId = 0,
  17937. // IsCapital = 1,
  17938. // CreateUserId = 208,
  17939. // CreateTime = DateTime.Now,
  17940. // IsDel = 0
  17941. // };
  17942. // if (item1.lv == "province") //省份
  17943. // {
  17944. // provinceInfo.Level = 1;
  17945. // int provinceId = 0;
  17946. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  17947. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  17948. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17949. // var data1 = item1.c;
  17950. // foreach (var item2 in data1)
  17951. // {
  17952. // if (item2.lv == "city")
  17953. // {
  17954. // string citycnname = item2.cn;
  17955. // string cityenname = item2.en;
  17956. // Sys_Cities cityInfo = new Sys_Cities()
  17957. // {
  17958. // CountriesId = countriesId,
  17959. // ParentId = provinceId,
  17960. // Level = 2,
  17961. // Name_CN = citycnname,
  17962. // Name_EN = cityenname,
  17963. // IsCapital = 1,
  17964. // CreateUserId = 208,
  17965. // CreateTime = DateTime.Now,
  17966. // IsDel = 0
  17967. // };
  17968. // if (item2.c != null)
  17969. // {
  17970. // int cityId = 0;
  17971. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  17972. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17973. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  17974. // foreach (var item3 in item2.c)
  17975. // {
  17976. // if (item3.lv == "district")
  17977. // {
  17978. // var districtInfo = new Sys_Cities()
  17979. // {
  17980. // CountriesId = countriesId,
  17981. // Name_CN = item3.cn,
  17982. // Name_EN = item3.en,
  17983. // Level = 3,
  17984. // ParentId = cityId,
  17985. // IsCapital = 1,
  17986. // CreateUserId = 208,
  17987. // CreateTime = DateTime.Now,
  17988. // IsDel = 0
  17989. // };
  17990. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17991. // //{
  17992. // districts.Add(districtInfo);
  17993. // //}
  17994. // }
  17995. // }
  17996. // }
  17997. // else
  17998. // {
  17999. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  18000. // //{
  18001. // cities.Add(cityInfo);
  18002. // //}
  18003. // }
  18004. // }
  18005. // }
  18006. // }
  18007. // else if (item1.lv == "city")//城市
  18008. // {
  18009. // provinceInfo.Level = 2;
  18010. // if (item1.c != null)
  18011. // {
  18012. // int cityId = 0;
  18013. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  18014. // if (citiesInfo != null) cityId = citiesInfo.Id;
  18015. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  18016. // foreach (var item3 in item1.c)
  18017. // {
  18018. // if (item3.lv == "district")
  18019. // {
  18020. // var districtInfo = new Sys_Cities()
  18021. // {
  18022. // CountriesId = countriesId,
  18023. // Name_CN = item3.cn,
  18024. // Name_EN = item3.en,
  18025. // Level = 3,
  18026. // ParentId = cityId,
  18027. // IsCapital = 1,
  18028. // CreateUserId = 208,
  18029. // CreateTime = DateTime.Now,
  18030. // IsDel = 0
  18031. // };
  18032. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  18033. // //{
  18034. // districts.Add(districtInfo);
  18035. // //}
  18036. // }
  18037. // }
  18038. // }
  18039. // else
  18040. // {
  18041. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  18042. // //{
  18043. // cities.Add(provinceInfo);
  18044. // //}
  18045. // }
  18046. // }
  18047. // }
  18048. // }
  18049. // }
  18050. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  18051. // cities = cities.Distinct().ToList();
  18052. // districts = districts.Distinct().ToList();
  18053. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  18054. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  18055. // cities.AddRange(districts);
  18056. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  18057. // //_sqlSugar.RollbackTran();
  18058. // _sqlSugar.CommitTran();
  18059. // return Ok(JsonView(false, "操作成功!"));
  18060. //}
  18061. //[HttpPost]
  18062. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  18063. //{
  18064. // List<CountitiesInfo> infos = dto.MyProperty;
  18065. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  18066. // _sqlSugar.BeginTran();
  18067. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  18068. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  18069. // foreach (var item in infos)
  18070. // {
  18071. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  18072. // if (countryInfo != null)
  18073. // {
  18074. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  18075. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  18076. // if (cityInfo1 != null)
  18077. // {
  18078. // cityInfo1.IsCapital = 0;
  18079. // cityInfos.Add(cityInfo1);
  18080. // }
  18081. // }
  18082. // }
  18083. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  18084. // .UpdateColumns(it => it.IsCapital)
  18085. // .WhereColumns(it => it.Id)
  18086. // .ExecuteCommand();
  18087. // //_sqlSugar.RollbackTran();
  18088. // _sqlSugar.CommitTran();
  18089. // return Ok(JsonView(false, "操作成功!"));
  18090. //}
  18091. //public class CounrtiesDto
  18092. //{
  18093. // public List<CountitiesInfo> MyProperty { get; set; }
  18094. //}
  18095. //public class CountitiesInfo
  18096. //{
  18097. // /// <summary>
  18098. // /// 圣约翰
  18099. // /// </summary>
  18100. // public string capital_name_chinese { get; set; }
  18101. // /// <summary>
  18102. // ///
  18103. // /// </summary>
  18104. // public string capital_name { get; set; }
  18105. // /// <summary>
  18106. // ///
  18107. // /// </summary>
  18108. // public string country_type { get; set; }
  18109. // /// <summary>
  18110. // /// 安提瓜和巴布达
  18111. // /// </summary>
  18112. // public string country_name_chinese { get; set; }
  18113. // /// <summary>
  18114. // /// 安提瓜和巴布达
  18115. // /// </summary>
  18116. // public string country_name_chinese_short { get; set; }
  18117. // /// <summary>
  18118. // /// 安提瓜和巴布达
  18119. // /// </summary>
  18120. // public string country_name_chinese_UN { get; set; }
  18121. // /// <summary>
  18122. // ///
  18123. // /// </summary>
  18124. // public string country_name_english_abbreviation { get; set; }
  18125. // /// <summary>
  18126. // ///
  18127. // /// </summary>
  18128. // public string country_name_english_formal { get; set; }
  18129. // /// <summary>
  18130. // ///
  18131. // /// </summary>
  18132. // public string country_name_english_UN { get; set; }
  18133. // /// <summary>
  18134. // ///
  18135. // /// </summary>
  18136. // public string continent_name { get; set; }
  18137. // /// <summary>
  18138. // ///
  18139. // /// </summary>
  18140. // public string subregion_name { get; set; }
  18141. // /// <summary>
  18142. // ///
  18143. // /// </summary>
  18144. // public string country_code2 { get; set; }
  18145. // /// <summary>
  18146. // ///
  18147. // /// </summary>
  18148. // public string country_code3 { get; set; }
  18149. // /// <summary>
  18150. // ///
  18151. // /// </summary>
  18152. // public string phone_code { get; set; }
  18153. //}
  18154. //public class CountriesInfo : BasicInfo
  18155. //{
  18156. // public List<CitiesInfo> c { get; set; }
  18157. //}
  18158. //public class CitiesInfo : BasicInfo
  18159. //{
  18160. // public List<AreaInfo> c { get; set; }
  18161. //}
  18162. //public class AreaInfo : BasicInfo
  18163. //{
  18164. // public List<AreaInfo> c { get; set; }
  18165. //}
  18166. //public class BasicInfo
  18167. //{
  18168. // public string code { get; set; }
  18169. // public string cn { get; set; }
  18170. // public string lv { get; set; }
  18171. // public string en { get; set; }
  18172. //}
  18173. #endregion
  18174. #region 查看邀请方
  18175. /// <summary>
  18176. /// 查看邀请方
  18177. /// 邀请方信息 Init
  18178. /// </summary>
  18179. /// <param name="dto"></param>
  18180. /// <returns></returns>
  18181. [HttpPost]
  18182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18183. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  18184. {
  18185. string sqlWhere = string.Empty;
  18186. if (!string.IsNullOrEmpty(dto.Search))
  18187. {
  18188. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  18189. }
  18190. string sql = string.Format($@"Select
  18191. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  18192. Id,
  18193. UnitName
  18194. From Res_InvitationOfficialActivityData
  18195. Where IsDel = 0
  18196. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  18197. RefAsync<int> total = 0;
  18198. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18199. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  18200. }
  18201. /// <summary>
  18202. /// 查看邀请方
  18203. /// 国家信息 Init
  18204. /// </summary>
  18205. /// <param name="dto"></param>
  18206. /// <returns></returns>
  18207. [HttpPost]
  18208. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18209. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  18210. {
  18211. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  18212. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  18213. var diids = groupInfos.Select(it => it.Id).ToList();
  18214. List<string> countrys = new List<string>();
  18215. foreach (var item in country)
  18216. {
  18217. var data = _groupRepository.FormartTeamName(item);
  18218. var dataArray = _groupRepository.GroupSplitCountry(data);
  18219. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  18220. }
  18221. countrys = countrys.Distinct().ToList();
  18222. for (int i = 0; i < countrys.Count; i++)
  18223. {
  18224. string item = countrys[i];
  18225. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  18226. {
  18227. countrys.Remove(item);
  18228. i--;
  18229. }
  18230. }
  18231. RefAsync<int> total = 0;
  18232. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  18233. .Where(it => countrys.Contains(it.Name_CN))
  18234. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18235. .Select(it => new { id = it.Id, name = it.Name_CN })
  18236. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18237. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18238. }
  18239. /// <summary>
  18240. /// 查看邀请方
  18241. /// 城市信息 Init
  18242. /// </summary>
  18243. /// <param name="dto"></param>
  18244. /// <returns></returns>
  18245. [HttpPost]
  18246. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18247. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  18248. {
  18249. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  18250. RefAsync<int> total = 0;
  18251. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  18252. .Where(it => it.CountriesId == dto.CountiesId)
  18253. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  18254. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  18255. .Select(it => new { id = it.Id, name = it.Name_CN })
  18256. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18257. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  18258. }
  18259. /// <summary>
  18260. /// 查看邀请方
  18261. /// 团组名称 Init
  18262. /// </summary>
  18263. /// <param name="dto"></param>
  18264. /// <returns></returns>
  18265. [HttpPost]
  18266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18267. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  18268. {
  18269. var watch = new Stopwatch();
  18270. watch.Start();
  18271. RefAsync<int> total = 0;
  18272. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  18273. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  18274. .Where((oa, di) => oa.IsDel == 0)
  18275. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  18276. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  18277. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  18278. .Distinct()
  18279. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18280. watch.Stop();
  18281. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  18282. }
  18283. /// <summary>
  18284. /// 查看邀请方
  18285. /// 团组 & 邀请方信息
  18286. /// </summary>
  18287. /// <param name="dto"></param>
  18288. /// <returns></returns>
  18289. [HttpPost]
  18290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18291. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  18292. {
  18293. var watch = new Stopwatch();
  18294. watch.Start();
  18295. RefAsync<int> total = 0;
  18296. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  18297. .AS("Grp_DelegationInfo")
  18298. .Includes(x => x.InvitingInfos)
  18299. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  18300. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  18301. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  18302. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  18303. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  18304. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  18305. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  18306. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  18307. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  18308. infos.ForEach(x =>
  18309. {
  18310. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  18311. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  18312. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  18313. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  18314. });
  18315. watch.Stop();
  18316. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  18317. }
  18318. #endregion
  18319. #region 报批行程
  18320. /// <summary>
  18321. /// 报批行程初始化
  18322. /// </summary>
  18323. /// <param name="dto"></param>
  18324. /// <returns></returns>
  18325. [HttpPost]
  18326. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  18327. {
  18328. const int chiNumber = 5;
  18329. var jw = JsonView(false);
  18330. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  18331. var group = groupList.First();
  18332. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  18333. group = groupList.First(x => x.Id == diid);
  18334. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18335. .Where(x => x.DiId == diid && x.IsDel == 0)
  18336. .ToArray();
  18337. var count = 1;
  18338. foreach (var item in blackCodeList)
  18339. {
  18340. if (string.IsNullOrWhiteSpace(item.Title))
  18341. {
  18342. item.Title = "未设置名称数据" + count;
  18343. }
  18344. count++;
  18345. };
  18346. if (group == null)
  18347. {
  18348. jw.Msg = "暂无团组!";
  18349. return Ok(jw);
  18350. }
  18351. var data = new
  18352. {
  18353. groupList = groupList.Select(x => new
  18354. {
  18355. x.TeamName,
  18356. x.Id
  18357. }),
  18358. content = new ArrayList(),
  18359. groupInfo = new
  18360. {
  18361. group.VisitDays,
  18362. group.TourCode,
  18363. group.VisitPNumber,
  18364. group.TeamName,
  18365. group.Id,
  18366. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  18367. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  18368. },
  18369. blackCodeList = blackCodeList.Select(x => new
  18370. {
  18371. x.Title,
  18372. x.Id
  18373. }),
  18374. FileTempList = new ArrayList()
  18375. {
  18376. new { Index = 1,FileName = "旧模板" },
  18377. new { Index = 2,FileName = "省外办" },
  18378. new { Index = 3,FileName = "市外办" },
  18379. }
  18380. };
  18381. var resultArr = new ArrayList();
  18382. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  18383. #region 默认不生成行程
  18384. //if (content.Count == 0)
  18385. //{
  18386. // var stay = "-";
  18387. // var cityPath = "-";
  18388. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  18389. // .Where(x => x.DiId == diid && x.IsDel == 0)
  18390. // .ToList();
  18391. // //添加城市路径以及住宿地
  18392. // //黑屏代码数据
  18393. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  18394. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18395. // {
  18396. // jw = JsonView(true, "黑屏代码有误!", data);
  18397. // return Ok(jw);
  18398. // }
  18399. // data = data with
  18400. // {
  18401. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  18402. // {
  18403. // x.Title,
  18404. // x.Id,
  18405. // }).ToArray())
  18406. // };
  18407. // foreach (DataRow row in dtBlack.Rows)
  18408. // {
  18409. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18410. // {
  18411. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  18412. // return Ok(jw);
  18413. // }
  18414. // }
  18415. // //黑屏代码获取时间区间
  18416. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18417. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18418. // _sqlSugar.BeginTran();
  18419. // for (int i = 0; i < timeArr.Count; i++)
  18420. // {
  18421. // stay = "-";
  18422. // cityPath = "-";
  18423. // DateTime NewData = DateTime.Parse(timeArr[i]);
  18424. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18425. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18426. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18427. // if (tbSelect.Length > 0)
  18428. // {
  18429. // List<string> threeCodeStr = new List<string>();
  18430. // foreach (var item in tbSelect)
  18431. // {
  18432. // var threeCode = item["Three"].ToString() ?? "";
  18433. // if (threeCode.Length == 6)
  18434. // {
  18435. // var start = threeCode.Substring(0, 3);
  18436. // var end = threeCode.Substring(3, 3);
  18437. // if (threeCodeStr.Count == 0)
  18438. // {
  18439. // threeCodeStr.Add(start);
  18440. // threeCodeStr.Add(end);
  18441. // }
  18442. // else
  18443. // {
  18444. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18445. // {
  18446. // threeCodeStr.Add(end);
  18447. // }
  18448. // else
  18449. // {
  18450. // threeCodeStr.Add(start);
  18451. // threeCodeStr.Add(end);
  18452. // }
  18453. // }
  18454. // }
  18455. // }
  18456. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18457. // var last = threeCodeStr.Last();
  18458. // foreach (var item in threeCodeStr)
  18459. // {
  18460. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18461. // if (item.Equals(last))
  18462. // {
  18463. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18464. // }
  18465. // }
  18466. // cityPath = cityPath.Trim('-');
  18467. // }
  18468. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  18469. // appro.Diid = diid ?? -1;
  18470. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18471. // appro.Id = thisId;
  18472. // appro.CreateUserId = dto.UserId;
  18473. // appro.CreateTime = DateTime.Now;
  18474. // content.Add(appro);
  18475. // }
  18476. // _sqlSugar.CommitTran();
  18477. //}
  18478. #endregion
  18479. foreach (var x in content)
  18480. {
  18481. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  18482. if (chiList.Count < chiNumber)
  18483. {
  18484. for (int i = chiList.Count; i < chiNumber; i++)
  18485. {
  18486. chiList.Add(new Grp_ApprovalTravelDetails());
  18487. }
  18488. }
  18489. resultArr.Add(new
  18490. {
  18491. x.Id,
  18492. x.Date,
  18493. x.Diid,
  18494. chiList = chiList.Select(x1 => new
  18495. {
  18496. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18497. x1.Details,
  18498. x1.ParentId,
  18499. x1.Id
  18500. })
  18501. });
  18502. }
  18503. data = data with
  18504. {
  18505. content = resultArr,
  18506. };
  18507. jw = JsonView(true, "获取成功!", data);
  18508. return Ok(jw);
  18509. }
  18510. /// <summary>
  18511. /// 报批行程删除
  18512. /// </summary>
  18513. /// <param name="dto"></param>
  18514. /// <returns></returns>
  18515. [HttpPost]
  18516. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  18517. {
  18518. var jw = JsonView(false);
  18519. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18520. if (group == null)
  18521. {
  18522. jw.Msg = "团组参数有误!";
  18523. return Ok(jw);
  18524. }
  18525. try
  18526. {
  18527. _sqlSugar.BeginTran();
  18528. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  18529. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  18530. {
  18531. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18532. DeleteUserId = dto.uesrId,
  18533. IsDel = 1
  18534. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  18535. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  18536. {
  18537. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18538. DeleteUserId = dto.uesrId,
  18539. IsDel = 1
  18540. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  18541. _sqlSugar.CommitTran();
  18542. jw = JsonView(true, "删除成功");
  18543. }
  18544. catch (Exception ex)
  18545. {
  18546. jw = JsonView(false, ex.Message);
  18547. }
  18548. return Ok(jw);
  18549. }
  18550. /// <summary>
  18551. /// 报批行程保存
  18552. /// </summary>
  18553. /// <param name="dto"></param>
  18554. /// <returns></returns>
  18555. [HttpPost]
  18556. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  18557. {
  18558. var jw = JsonView(false);
  18559. var Find = dto.Arr.Find(x => x.id == 0);
  18560. if (Find != null)
  18561. {
  18562. jw.Msg = "生成的ID为0!";
  18563. return Ok(jw);
  18564. }
  18565. foreach (var item in dto.Arr)
  18566. {
  18567. foreach (var chi in item.chiList)
  18568. {
  18569. if (chi.parentId == 0)
  18570. {
  18571. chi.parentId = item.id;
  18572. }
  18573. }
  18574. }
  18575. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  18576. _sqlSugar.BeginTran();
  18577. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  18578. {
  18579. var parentIds = dto.Arr.Select(x => x.id).ToList();
  18580. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  18581. {
  18582. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  18583. DeleteUserId = dto.UserId,
  18584. IsDel = 1
  18585. }).ExecuteCommand();
  18586. }
  18587. try
  18588. {
  18589. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  18590. {
  18591. CreateTime = DateTime.Now,
  18592. CreateUserId = dto.UserId,
  18593. Details = x.details,
  18594. ParentId = x.parentId,
  18595. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18596. Remark = "",
  18597. IsDel = 0
  18598. }).ToList()).ExecuteCommand();
  18599. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  18600. {
  18601. Id = x.id,
  18602. Details = x.details,
  18603. ParentId = x.parentId,
  18604. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  18605. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  18606. {
  18607. Details = x.Details,
  18608. ParentId = x.ParentId,
  18609. Time = x.Time
  18610. }).ExecuteCommand();
  18611. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  18612. {
  18613. Id = x.id,
  18614. Date = x.date,
  18615. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  18616. {
  18617. Date = x.Date
  18618. }).ExecuteCommand();
  18619. _sqlSugar.CommitTran();
  18620. jw = JsonView(true, "保存成功!");
  18621. }
  18622. catch (Exception ex)
  18623. {
  18624. _sqlSugar.RollbackTran();
  18625. jw = JsonView(false, "保存失败!" + ex.Message);
  18626. }
  18627. return Ok(jw);
  18628. }
  18629. /// <summary>
  18630. /// 报批行程生成
  18631. /// </summary>
  18632. /// <param name="dto"></param>
  18633. /// <returns></returns>
  18634. [HttpPost]
  18635. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  18636. {
  18637. var jw = JsonView(false);
  18638. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18639. if (group == null)
  18640. {
  18641. jw.Msg = "暂无该团组!";
  18642. return Ok(jw);
  18643. }
  18644. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  18645. //黑屏代码数据
  18646. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  18647. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  18648. {
  18649. jw.Msg = "黑屏代码有误!";
  18650. return Ok(jw);
  18651. }
  18652. foreach (DataRow row in dtBlack.Rows)
  18653. {
  18654. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  18655. {
  18656. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  18657. return Ok(jw);
  18658. }
  18659. }
  18660. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  18661. var resultArr = new ArrayList();
  18662. //if (officialActivitiesArr.Count == 0)
  18663. //{
  18664. // jw.Msg = "暂无公务出访信息!";
  18665. // return Ok(jw);
  18666. //}
  18667. try
  18668. {
  18669. _sqlSugar.BeginTran();
  18670. DeleteApprovalJourney(new
  18671. Domain.Dtos.Groups.DeleteApprovalJourney
  18672. {
  18673. Diid = dto.Diid,
  18674. uesrId = dto.Userid
  18675. });
  18676. var stay = "-";
  18677. var cityPath = "-";
  18678. //添加城市路径以及住宿地
  18679. //黑屏代码获取时间区间
  18680. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  18681. var empty = "【未收入该三字码!请机票同事录入】";
  18682. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  18683. for (int i = 0; i < timeArr.Count; i++)
  18684. {
  18685. stay = "-";
  18686. cityPath = "-";
  18687. var chiarr = new List<Grp_ApprovalTravelDetails>();
  18688. DateTime NewData = DateTime.Parse(timeArr[i]);
  18689. //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();
  18690. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  18691. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  18692. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  18693. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  18694. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  18695. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  18696. if (tbSelect.Length > 0)
  18697. {
  18698. List<string> threeCodeStr = new List<string>();
  18699. bool isTrade = false;
  18700. string trip = string.Empty;
  18701. var rowLast = tbSelect.Last();
  18702. var rowFirst = tbSelect.First();
  18703. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  18704. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  18705. var takeOffTime = DateTime.Parse(timeArr[i]);
  18706. var fallToTime = DateTime.Parse(timeArr[i]);
  18707. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  18708. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  18709. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  18710. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  18711. foreach (var item in tbSelect)
  18712. {
  18713. var start = string.Empty;
  18714. var end = string.Empty;
  18715. var threeCode = item["Three"].ToString() ?? "";
  18716. if (threeCode.Length == 6)
  18717. {
  18718. start = threeCode.Substring(0, 3);
  18719. end = threeCode.Substring(3, 3);
  18720. if (threeCodeStr.Count == 0)
  18721. {
  18722. threeCodeStr.Add(start);
  18723. threeCodeStr.Add(end);
  18724. }
  18725. else
  18726. {
  18727. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  18728. {
  18729. threeCodeStr.Add(end);
  18730. }
  18731. else
  18732. {
  18733. threeCodeStr.Add(start);
  18734. threeCodeStr.Add(end);
  18735. }
  18736. }
  18737. }
  18738. //处理机票信息
  18739. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  18740. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  18741. if (start_Object == null)
  18742. {
  18743. start_Object = new Res_ThreeCode()
  18744. {
  18745. AirPort = empty,
  18746. AirPort_En = empty,
  18747. City = empty,
  18748. Country = empty,
  18749. Four = empty,
  18750. Three = empty,
  18751. };
  18752. }
  18753. if (end_Object == null)
  18754. {
  18755. end_Object = new Res_ThreeCode()
  18756. {
  18757. AirPort = empty,
  18758. AirPort_En = empty,
  18759. City = empty,
  18760. Country = empty,
  18761. Four = empty,
  18762. Three = empty,
  18763. };
  18764. }
  18765. //机型判断
  18766. string airModel = item["AirModel"].ToString();
  18767. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  18768. string flightTime = item["FlightTime"].ToString();
  18769. if (flightTime!.Contains(":"))
  18770. {
  18771. flightTime = flightTime.Replace(":", "小时");
  18772. flightTime += "分钟";
  18773. }
  18774. if (flightTime.Contains("H"))
  18775. {
  18776. flightTime = flightTime.Replace("H", "小时");
  18777. }
  18778. if (flightTime.Contains("M"))
  18779. {
  18780. flightTime = flightTime.Replace("M", "分钟");
  18781. }
  18782. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  18783. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  18784. {
  18785. flightTime = flightDataTime.Hour > 0
  18786. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  18787. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  18788. ? flightDataTime.Minute.ToString() + "分钟" : "";
  18789. }
  18790. //航班号
  18791. string flightcode = item["Fliagtcode"].ToString();
  18792. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  18793. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  18794. if (aircompany == null)
  18795. {
  18796. aircompany = new Res_AirCompany
  18797. {
  18798. CnName = hsEmpty,
  18799. EnName = hsEmpty,
  18800. ShortCode = hsEmpty,
  18801. };
  18802. }
  18803. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  18804. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  18805. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  18806. if (isTrade)
  18807. {
  18808. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  18809. }
  18810. else
  18811. {
  18812. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  18813. }
  18814. }
  18815. chiarr.Add(new Grp_ApprovalTravelDetails
  18816. {
  18817. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  18818. CreateTime = DateTime.Now,
  18819. CreateUserId = dto.Userid,
  18820. ParentId = 0,
  18821. Details = trip
  18822. });
  18823. //添加乘车语句
  18824. chiarr.Add(new Grp_ApprovalTravelDetails
  18825. {
  18826. Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  18827. CreateTime = DateTime.Now,
  18828. CreateUserId = dto.Userid,
  18829. ParentId = 0,
  18830. Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  18831. });
  18832. if (i != timeArr.Count - 1)
  18833. {
  18834. fallToTime = fallToTime.AddHours(2.5);
  18835. foreach (var item in Times)
  18836. {
  18837. //排列公务时间
  18838. if (fallToTime.Hour < item.Item1)
  18839. {
  18840. chiarr.Add(new Grp_ApprovalTravelDetails
  18841. {
  18842. Time = $"{item.Item2} - {item.Item3}",
  18843. CreateTime = DateTime.Now,
  18844. CreateUserId = dto.Userid,
  18845. ParentId = 0,
  18846. Details = "公务活动"
  18847. });
  18848. }
  18849. }
  18850. }
  18851. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  18852. var last = threeCodeStr.Last();
  18853. foreach (var item in threeCodeStr)
  18854. {
  18855. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  18856. if (item.Equals(last))
  18857. {
  18858. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  18859. }
  18860. }
  18861. cityPath = cityPath.Trim('-');
  18862. }
  18863. else
  18864. {
  18865. foreach (var item in Times)
  18866. {
  18867. chiarr.Add(new Grp_ApprovalTravelDetails
  18868. {
  18869. Time = $"{item.Item2} - {item.Item3}",
  18870. CreateTime = DateTime.Now,
  18871. CreateUserId = dto.Userid,
  18872. ParentId = 0,
  18873. Details = "公务活动"
  18874. });
  18875. }
  18876. }
  18877. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  18878. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  18879. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")"+ "第" + intToString(i + 1) + "天 ";
  18880. appro.Diid = dto.Diid;
  18881. appro.CreateUserId = dto.Userid;
  18882. appro.CreateTime = DateTime.Now;
  18883. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  18884. appro.Id = thisId;
  18885. //foreach (var item in gwinfo)
  18886. //{
  18887. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  18888. // chi.Details = "拜访" + item.Client;
  18889. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  18890. // {
  18891. // chi.Details += "," + item.ReqSample;
  18892. // }
  18893. // chi.ParentId = thisId;
  18894. // chi.Time = item.Time;
  18895. // chiarr.Add(chi);
  18896. //}
  18897. if (chiarr.Count < 6)
  18898. {
  18899. for (int j = chiarr.Count; j < 6; j++)
  18900. {
  18901. chiarr.Add(new
  18902. Grp_ApprovalTravelDetails());
  18903. }
  18904. }
  18905. resultArr.Add(new
  18906. {
  18907. appro.Id,
  18908. appro.Date,
  18909. appro.Diid,
  18910. chiList = chiarr.Select(x1 => new
  18911. {
  18912. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  18913. x1.Details,
  18914. x1.ParentId,
  18915. x1.Id
  18916. })
  18917. });
  18918. }
  18919. _sqlSugar.CommitTran();
  18920. jw = JsonView(true, "生成成功!", resultArr);
  18921. }
  18922. catch (Exception ex)
  18923. {
  18924. jw.Code = 400;
  18925. jw.Msg = "生成失败!" + ex.Message;
  18926. }
  18927. return Ok(jw);
  18928. }
  18929. /// <summary>
  18930. /// 报批行程word导出
  18931. /// </summary>
  18932. /// <param name="dto"></param>
  18933. /// <returns></returns>
  18934. [HttpPost]
  18935. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  18936. {
  18937. var jw = JsonView(false);
  18938. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  18939. if (group == null)
  18940. {
  18941. jw.Msg = "暂无该团组!";
  18942. return Ok(jw);
  18943. }
  18944. //模板路径
  18945. string tempPath = AppSettingsHelper.Get("WordBasePath")+ "Template/";
  18946. var fileName = string.Empty;
  18947. string titleFont = string.Empty,timeFont = string.Empty, contentFont = string.Empty;
  18948. bool bold = false;
  18949. if (dto.FileIndex == 1)
  18950. {
  18951. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  18952. }
  18953. else if (dto.FileIndex == 2)
  18954. {
  18955. fileName = "省外办-报批.docx";
  18956. bold = false;
  18957. titleFont = "方正黑体简体";
  18958. timeFont = "Times New Roman";
  18959. contentFont = "方正仿宋_GBK";
  18960. }
  18961. else if (dto.FileIndex == 3)
  18962. {
  18963. fileName = "市外办-报批.docx";
  18964. titleFont = "方正黑体简体";
  18965. timeFont = "Times New Roman";
  18966. contentFont = "方正仿宋简体";
  18967. }
  18968. tempPath = tempPath + fileName;
  18969. //载入模板
  18970. Document doc = new Document(tempPath);
  18971. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18972. //获取所填表格的序数
  18973. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18974. Aspose.Words.Tables.Row titleRowClone = null;
  18975. Aspose.Words.Tables.Row CenterRowClone = null;
  18976. int index = 0;
  18977. int indexChi = 0;
  18978. int SetIndex = 0;
  18979. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  18980. //获取数据,放到datatable
  18981. foreach (var item in ApprovalTravelArr)
  18982. {
  18983. if (index > 0)
  18984. {
  18985. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  18986. tableOne.AppendChild(titleRowClone);
  18987. }
  18988. var textTime = item.Date;
  18989. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  18990. SetCells(tableOne, doc, SetIndex, 0, textTime,titleFont,bold);
  18991. SetIndex++;
  18992. if (ChiRep.Count > 0)
  18993. {
  18994. foreach (var itemChi in ChiRep)
  18995. {
  18996. var txtTime = itemChi.Time;
  18997. var txtDetail = itemChi.Details;
  18998. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  18999. {
  19000. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  19001. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  19002. //indexChi++;
  19003. //SetIndex++;
  19004. break;
  19005. }
  19006. if (indexChi > 0)
  19007. {
  19008. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  19009. tableOne.AppendChild(CenterRowClone);
  19010. }
  19011. SetCells(tableOne, doc, SetIndex, 0, txtTime,timeFont,bold);
  19012. SetCells(tableOne, doc, SetIndex, 1, txtDetail,contentFont, bold);
  19013. indexChi++;
  19014. SetIndex++;
  19015. }
  19016. }
  19017. //else
  19018. //{
  19019. // if (indexChi > 0)
  19020. // {
  19021. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  19022. // tableOne.AppendChild(CenterRowClone);
  19023. // }
  19024. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  19025. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  19026. // indexChi++;
  19027. // SetIndex++;
  19028. //}
  19029. index++;
  19030. }
  19031. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  19032. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName,Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  19033. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  19034. jw.Code = 200;
  19035. jw.Msg = "";
  19036. return Ok(jw);
  19037. }
  19038. private string intToString(int numberVal)
  19039. {
  19040. string numberval = numberVal.ToString();
  19041. Dictionary<char, string> Number = new Dictionary<char, string>();
  19042. Number.Add('1', "一");
  19043. Number.Add('2', "二");
  19044. Number.Add('3', "三");
  19045. Number.Add('4', "四");
  19046. Number.Add('5', "五");
  19047. Number.Add('6', "六");
  19048. Number.Add('7', "七");
  19049. Number.Add('8', "八");
  19050. Number.Add('9', "九");
  19051. string stringNumberVal = string.Empty;
  19052. for (int i = 0; i < numberval.Length; i++)
  19053. {
  19054. if (i == 0)
  19055. {
  19056. stringNumberVal += Number[numberval[i]];
  19057. }
  19058. else if (i >= 1)
  19059. {
  19060. if (numberval[i] == '0')
  19061. {
  19062. stringNumberVal = "十";
  19063. }
  19064. else
  19065. {
  19066. stringNumberVal += "十" + Number[numberval[i]];
  19067. }
  19068. }
  19069. }
  19070. return stringNumberVal;
  19071. }
  19072. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val,string font ,bool bold)
  19073. {
  19074. //获取table中的某个单元格,从0开始
  19075. Cell lshCell = table.Rows[rows].Cells[cells];
  19076. //将单元格中段落移除
  19077. foreach (Paragraph item in lshCell.Paragraphs)
  19078. {
  19079. lshCell.Paragraphs.Remove(item);
  19080. }
  19081. if (val.Contains("\r\n"))
  19082. {
  19083. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  19084. foreach (var item in spArr)
  19085. {
  19086. //新建一个段落
  19087. Paragraph p = new Paragraph(doc);
  19088. var r = new Run(doc, item);
  19089. //设置字体
  19090. if (!string.IsNullOrEmpty(font))
  19091. {
  19092. r.Font.Name = font;
  19093. }
  19094. r.Font.Bold = bold;
  19095. //把设置的值赋给之前新建的段落
  19096. p.AppendChild(r);
  19097. //将此段落加到单元格内
  19098. lshCell.AppendChild(p);
  19099. }
  19100. }
  19101. else
  19102. {
  19103. //新建一个段落
  19104. Paragraph p = new Paragraph(doc);
  19105. var r = new Run(doc, val);
  19106. //设置字体
  19107. if (!string.IsNullOrEmpty(font))
  19108. {
  19109. r.Font.Name = font;
  19110. }
  19111. r.Font.Bold = bold;
  19112. //把设置的值赋给之前新建的段落
  19113. p.AppendChild(r);
  19114. //将此段落加到单元格内
  19115. lshCell.AppendChild(p);
  19116. }
  19117. }
  19118. [HttpPost]
  19119. public async Task<IActionResult> ServerHttp(string paramStr)
  19120. {
  19121. paramStr = paramStr.TrimEnd('\'');
  19122. paramStr = paramStr.TrimStart('\'');
  19123. JsonView jw = JsonView(false);
  19124. JObject param = JObject.Parse(paramStr);
  19125. if (!param.ContainsKey("url"))
  19126. {
  19127. jw.Msg = "url null";
  19128. return Ok(jw);
  19129. }
  19130. string url = param["url"]!.ToString();
  19131. var methon = "get";
  19132. Dictionary<string, string> headValues = null;
  19133. string bodyStr = string.Empty;
  19134. if (param.ContainsKey("methon"))
  19135. {
  19136. methon = param["methon"]!.ToString().ToLower();
  19137. }
  19138. if (param.ContainsKey("header"))
  19139. {
  19140. var header = param["header"]!.ToString();
  19141. JObject headerJobject = JObject.Parse(header);
  19142. headValues = new Dictionary<string, string>();
  19143. foreach (JProperty item in headerJobject.Properties())
  19144. {
  19145. var value = item.Value.ToString();
  19146. var head = item.Path;
  19147. headValues.Add(head, value);
  19148. }
  19149. }
  19150. HttpClient client = new HttpClient();
  19151. string responseString = string.Empty;
  19152. StringContent content = null;
  19153. if (headValues != null)
  19154. {
  19155. foreach (var item in headValues.Keys)
  19156. {
  19157. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  19158. {
  19159. if (param.ContainsKey("body"))
  19160. {
  19161. bodyStr = param["body"]!.ToString();
  19162. }
  19163. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  19164. }
  19165. else
  19166. {
  19167. client.DefaultRequestHeaders.Add(item, headValues[item]);
  19168. }
  19169. }
  19170. }
  19171. try
  19172. {
  19173. if (methon == "get")
  19174. {
  19175. responseString = await client.GetStringAsync(url);
  19176. }
  19177. else if (methon == "post")
  19178. {
  19179. var request = new HttpRequestMessage(HttpMethod.Post, url)
  19180. {
  19181. Content = content
  19182. };
  19183. var response = await client.SendAsync(request);
  19184. try
  19185. {
  19186. Stream responseStream = await response.Content.ReadAsStreamAsync();
  19187. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  19188. {
  19189. using (StreamReader reader = new StreamReader(gzipStream))
  19190. {
  19191. responseString = await reader.ReadToEndAsync();
  19192. }
  19193. }
  19194. }
  19195. catch (Exception)
  19196. {
  19197. responseString = await response.Content.ReadAsStringAsync();
  19198. }
  19199. }
  19200. else
  19201. {
  19202. responseString = "methon error";
  19203. }
  19204. jw = JsonView(true, "success", responseString);
  19205. }
  19206. catch (Exception ex)
  19207. {
  19208. jw.Msg = "error " + ex.Message;
  19209. jw.Data = ex.StackTrace;
  19210. }
  19211. finally
  19212. {
  19213. client.Dispose();
  19214. }
  19215. return Ok(jw);
  19216. }
  19217. #endregion
  19218. #region 团组接待意见调查
  19219. /// <summary>
  19220. /// 团组接待意见调查 - 信息管理
  19221. /// 基础数据(团组)
  19222. /// </summary>
  19223. /// <returns></returns>
  19224. [HttpGet]
  19225. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19226. public async Task<IActionResult> OpinionaireInit()
  19227. {
  19228. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  19229. .Select(x => new
  19230. {
  19231. x.Id,
  19232. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  19233. })
  19234. .OrderByDescending(x => x.Id)
  19235. .ToListAsync();
  19236. return Ok(JsonView(groupData, groupData.Count));
  19237. }
  19238. /// <summary>
  19239. /// 团组接待意见调查 - 信息管理
  19240. /// 列表
  19241. /// </summary>
  19242. /// <param name="groupId"></param>
  19243. /// <returns></returns>
  19244. [HttpGet("{groupId}")]
  19245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19246. public async Task<IActionResult> OpinionaireManageList(int groupId)
  19247. {
  19248. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19249. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  19250. .Select(x => new
  19251. {
  19252. x.Id,
  19253. x.TourGuideName,
  19254. x.CityName,
  19255. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  19256. x.CreateTime
  19257. })
  19258. .OrderBy(x => x.Id)
  19259. .ToListAsync();
  19260. return Ok(JsonView(data));
  19261. }
  19262. /// <summary>
  19263. /// 团组接待意见调查 - 信息管理
  19264. /// 保存
  19265. /// </summary>
  19266. /// <param name="dto"></param>
  19267. /// <returns></returns>
  19268. [HttpPost]
  19269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19270. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  19271. {
  19272. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19273. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19274. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19275. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  19276. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  19277. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  19278. _opinionaireRep.BeginTran();
  19279. if (addData != null && addData.Count > 0)
  19280. {
  19281. foreach (var item in addData)
  19282. {
  19283. item.CreateUserId = currUserInfo.UserId;
  19284. item.DiId = dto.DiId;
  19285. }
  19286. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  19287. }
  19288. if (updData != null && updData.Count > 0)
  19289. {
  19290. var upd = await _opinionaireRep._sqlSugar
  19291. .Updateable(updData)
  19292. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  19293. .WhereColumns(x => new { x.Id })
  19294. .ExecuteCommandAsync();
  19295. }
  19296. _opinionaireRep.CommitTran();
  19297. return Ok(JsonView("操作成功!"));
  19298. }
  19299. /// <summary>
  19300. /// 团组接待意见调查 - 信息管理
  19301. /// 删除
  19302. /// </summary>
  19303. /// <param name="id"></param>
  19304. /// <returns></returns>
  19305. [HttpDelete("{id}")]
  19306. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19307. public async Task<IActionResult> OpinionaireManageDel(int id)
  19308. {
  19309. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  19310. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  19311. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  19312. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  19313. if (!del) return Ok(JsonView("操作失败!"));
  19314. return Ok(JsonView("操作成功!"));
  19315. }
  19316. /// <summary>
  19317. /// 团组接待意见调查 - 用户
  19318. /// 列表
  19319. /// </summary>
  19320. /// <param name="diId"></param>
  19321. /// <returns></returns>
  19322. [HttpGet("{diId}")]
  19323. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19324. public async Task<IActionResult> OpinionaireUserList(int diId)
  19325. {
  19326. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  19327. var sql = string.Format(@"
  19328. SELECT
  19329. o.Id,
  19330. o.DiId,
  19331. di.TeamName AS 'GroupName',
  19332. di.VisitPNumber AS 'PeopleNumber',
  19333. di.ClientName AS 'LeadGroup',
  19334. di.VisitCountry AS 'Travel',
  19335. di.VisitDays AS 'Days',
  19336. o.CityName,
  19337. o.TourGuideName,
  19338. o.Catering,
  19339. o.CateringReason,
  19340. o.Stay,
  19341. o.StayReason,
  19342. o.[Route],
  19343. o.RouteReason,
  19344. o.OfficialActivity,
  19345. o.OfficialActivityReason,
  19346. o.TourGuide,
  19347. o.TourGuideReason,
  19348. o.[Translate],
  19349. o.TranslateReason,
  19350. o.Trip,
  19351. o.TripReason,
  19352. o.ESFileName,
  19353. o.SignatureDate,
  19354. o.Remark
  19355. FROM
  19356. Grp_Opinionaire o
  19357. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  19358. WHERE
  19359. o.IsDel = 0
  19360. AND o.DiId = {0}
  19361. ORDER BY
  19362. o.Id ASC", diId);
  19363. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  19364. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  19365. return Ok(JsonView(data));
  19366. }
  19367. /// <summary>
  19368. /// 团组接待意见调查 - 用户
  19369. /// 保存
  19370. /// </summary>
  19371. /// <param name="dto"></param>
  19372. /// <returns></returns>
  19373. [HttpPost]
  19374. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19375. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  19376. {
  19377. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  19378. foreach (var item in dto)
  19379. {
  19380. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  19381. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  19382. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  19383. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  19384. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  19385. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  19386. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  19387. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  19388. }
  19389. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  19390. if (!Directory.Exists(filePathBase))
  19391. {
  19392. Directory.CreateDirectory(filePathBase);
  19393. }
  19394. #region 上传文件
  19395. var filePaths = new List<string>();
  19396. foreach (var item in dto)
  19397. {
  19398. var file = item.File;
  19399. // 将文件保存到指定位置
  19400. var filePath = Path.Combine(filePathBase, file.FileName);
  19401. using (var stream = new FileStream(filePath, FileMode.Create))
  19402. {
  19403. await file.CopyToAsync(stream);
  19404. }
  19405. //验证文件是否上传成功
  19406. if (!System.IO.File.Exists(filePath))
  19407. {
  19408. foreach (var filePathStr in filePaths)
  19409. {
  19410. System.IO.File.Delete(filePathStr);
  19411. }
  19412. return Ok(JsonView(false, "文件上传失败!"));
  19413. }
  19414. item.ESFileName = file.FileName;
  19415. }
  19416. #endregion
  19417. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  19418. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  19419. .UpdateColumns(x => new
  19420. {
  19421. x.Catering,
  19422. x.CateringReason,
  19423. x.Stay,
  19424. x.StayReason,
  19425. x.Route,
  19426. x.RouteReason,
  19427. x.OfficialActivity,
  19428. x.OfficialActivityReason,
  19429. x.TourGuide,
  19430. x.TourGuideReason,
  19431. x.Translate,
  19432. x.TranslateReason,
  19433. x.Trip,
  19434. x.TripReason,
  19435. x.ESFileName,
  19436. x.SignatureDate,
  19437. x.Remark
  19438. })
  19439. .WhereColumns(x => new { x.Id })
  19440. .ExecuteCommandAsync();
  19441. if (upd < 1)
  19442. {
  19443. foreach (var filePathStr in filePaths)
  19444. {
  19445. System.IO.File.Delete(filePathStr);
  19446. }
  19447. return Ok(JsonView(false));
  19448. }
  19449. return Ok(JsonView(true));
  19450. }
  19451. #endregion
  19452. #region 团组餐厅相关信息
  19453. /// <summary>
  19454. /// 团组相关餐厅信息
  19455. /// 基础数据(团组)
  19456. /// </summary>
  19457. /// <returns></returns>
  19458. [HttpGet]
  19459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19460. public async Task<IActionResult> RestaurantInit()
  19461. {
  19462. return Ok(await _restaurantRep.InitAsync());
  19463. }
  19464. /// <summary>
  19465. /// 团组相关餐厅信息
  19466. /// Item
  19467. /// </summary>
  19468. /// <param name="dto"></param>
  19469. /// <returns></returns>
  19470. [HttpPost]
  19471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19472. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  19473. {
  19474. int portType = dto.PortType,
  19475. groupId = dto.GroupId;
  19476. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19477. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19478. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  19479. }
  19480. /// <summary>
  19481. /// 团组相关餐厅信息
  19482. /// List
  19483. /// </summary>
  19484. /// <param name="dto"></param>
  19485. /// <returns></returns>
  19486. [HttpPost]
  19487. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19488. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  19489. {
  19490. int portType = dto.PortType,
  19491. groupId = dto.GroupId;
  19492. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19493. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19494. var sql = string.Format(@" SELECT
  19495. ri.Id,
  19496. ri.GroupId,
  19497. ri.Date,
  19498. ri.StartTime,
  19499. ri.EndTime,
  19500. CASE WHEN ri.Type = 1 THEN '早餐'
  19501. WHEN ri.Type = 2 THEN '午餐'
  19502. WHEN ri.Type = 3 THEN '晚餐'
  19503. ELSE '其他'
  19504. END AS 'Type',
  19505. ri.Name,
  19506. ri.Address,
  19507. ri.Tel,
  19508. ri.Remark,
  19509. ri.CreateTime,
  19510. u.CnName AS CreateUserName
  19511. FROM
  19512. Grp_RestaurantInfo ri
  19513. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  19514. WHERE
  19515. ri.IsDel = 0
  19516. AND ri.GroupId = {0}
  19517. ORDER BY
  19518. ri.Date ASC
  19519. ", groupId);
  19520. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  19521. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  19522. return Ok(JsonView(infos));
  19523. }
  19524. /// <summary>
  19525. /// 团组相关餐厅信息
  19526. /// Info
  19527. /// </summary>
  19528. /// <param name="dto"></param>
  19529. /// <returns></returns>
  19530. [HttpPost]
  19531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19532. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  19533. {
  19534. int portType = dto.PortType,
  19535. id = dto.Id;
  19536. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  19537. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19538. return Ok(await _restaurantRep.InfoAsync(portType, id));
  19539. }
  19540. /// <summary>
  19541. /// 团组相关餐厅信息
  19542. /// Op
  19543. /// </summary>
  19544. /// <param name="dto"></param>
  19545. /// <returns></returns>
  19546. [HttpPost]
  19547. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19548. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  19549. {
  19550. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19551. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  19552. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  19553. return Ok(await _restaurantRep.OpAsync(dto));
  19554. }
  19555. /// <summary>
  19556. /// 团组相关餐厅信息
  19557. /// Del
  19558. /// </summary>
  19559. /// <param name="dto"></param>
  19560. /// <returns></returns>
  19561. [HttpPost]
  19562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19563. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  19564. {
  19565. int userId = dto.DeleteUserId;
  19566. var id = dto.Id;
  19567. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  19568. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  19569. return Ok(await _restaurantRep.DelAsync(dto));
  19570. }
  19571. #endregion
  19572. // /// <summary>
  19573. // ///
  19574. // /// </summary>
  19575. // /// <param name="_dto"></param>
  19576. // /// <returns></returns>
  19577. // [HttpPost]
  19578. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19579. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19580. // {
  19581. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19582. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  19583. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  19584. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19585. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  19586. // dic_psg.Add("客人", 974);
  19587. // dic_psg.Add("司机", 975);
  19588. // dic_psg.Add("导游", 976);
  19589. // dic_psg.Add("公司内部人员", 977);
  19590. // dic_psg.Add("司机/导游/公司内部人员", 978);
  19591. // foreach (var item in list_visa)
  19592. // {
  19593. // Grp_VisaInfo temp = new Grp_VisaInfo();
  19594. // temp.Id = item.Id;
  19595. // temp.DIId = item.DIId;
  19596. // temp.VisaClient = item.VisaClient;
  19597. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  19598. // temp.VisaCurrency = item.VisaCurrency;
  19599. // temp.IsThird = item.IsThird;
  19600. // if (dic_psg.ContainsKey(item.PassengerType))
  19601. // {
  19602. // temp.PassengerType = dic_psg[item.PassengerType];
  19603. // }
  19604. // else {
  19605. // temp.PassengerType = -1;
  19606. // }
  19607. // temp.VisaNumber = item.VisaNumber;
  19608. // temp.VisaFreeNumber = item.VisaFreeNumber;
  19609. // temp.CreateUserId = item.Operators;
  19610. // DateTime dt_ct;
  19611. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  19612. // if (b_ct)
  19613. // {
  19614. // temp.CreateTime = dt_ct;
  19615. // }
  19616. // else
  19617. // {
  19618. // temp.CreateTime = DateTime.Now;
  19619. // }
  19620. // temp.DeleteTime = "";
  19621. // temp.DeleteUserId = 0;
  19622. // temp.Remark = item.Remark;
  19623. // if (string.IsNullOrEmpty(temp.Remark)) {
  19624. // temp.Remark = "";
  19625. // }
  19626. // temp.IsDel = item.IsDel;
  19627. // temp.VisaDescription = item.VisaAttachment;
  19628. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  19629. //([Id]
  19630. // ,[DIId]
  19631. // ,[VisaClient]
  19632. // ,[VisaPrice]
  19633. // ,[VisaCurrency]
  19634. // ,[IsThird]
  19635. // ,[PassengerType]
  19636. // ,[VisaNumber]
  19637. // ,[VisaFreeNumber]
  19638. // ,[CreateUserId]
  19639. // ,[CreateTime]
  19640. // ,[DeleteTime]
  19641. // ,[DeleteUserId]
  19642. // ,[Remark]
  19643. // ,[IsDel]
  19644. // ,[visaDescription])
  19645. // VALUES
  19646. // ({0},{1},'{2}',{3},{4}
  19647. //,{5},{6},{7},{8},{9}
  19648. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  19649. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  19650. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  19651. //);
  19652. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  19653. // }
  19654. // return Ok(JsonView(true, "操作成功!"));
  19655. // }
  19656. /// <summary>
  19657. /// 123132123
  19658. /// </summary>
  19659. /// <param name="_dto"></param>
  19660. /// <returns></returns>
  19661. [HttpPost]
  19662. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19663. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  19664. {
  19665. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  19666. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  19667. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  19668. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  19669. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  19670. dicDetail.Add(789, 1034);
  19671. dicDetail.Add(790, 1035);
  19672. dicDetail.Add(791, 1036);
  19673. dicDetail.Add(792, 1037);
  19674. dicDetail.Add(793, 1038);
  19675. dicDetail.Add(794, 1039);
  19676. dicDetail.Add(795, 1040);
  19677. dicDetail.Add(796, 1041);
  19678. dicDetail.Add(797, 1042);
  19679. dicDetail.Add(798, 1043);
  19680. dicDetail.Add(801, 1044);
  19681. dicDetail.Add(802, 1045);
  19682. dicDetail.Add(803, 1046);
  19683. Dictionary<int, int> dic = new Dictionary<int, int>();
  19684. dic.Add(806, 1027);
  19685. dic.Add(807, 1028);
  19686. dic.Add(808, 1029);
  19687. dic.Add(809, 1030);
  19688. dic.Add(810, 1031);
  19689. dic.Add(811, 1032);
  19690. dic.Add(812, 1033);
  19691. foreach (var item in list_visa)
  19692. {
  19693. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  19694. temp.Coefficient = item.coefficient;
  19695. DateTime dtCrt;
  19696. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  19697. if (b1)
  19698. {
  19699. temp.CreateTime = dtCrt;
  19700. }
  19701. else
  19702. {
  19703. temp.CreateTime = DateTime.Now;
  19704. }
  19705. temp.CreateUserId = item.Operators;
  19706. temp.DeleteTime = "";
  19707. temp.DeleteUserId = 0;
  19708. temp.DiId = int.Parse(item.DIID);
  19709. temp.FilePath = item.FilePath;
  19710. temp.IsDel = item.IsDel;
  19711. temp.Price = item.Price;
  19712. temp.PriceCount = 1;
  19713. temp.PriceCurrency = item.Currency;
  19714. int detailId = 0;
  19715. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  19716. {
  19717. detailId = dicDetail[item.PriceTypeDetail];
  19718. }
  19719. temp.PriceDetailType = detailId;
  19720. temp.PriceDt = DateTime.Now;
  19721. temp.PriceName = item.PriceName;
  19722. temp.PriceSum = item.Price;
  19723. int tid = 0;
  19724. if (dic.ContainsKey(item.PriceType))
  19725. {
  19726. tid = dic[item.PriceType];
  19727. }
  19728. temp.PriceType = tid;
  19729. temp.Remark = item.Remark;
  19730. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  19731. }
  19732. return Ok(JsonView(true, "操作成功!"));
  19733. }
  19734. [HttpPost]
  19735. public IActionResult TimeTest()
  19736. {
  19737. var jw = JsonView(false, "error");
  19738. _sqlSugar.BeginTran();
  19739. try
  19740. {
  19741. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  19742. .Select(x => new Crm_NewClientData
  19743. {
  19744. Id = x.Id,
  19745. Client = x.Client,
  19746. Contact = x.Contact,
  19747. Location = x.Location,
  19748. })
  19749. .ToList();
  19750. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  19751. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  19752. Stopwatch stopwatch = new Stopwatch();
  19753. // 开始计时
  19754. stopwatch.Start();
  19755. foreach (var item in clientList)
  19756. {
  19757. EncryptionProcessor.DecryptProperties(item);
  19758. }
  19759. stopwatch.Stop();
  19760. jw.Code = 200;
  19761. jw.Data = stopwatch.ElapsedMilliseconds;
  19762. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  19763. }
  19764. catch (Exception ex)
  19765. {
  19766. jw.Code = 400;
  19767. jw.Msg = ex.Message;
  19768. }
  19769. return Ok(jw);
  19770. }
  19771. }
  19772. }