GroupsController.cs 929 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909
  1. using Aspose.Cells;
  2. using Aspose.Cells.Charts;
  3. using Aspose.Words;
  4. using Aspose.Words.Drawing;
  5. using Aspose.Words.Tables;
  6. using DiffMatchPatch;
  7. using EyeSoft.Collections.Generic;
  8. using EyeSoft.IO;
  9. using Google.Protobuf.WellKnownTypes;
  10. using Microsoft.AspNetCore.SignalR;
  11. using MySqlX.XDevAPI.Relational;
  12. using NetUV.Core.Handles;
  13. using NPOI.HSSF.UserModel;
  14. using NPOI.POIFS.Crypt.Dsig;
  15. using NPOI.POIFS.Properties;
  16. using NPOI.SS.Format;
  17. using NPOI.SS.Formula.Functions;
  18. using NPOI.SS.UserModel;
  19. using NPOI.SS.Util;
  20. using NPOI.XSSF.UserModel;
  21. using OASystem.API.Middlewares;
  22. using OASystem.API.OAMethodLib;
  23. using OASystem.API.OAMethodLib.APNs;
  24. using OASystem.API.OAMethodLib.File;
  25. using OASystem.API.OAMethodLib.Hub.HubClients;
  26. using OASystem.API.OAMethodLib.Hub.Hubs;
  27. using OASystem.API.OAMethodLib.JuHeAPI;
  28. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  29. using OASystem.Domain.AesEncryption;
  30. using OASystem.Domain.Dtos.CRM;
  31. using OASystem.Domain.Dtos.FileDto;
  32. using OASystem.Domain.Dtos.Financial;
  33. using OASystem.Domain.Dtos.Groups;
  34. using OASystem.Domain.Entities.Customer;
  35. using OASystem.Domain.Entities.Financial;
  36. using OASystem.Domain.Entities.Groups;
  37. using OASystem.Domain.ViewModels;
  38. using OASystem.Domain.ViewModels.Financial;
  39. using OASystem.Domain.ViewModels.Groups;
  40. using OASystem.Domain.ViewModels.Statistics;
  41. using OASystem.Infrastructure.Repositories.CRM;
  42. using OASystem.Infrastructure.Repositories.Financial;
  43. using OASystem.Infrastructure.Repositories.Groups;
  44. using OfficeOpenXml;
  45. using Org.BouncyCastle.Asn1.Ocsp;
  46. using Org.BouncyCastle.Utilities.Encoders;
  47. using Quartz.Util;
  48. using SqlSugar;
  49. using SqlSugar.Extensions;
  50. using System.Collections;
  51. using System.Data;
  52. using System.Data.OleDb;
  53. using System.Diagnostics;
  54. using System.Globalization;
  55. using System.IO;
  56. using System.IO.Compression;
  57. using System.Net.Http;
  58. using System.Reflection.PortableExecutable;
  59. using System.Security.Cryptography;
  60. using Ubiety.Dns.Core;
  61. using static NPOI.POIFS.Crypt.CryptoFunctions;
  62. using static OASystem.API.OAMethodLib.JWTHelper;
  63. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  64. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  65. using Bookmark = Aspose.Words.Bookmark;
  66. using Cell = Aspose.Words.Tables.Cell;
  67. using Table = Aspose.Words.Tables.Table;
  68. namespace OASystem.API.Controllers
  69. {
  70. /// <summary>
  71. /// 团组相关
  72. /// </summary>
  73. //[Authorize]
  74. [Route("api/[controller]/[action]")]
  75. public class GroupsController : ControllerBase
  76. {
  77. private readonly ILogger<GroupsController> _logger;
  78. private readonly GrpScheduleRepository _grpScheduleRep;
  79. private readonly IMapper _mapper;
  80. private readonly DelegationInfoRepository _groupRepository;
  81. private readonly TaskAssignmentRepository _taskAssignmentRep;
  82. private readonly AirTicketResRepository _airTicketResRep;
  83. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  84. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  85. private readonly DelegationEnDataRepository _delegationEnDataRep;
  86. private readonly DelegationVisaRepository _delegationVisaRep;
  87. private readonly VisaPriceRepository _visaPriceRep;
  88. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  89. private readonly HotelPriceRepository _hotelPriceRep;
  90. private readonly CustomersRepository _customersRep;
  91. private readonly MessageRepository _message;
  92. private readonly SqlSugarClient _sqlSugar;
  93. private readonly TourClientListRepository _tourClientListRep;
  94. private readonly TeamRateRepository _teamRateRep;
  95. #region 成本相关
  96. private readonly CheckBoxsRepository _checkBoxs;
  97. private readonly GroupCostRepository _GroupCostRepository;
  98. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  99. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  100. #endregion
  101. private readonly SetDataRepository _setDataRep;
  102. private string url;
  103. private string path;
  104. private readonly EnterExitCostRepository _enterExitCostRep;
  105. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  106. private readonly UsersRepository _usersRep;
  107. private readonly IJuHeApiService _juHeApi;
  108. private readonly InvertedListRepository _invertedListRep;
  109. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  110. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  111. private readonly ThreeCodeRepository _threeCodeRepository;
  112. private readonly HotelInquiryRepository _hotelInquiryRep;
  113. private readonly FeeAuditRepository _feeAuditRep;
  114. private readonly VisaCommissionRepository _visaCommissionRep;
  115. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  116. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  117. private readonly List<CurrencyInfo> _currencyInit;
  118. private readonly List<int> _portTypeData;
  119. private readonly TableOperationRecordRepository _tableorRep;
  120. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  121. /// <summary>
  122. /// 构造函数
  123. /// </summary>
  124. /// <param name="logger"></param>
  125. /// <param name="mapper"></param>
  126. /// <param name="hubContext"></param>
  127. /// <param name="sqlSugar"></param>
  128. /// <param name="grpScheduleRep"></param>
  129. /// <param name="groupRepository"></param>
  130. /// <param name="taskAssignmentRep"></param>
  131. /// <param name="airTicketResRep"></param>
  132. /// <param name="decreasePaymentsRep"></param>
  133. /// <param name="InvitationOfficialActivitiesRep"></param>
  134. /// <param name="delegationEnDataRep"></param>
  135. /// <param name="enterExitCostRep"></param>
  136. /// <param name="delegationVisaRep"></param>
  137. /// <param name="message"></param>
  138. /// <param name="visaPriceRep"></param>
  139. /// <param name="carTouristGuideGroundRep"></param>
  140. /// <param name="checkBoxs"></param>
  141. /// <param name="GroupCostRepository"></param>
  142. /// <param name="CostTypeHotelNumberRepository"></param>
  143. /// <param name="GroupCostParameterRepository"></param>
  144. /// <param name="hotelPriceRep"></param>
  145. /// <param name="customersRep"></param>
  146. /// <param name="setDataRep"></param>
  147. /// <param name="tourClientListRep"></param>
  148. /// <param name="teamRateRep"></param>
  149. /// <param name="usersRep"></param>
  150. /// <param name="juHeApi"></param>
  151. /// <param name="invertedListRep"></param>
  152. /// <param name="visaFeeInfoRep"></param>
  153. /// <param name="ticketBlackCodeRep"></param>
  154. /// <param name="hotelInquiryRep"></param>
  155. /// <param name="threeCodeRepository"></param>
  156. /// <param name="feeAuditRep"></param>
  157. /// <param name="visaCommissionRep"></param>
  158. /// <param name="ffrRep"></param>
  159. /// <param name="opinionaireRep"></param>
  160. /// <param name="tableorRep"></param>
  161. public GroupsController(
  162. ILogger<GroupsController> logger,
  163. IMapper mapper,
  164. IHubContext<ChatHub, IChatClient> hubContext,
  165. SqlSugarClient sqlSugar,
  166. GrpScheduleRepository grpScheduleRep,
  167. DelegationInfoRepository groupRepository,
  168. TaskAssignmentRepository taskAssignmentRep,
  169. AirTicketResRepository airTicketResRep,
  170. DecreasePaymentsRepository decreasePaymentsRep,
  171. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  172. DelegationEnDataRepository delegationEnDataRep,
  173. EnterExitCostRepository enterExitCostRep,
  174. DelegationVisaRepository delegationVisaRep,
  175. MessageRepository message,
  176. VisaPriceRepository visaPriceRep,
  177. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  178. CheckBoxsRepository checkBoxs,
  179. GroupCostRepository GroupCostRepository,
  180. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  181. GroupCostParameterRepository GroupCostParameterRepository,
  182. HotelPriceRepository hotelPriceRep,
  183. CustomersRepository customersRep,
  184. SetDataRepository setDataRep,
  185. TourClientListRepository tourClientListRep,
  186. TeamRateRepository teamRateRep,
  187. UsersRepository usersRep, IJuHeApiService juHeApi,
  188. InvertedListRepository invertedListRep,
  189. VisaFeeInfoRepository visaFeeInfoRep,
  190. TicketBlackCodeRepository ticketBlackCodeRep,
  191. HotelInquiryRepository hotelInquiryRep,
  192. ThreeCodeRepository threeCodeRepository,
  193. FeeAuditRepository feeAuditRep,
  194. VisaCommissionRepository visaCommissionRep,
  195. ForeignReceivablesRepository ffrRep,
  196. OpinionaireRepository opinionaireRep,
  197. TableOperationRecordRepository tableorRep,
  198. EnterExitCostDraftRepository enterExitCostDraftRep
  199. )
  200. {
  201. _logger = logger;
  202. _mapper = mapper;
  203. _grpScheduleRep = grpScheduleRep;
  204. _groupRepository = groupRepository;
  205. _taskAssignmentRep = taskAssignmentRep;
  206. _airTicketResRep = airTicketResRep;
  207. _sqlSugar = sqlSugar;
  208. url = AppSettingsHelper.Get("ExcelBaseUrl");
  209. path = AppSettingsHelper.Get("ExcelBasePath");
  210. if (!System.IO.Directory.Exists(path))
  211. {
  212. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  213. }
  214. _decreasePaymentsRep = decreasePaymentsRep;
  215. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  216. _delegationEnDataRep = delegationEnDataRep;
  217. _enterExitCostRep = enterExitCostRep;
  218. _delegationVisaRep = delegationVisaRep;
  219. _message = message;
  220. _visaPriceRep = visaPriceRep;
  221. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  222. _checkBoxs = checkBoxs;
  223. _GroupCostRepository = GroupCostRepository;
  224. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  225. _GroupCostParameterRepository = GroupCostParameterRepository;
  226. _hotelPriceRep = hotelPriceRep;
  227. _customersRep = customersRep;
  228. _setDataRep = setDataRep;
  229. _tourClientListRep = tourClientListRep;
  230. _teamRateRep = teamRateRep;
  231. _hubContext = hubContext;
  232. _usersRep = usersRep;
  233. _juHeApi = juHeApi;
  234. _invertedListRep = invertedListRep;
  235. _visaFeeInfoRep = visaFeeInfoRep;
  236. _ticketBlackCodeRep = ticketBlackCodeRep;
  237. _hotelInquiryRep = hotelInquiryRep;
  238. _threeCodeRepository = threeCodeRepository;
  239. _feeAuditRep = feeAuditRep;
  240. _visaCommissionRep = visaCommissionRep;
  241. _ffrRep = ffrRep;
  242. _opinionaireRep = opinionaireRep;
  243. _currencyInit = new List<CurrencyInfo>()
  244. {
  245. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  246. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  247. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  248. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  249. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  250. };
  251. _portTypeData = new List<int>() { 2, 3 };
  252. _tableorRep = tableorRep;
  253. _enterExitCostDraftRep = enterExitCostDraftRep;
  254. }
  255. #region 流程管控
  256. /// <summary>
  257. /// 获取团组流程管控信息
  258. /// </summary>
  259. /// <param name="paras">参数Json字符串</param>
  260. /// <returns></returns>
  261. [HttpPost]
  262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  263. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  264. {
  265. if (string.IsNullOrEmpty(_jsonDto.Paras))
  266. {
  267. return Ok(JsonView(false, "参数为空"));
  268. }
  269. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  270. if (_ScheduleDto != null)
  271. {
  272. if (_ScheduleDto.SearchType == 2)//获取列表
  273. {
  274. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  275. return Ok(JsonView(_grpScheduleViewList));
  276. }
  277. else//获取对象
  278. {
  279. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  280. if (_grpScheduleView != null)
  281. {
  282. return Ok(JsonView(_grpScheduleView));
  283. }
  284. }
  285. }
  286. else
  287. {
  288. return Ok(JsonView(false, "参数反序列化失败"));
  289. }
  290. return Ok(JsonView(false, "暂无数据!"));
  291. }
  292. /// <summary>
  293. /// 修改团组流程管控详细表数据
  294. /// </summary>
  295. /// <param name="paras"></param>
  296. /// <returns></returns>
  297. [HttpPost]
  298. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  299. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  300. {
  301. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  302. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  303. .SetColumns(it => it.Duty == _detail.Duty)
  304. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  305. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  306. .SetColumns(it => it.JobContent == _detail.JobContent)
  307. .SetColumns(it => it.Remark == _detail.Remark)
  308. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  309. .Where(s => s.Id == dto.Id)
  310. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  311. .ExecuteCommandAsync();
  312. if (result > 0)
  313. {
  314. return Ok(JsonView(true, "保存成功!"));
  315. }
  316. return Ok(JsonView(false, "保存失败!"));
  317. }
  318. /// <summary>
  319. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  320. /// </summary>
  321. /// <param name="dto"></param>
  322. /// <returns></returns>
  323. [HttpPost]
  324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  325. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  326. {
  327. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  328. _detail.IsDel = 1;
  329. _detail.DeleteUserId = dto.Duty;
  330. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  331. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  332. .SetColumns(it => it.IsDel == _detail.IsDel)
  333. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  334. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  335. .Where(it => it.Id == dto.Id)
  336. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  337. //.WhereColumns(s => s.Id == dto.Id)
  338. .ExecuteCommandAsync();
  339. if (result > 0)
  340. {
  341. return Ok(JsonView(true, "删除成功!"));
  342. }
  343. return Ok(JsonView(false, "删除失败!"));
  344. }
  345. /// <summary>
  346. /// 增加团组流程管控详细表数据
  347. /// </summary>
  348. /// <param name="dto"></param>
  349. /// <returns></returns>
  350. [HttpPost]
  351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  352. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  353. {
  354. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  355. if (DateTime.Now < _detail.ExpectBeginDt)
  356. {
  357. _detail.StepStatus = 0;
  358. }
  359. else
  360. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  361. _detail.StepStatus = 1;
  362. }
  363. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  364. if (result > 0)
  365. {
  366. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  367. return Ok(JsonView(true, "添加成功!", _result));
  368. }
  369. return Ok(JsonView(false, "添加失败!"));
  370. }
  371. #endregion
  372. #region 团组基本信息
  373. /// <summary>
  374. /// 接团信息列表
  375. /// </summary>
  376. /// <param name="dto">团组列表请求dto</param>
  377. /// <returns></returns>
  378. [HttpPost]
  379. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  380. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  381. {
  382. var groupData = await _groupRepository.GetGroupList(dto);
  383. if (groupData.Code != 0)
  384. {
  385. return Ok(JsonView(false, groupData.Msg));
  386. }
  387. return Ok(JsonView(groupData.Data));
  388. }
  389. /// <summary>
  390. /// 分页查询团组列表
  391. /// </summary>
  392. /// <param name="dto"></param>
  393. /// <returns></returns>
  394. [HttpPost]
  395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  396. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  397. {
  398. var watch = new Stopwatch();
  399. watch.Start();
  400. RefAsync<int> total = 0;
  401. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  402. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  403. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  404. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  405. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  406. .Distinct()
  407. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  408. watch.Stop();
  409. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  410. }
  411. /// <summary>
  412. /// 接团信息列表 Page
  413. /// </summary>
  414. /// <param name="dto">团组列表请求dto</param>
  415. /// <returns></returns>
  416. [HttpPost]
  417. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  418. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  419. {
  420. #region 参数验证
  421. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  422. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  423. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  424. #region 页面操作权限验证
  425. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  426. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  427. #endregion
  428. #endregion
  429. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  430. {
  431. string sqlWhere = string.Empty;
  432. if (dto.IsSure == 0) //未完成
  433. {
  434. sqlWhere += string.Format(@" And IsSure = 0");
  435. }
  436. else if (dto.IsSure == 1) //已完成
  437. {
  438. sqlWhere += string.Format(@" And IsSure = 1");
  439. }
  440. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  441. {
  442. string tj = dto.SearchCriteria;
  443. 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}%')",
  444. tj, tj, tj, tj, tj);
  445. }
  446. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  447. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  448. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  449. JietuanOperator,IsSure,CreateTime,IsBid
  450. From (
  451. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  452. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  453. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  454. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  455. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  456. From Grp_DelegationInfo gdi
  457. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  458. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  459. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  460. Where gdi.IsDel = 0 {0}
  461. ) temp", sqlWhere);
  462. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  463. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  464. #region 处理所属部门
  465. /*
  466. * 1.sq 和 gyy 等显示 市场部
  467. * 2.王鸽和主管及张总还有管理员号统一国交部
  468. * 2-1. 4 管理员 ,21 张海麟
  469. */
  470. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  471. List<int> userIds1 = new List<int>() { 4, 21 };
  472. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  473. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  474. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  475. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  476. .ToList();
  477. foreach (var item in _DelegationList)
  478. {
  479. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  480. }
  481. #endregion
  482. var _view = new
  483. {
  484. PageFuncAuth = pageFunAuthView,
  485. Data = _DelegationList
  486. };
  487. return Ok(JsonView(true, "查询成功!", _view, total));
  488. }
  489. else
  490. {
  491. return Ok(JsonView(false, "查询失败"));
  492. }
  493. }
  494. /// <summary>
  495. /// 团组列表
  496. /// </summary>
  497. /// <returns></returns>
  498. [HttpPost]
  499. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  500. {
  501. #region 参数验证
  502. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  503. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  504. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  505. #region 页面操作权限验证
  506. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  507. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  508. #endregion
  509. #endregion
  510. if (dto.PortType != 1 && dto.PortType != 2)
  511. {
  512. return Ok(JsonView(false, "查询失败!"));
  513. }
  514. string orderbyStr = "order by gdi.CreateTime Desc";
  515. string sqlWhere = string.Empty;
  516. if (dto.IsSure == 0) //未完成
  517. {
  518. sqlWhere += string.Format(@" And IsSure = 0");
  519. }
  520. else if (dto.IsSure == 1) //已完成
  521. {
  522. sqlWhere += string.Format(@" And IsSure = 1");
  523. }
  524. //团组类型
  525. if (dto.TeamDid > 0)
  526. {
  527. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  528. }
  529. //团组名称
  530. if (!string.IsNullOrEmpty(dto.TeamName))
  531. {
  532. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  533. }
  534. //客户名称
  535. if (!string.IsNullOrEmpty(dto.ClientName))
  536. {
  537. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  538. }
  539. //客户单位
  540. if (!string.IsNullOrEmpty(dto.ClientUnit))
  541. {
  542. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  543. }
  544. //出访时间
  545. if (!string.IsNullOrEmpty(dto.visitDataTime))
  546. {
  547. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  548. orderbyStr = "order by gdi.VisitDate";
  549. }
  550. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  551. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  552. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  553. JietuanOperator,IsSure,CreateTime
  554. From (
  555. Select row_number() over({0}) as Row_Number,
  556. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  557. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  558. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  559. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  560. From Grp_DelegationInfo gdi
  561. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  562. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  563. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  564. Where gdi.IsDel = 0 {1}
  565. ) temp ", orderbyStr, sqlWhere);
  566. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  567. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  568. #region 处理所属部门
  569. /*
  570. * 1.sq 和 gyy 等显示 市场部
  571. * 2.王鸽和主管及张总还有管理员号统一国交部
  572. * 2-1. 4 管理员 ,21 张海麟
  573. */
  574. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  575. List<int> userIds1 = new List<int>() { 4, 21 };
  576. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  577. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  578. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  579. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  580. .ToList();
  581. foreach (var item in _DelegationList)
  582. {
  583. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  584. }
  585. #endregion
  586. var _view = new
  587. {
  588. PageFuncAuth = pageFunAuthView,
  589. Data = _DelegationList
  590. };
  591. return Ok(JsonView(true, "查询成功!", _view, total));
  592. }
  593. /// <summary>
  594. /// 接团信息详情
  595. /// </summary>
  596. /// <param name="dto">团组info请求dto</param>
  597. /// <returns></returns>
  598. [HttpPost]
  599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  600. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  601. {
  602. var groupData = await _groupRepository.GetGroupInfo(dto);
  603. if (groupData.Code != 0)
  604. {
  605. return Ok(JsonView(false, groupData.Msg));
  606. }
  607. return Ok(JsonView(groupData.Data));
  608. }
  609. /// <summary>
  610. /// 接团信息 编辑添加
  611. /// 基础信息数据源
  612. /// </summary>
  613. /// <param name="dto"></param>
  614. /// <returns></returns>
  615. [HttpPost]
  616. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  617. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  618. {
  619. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  620. if (groupData.Code != 0)
  621. {
  622. return Ok(JsonView(false, groupData.Msg));
  623. }
  624. return Ok(JsonView(groupData.Data));
  625. }
  626. /// <summary>
  627. /// 接团信息 操作(增改)
  628. /// </summary>
  629. /// <param name="dto"></param>
  630. /// <returns></returns>
  631. [HttpPost]
  632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  633. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  634. {
  635. // 创建 Stopwatch 实例
  636. Stopwatch stopwatch = Stopwatch.StartNew();
  637. decimal ffrPrice = 0.00M;
  638. DateTime? visitDt = null;
  639. if (dto.Status == 2)
  640. {
  641. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  642. if (groupInfo != null)
  643. {
  644. ffrPrice = groupInfo.PaymentMoney;
  645. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  646. }
  647. }
  648. var groupData = await _groupRepository.GroupOperation(dto);
  649. if (groupData.Code != 0)
  650. {
  651. return Ok(JsonView(false, groupData.Msg));
  652. }
  653. int diId = 0;
  654. try
  655. {
  656. //添加时 默认加入团组汇率
  657. if (dto.Status == 1) //添加
  658. {
  659. diId = groupData.Data;
  660. //添加默认币种
  661. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  662. //默认分配权限
  663. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  664. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  665. var _managerIds = new List<int>() { 22, 32, 21 };
  666. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  667. if (userIds.Count > 0)
  668. {
  669. userIds.Add(208);
  670. //创建团组管控
  671. GroupStepForDelegation.CreateWorkStep(diId);
  672. //发送消息
  673. string groupName = dto.TeamName;
  674. string createGroupUser = string.Empty;
  675. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  676. if (userInfo != null) createGroupUser = userInfo.CnName;
  677. string title = $"系统通知";
  678. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  679. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  680. }
  681. //默认创建倒推表
  682. await _invertedListRep._Create(dto.UserId, diId);
  683. }
  684. else if (dto.Status == 2)
  685. {
  686. diId = dto.Id;
  687. }
  688. #region 签证人员团组时间通知
  689. #region 计算出访起止时间
  690. var startTime = new DateTime();
  691. var endTime = new DateTime();
  692. if (DateTime.TryParse(dto.VisitDate, out startTime))
  693. {
  694. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  695. }
  696. #endregion
  697. #endregion
  698. #region 团组操作默认添加/修改收款账单
  699. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  700. {
  701. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  702. .Where(x => x.IsDel == 0 &&
  703. x.Diid == diId &&
  704. x.Remark.Equals("预付款")
  705. )
  706. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  707. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  708. .FirstAsync();
  709. ffrInfo = new Fin_ForeignReceivables()
  710. {
  711. Diid = diId,
  712. PriceName = dto.ClientUnit,
  713. Price = dto.PaymentMoney,
  714. Count = 1,
  715. Unit = $"元",
  716. ItemSumPrice = dto.PaymentMoney,
  717. Rate = 1.0000M,
  718. Currency = 836,
  719. AddingWay = 0,
  720. CreateUserId = dto.UserId,
  721. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  722. Remark = $"预付款"
  723. };
  724. if (ffrInfo == null) //Add
  725. {
  726. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  727. }
  728. else //修改
  729. {
  730. await _sqlSugar.Updateable(ffrInfo)
  731. .UpdateColumns(x => new
  732. {
  733. x.PriceName,
  734. x.Price,
  735. x.ItemSumPrice,
  736. x.CreateTime,
  737. x.CreateUserId
  738. })
  739. .WhereColumns(x => x.Id)
  740. .ExecuteCommandAsync();
  741. }
  742. }
  743. #endregion
  744. if (diId > 0)
  745. {
  746. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  747. }
  748. // 停止计时
  749. stopwatch.Stop();
  750. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  751. }
  752. catch (Exception ex)
  753. {
  754. // 停止计时
  755. stopwatch.Stop();
  756. Logs("[response]" + JsonConvert.SerializeObject(dto));
  757. Logs(ex.Message);
  758. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  759. }
  760. // 停止计时
  761. stopwatch.Stop();
  762. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  763. }
  764. /// <summary>
  765. /// 接团流程操作(增改)
  766. /// 安卓端使用 建团时添加客户名单
  767. /// </summary>
  768. /// <param name="dto"></param>
  769. /// <returns></returns>
  770. [HttpPost]
  771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  772. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  773. {
  774. #region 参数验证
  775. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  776. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  777. #region 页面操作权限验证
  778. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  779. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  780. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  781. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  782. #endregion
  783. #endregion
  784. try
  785. {
  786. //_sqlSugar.BeginTran();
  787. decimal ffrPrice = 0.00M;
  788. DateTime? visitDt = null;
  789. if (dto.Status == 2)
  790. {
  791. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  792. if (groupInfo != null)
  793. {
  794. ffrPrice = groupInfo.PaymentMoney;
  795. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  796. }
  797. }
  798. var _dto = new GroupOperationDto();
  799. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  800. var groupData = await _groupRepository.GroupOperation(_dto);
  801. if (groupData.Code != 0)
  802. {
  803. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  804. }
  805. int diId = 0;
  806. //添加时 默认加入团组汇率
  807. if (dto.Status == 1) //添加
  808. {
  809. diId = groupData.Data;
  810. //添加默认币种
  811. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  812. //默认分配权限
  813. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  814. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  815. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  816. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  817. if (userIds.Count > 0)
  818. {
  819. userIds.Add(208);
  820. //创建团组管控
  821. GroupStepForDelegation.CreateWorkStep(diId);
  822. //发送消息
  823. string groupName = dto.TeamName;
  824. string createGroupUser = string.Empty;
  825. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  826. if (userInfo != null) createGroupUser = userInfo.CnName;
  827. string title = $"系统通知";
  828. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  829. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  830. }
  831. #region 应用推送
  832. try
  833. {
  834. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  835. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  836. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  837. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  838. {
  839. List<string> userList = new List<string>() { users.QiyeChatUserId };
  840. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  841. }
  842. }
  843. catch (Exception ex)
  844. {
  845. }
  846. #endregion
  847. //默认创建倒推表
  848. await _invertedListRep._Create(dto.UserId, diId);
  849. }
  850. if (dto.Status == 2)
  851. {
  852. diId = dto.Id;
  853. if (diId == 0)
  854. {
  855. //_sqlSugar.RollbackTran();
  856. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  857. }
  858. }
  859. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  860. if (viewData.Code != 0)
  861. {
  862. //_sqlSugar.RollbackTran();
  863. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  864. }
  865. #region 团组操作默认添加/修改收款账单
  866. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  867. {
  868. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  869. .Where(x => x.IsDel == 0 &&
  870. x.Diid == diId &&
  871. x.Remark.Equals("预付款")
  872. )
  873. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  874. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  875. .FirstAsync();
  876. ffrInfo = new Fin_ForeignReceivables()
  877. {
  878. Diid = diId,
  879. PriceName = dto.ClientUnit,
  880. Price = dto.PaymentMoney,
  881. Count = 1,
  882. Unit = $"元",
  883. ItemSumPrice = dto.PaymentMoney,
  884. Rate = 1.0000M,
  885. Currency = 836,
  886. AddingWay = 0,
  887. CreateUserId = dto.UserId,
  888. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  889. Remark = $"预付款"
  890. };
  891. if (ffrInfo == null) //Add
  892. {
  893. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  894. }
  895. else //修改
  896. {
  897. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  898. .UpdateColumns(x => new
  899. {
  900. x.PriceName,
  901. x.Price,
  902. x.ItemSumPrice,
  903. x.CreateTime,
  904. x.CreateUserId
  905. })
  906. .WhereColumns(x => x.Id)
  907. .ExecuteCommandAsync();
  908. }
  909. }
  910. #endregion
  911. #region 签证人员团组时间通知
  912. #region 计算出访起止时间
  913. var startTime = new DateTime();
  914. var endTime = new DateTime();
  915. if (DateTime.TryParse(dto.VisitDate, out startTime))
  916. {
  917. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  918. }
  919. #endregion
  920. if (diId > 0)
  921. {
  922. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  923. }
  924. #endregion
  925. //_sqlSugar.CommitTran();
  926. return Ok(JsonView(true, "添加成功"));
  927. }
  928. catch (Exception ex)
  929. {
  930. _sqlSugar.RollbackTran();
  931. return Ok(JsonView(false, ex.Message));
  932. }
  933. }
  934. /// <summary>
  935. /// 接团流程操作(增改)
  936. /// 安卓端使用 建团时添加客户名单
  937. /// </summary>
  938. /// <param name="dto"></param>
  939. /// <returns></returns>
  940. [HttpPost]
  941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  942. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  943. {
  944. #region 参数验证
  945. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  946. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  947. #region 页面操作权限验证
  948. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  949. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  950. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  951. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  952. #endregion
  953. #endregion
  954. _sqlSugar.BeginTran();
  955. decimal ffrPrice = 0.00M;
  956. DateTime? visitDt = null;
  957. if (dto.Status == 2)
  958. {
  959. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  960. if (groupInfo != null)
  961. {
  962. ffrPrice = groupInfo.PaymentMoney;
  963. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  964. }
  965. }
  966. var _dto = new GroupOperationDto();
  967. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  968. var groupData = await _groupRepository.GroupOperation(_dto);
  969. if (groupData.Code != 0)
  970. {
  971. _sqlSugar.RollbackTran();
  972. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  973. }
  974. try
  975. {
  976. int diId = 0;
  977. //添加时 默认加入团组汇率
  978. if (dto.Status == 1) //添加
  979. {
  980. diId = groupData.Data;
  981. //添加默认币种
  982. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  983. //默认分配权限
  984. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  985. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  986. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  987. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  988. if (userIds.Count > 0)
  989. {
  990. userIds.Add(208);
  991. //创建团组管控
  992. GroupStepForDelegation.CreateWorkStep(diId);
  993. //发送消息
  994. string groupName = dto.TeamName;
  995. string createGroupUser = string.Empty;
  996. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  997. if (userInfo != null) createGroupUser = userInfo.CnName;
  998. string title = $"系统通知";
  999. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1000. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1001. }
  1002. #region 应用推送
  1003. try
  1004. {
  1005. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1006. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1007. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1008. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1009. {
  1010. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1011. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1012. }
  1013. }
  1014. catch (Exception ex)
  1015. {
  1016. _sqlSugar.CommitTran();
  1017. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1018. }
  1019. #endregion
  1020. //默认创建倒推表
  1021. await _invertedListRep._Create(dto.UserId, diId);
  1022. }
  1023. else if (dto.Status == 2)
  1024. {
  1025. diId = dto.Id;
  1026. if (diId == 0)
  1027. {
  1028. _sqlSugar.RollbackTran();
  1029. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1030. }
  1031. }
  1032. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1033. if (viewData.Code != 0)
  1034. {
  1035. _sqlSugar.RollbackTran();
  1036. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1037. }
  1038. #region 团组操作默认添加/修改收款账单
  1039. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1040. {
  1041. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1042. .Where(x => x.IsDel == 0 &&
  1043. x.Diid == diId &&
  1044. x.Remark.Equals("预付款")
  1045. )
  1046. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1047. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1048. .FirstAsync();
  1049. ffrInfo = new Fin_ForeignReceivables()
  1050. {
  1051. Diid = diId,
  1052. PriceName = dto.ClientUnit,
  1053. Price = dto.PaymentMoney,
  1054. Count = 1,
  1055. Unit = $"元",
  1056. ItemSumPrice = dto.PaymentMoney,
  1057. Rate = 1.0000M,
  1058. Currency = 836,
  1059. AddingWay = 0,
  1060. CreateUserId = dto.UserId,
  1061. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1062. Remark = $"预付款"
  1063. };
  1064. if (ffrInfo == null) //Add
  1065. {
  1066. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1067. }
  1068. else //修改
  1069. {
  1070. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1071. .UpdateColumns(x => new
  1072. {
  1073. x.PriceName,
  1074. x.Price,
  1075. x.ItemSumPrice,
  1076. x.CreateTime,
  1077. x.CreateUserId
  1078. })
  1079. .WhereColumns(x => x.Id)
  1080. .ExecuteCommandAsync();
  1081. }
  1082. }
  1083. #endregion
  1084. #region 签证人员团组时间通知
  1085. #region 计算出访起止时间
  1086. var startTime = new DateTime();
  1087. var endTime = new DateTime();
  1088. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1089. {
  1090. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1091. }
  1092. #endregion
  1093. if (diId > 0)
  1094. {
  1095. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1096. }
  1097. #endregion
  1098. _sqlSugar.CommitTran();
  1099. return Ok(JsonView(true));
  1100. }
  1101. catch (Exception ex)
  1102. {
  1103. _sqlSugar.RollbackTran();
  1104. return Ok(JsonView(false, ex.Message));
  1105. }
  1106. }
  1107. /// <summary>
  1108. /// 接团信息 操作(删除)
  1109. /// </summary>
  1110. /// <param name="dto"></param>
  1111. /// <returns></returns>
  1112. [HttpPost]
  1113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1114. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1115. {
  1116. var diId = dto.Id;
  1117. if (diId < 1) return Ok(JsonView(false,MsgTips.Id));
  1118. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1119. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1120. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1121. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1122. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1123. #endregion
  1124. var groupData = await _groupRepository.GroupDel(dto);
  1125. if (groupData.Code != 0)
  1126. {
  1127. return Ok(JsonView(false, groupData.Msg));
  1128. }
  1129. return Ok(JsonView(true));
  1130. }
  1131. /// <summary>
  1132. /// 获取团组销售报价号
  1133. /// 团组添加时 使用
  1134. /// </summary>
  1135. /// <returns></returns>
  1136. [HttpPost]
  1137. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1138. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1139. {
  1140. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1141. if (groupData.Code != 0)
  1142. {
  1143. return Ok(JsonView(false, groupData.Msg));
  1144. }
  1145. object salesQuoteNo = new
  1146. {
  1147. SalesQuoteNo = groupData.Data
  1148. };
  1149. return Ok(JsonView(salesQuoteNo));
  1150. }
  1151. /// <summary>
  1152. /// 设置确认出团
  1153. /// </summary>
  1154. /// <param name="dto"></param>
  1155. /// <returns></returns>
  1156. [HttpPost]
  1157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1158. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1159. {
  1160. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1161. if (groupData.Code != 0)
  1162. {
  1163. return Ok(JsonView(false, groupData.Msg));
  1164. }
  1165. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1166. #region OA消息推送
  1167. try
  1168. {
  1169. string groupName = groupInfo.TeamName;
  1170. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1171. string title = $"系统通知";
  1172. string content = $"团组[{groupName}]已确认出团!";
  1173. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1174. }
  1175. catch (Exception ex)
  1176. {
  1177. }
  1178. #endregion
  1179. #region 应用推送
  1180. try
  1181. {
  1182. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1183. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1184. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1185. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1186. {
  1187. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1188. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1189. }
  1190. }
  1191. catch (Exception ex)
  1192. {
  1193. }
  1194. #endregion
  1195. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1196. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1197. }
  1198. /// <summary>
  1199. /// 获取团组名称data And 签证国别Data
  1200. /// </summary>
  1201. /// <param name="dto"></param>
  1202. /// <returns></returns>
  1203. [HttpPost]
  1204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1205. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1206. {
  1207. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1208. if (groupData.Code != 0)
  1209. {
  1210. return Ok(JsonView(false, groupData.Msg));
  1211. }
  1212. return Ok(JsonView(groupData.Data));
  1213. }
  1214. /// <summary>
  1215. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1216. /// </summary>
  1217. /// <returns></returns>
  1218. [HttpPost]
  1219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1220. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1221. {
  1222. try
  1223. {
  1224. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1225. if (groupData.Code != 0)
  1226. {
  1227. return Ok(JsonView(false, groupData.Msg));
  1228. }
  1229. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1230. }
  1231. catch (Exception ex)
  1232. {
  1233. return Ok(JsonView(false, "程序错误!"));
  1234. throw;
  1235. }
  1236. }
  1237. /// <summary>
  1238. /// 团组清单 Excel
  1239. /// </summary>
  1240. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1241. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1242. /// <returns></returns>
  1243. [HttpGet]
  1244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1245. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1246. {
  1247. DateTime _beginDt, _endDt;
  1248. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1249. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1250. if (!beginBool && !endBool)
  1251. {
  1252. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1253. }
  1254. string sql = string.Format(@"
  1255. SELECT
  1256. ROW_NUMBER,
  1257. Id,
  1258. SalesQuoteNo,
  1259. TourCode,
  1260. TeamTypeId,
  1261. TeamType,
  1262. TeamLevId,
  1263. TeamLev,
  1264. TeamName,
  1265. ClientName,
  1266. ClientUnit,
  1267. VisitDate,
  1268. VisitDays,
  1269. VisitPNumber,
  1270. JietuanOperatorId,
  1271. JietuanOperator,
  1272. IsSure,
  1273. CreateUserName,
  1274. IsBid
  1275. FROM
  1276. (
  1277. SELECT
  1278. ROW_NUMBER() OVER(
  1279. ORDER BY
  1280. gdi.CreateTime Desc
  1281. ) AS ROW_NUMBER,
  1282. gdi.Id,
  1283. SalesQuoteNo,
  1284. TourCode,
  1285. ssd.Id TeamTypeId,
  1286. ssd.Name TeamType,
  1287. ssd1.Id TeamLevId,
  1288. ssd1.Name TeamLev,
  1289. TeamName,
  1290. ClientName,
  1291. ClientUnit,
  1292. VisitDate,
  1293. VisitDays,
  1294. VisitPNumber,
  1295. JietuanOperator JietuanOperatorId,
  1296. su.CnName JietuanOperator,
  1297. IsSure,
  1298. gdi.CreateTime,
  1299. su1.CnName As CreateUserName,
  1300. gdi.IsBid
  1301. FROM
  1302. Grp_DelegationInfo gdi
  1303. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1304. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1305. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1306. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1307. WHERE
  1308. gdi.IsDel = 0
  1309. AND gdi.IsBid = 0
  1310. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1311. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1312. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1313. #region 处理所属部门
  1314. /*
  1315. * 1.sq 和 gyy 等显示 市场部
  1316. * 2.王鸽和主管及张总还有管理员号统一国交部
  1317. * 2-1. 4 管理员 ,21 张海麟
  1318. */
  1319. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1320. List<int> userIds1 = new List<int>() { 4, 21 };
  1321. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1322. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1323. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1324. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1325. .ToListAsync();
  1326. var droupIds = groupList.Select(it => it.Id).ToList();
  1327. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1328. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1329. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1330. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1331. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1332. {
  1333. DiId = tcl.DiId,
  1334. LastName = dc.LastName,
  1335. FirstName = dc.FirstName,
  1336. Sex = dc.Sex,
  1337. Birthday = dc.BirthDay,
  1338. Company = cc.CompanyFullName,
  1339. Job = dc.Job,
  1340. CreateTime = tcl.CreateTime,
  1341. })
  1342. .ToList();
  1343. foreach (var item in groupList)
  1344. {
  1345. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1346. string groupFirstName = "";
  1347. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1348. if (currDatas.Any())
  1349. {
  1350. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1351. }
  1352. item.GroupFirst = groupFirstName;
  1353. }
  1354. #endregion
  1355. #region Excel
  1356. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1357. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1358. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1359. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1360. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1361. //载入模板
  1362. WorkbookDesigner designer = new WorkbookDesigner();
  1363. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1364. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1365. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1366. dt.TableName = "GroupList";
  1367. designer.SetDataSource(dt);
  1368. designer.Process();
  1369. if (!Directory.Exists(savePath))
  1370. {
  1371. Directory.CreateDirectory(savePath);
  1372. }
  1373. string serverPath = $"{savePath}{fileName}";
  1374. designer.Workbook.Save(serverPath);
  1375. string rst = $"{servicePath}{ftpPath}{fileName}";
  1376. #endregion
  1377. return Ok(JsonView(true, "操作成功!", rst));
  1378. }
  1379. #endregion
  1380. #region 团组&签证
  1381. /// <summary>
  1382. /// 根据团组Id获取签证客户信息List
  1383. /// </summary>
  1384. /// <param name="dto">请求dto</param>
  1385. /// <returns></returns>
  1386. [HttpPost]
  1387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1388. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1389. {
  1390. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1391. if (groupData.Code != 0)
  1392. {
  1393. return Ok(JsonView(false, groupData.Msg));
  1394. }
  1395. return Ok(JsonView(groupData.Data));
  1396. }
  1397. /// <summary>
  1398. /// IOS获取团组签证拍照上传进度01(团组列表)
  1399. /// </summary>
  1400. /// <param name="dto">请求dto</param>
  1401. /// <returns></returns>
  1402. [HttpPost]
  1403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1404. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1405. {
  1406. if (dto == null)
  1407. {
  1408. return Ok(JsonView(false, "参数为空"));
  1409. }
  1410. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1411. return Ok(JsonView(visaList));
  1412. }
  1413. /// <summary>
  1414. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1415. /// </summary>
  1416. /// <returns></returns>
  1417. [HttpPost]
  1418. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1419. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1420. {
  1421. if (dto == null)
  1422. {
  1423. return Ok(JsonView(false, "请求错误:"));
  1424. }
  1425. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1426. return Ok(JsonView(list));
  1427. }
  1428. /// <summary>
  1429. /// IOS获取团组签证拍照上传进度03(相册)
  1430. /// </summary>
  1431. /// <returns></returns>
  1432. [HttpPost]
  1433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1434. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1435. {
  1436. if (dto == null)
  1437. {
  1438. return Ok(JsonView(false, "请求错误:"));
  1439. }
  1440. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1441. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1442. list.ForEach(s => s.url = url);
  1443. return Ok(JsonView(list));
  1444. }
  1445. /// <summary>
  1446. /// IOS获取团组签证拍照上传进度04(图片上传)
  1447. /// </summary>
  1448. /// <param name="dto"></param>
  1449. /// <returns></returns>
  1450. [HttpPost]
  1451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1452. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1453. {
  1454. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1455. //if (!string.IsNullOrEmpty(result))
  1456. //{
  1457. //}
  1458. //else {
  1459. // return Ok(JsonView(false, "上传失败"));
  1460. //}
  1461. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1462. int sucNum = 0;
  1463. try
  1464. {
  1465. foreach (var item in dto.base64DataList)
  1466. {
  1467. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1468. string result = decodeBase64ToImage(item, imageName);
  1469. if (!string.IsNullOrEmpty(result))
  1470. {
  1471. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1472. pic.CreateUserId = dto.CreateUserId;
  1473. pic.PicName = imageName;
  1474. pic.PicPath = result;
  1475. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1476. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1477. if (insertResult > 0)
  1478. {
  1479. sucNum++;
  1480. }
  1481. }
  1482. }
  1483. }
  1484. catch (Exception ex)
  1485. {
  1486. return Ok(JsonView(false, ex.Message));
  1487. }
  1488. string msg = string.Format(@"成功上传{0}张", sucNum);
  1489. return Ok(JsonView(true, msg));
  1490. }
  1491. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1492. {
  1493. string filename = "";//声明一个string类型的相对路径
  1494. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1495. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1496. try//会有异常抛出,try,catch一下
  1497. {
  1498. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1499. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1500. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1501. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1502. //文件名称
  1503. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1504. //上传的文件的路径
  1505. string filePath = "";
  1506. if (!Directory.Exists(fileDir))
  1507. {
  1508. Directory.CreateDirectory(fileDir);
  1509. }
  1510. //上传的文件的路径
  1511. filePath = fileDir + filename;
  1512. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1513. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1514. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1515. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1516. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1517. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1518. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1519. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1520. bitmap.Dispose();
  1521. }
  1522. catch (Exception e)
  1523. {
  1524. string massage = e.Message;
  1525. Logs("IOS图片上传Error:" + massage);
  1526. //filename = e.Message;
  1527. }
  1528. return filename;//返回相对路径
  1529. }
  1530. /// <summary>
  1531. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1532. /// </summary>
  1533. /// <param name="dto"></param>
  1534. /// <returns></returns>
  1535. [HttpPost]
  1536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1537. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1538. {
  1539. if (dto == null)
  1540. {
  1541. return Ok(JsonView(false, "请求错误:"));
  1542. }
  1543. string msg = "参数错误";
  1544. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1545. {
  1546. try
  1547. {
  1548. //_delegationVisaRep.BeginTran();
  1549. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1550. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1551. .Where(s => s.Id == dto.visaProgressCustomerId)
  1552. .ExecuteCommandAsync();
  1553. if (updCount > 0 && dto.publishCode == 1)
  1554. {
  1555. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1556. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1557. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1558. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1559. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1560. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1561. if (groupData == null)
  1562. {
  1563. _delegationVisaRep.RollbackTran();
  1564. }
  1565. string title = string.Format(@"[签证进度更新]");
  1566. string content = string.Format(@"测试文本");
  1567. bool rst = await _message.AddMsg(new MessageDto()
  1568. {
  1569. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1570. IssuerId = dto.publisher,
  1571. Title = title,
  1572. Content = content,
  1573. ReleaseTime = DateTime.Now,
  1574. UIdList = new List<int> {
  1575. 234
  1576. }
  1577. });
  1578. if (rst)
  1579. {
  1580. return Ok(JsonView(true, "发送通知成功"));
  1581. }
  1582. }
  1583. //_delegationVisaRep.CommitTran();
  1584. }
  1585. catch (Exception)
  1586. {
  1587. //_delegationVisaRep.RollbackTran();
  1588. }
  1589. }
  1590. return Ok(JsonView(true, msg));
  1591. }
  1592. #endregion
  1593. #region 团组任务分配
  1594. /// <summary>
  1595. /// 团组任务分配初始化
  1596. /// </summary>
  1597. /// <param name="dto"></param>
  1598. /// <returns></returns>
  1599. [HttpPost]
  1600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1601. public async Task<IActionResult> GetTaskAssignmen()
  1602. {
  1603. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1604. if (groupData.Code != 0)
  1605. {
  1606. return Ok(JsonView(false, groupData.Msg));
  1607. }
  1608. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1609. }
  1610. /// <summary>
  1611. /// 团组任务分配查询
  1612. /// </summary>
  1613. /// <param name="dto"></param>
  1614. /// <returns></returns>
  1615. [HttpPost]
  1616. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1617. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1618. {
  1619. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1620. if (groupData.Code != 0)
  1621. {
  1622. return Ok(JsonView(false, groupData.Msg));
  1623. }
  1624. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1625. }
  1626. /// <summary>
  1627. /// 团组任务分配操作
  1628. /// </summary>
  1629. /// <param name="dto"></param>
  1630. /// <returns></returns>
  1631. [HttpPost]
  1632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1633. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1634. {
  1635. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1636. if (groupData.Code != 0)
  1637. {
  1638. return Ok(JsonView(false, groupData.Msg));
  1639. }
  1640. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1641. }
  1642. /// <summary>
  1643. /// 团组任务分配
  1644. /// 批量分配
  1645. /// 查询团组
  1646. /// </summary>
  1647. /// <param name="dto"></param>
  1648. /// <returns></returns>
  1649. [HttpPost]
  1650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1651. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1652. {
  1653. //参数验证
  1654. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1655. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1656. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1657. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1658. }
  1659. /// <summary>
  1660. /// 团组任务分配
  1661. /// 批量分配
  1662. /// </summary>
  1663. /// <param name="dto"></param>
  1664. /// <returns></returns>
  1665. [HttpPost]
  1666. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1667. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1668. {
  1669. //参数验证
  1670. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1671. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1672. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1673. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1674. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1675. }
  1676. #endregion
  1677. #region 团组费用审核
  1678. /// <summary>
  1679. /// 费用审核
  1680. /// 团组列表 Page
  1681. /// </summary>
  1682. /// <param name="_dto">团组列表请求dto</param>
  1683. /// <returns></returns>
  1684. [HttpPost]
  1685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1686. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1687. {
  1688. #region 参数验证
  1689. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1690. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1691. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1692. #region 页面操作权限验证
  1693. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1694. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1695. #endregion
  1696. #endregion
  1697. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1698. {
  1699. string sqlWhere = string.Empty;
  1700. if (_dto.IsSure == 0) //未完成
  1701. {
  1702. sqlWhere += string.Format(@" And IsSure = 0");
  1703. }
  1704. else if (_dto.IsSure == 1) //已完成
  1705. {
  1706. sqlWhere += string.Format(@" And IsSure = 1");
  1707. }
  1708. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1709. {
  1710. string tj = _dto.SearchCriteria;
  1711. 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}%')",
  1712. tj, tj, tj, tj, tj);
  1713. }
  1714. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1715. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1716. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1717. From (
  1718. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1719. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1720. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1721. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1722. From Grp_DelegationInfo gdi
  1723. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1724. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1725. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1726. Where gdi.IsDel = 0 {0}
  1727. ) temp ", sqlWhere);
  1728. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1729. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1730. var _view = new
  1731. {
  1732. PageFuncAuth = pageFunAuthView,
  1733. Data = _DelegationList
  1734. };
  1735. return Ok(JsonView(true, "查询成功!", _view, total));
  1736. }
  1737. else
  1738. {
  1739. return Ok(JsonView(false, "查询失败"));
  1740. }
  1741. }
  1742. /// <summary>
  1743. /// 获取团组费用审核
  1744. /// </summary>
  1745. /// <param name="paras">参数Json字符串</param>
  1746. /// <returns></returns>
  1747. [HttpPost]
  1748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1749. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1750. {
  1751. try
  1752. {
  1753. #region 参数验证
  1754. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1755. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1756. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1757. #region 页面操作权限验证
  1758. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1759. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1760. #endregion
  1761. #endregion
  1762. var _view = new Grp_CreditCardPaymentView();
  1763. var clientNameList = getSimplClientList(_dto.DiId);
  1764. #region 费用清单
  1765. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1766. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1767. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1768. var entityList = _groupRepository .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1769. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1770. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1771. /*
  1772. * 76://酒店预订
  1773. */
  1774. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1775. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1776. /*
  1777. * 79://车/导游地接
  1778. */
  1779. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1780. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1781. /*
  1782. * 80: //签证
  1783. */
  1784. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1785. /*
  1786. *81: //邀请/公务活动
  1787. */
  1788. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1789. /*
  1790. * 82: //团组客户保险
  1791. */
  1792. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1793. /*
  1794. * Lable = 85 机票预订
  1795. */
  1796. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1797. /*
  1798. * 85 机票预定
  1799. */
  1800. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1801. /*
  1802. * 98 其他款项
  1803. */
  1804. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1805. /*
  1806. * 285:收款退还
  1807. */
  1808. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1809. /*
  1810. * 1015: //超支费用
  1811. */
  1812. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1813. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1814. /*
  1815. * 币种信息
  1816. */
  1817. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1818. /*
  1819. * 车/导游地接 费用类型
  1820. */
  1821. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1822. /*
  1823. * 车/导游地接 费用类型
  1824. */
  1825. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  1826. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1827. /*
  1828. * 用户信息
  1829. */
  1830. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  1831. /*
  1832. * 费用模块
  1833. */
  1834. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  1835. string priceModule = string.Empty;
  1836. if (sdPriceName != null)
  1837. {
  1838. priceModule = sdPriceName.Name;
  1839. }
  1840. /*
  1841. * 成本信息
  1842. */
  1843. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1844. decimal _groupRate = 0.0000M;
  1845. string _groupCurrencyCode = "-";
  1846. if (groupCost != null)
  1847. {
  1848. _groupRate = groupCost.Rate;
  1849. if (int.TryParse(groupCost.Currency, out int _currency))
  1850. {
  1851. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1852. }
  1853. else _groupCurrencyCode = groupCost.Currency;
  1854. }
  1855. string costContentSql = $"Select * From Grp_GroupCost";
  1856. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1857. //处理日期为空的天数
  1858. for (int i = 0; i < groupCostDetails.Count; i++)
  1859. if (i != 0)
  1860. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1861. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1862. /*
  1863. * 处理详情数据
  1864. */
  1865. foreach (var entity in entityList)
  1866. {
  1867. var _detail = new Grp_CreditCardPaymentDetailView();
  1868. _detail.Id = entity.Id;
  1869. _detail.PriceName = priceModule;
  1870. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1871. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1872. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1873. //处理金额
  1874. if (entity.CTable == 1015)
  1875. {
  1876. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1877. if (czInfo != null)
  1878. {
  1879. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1880. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1881. }
  1882. }
  1883. /*
  1884. * 应付款金额
  1885. */
  1886. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1887. string PaymentCurrency_WaitPay = "Unknown";
  1888. string hotelCurrncyCode = "Unknown";
  1889. string hotelCurrncyName = "Unknown";
  1890. if (sdPaymentCurrency_WaitPay != null)
  1891. {
  1892. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1893. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1894. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1895. if (hotelCurrncyCode.Equals("CNY"))
  1896. {
  1897. entity.DayRate = 1.0000M;
  1898. }
  1899. }
  1900. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1901. /*
  1902. * 此次付款金额
  1903. */
  1904. decimal CurrPayStr = 0.00M,
  1905. OriginalCurrPay = 0.00M;
  1906. if (entity.PayPercentage == 0)
  1907. {
  1908. if (entity.PayThenMoney != 0)
  1909. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1910. }
  1911. else
  1912. {
  1913. if (entity.PayMoney != 0)
  1914. {
  1915. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1916. }
  1917. }
  1918. //if (_dto.Label == 79)
  1919. //{
  1920. // string original = string.Empty;
  1921. // if (hotelCurrncyCode.Equals("CNY"))
  1922. // {
  1923. // OriginalCurrPay = CurrPayStr;
  1924. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1925. // }
  1926. // else
  1927. // {
  1928. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1929. // //760 EUR(7600.00 CNY)
  1930. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1931. // }
  1932. //}
  1933. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1934. string original = string.Empty;
  1935. if (hotelCurrncyCode.Equals("CNY"))
  1936. {
  1937. OriginalCurrPay = CurrPayStr;
  1938. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1939. }
  1940. else
  1941. {
  1942. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1943. //760 EUR(7600.00 CNY)
  1944. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1945. }
  1946. /*
  1947. * 剩余尾款
  1948. */
  1949. decimal BalanceStr = 0;
  1950. if (CurrPayStr != 0)
  1951. {
  1952. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1953. BalanceStr = 0;
  1954. else
  1955. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1956. }
  1957. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1958. /*
  1959. * Bus名称
  1960. */
  1961. _detail.BusName = "待增加";
  1962. /*
  1963. *费用所属
  1964. */
  1965. switch (entity.CTable)
  1966. {
  1967. case 76://酒店预订
  1968. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1969. if (hotelReservations != null)
  1970. {
  1971. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1972. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1973. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1974. string roomFeeStr = "", roomFeestr1 = "";
  1975. //是否比较房型价格
  1976. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1977. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1978. roomFeeStr += $"<br/>";
  1979. var roomTotal = 0.00M;
  1980. if (hotelReservations.SingleRoomPrice > 0)
  1981. {
  1982. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1983. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1984. __isSingle = true;
  1985. roomTotal += fee;
  1986. }
  1987. if (hotelReservations.DoubleRoomPrice > 0)
  1988. {
  1989. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1990. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1991. __isDouble = true;
  1992. roomTotal += fee;
  1993. }
  1994. if (hotelReservations.SuiteRoomPrice > 0)
  1995. {
  1996. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  1997. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1998. __isSuite = true;
  1999. roomTotal += fee;
  2000. }
  2001. if (hotelReservations.OtherRoomPrice > 0)
  2002. {
  2003. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2004. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2005. __isOther = true;
  2006. roomTotal += fee;
  2007. }
  2008. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2009. else roomFeeStr += " 0.00 * 0";
  2010. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2011. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2012. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2013. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2014. /*
  2015. * 费用类型
  2016. * 1:房费
  2017. * 2:早餐
  2018. * 3:地税
  2019. * 4:城市税
  2020. * </summary>
  2021. */
  2022. //地税
  2023. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2024. if (governmentRentData != null)
  2025. {
  2026. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2027. governmentRentFee = governmentRentData.Price;
  2028. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2029. if (governmentRentCurrData != null)
  2030. {
  2031. governmentRentCode = governmentRentCurrData.Name;
  2032. governmentRentName = $"({governmentRentCurrData.Remark})";
  2033. }
  2034. }
  2035. //城市税
  2036. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2037. if (cityTaxData != null)
  2038. {
  2039. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2040. cityTaxFee = cityTaxData.Price;
  2041. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2042. if (cityTaxCurrData != null)
  2043. {
  2044. cityTaxCode = cityTaxCurrData.Name;
  2045. cityTaxName = $"({cityTaxCurrData.Remark})";
  2046. }
  2047. }
  2048. //酒店早餐
  2049. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2050. if (breakfastData != null)
  2051. {
  2052. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2053. breakfastFee = breakfastData.Price;
  2054. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2055. if (breakfastCurrData != null)
  2056. {
  2057. breakfastCode = breakfastCurrData.Name;
  2058. breakfastName = $"({breakfastCurrData.Remark})";
  2059. }
  2060. }
  2061. //房间费用
  2062. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2063. if (roomData != null)
  2064. {
  2065. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2066. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2067. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2068. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2069. roomFee = roomData.Price;
  2070. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2071. if (roomCurrData != null)
  2072. {
  2073. roomCode = roomCurrData.Name;
  2074. roomName = $"({roomCurrData.Remark})";
  2075. }
  2076. }
  2077. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2078. string hotelCostStr = "";
  2079. decimal hotelCsotTotal = 0.00M;
  2080. if (groupCost != null)
  2081. {
  2082. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2083. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2084. }
  2085. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2086. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2087. string hotelCost_day = "";
  2088. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2089. foreach (var item in hotelCostDetails1)
  2090. {
  2091. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2092. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2093. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2094. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2095. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2096. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2097. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2098. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2099. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2100. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2101. hotelCost_day += @$"<br/>";
  2102. }
  2103. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2104. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2105. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2106. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2107. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2108. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2109. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2110. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2111. $"房间说明: {hotelReservations.Remark} <br/>" +
  2112. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2113. $"{hotelBreakfastStr}" +
  2114. $"{hotelGovernmentRentStr}" +
  2115. $"{hotelCityTaxStr}";
  2116. _detail.PriceNameContent = hotelReservations.HotelName;
  2117. }
  2118. break;
  2119. case 79://车/导游地接
  2120. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2121. if (touristGuideGroundReservations != null)
  2122. {
  2123. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2124. {
  2125. _detail.BusName = touristGuideGroundReservations.BusName;
  2126. }
  2127. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2128. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2129. //if (isInt)
  2130. //{
  2131. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2132. // if (cityInfo != null)
  2133. // {
  2134. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2135. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2136. // if (carFeeItem != null)
  2137. // {
  2138. // nameContent += $@"({carFeeItem.Name})";
  2139. // }
  2140. // _detail.PriceNameContent = nameContent;
  2141. // }
  2142. //}
  2143. //else
  2144. //{
  2145. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2146. //}
  2147. var touristGuideGroundReservationsContents =
  2148. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2149. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2150. foreach (var item in touristGuideGroundReservationsContents)
  2151. {
  2152. string typeName = "Unknown";
  2153. string carCurrencyCode = "Unknown";
  2154. string carCurrencyName = "Unknown";
  2155. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2156. if (carTypeData != null) typeName = carTypeData.Name;
  2157. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2158. if (currencyData != null)
  2159. {
  2160. carCurrencyCode = currencyData.Name;
  2161. carCurrencyName = currencyData.Remark;
  2162. }
  2163. //op、成本 币种是否一致
  2164. bool IsCurrencyAgreement = false;
  2165. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2166. string opCostStr = string.Empty;
  2167. decimal opCostTypePrice = 0.00M;
  2168. #region 处理成本各项费用
  2169. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2170. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2171. if (opCost.Count > 0)
  2172. {
  2173. switch (item.SId)
  2174. {
  2175. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2176. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2177. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2178. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2179. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2180. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2181. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2182. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2183. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2184. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2185. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2186. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2187. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2188. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2189. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2190. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2191. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2192. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2193. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2194. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2195. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2196. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2197. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2198. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2199. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2200. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2201. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2202. }
  2203. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2204. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2205. }
  2206. #endregion
  2207. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2208. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2209. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2210. $"{opTypeStr} {opCostStr}<br/>" +
  2211. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2212. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2213. }
  2214. _detail.PriceMsgContent = priceMsg;
  2215. }
  2216. break;
  2217. case 80: //签证
  2218. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2219. if (visaInfo != null)
  2220. {
  2221. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2222. _detail.PriceNameContent = visaInfo.VisaDescription;
  2223. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2224. }
  2225. break;
  2226. case 81: //邀请/公务活动
  2227. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2228. if (_ioa != null)
  2229. {
  2230. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2231. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2232. sendCurrName = "Unknown", //快递费用币种 Name
  2233. sendCurrCode = "Unknown", //快递费用币种 Code
  2234. eventsCurrName = "Unknown", //公务活动费币种 Name
  2235. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2236. translateCurrName = "Unknown", //公务翻译费 Name
  2237. translateCurrCode = "Unknown"; //公务翻译费 Code
  2238. #region 处理费用币种
  2239. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2240. if (inviteCurrData != null)
  2241. {
  2242. inviteCurrName = inviteCurrData.Remark;
  2243. inviteCurrCode = inviteCurrData.Name;
  2244. }
  2245. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2246. if (sendCurrData != null)
  2247. {
  2248. sendCurrName = sendCurrData.Remark;
  2249. sendCurrCode = sendCurrData.Name;
  2250. }
  2251. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2252. if (eventsCurrData != null)
  2253. {
  2254. eventsCurrName = eventsCurrData.Remark;
  2255. eventsCurrCode = eventsCurrData.Name;
  2256. }
  2257. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2258. if (translateCurrData != null)
  2259. {
  2260. translateCurrName = translateCurrData.Remark;
  2261. translateCurrCode = translateCurrData.Name;
  2262. }
  2263. #endregion
  2264. _detail.PriceNameContent = _ioa.InviterArea;
  2265. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2266. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2267. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2268. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2269. $@"备注:" + _ioa.Remark + "<br/>";
  2270. }
  2271. break;
  2272. case 82: //团组客户保险
  2273. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2274. if (customers != null)
  2275. {
  2276. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2277. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2278. }
  2279. break;
  2280. case 85: //机票预订
  2281. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2282. if (jpRes != null)
  2283. {
  2284. string FlightsDescription = jpRes.FlightsDescription;
  2285. string PriceDescription = jpRes.PriceDescription;
  2286. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2287. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2288. }
  2289. break;
  2290. case 98://其他款项
  2291. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2292. if (gdpRes != null)
  2293. {
  2294. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2295. _detail.PriceNameContent = gdpRes.PriceName;
  2296. }
  2297. break;
  2298. case 285://收款退还
  2299. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2300. if (refundAndOtherMoney != null)
  2301. {
  2302. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2303. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2304. }
  2305. break;
  2306. case 751://酒店早餐
  2307. break;
  2308. case 1015://超支费用
  2309. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2310. if (groupExtraCost != null)
  2311. {
  2312. _detail.PriceNameContent = groupExtraCost.PriceName;
  2313. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2314. }
  2315. break;
  2316. default:
  2317. break;
  2318. }
  2319. /*
  2320. * 申请人
  2321. */
  2322. string operatorName = " - ";
  2323. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2324. if (_opUser != null)
  2325. {
  2326. operatorName = _opUser.CnName;
  2327. }
  2328. _detail.OperatorName = operatorName;
  2329. /*
  2330. * 审核人
  2331. */
  2332. string auditOperatorName = "Unknown";
  2333. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2334. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2335. else
  2336. {
  2337. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2338. if (_adUser != null)
  2339. {
  2340. auditOperatorName = _adUser.CnName;
  2341. }
  2342. }
  2343. _detail.AuditOperatorName = auditOperatorName;
  2344. /*
  2345. * 超预算比例
  2346. */
  2347. string overBudgetStr = "";
  2348. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2349. else if (entity.ExceedBudget == 0)
  2350. {
  2351. if (entity.CTable == 76 || entity.CTable == 79)
  2352. {
  2353. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2354. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2355. }
  2356. else
  2357. {
  2358. overBudgetStr = "未超预算";
  2359. }
  2360. }
  2361. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2362. _detail.OverBudget = overBudgetStr;
  2363. decimal auditFee = 0.00M; //已审核金额 人名币
  2364. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2365. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2366. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2367. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2368. {
  2369. auditedFeeOriginal = entity.PayMoney;
  2370. auditFee = CurrPayStr;
  2371. }
  2372. else if (entity.IsAuditGM == 0)
  2373. {
  2374. unAuditFeeCNY = CurrPayStr;
  2375. unAuditFeeOriginal = OriginalCurrPay;
  2376. OriginalCurrPay = 0.00M;
  2377. }
  2378. /*
  2379. * 费用总计
  2380. */
  2381. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2382. {
  2383. CurrencyId = entity.PaymentCurrency,
  2384. CurrencyName = PaymentCurrency_WaitPay,
  2385. AmountPayable = entity.PayMoney,
  2386. ThisPayment = OriginalCurrPay,
  2387. BalancePayment = BalanceStr,
  2388. AuditedFunds = auditFee,
  2389. AuditedFundsOriginal = auditedFeeOriginal,
  2390. UnAuditFundsCNY = unAuditFeeCNY,
  2391. UnAuditFundsOriginal = unAuditFeeOriginal
  2392. });
  2393. _detail.IsAuditGM = entity.IsAuditGM;
  2394. detailList.Add(_detail);
  2395. }
  2396. #endregion
  2397. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2398. /*
  2399. * 下方描述处理
  2400. */
  2401. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2402. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2403. if (ccpCurrencyPrice != null)
  2404. {
  2405. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2406. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2407. }
  2408. else
  2409. {
  2410. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2411. }
  2412. string amountPayableStr = string.Format(@"应付款总金额: ");
  2413. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2414. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2415. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2416. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2417. foreach (var item in nonDuplicat)
  2418. {
  2419. var currencyName = item.CurrencyName;
  2420. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2421. if (strs.Count > 0)
  2422. {
  2423. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2424. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2425. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2426. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2427. //单独处理此次付款金额
  2428. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2429. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2430. //单独处理已审核费用
  2431. //if (item.CurrencyId == 836) //人民币
  2432. //{
  2433. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2434. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2435. //}
  2436. //else
  2437. //{
  2438. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2439. //}
  2440. if (currencyName.Equals("CNY"))
  2441. {
  2442. //已审核费用
  2443. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2444. //未审核费用
  2445. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2446. }
  2447. else
  2448. {
  2449. //已审核费用
  2450. 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"));
  2451. //未审核费用
  2452. 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"));
  2453. }
  2454. }
  2455. }
  2456. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2457. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2458. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2459. _view.TotalStr4 = $"{auditedFundsStr.Substring(0, auditedFundsStr.Length - 1)}<br/>{unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1)}";
  2460. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2461. var _view1 = new
  2462. {
  2463. PageFuncAuth = pageFunAuthView,
  2464. Data = _view
  2465. };
  2466. return Ok(JsonView(_view1));
  2467. }
  2468. catch (Exception ex)
  2469. {
  2470. return Ok(JsonView(false, ex.Message));
  2471. }
  2472. }
  2473. /// <summary>
  2474. /// 费用审核
  2475. /// 修改团组费用审核状态
  2476. /// </summary>
  2477. /// <param name="_dto">参数Json字符串</param>
  2478. /// <returns></returns>
  2479. [HttpPost]
  2480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2481. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2482. {
  2483. #region 参数验证
  2484. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2485. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2486. #endregion
  2487. #region 页面操作权限验证
  2488. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2489. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2490. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2491. #endregion
  2492. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2493. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2494. DateTime dtNow = DateTime.Now;
  2495. _groupRepository.BeginTran();
  2496. int rst = 0;
  2497. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2498. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2499. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2500. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2501. List<dynamic> msgDatas = new List<dynamic>();
  2502. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2503. foreach (var item in idList)
  2504. {
  2505. int CreditId = int.Parse(item);
  2506. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2507. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2508. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2509. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2510. .Where(s => s.Id == CreditId)
  2511. .ExecuteCommandAsync();
  2512. if (result < 1)
  2513. {
  2514. rst = -1;
  2515. _groupRepository.RollbackTran();
  2516. return Ok(JsonView(false, "操作失败并回滚!"));
  2517. }
  2518. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2519. if (creditData != null)
  2520. {
  2521. #region 应用通知配置
  2522. try
  2523. {
  2524. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2525. }
  2526. catch (Exception ex)
  2527. {
  2528. }
  2529. #endregion
  2530. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2531. string groupNameStr = string.Empty;
  2532. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2533. if (groupData != null) groupNameStr = groupData.TeamName;
  2534. string creditTypeStr = string.Empty;
  2535. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2536. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2537. string creditCurrency = string.Empty;
  2538. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2539. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2540. if (creditCurrency.Equals("CNY"))
  2541. {
  2542. creditData.DayRate = 1.0000M;
  2543. }
  2544. if (creditData.PayPercentage == 0.00M)
  2545. {
  2546. creditData.PayPercentage = 100M;
  2547. }
  2548. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2549. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2550. string msgContent = "";
  2551. if (creditCurrency.Equals("CNY"))
  2552. {
  2553. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2554. }
  2555. else
  2556. {
  2557. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2558. }
  2559. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2560. }
  2561. }
  2562. if (rst == 0)
  2563. {
  2564. _groupRepository.CommitTran();
  2565. foreach (var item in msgDatas)
  2566. {
  2567. //发送消息
  2568. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2569. }
  2570. #region 应用推送
  2571. try
  2572. {
  2573. foreach (var ccpId in dic_ccp_user.Keys)
  2574. {
  2575. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2576. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2577. }
  2578. }
  2579. catch (Exception)
  2580. {
  2581. }
  2582. #endregion
  2583. return Ok(JsonView(true, "操作成功!"));
  2584. }
  2585. return Ok(JsonView(false, "操作失败!"));
  2586. }
  2587. #endregion
  2588. #region 机票费用录入
  2589. /// <summary>
  2590. /// 机票录入当前登录人可操作团组
  2591. /// </summary>
  2592. /// <param name="dto"></param>
  2593. /// <returns></returns>
  2594. [HttpPost]
  2595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2596. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2597. {
  2598. try
  2599. {
  2600. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2601. if (groupData.Code != 0)
  2602. {
  2603. return Ok(JsonView(false, groupData.Msg));
  2604. }
  2605. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2606. }
  2607. catch (Exception ex)
  2608. {
  2609. return Ok(JsonView(false, "程序错误!"));
  2610. throw;
  2611. }
  2612. }
  2613. /// <summary>
  2614. /// 机票费用录入列表
  2615. /// </summary>
  2616. /// <param name="dto"></param>
  2617. /// <returns></returns>
  2618. [HttpPost]
  2619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2620. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2621. {
  2622. try
  2623. {
  2624. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2625. if (groupData.Code != 0)
  2626. {
  2627. return Ok(JsonView(false, groupData.Msg));
  2628. }
  2629. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2630. }
  2631. catch (Exception ex)
  2632. {
  2633. return Ok(JsonView(false, ex.Message));
  2634. throw;
  2635. }
  2636. }
  2637. /// <summary>
  2638. /// 根据id查询费用录入信息
  2639. /// </summary>
  2640. /// <param name="dto"></param>
  2641. /// <returns></returns>
  2642. [HttpPost]
  2643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2644. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2645. {
  2646. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2647. if (groupData.Code != 0)
  2648. {
  2649. return Ok(JsonView(false, groupData.Msg));
  2650. }
  2651. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2652. }
  2653. /// <summary>
  2654. /// 机票费用录入操作(Status:1.新增,2.修改)
  2655. /// </summary>
  2656. /// <param name="dto"></param>
  2657. /// <returns></returns>
  2658. [HttpPost]
  2659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2660. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2661. {
  2662. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2663. if (groupData.Code != 0)
  2664. {
  2665. return Ok(JsonView(false, groupData.Msg));
  2666. }
  2667. #region 应用推送
  2668. try
  2669. {
  2670. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2671. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2672. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2673. //2024-10-21 新增LZ UID
  2674. var userIds = new List<int>() { 21 };
  2675. string title = $"系统通知";
  2676. string content = "";
  2677. var diId = dto.AirTicketResOpData.DiId;
  2678. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2679. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2680. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2681. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2682. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2683. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2684. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2685. }
  2686. catch (Exception ex)
  2687. {
  2688. }
  2689. #endregion
  2690. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2691. }
  2692. /// <summary>
  2693. /// 根据舱位类型查询接团客户名单信息
  2694. /// </summary>
  2695. /// <param name="dto"></param>
  2696. /// <returns></returns>
  2697. [HttpPost]
  2698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2699. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2700. {
  2701. try
  2702. {
  2703. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2704. if (crm_Groups.Count != 0)
  2705. {
  2706. List<dynamic> Customer = new List<dynamic>();
  2707. foreach (var item in crm_Groups)
  2708. {
  2709. var data = new
  2710. {
  2711. Id = item.Id,
  2712. Pinyin = item.Pinyin,
  2713. Name = item.LastName + item.FirstName
  2714. };
  2715. Customer.Add(data);
  2716. }
  2717. return Ok(JsonView(true, "查询成功!", Customer));
  2718. }
  2719. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2720. }
  2721. catch (Exception ex)
  2722. {
  2723. return Ok(JsonView(false, "程序错误!"));
  2724. throw;
  2725. }
  2726. }
  2727. /// <summary>
  2728. /// 根据团号获取客户信息
  2729. /// </summary>
  2730. /// <param name="dto"></param>
  2731. /// <returns></returns>
  2732. [HttpPost]
  2733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2734. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2735. {
  2736. var jw = JsonView(false);
  2737. if (dto.DIID < 1)
  2738. {
  2739. jw.Msg += "请输入正确的diid";
  2740. return Ok(jw);
  2741. }
  2742. var arr = getSimplClientList(dto.DIID);
  2743. jw = JsonView(true, "获取成功!", arr);
  2744. return Ok(jw);
  2745. }
  2746. private List<SimplClientInfo> getSimplClientList(int diId)
  2747. {
  2748. 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);
  2749. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2750. foreach (var item in arr)
  2751. {
  2752. EncryptionProcessor.DecryptProperties(item);
  2753. }
  2754. return arr;
  2755. }
  2756. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2757. {
  2758. string result = origin;
  2759. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2760. {
  2761. string[] temparr = origin.Split(',');
  2762. string fistrStr = temparr[0];
  2763. int count = temparr.Count();
  2764. int tempId;
  2765. bool success = int.TryParse(fistrStr, out tempId);
  2766. if (success)
  2767. {
  2768. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2769. if (tempInfo != null)
  2770. {
  2771. if (count > 1)
  2772. {
  2773. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2774. }
  2775. else
  2776. {
  2777. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2778. }
  2779. }
  2780. }
  2781. }
  2782. return result;
  2783. }
  2784. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2785. {
  2786. string result = origin;
  2787. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2788. {
  2789. string[] temparr = origin.Split(',');
  2790. result = "";
  2791. foreach (var item in temparr)
  2792. {
  2793. int tempId;
  2794. bool success = int.TryParse(item, out tempId);
  2795. if (success)
  2796. {
  2797. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2798. if (tempInfo != null)
  2799. {
  2800. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2801. }
  2802. }
  2803. }
  2804. }
  2805. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2806. return result;
  2807. }
  2808. /// <summary>
  2809. /// 机票费用录入,删除
  2810. /// </summary>
  2811. /// <param name="dto"></param>
  2812. /// <returns></returns>
  2813. [HttpPost]
  2814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2815. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2816. {
  2817. try
  2818. {
  2819. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2820. if (res)
  2821. {
  2822. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2823. {
  2824. IsDel = 1,
  2825. DeleteUserId = dto.DeleteUserId,
  2826. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2827. }).ExecuteCommandAsync();
  2828. return Ok(JsonView(true, "删除成功!"));
  2829. }
  2830. return Ok(JsonView(false, "删除失败!"));
  2831. }
  2832. catch (Exception ex)
  2833. {
  2834. return Ok(JsonView(false, "程序错误!"));
  2835. throw;
  2836. }
  2837. }
  2838. /// <summary>
  2839. /// 导出机票录入报表
  2840. /// </summary>
  2841. /// <param name="dto"></param>
  2842. /// <returns></returns>
  2843. [HttpPost]
  2844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2845. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2846. {
  2847. try
  2848. {
  2849. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2850. if (groupData.Code != 0)
  2851. {
  2852. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2853. }
  2854. else
  2855. {
  2856. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2857. if (AirTicketReservations.Count != 0)
  2858. {
  2859. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2860. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2861. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2862. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2863. WorkbookDesigner designer = new WorkbookDesigner();
  2864. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2865. decimal countCost = 0;
  2866. foreach (var item in AirTicketReservations)
  2867. {
  2868. #region 处理客人姓名
  2869. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2870. item.ClientName = clientNames;
  2871. #endregion
  2872. if (item.BankType == "其他")
  2873. {
  2874. item.BankNo = "--";
  2875. }
  2876. else
  2877. {
  2878. if (!string.IsNullOrEmpty(item.BankType))
  2879. {
  2880. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2881. }
  2882. }
  2883. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2884. item.Price = System.Decimal.Round(item.Price, 2);
  2885. countCost += Convert.ToDecimal(item.Price);
  2886. }
  2887. designer.SetDataSource("Export", AirTicketReservations);
  2888. designer.SetDataSource("ExportDiCode", diCode);
  2889. designer.SetDataSource("ExportDiName", diName);
  2890. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2891. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2892. designer.Process();
  2893. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2894. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2895. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2896. return Ok(JsonView(true, "成功", url = rst));
  2897. }
  2898. else
  2899. {
  2900. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2901. }
  2902. }
  2903. }
  2904. catch (Exception ex)
  2905. {
  2906. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2907. throw;
  2908. }
  2909. }
  2910. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2911. /// <summary>
  2912. /// 行程单导出
  2913. /// </summary>
  2914. /// <param name="dto"></param>
  2915. /// <returns></returns>
  2916. [HttpPost]
  2917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2918. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2919. {
  2920. try
  2921. {
  2922. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2923. if (groupData.Code != 0)
  2924. {
  2925. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2926. }
  2927. else
  2928. {
  2929. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2930. if (dto.Language == "CN")
  2931. {
  2932. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2933. DocumentBuilder builder = new DocumentBuilder(doc);
  2934. int tableIndex = 0;//表格索引
  2935. //得到文档中的第一个表格
  2936. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2937. foreach (var item in _AirTicketReservations)
  2938. {
  2939. #region 处理固定数据
  2940. string[] FlightsCode = item.FlightsCode.Split('/');
  2941. if (FlightsCode.Length != 0)
  2942. {
  2943. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2944. if (_AirCompany != null)
  2945. {
  2946. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2947. }
  2948. else
  2949. {
  2950. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2951. }
  2952. }
  2953. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2954. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2955. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2956. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2957. string name = "";
  2958. foreach (string clientName in nameArray)
  2959. {
  2960. if (!name.Contains(clientName))
  2961. {
  2962. name += clientName + ",";
  2963. }
  2964. }
  2965. if (!string.IsNullOrWhiteSpace(name))
  2966. {
  2967. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2968. }
  2969. else
  2970. {
  2971. table.Range.Bookmarks["ClientName"].Text = "--";
  2972. }
  2973. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2974. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2975. table.Range.Bookmarks["JointTicket"].Text = "--";
  2976. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2977. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2978. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2979. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2980. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2981. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2982. #endregion
  2983. #region 循环数据处理
  2984. List<AirInfo> airs = new List<AirInfo>();
  2985. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2986. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2987. for (int i = 0; i < FlightsCode.Length; i++)
  2988. {
  2989. AirInfo air = new AirInfo();
  2990. string[] tempstr = DayArray[i]
  2991. .Replace("\r\n", string.Empty)
  2992. .Replace("\\r\\n", string.Empty)
  2993. .TrimStart().TrimEnd()
  2994. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2995. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2996. string starCity = "";
  2997. if (star_Three != null)
  2998. {
  2999. starCity = star_Three.AirPort;
  3000. }
  3001. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3002. string EndCity = "";
  3003. if (End_Three != null)
  3004. {
  3005. EndCity = End_Three.AirPort;
  3006. }
  3007. air.Destination = starCity + "/" + EndCity;
  3008. air.Flight = FlightsCode[i];
  3009. air.SeatingClass = item.CTypeName;
  3010. string dateTime = tempstr[2];
  3011. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3012. air.FlightDate = DateTemp;
  3013. air.DepartureTime = tempstr[5];
  3014. air.LandingTime = tempstr[6];
  3015. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3016. air.TicketStatus = "--";
  3017. air.Luggage = "--";
  3018. air.DepartureTerminal = "--";
  3019. air.LandingTerminal = "--";
  3020. airs.Add(air);
  3021. }
  3022. int row = 13;
  3023. for (int i = 0; i < airs.Count; i++)
  3024. {
  3025. if (airs.Count > 2)
  3026. {
  3027. for (int j = 0; j < airs.Count - 2; j++)
  3028. {
  3029. var CopyRow = table.Rows[12].Clone(true);
  3030. table.Rows.Add(CopyRow);
  3031. }
  3032. }
  3033. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3034. int index = 0;
  3035. foreach (PropertyInfo property in properties)
  3036. {
  3037. string value = property.GetValue(airs[i]).ToString();
  3038. Cell ishcel0 = table.Rows[row].Cells[index];
  3039. Paragraph p = new Paragraph(doc);
  3040. string s = value;
  3041. p.AppendChild(new Run(doc, s));
  3042. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3043. ishcel0.AppendChild(p);
  3044. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3045. index++;
  3046. }
  3047. row++;
  3048. }
  3049. #endregion
  3050. Paragraph lastParagraph = new Paragraph(doc);
  3051. //第一个表格末尾加段落
  3052. table.ParentNode.InsertAfter(lastParagraph, table);
  3053. //复制第一个表格
  3054. Table cloneTable = (Table)table.Clone(true);
  3055. //在文档末尾段落后面加入复制的表格
  3056. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3057. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3058. {
  3059. int rownewsIndex = 13;
  3060. for (int i = 0; i < 2; i++)
  3061. {
  3062. var CopyRow = table.Rows[12].Clone(true);
  3063. table.Rows.RemoveAt(13);
  3064. table.Rows.Add(CopyRow);
  3065. rownewsIndex++;
  3066. }
  3067. }
  3068. else
  3069. {
  3070. table.Rows.RemoveAt(12);
  3071. }
  3072. cloneTable.Rows.RemoveAt(12);
  3073. }
  3074. if (_AirTicketReservations.Count != 0)
  3075. {
  3076. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3077. if (FlightsCode.Length != 0)
  3078. {
  3079. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3080. if (_AirCompany != null)
  3081. {
  3082. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3083. }
  3084. else
  3085. {
  3086. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3087. }
  3088. }
  3089. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3090. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3091. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3092. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3093. string name = "";
  3094. foreach (string clientName in nameArray)
  3095. {
  3096. if (!name.Contains(clientName))
  3097. {
  3098. name += clientName + ",";
  3099. }
  3100. }
  3101. if (!string.IsNullOrWhiteSpace(name))
  3102. {
  3103. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3104. }
  3105. else
  3106. {
  3107. table.Range.Bookmarks["ClientName"].Text = "--";
  3108. }
  3109. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3110. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3111. table.Range.Bookmarks["JointTicket"].Text = "--";
  3112. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3113. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3114. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3115. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3116. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3117. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3118. }
  3119. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3120. //保存合并后的文档
  3121. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3122. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3123. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3124. return Ok(JsonView(true, "成功!", rst));
  3125. }
  3126. else
  3127. {
  3128. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3129. DocumentBuilder builder = new DocumentBuilder(doc);
  3130. int tableIndex = 0;//表格索引
  3131. //得到文档中的第一个表格
  3132. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3133. List<string> texts = new List<string>();
  3134. foreach (var item in _AirTicketReservations)
  3135. {
  3136. string[] FlightsCode = item.FlightsCode.Split('/');
  3137. if (FlightsCode.Length != 0)
  3138. {
  3139. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3140. if (_AirCompany != null)
  3141. {
  3142. if (!transDic.ContainsKey(_AirCompany.CnName))
  3143. {
  3144. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3145. }
  3146. }
  3147. else
  3148. {
  3149. if (!transDic.ContainsKey("--"))
  3150. {
  3151. transDic.Add("--", "--");
  3152. }
  3153. }
  3154. }
  3155. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3156. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3157. string name = "";
  3158. foreach (string clientName in nameArray)
  3159. {
  3160. name += clientName + ",";
  3161. }
  3162. if (!texts.Contains(name))
  3163. {
  3164. texts.Add(name);
  3165. }
  3166. List<AirInfo> airs = new List<AirInfo>();
  3167. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3168. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3169. for (int i = 0; i < FlightsCode.Length; i++)
  3170. {
  3171. AirInfo air = new AirInfo();
  3172. string[] tempstr = DayArray[i]
  3173. .Replace("\r\n", string.Empty)
  3174. .Replace("\\r\\n", string.Empty)
  3175. .TrimStart().TrimEnd()
  3176. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3177. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3178. if (star_Three != null)
  3179. {
  3180. if (!transDic.ContainsKey(star_Three.AirPort))
  3181. {
  3182. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3183. }
  3184. }
  3185. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3186. if (End_Three != null)
  3187. {
  3188. if (!transDic.ContainsKey(End_Three.AirPort))
  3189. {
  3190. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3191. }
  3192. }
  3193. if (!texts.Contains(item.CTypeName))
  3194. {
  3195. texts.Add(item.CTypeName);
  3196. }
  3197. }
  3198. }
  3199. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3200. if (transData.Count > 0)
  3201. {
  3202. foreach (TranslateResult item in transData)
  3203. {
  3204. if (!transDic.ContainsKey(item.Query))
  3205. {
  3206. transDic.Add(item.Query, item.Translation);
  3207. }
  3208. }
  3209. }
  3210. foreach (var item in _AirTicketReservations)
  3211. {
  3212. #region 处理固定数据
  3213. string[] FlightsCode = item.FlightsCode.Split('/');
  3214. if (FlightsCode.Length != 0)
  3215. {
  3216. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3217. if (_AirCompany != null)
  3218. {
  3219. string str = "--";
  3220. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3221. if (!string.IsNullOrEmpty(translateResult))
  3222. {
  3223. str = translateResult;
  3224. str = _airTicketResRep.Processing(str);
  3225. }
  3226. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3227. }
  3228. else
  3229. {
  3230. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3231. }
  3232. }
  3233. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3234. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3235. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3236. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3237. string names = "";
  3238. foreach (string clientName in nameArray)
  3239. {
  3240. names += clientName + ",";
  3241. }
  3242. if (!string.IsNullOrWhiteSpace(names))
  3243. {
  3244. string str = "--";
  3245. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3246. if (!string.IsNullOrEmpty(translateResult))
  3247. {
  3248. str = translateResult;
  3249. str = _airTicketResRep.Processing(str);
  3250. }
  3251. table.Range.Bookmarks["ClientName"].Text = str;
  3252. }
  3253. else
  3254. {
  3255. table.Range.Bookmarks["ClientName"].Text = "--";
  3256. }
  3257. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3258. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3259. table.Range.Bookmarks["JointTicket"].Text = "--";
  3260. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3261. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3262. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3263. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3264. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3265. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3266. #endregion
  3267. #region 循环数据处理
  3268. List<AirInfo> airs = new List<AirInfo>();
  3269. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3270. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3271. for (int i = 0; i < FlightsCode.Length; i++)
  3272. {
  3273. AirInfo air = new AirInfo();
  3274. string[] tempstr = DayArray[i]
  3275. .Replace("\r\n", string.Empty)
  3276. .Replace("\\r\\n", string.Empty)
  3277. .TrimStart().TrimEnd()
  3278. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3279. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3280. string starCity = "";
  3281. if (star_Three != null)
  3282. {
  3283. string str2 = "--";
  3284. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3285. if (!string.IsNullOrEmpty(translateResult2))
  3286. {
  3287. str2 = translateResult2;
  3288. str2 = _airTicketResRep.Processing(str2);
  3289. }
  3290. starCity = str2;
  3291. }
  3292. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3293. string EndCity = "";
  3294. if (End_Three != null)
  3295. {
  3296. string str1 = "--";
  3297. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3298. if (!string.IsNullOrEmpty(translateResult1))
  3299. {
  3300. str1 = translateResult1;
  3301. str1 = _airTicketResRep.Processing(str1);
  3302. }
  3303. EndCity = str1;
  3304. }
  3305. air.Destination = starCity + "/" + EndCity;
  3306. air.Flight = FlightsCode[i];
  3307. string str = "--";
  3308. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3309. if (!string.IsNullOrEmpty(translateResult))
  3310. {
  3311. str = translateResult;
  3312. str = _airTicketResRep.Processing(str);
  3313. }
  3314. air.SeatingClass = str;
  3315. string dateTime = tempstr[2];
  3316. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3317. air.FlightDate = DateTemp;
  3318. air.DepartureTime = tempstr[5];
  3319. air.LandingTime = tempstr[6];
  3320. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3321. air.TicketStatus = "--";
  3322. air.Luggage = "--";
  3323. air.DepartureTerminal = "--";
  3324. air.LandingTerminal = "--";
  3325. airs.Add(air);
  3326. }
  3327. int row = 13;
  3328. for (int i = 0; i < airs.Count; i++)
  3329. {
  3330. if (airs.Count > 2)
  3331. {
  3332. for (int j = 0; j < airs.Count - 2; j++)
  3333. {
  3334. var CopyRow = table.Rows[12].Clone(true);
  3335. table.Rows.Add(CopyRow);
  3336. }
  3337. }
  3338. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3339. int index = 0;
  3340. foreach (PropertyInfo property in properties)
  3341. {
  3342. string value = property.GetValue(airs[i]).ToString();
  3343. Cell ishcel0 = table.Rows[row].Cells[index];
  3344. Paragraph p = new Paragraph(doc);
  3345. string s = value;
  3346. p.AppendChild(new Run(doc, s));
  3347. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3348. ishcel0.AppendChild(p);
  3349. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3350. //ishcel0.CellFormat.VerticalAlignment=
  3351. index++;
  3352. }
  3353. row++;
  3354. }
  3355. #endregion
  3356. Paragraph lastParagraph = new Paragraph(doc);
  3357. //第一个表格末尾加段落
  3358. table.ParentNode.InsertAfter(lastParagraph, table);
  3359. //复制第一个表格
  3360. Table cloneTable = (Table)table.Clone(true);
  3361. //在文档末尾段落后面加入复制的表格
  3362. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3363. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3364. {
  3365. int rownewsIndex = 13;
  3366. for (int i = 0; i < 2; i++)
  3367. {
  3368. var CopyRow = table.Rows[12].Clone(true);
  3369. table.Rows.RemoveAt(13);
  3370. table.Rows.Add(CopyRow);
  3371. rownewsIndex++;
  3372. }
  3373. }
  3374. else
  3375. {
  3376. table.Rows.RemoveAt(12);
  3377. }
  3378. cloneTable.Rows.RemoveAt(12);
  3379. }
  3380. if (_AirTicketReservations.Count != 0)
  3381. {
  3382. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3383. if (FlightsCode.Length != 0)
  3384. {
  3385. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3386. if (_AirCompany != null)
  3387. {
  3388. string str = "--";
  3389. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3390. if (!string.IsNullOrEmpty(translateResult))
  3391. {
  3392. str = translateResult;
  3393. str = _airTicketResRep.Processing(str);
  3394. }
  3395. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3396. }
  3397. else
  3398. {
  3399. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3400. }
  3401. }
  3402. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3403. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3404. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3405. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3406. string names = "";
  3407. foreach (string clientName in nameArray)
  3408. {
  3409. names += clientName + ",";
  3410. }
  3411. if (!string.IsNullOrWhiteSpace(names))
  3412. {
  3413. string str = "--";
  3414. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3415. if (!string.IsNullOrEmpty(translateResult))
  3416. {
  3417. str = translateResult;
  3418. str = _airTicketResRep.Processing(str);
  3419. }
  3420. table.Range.Bookmarks["ClientName"].Text = str;
  3421. }
  3422. else
  3423. {
  3424. table.Range.Bookmarks["ClientName"].Text = "--";
  3425. }
  3426. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3427. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3428. table.Range.Bookmarks["JointTicket"].Text = "--";
  3429. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3430. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3431. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3432. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3433. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3434. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3435. }
  3436. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3437. //保存合并后的文档
  3438. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3439. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3440. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3441. return Ok(JsonView(true, "成功!", rst));
  3442. }
  3443. }
  3444. }
  3445. catch (Exception ex)
  3446. {
  3447. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3448. throw;
  3449. }
  3450. }
  3451. #endregion
  3452. #region 团组增减款项 --> 其他款项
  3453. /// <summary>
  3454. /// 团组增减款项下拉框绑定
  3455. /// </summary>
  3456. /// <param name="dto"></param>
  3457. /// <returns></returns>
  3458. [HttpPost]
  3459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3460. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3461. {
  3462. #region 参数验证
  3463. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3464. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3465. #endregion
  3466. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3467. }
  3468. /// <summary>
  3469. /// 根据团组Id查询团组增减款项
  3470. /// </summary>
  3471. /// <param name="dto"></param>
  3472. /// <returns></returns>
  3473. [HttpPost]
  3474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3475. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3476. {
  3477. #region 参数验证
  3478. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3479. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3480. #endregion
  3481. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3482. }
  3483. /// <summary>
  3484. /// 团组增减款项操作(Status:1.新增,2.修改)
  3485. /// </summary>
  3486. /// <param name="dto"></param>
  3487. /// <returns></returns>
  3488. [HttpPost]
  3489. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3490. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3491. {
  3492. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3493. if (groupData.Code != 200)
  3494. {
  3495. return Ok(JsonView(false, groupData.Msg));
  3496. }
  3497. #region 应用推送
  3498. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3499. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3500. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3501. //自动审核
  3502. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3503. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3504. //2024-10-21 新增LZ UID
  3505. var userIds = new List<int>() { 21 };
  3506. string title = $"系统通知";
  3507. string content = "";
  3508. var diId = dto.DiId;
  3509. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3510. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3511. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3512. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3513. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3514. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3515. #endregion
  3516. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3517. }
  3518. /// <summary>
  3519. /// 团组增减款项操作 删除
  3520. /// </summary>
  3521. /// <param name="dto"></param>
  3522. /// <returns></returns>
  3523. [HttpPost]
  3524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3525. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3526. {
  3527. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3528. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3529. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3530. if (res.Code == 0)
  3531. {
  3532. return Ok(JsonView(true, "删除成功!"));
  3533. }
  3534. return Ok(JsonView(false, "删除失败!"));
  3535. }
  3536. /// <summary>
  3537. /// 根据团组增减款项Id查询
  3538. /// </summary>
  3539. /// <param name="dto"></param>
  3540. /// <returns></returns>
  3541. [HttpPost]
  3542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3543. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3544. {
  3545. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3546. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3547. }
  3548. /// <summary>
  3549. /// 查询供应商名称
  3550. /// </summary>
  3551. /// <param name="dto"></param>
  3552. /// <returns></returns>
  3553. [HttpPost]
  3554. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3555. {
  3556. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3557. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3558. ?? new List<Grp_DecreasePayments>();
  3559. dbResult = dbResult.Distinct(new
  3560. ProductComparer()).ToList();
  3561. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3562. {
  3563. x.Id,
  3564. x.SupplierAddress,
  3565. x.SupplierArea,
  3566. x.SupplierContact,
  3567. x.SupplierContactNumber,
  3568. x.SupplierEmail,
  3569. x.SupplierName,
  3570. x.SupplierSocialAccount,
  3571. x.SupplierTypeId,
  3572. }).ToList());
  3573. return Ok(jw);
  3574. }
  3575. /// <summary>
  3576. /// 团组增减款项 OTA匹配
  3577. /// </summary>
  3578. /// <param name="file"></param>
  3579. /// <returns></returns>
  3580. [HttpPost]
  3581. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3582. {
  3583. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3584. string fileName = file.FileName;
  3585. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3586. {
  3587. return Ok(JsonView(false, "请上传Excel文件!"));
  3588. }
  3589. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3590. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3591. if (!Directory.Exists(path))
  3592. {
  3593. Directory.CreateDirectory(path);
  3594. }
  3595. var filePath = @$"{path}/{fileName}";
  3596. //保存文件
  3597. using (FileStream fs = System.IO.File.Create(filePath))
  3598. {
  3599. file.CopyTo(fs);
  3600. fs.Flush();
  3601. }
  3602. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3603. //读取ExcelFile
  3604. DataTable dt = ConvertExcelToDataTable(filePath);
  3605. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3606. dt.TableName = "TB";
  3607. //修改table列名
  3608. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3609. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3610. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3611. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3612. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3613. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3614. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3615. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3616. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3617. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3618. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3619. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3620. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3621. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3622. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3623. var otaOrderNos = new List<string>();
  3624. foreach (DataRow item in dt.Rows)
  3625. {
  3626. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3627. }
  3628. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3629. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3630. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3631. .Select((dp, di) => new
  3632. {
  3633. dp.PriceName,
  3634. dp.OTAOrderNo,
  3635. dp.FeeTotal,
  3636. di.TeamName,
  3637. })
  3638. .ToListAsync();
  3639. foreach (DataRow item in dt.Rows)
  3640. {
  3641. var otaOrderNo = item["OTAOrderNo"].ToString();
  3642. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3643. if (oaData == null) continue;
  3644. item["GroupName"] = oaData.TeamName;
  3645. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3646. }
  3647. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3648. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3649. List<DataTable> datas = new List<DataTable>();
  3650. datas.Add(dt);
  3651. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3652. return Ok(JsonView(true, "操作成功", new { url = url }));
  3653. }
  3654. #region
  3655. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3656. {
  3657. // 创建Workbook对象
  3658. Workbook workbook = new Workbook(excelFilePath);
  3659. // 获取第一个工作表
  3660. Worksheet worksheet = workbook.Worksheets[0];
  3661. // 将工作表转换为DataTable
  3662. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3663. return dataTable;
  3664. }
  3665. #endregion
  3666. #endregion
  3667. #region 文件上传、删除
  3668. /// <summary>
  3669. /// region 文件上传 可以带参数
  3670. /// </summary>
  3671. /// <param name="file"></param>
  3672. /// <returns></returns>
  3673. [HttpPost]
  3674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3675. public async Task<IActionResult> UploadProject(IFormFile file)
  3676. {
  3677. //var TypeName = Request.Headers["TypeName"].ToString();
  3678. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3679. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3680. ////文件名称
  3681. //string projectFileName = file.FileName;
  3682. ////上传的文件的路径
  3683. //string filePath = $"{fileDir}/{projectFileName}";
  3684. //if (TypeName == "A")//A代表团组增减款项
  3685. //{
  3686. // filePath = fileDir + $@"\团组增减款项相关文件";
  3687. // if (!Directory.Exists(filePath))
  3688. // {
  3689. // Directory.CreateDirectory(filePath);
  3690. // }
  3691. // //上传的文件的路径
  3692. // filePath += $@"\{projectFileName}";
  3693. //}
  3694. //else if (TypeName == "B")//B代表商邀相关文件
  3695. //{
  3696. // //上传的文件的路径
  3697. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3698. // if (!Directory.Exists(filePath))
  3699. // {
  3700. // Directory.CreateDirectory(filePath);
  3701. // }
  3702. // //上传的文件的路径
  3703. // filePath = $@"\{projectFileName}";
  3704. //}
  3705. //try
  3706. //{
  3707. // using (FileStream fs = System.IO.File.Create(filePath))
  3708. // {
  3709. // file.CopyTo(fs);
  3710. // fs.Flush();
  3711. // }
  3712. //}
  3713. //catch (Exception ex)
  3714. //{
  3715. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3716. //}
  3717. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3718. try
  3719. {
  3720. var TypeName = Request.Headers["TypeName"].ToString();
  3721. if (file != null)
  3722. {
  3723. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3724. //文件名称
  3725. string projectFileName = file.FileName;
  3726. //上传的文件的路径
  3727. string filePath = $"{fileDir}/{projectFileName}";
  3728. if (TypeName == "A")//A代表团组增减款项
  3729. {
  3730. if (!Directory.Exists(fileDir))
  3731. {
  3732. Directory.CreateDirectory(fileDir);
  3733. }
  3734. //上传的文件的路径
  3735. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3736. }
  3737. else if (TypeName == "B")//B代表商邀相关文件
  3738. {
  3739. if (!Directory.Exists(fileDir))
  3740. {
  3741. Directory.CreateDirectory(fileDir);
  3742. }
  3743. //上传的文件的路径
  3744. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3745. }
  3746. using (FileStream fs = System.IO.File.Create(filePath))
  3747. {
  3748. file.CopyTo(fs);
  3749. fs.Flush();
  3750. }
  3751. return Ok(JsonView(true, "上传成功!", projectFileName));
  3752. }
  3753. else
  3754. {
  3755. return Ok(JsonView(false, "上传失败!"));
  3756. }
  3757. }
  3758. catch (Exception ex)
  3759. {
  3760. return Ok(JsonView(false, "程序错误!"));
  3761. }
  3762. }
  3763. /// <summary>
  3764. /// 删除指定文件
  3765. /// </summary>
  3766. /// <param name="dto"></param>
  3767. /// <returns></returns>
  3768. [HttpPost]
  3769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3770. public async Task<IActionResult> DelFile(DelFileDto dto)
  3771. {
  3772. try
  3773. {
  3774. var TypeName = Request.Headers["TypeName"].ToString();
  3775. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3776. string filePath = "";
  3777. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3778. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3779. int id = 0;
  3780. if (TypeName == "A")
  3781. {
  3782. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3783. // 删除该文件
  3784. System.IO.File.Delete(filePath);
  3785. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3786. .Where(a => a.Id == dto.Id)
  3787. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3788. .ExecuteCommandAsync();
  3789. }
  3790. else if (TypeName == "B")
  3791. {
  3792. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3793. // 删除该文件
  3794. System.IO.File.Delete(filePath);
  3795. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3796. if (info != null)
  3797. {
  3798. string[] files = new string[] { };
  3799. if (!string.IsNullOrEmpty(info.Attachment))
  3800. {
  3801. try
  3802. {
  3803. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3804. }
  3805. catch (Exception)
  3806. {
  3807. files = new List<string>() { info.Attachment }.ToArray();
  3808. }
  3809. }
  3810. if (files.Length > 0)
  3811. {
  3812. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3813. string filePath2 = string.Empty;
  3814. if (files1.Length > 0)
  3815. {
  3816. filePath2 = JsonConvert.SerializeObject(files1);
  3817. }
  3818. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3819. .Where(a => a.Id == dto.Id)
  3820. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3821. .ExecuteCommandAsync();
  3822. }
  3823. }
  3824. }
  3825. if (id != 0)
  3826. {
  3827. return Ok(JsonView(true, "成功!"));
  3828. }
  3829. else
  3830. {
  3831. return Ok(JsonView(false, "失败!"));
  3832. }
  3833. }
  3834. catch (Exception ex)
  3835. {
  3836. return Ok(JsonView(false, "程序错误!"));
  3837. throw;
  3838. }
  3839. }
  3840. /// <summary>
  3841. /// 文件上传多个文件 可以带参数
  3842. /// </summary>
  3843. /// <param name="file"></param>
  3844. /// <returns></returns>
  3845. [HttpPost]
  3846. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3847. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3848. {
  3849. try
  3850. {
  3851. var TypeName = Request.Headers["TypeName"].ToString();
  3852. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3853. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3854. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3855. var filePahts = new List<string>();
  3856. foreach (var file in files)
  3857. {
  3858. //文件名称
  3859. string projectFileName = file.FileName;
  3860. //上传的文件的路径
  3861. string filePath = $"{fileDir}/{projectFileName}";
  3862. if (TypeName == "A")//A代表团组增减款项
  3863. {
  3864. if (!Directory.Exists(fileDir))
  3865. {
  3866. Directory.CreateDirectory(fileDir);
  3867. }
  3868. //上传的文件的路径
  3869. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3870. }
  3871. else if (TypeName == "B")//B代表商邀相关文件
  3872. {
  3873. if (!Directory.Exists(fileDir))
  3874. {
  3875. Directory.CreateDirectory(fileDir);
  3876. }
  3877. //上传的文件的路径
  3878. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3879. }
  3880. using (FileStream fs = System.IO.File.Create(filePath))
  3881. {
  3882. file.CopyTo(fs);
  3883. fs.Flush();
  3884. }
  3885. filePahts.Add(projectFileName);
  3886. }
  3887. return Ok(JsonView(true, "上传成功!", filePahts));
  3888. }
  3889. catch (Exception ex)
  3890. {
  3891. return Ok(JsonView(false, "程序错误!"));
  3892. }
  3893. }
  3894. #endregion
  3895. #region 商邀费用录入
  3896. /// <summary>
  3897. /// 根据团组Id查询商邀费用列表
  3898. /// </summary>
  3899. /// <param name="dto"></param>
  3900. /// <returns></returns>
  3901. [HttpPost]
  3902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3903. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3904. {
  3905. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3906. if (groupData.Code != 0)
  3907. {
  3908. return Ok(JsonView(false, groupData.Msg));
  3909. }
  3910. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3911. }
  3912. /// <summary>
  3913. /// 商邀费用列表
  3914. /// 下载文件
  3915. /// </summary>
  3916. /// <param name="dto"></param>
  3917. /// <returns></returns>
  3918. [HttpGet("{id}")]
  3919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3920. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3921. {
  3922. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3923. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3924. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3925. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3926. var filePaths = new List<string>();
  3927. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3928. try
  3929. {
  3930. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3931. }
  3932. catch (Exception ex)
  3933. {
  3934. filePaths.Add(info.Attachment);
  3935. }
  3936. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3937. for (int i = 0; i < filePaths.Count; i++)
  3938. {
  3939. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3940. }
  3941. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3942. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3943. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3944. {
  3945. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3946. {
  3947. foreach (string filePath in filePaths)
  3948. {
  3949. if (System.IO.File.Exists(filePath))
  3950. {
  3951. // 获取文件名
  3952. string fileName = Path.GetFileName(filePath);
  3953. // 将文件添加到ZIP归档中
  3954. zipArchive.CreateEntryFromFile(filePath, fileName);
  3955. }
  3956. }
  3957. }
  3958. }
  3959. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3960. }
  3961. /// <summary>
  3962. /// 商邀费用 Info Page 基础数据源
  3963. /// </summary>
  3964. /// <param name="dto"></param>
  3965. /// <returns></returns>
  3966. [HttpPost]
  3967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3968. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3969. {
  3970. try
  3971. {
  3972. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3973. if (groupData.Code != 0)
  3974. {
  3975. return Ok(JsonView(false, groupData.Msg));
  3976. }
  3977. return Ok(JsonView(true, "操作成功", groupData.Data));
  3978. }
  3979. catch (Exception ex)
  3980. {
  3981. return Ok(JsonView(false, ex.Message));
  3982. throw;
  3983. }
  3984. }
  3985. /// <summary>
  3986. /// 根据商邀费用ID查询C表和商邀费用数据
  3987. /// </summary>
  3988. /// <param name="dto"></param>
  3989. /// <returns></returns>
  3990. [HttpPost]
  3991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3992. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3993. {
  3994. try
  3995. {
  3996. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3997. if (groupData.Code != 0)
  3998. {
  3999. return Ok(JsonView(false, groupData.Msg));
  4000. }
  4001. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4002. }
  4003. catch (Exception ex)
  4004. {
  4005. return Ok(JsonView(false, ex.Message));
  4006. throw;
  4007. }
  4008. }
  4009. /// <summary>
  4010. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4011. /// </summary>
  4012. /// <param name="dto"></param>
  4013. /// <returns></returns>
  4014. [HttpPost]
  4015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4016. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4017. {
  4018. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4019. if (groupData.Code != 0)
  4020. {
  4021. return Ok(JsonView(false, groupData.Msg));
  4022. }
  4023. #region 应用推送
  4024. try
  4025. {
  4026. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4027. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4028. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4029. //2024-10-21 新增LZ UID
  4030. var userIds = new List<int>() { 21 };
  4031. string title = $"系统通知";
  4032. string content = "";
  4033. var diId = dto.DiId;
  4034. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4035. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4036. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4037. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4038. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4039. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4040. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4041. }
  4042. catch (Exception ex)
  4043. {
  4044. }
  4045. #endregion
  4046. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4047. }
  4048. /// <summary>
  4049. /// 商邀删除
  4050. /// </summary>
  4051. /// <param name="dto"></param>
  4052. /// <returns></returns>
  4053. [HttpPost]
  4054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4055. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4056. {
  4057. try
  4058. {
  4059. _sqlSugar.BeginTran();
  4060. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4061. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4062. {
  4063. IsDel = 1,
  4064. DeleteUserId = dto.DeleteUserId,
  4065. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4066. })
  4067. .Where(it => it.Id == dto.Id)
  4068. .ExecuteCommand();
  4069. if (res1 > 0)
  4070. {
  4071. int _diId = 0;
  4072. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4073. if (_ioaInfo != null)
  4074. {
  4075. _diId = _ioaInfo.DiId;
  4076. }
  4077. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4078. .SetColumns(a => new Grp_CreditCardPayment()
  4079. {
  4080. IsDel = 1,
  4081. DeleteUserId = dto.DeleteUserId,
  4082. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4083. })
  4084. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4085. .ExecuteCommand();
  4086. if (res2 > 0)
  4087. {
  4088. _sqlSugar.CommitTran();
  4089. return Ok(JsonView(true, "删除成功!"));
  4090. }
  4091. }
  4092. _sqlSugar.RollbackTran();
  4093. return Ok(JsonView(false, "删除失败"));
  4094. }
  4095. catch (Exception ex)
  4096. {
  4097. _sqlSugar.RollbackTran();
  4098. return Ok(JsonView(false, ex.Message));
  4099. }
  4100. }
  4101. /// <summary>
  4102. /// 团组模块文件上传
  4103. /// </summary>
  4104. /// <param name="dto"></param>
  4105. /// <returns></returns>
  4106. [HttpPost]
  4107. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4108. {
  4109. var jw = JsonView(false);
  4110. long M = 1024 * 1024;
  4111. if (dto.Files == null || dto.Files.Count == 0)
  4112. {
  4113. jw.Msg = "无文件信息!";
  4114. return Ok(jw);
  4115. }
  4116. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4117. {
  4118. jw.Msg = "文件大小超过20M!";
  4119. return Ok(jw);
  4120. }
  4121. //var nameSp = dto.File.FileName.Split(".");
  4122. //if (nameSp.Length < 2)
  4123. //{
  4124. // jw.Msg = "拓展名称有误!";
  4125. // return Ok(jw);
  4126. //}
  4127. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4128. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4129. //{
  4130. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4131. // return Ok(jw);
  4132. //}
  4133. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4134. if (Ctable == null)
  4135. {
  4136. jw.Msg = "Ctable指向有误!";
  4137. return Ok(jw);
  4138. }
  4139. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4140. if (groupInfo == null)
  4141. {
  4142. jw.Msg = "团组信息不存在!";
  4143. return Ok(jw);
  4144. }
  4145. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4146. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4147. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4148. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4149. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4150. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4151. try
  4152. {
  4153. if (!Directory.Exists(fileBase))
  4154. {
  4155. Directory.CreateDirectory(fileBase);
  4156. }
  4157. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4158. foreach (var fileStream in dto.Files)
  4159. {
  4160. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4161. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4162. {
  4163. Cid = dto.Cid,
  4164. CreateTime = DateTime.Now,
  4165. CreateUserId = dto.Userid,
  4166. Ctable = dto.Ctable,
  4167. Diid = dto.Diid,
  4168. IsDel = 0,
  4169. FilePath = saveFilePath,
  4170. FileName = fileStream.FileName
  4171. };
  4172. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4173. {
  4174. fileStream.CopyTo(fs);
  4175. fs.Flush();
  4176. }
  4177. saveArr.Add(file);
  4178. }
  4179. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4180. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4181. jw = JsonView(true, "保存成功!", new
  4182. {
  4183. count = addResult,
  4184. filesName = saveArr.Select(x => x.FileName)
  4185. });
  4186. }
  4187. catch (Exception ex)
  4188. {
  4189. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4190. {
  4191. count = 0,
  4192. filesName = new string[0],
  4193. });
  4194. }
  4195. return Ok(jw);
  4196. }
  4197. /// <summary>
  4198. /// 查询各模块已保存文件
  4199. /// </summary>
  4200. /// <param name="dto"></param>
  4201. /// <returns></returns>
  4202. [HttpPost]
  4203. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4204. {
  4205. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4206. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4207. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4208. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4209. {
  4210. expression = Expressionable.Create<Grp_GroupModelFile>()
  4211. .And(x => visaIds.Contains(x.CreateUserId));
  4212. }
  4213. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4214. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4215. .Where(expression.ToExpression())
  4216. .ToList();
  4217. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4218. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4219. {
  4220. x.FileName,
  4221. x.Id,
  4222. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4223. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4224. })));
  4225. }
  4226. /// <summary>
  4227. /// 下载该团组下的所有文件
  4228. /// </summary>
  4229. /// <param name="dto"></param>
  4230. /// <returns></returns>
  4231. [HttpPost]
  4232. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4233. {
  4234. var jw = JsonView(false);
  4235. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4236. if (groupInfo == null)
  4237. {
  4238. jw.Msg = "团组信息不存在!";
  4239. return Ok(jw);
  4240. }
  4241. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4242. var isModule = Convert.ToBoolean(dto.isModule);
  4243. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4244. IOOperatorHelper io = new IOOperatorHelper();
  4245. if (isModule)
  4246. {
  4247. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4248. foreach (var moduleArr in moduleGroup)
  4249. {
  4250. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4251. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4252. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4253. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4254. foreach (var item in moduleArr)
  4255. {
  4256. if (System.IO.File.Exists(item.FilePath))
  4257. {
  4258. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4259. {
  4260. byte[] bytes = new byte[fileStream.Length];
  4261. fileStream.Read(bytes, 0, bytes.Length);
  4262. fileStream.Close();
  4263. Stream stream = new MemoryStream(bytes);
  4264. chiZips.Add(item.FileName, stream);
  4265. }
  4266. }
  4267. }
  4268. if (chiZips.Count > 0)
  4269. {
  4270. var byts = io.ConvertZipStream(chiZips);
  4271. Stream stream = new MemoryStream(byts);
  4272. Zips.Add(key.Name + "_.zip", stream);
  4273. }
  4274. }
  4275. }
  4276. else
  4277. {
  4278. foreach (var item in dbQuery)
  4279. {
  4280. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4281. {
  4282. byte[] bytes = new byte[fileStream.Length];
  4283. fileStream.Read(bytes, 0, bytes.Length);
  4284. fileStream.Close();
  4285. Stream stream = new MemoryStream(bytes);
  4286. while (Zips.Keys.Contains(item.FileName))
  4287. {
  4288. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4289. }
  4290. Zips.Add(item.FileName, stream);
  4291. }
  4292. }
  4293. }
  4294. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4295. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4296. if (Zips.Count > 0)
  4297. {
  4298. var byts = io.ConvertZipStream(Zips);
  4299. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4300. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4301. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4302. }
  4303. else
  4304. {
  4305. jw.Msg = "暂无生成文件!";
  4306. }
  4307. return Ok(jw);
  4308. }
  4309. /// <summary>
  4310. /// 下载该团组下此模块的所有文件
  4311. /// </summary>
  4312. /// <param name="dto"></param>
  4313. /// <returns></returns>
  4314. [HttpPost]
  4315. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4316. {
  4317. var jw = JsonView(false);
  4318. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4319. if (groupInfo == null)
  4320. {
  4321. jw.Msg = "团组信息不存在!";
  4322. return Ok(jw);
  4323. }
  4324. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4325. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4326. && x.IsDel == 0);
  4327. if (key == null)
  4328. {
  4329. jw.Msg = "Ctable指向错误!";
  4330. return Ok(jw);
  4331. }
  4332. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4333. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4334. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4335. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4336. IOOperatorHelper io = new IOOperatorHelper();
  4337. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4338. foreach (var item in dbQuery)
  4339. {
  4340. if (System.IO.File.Exists(item.FilePath))
  4341. {
  4342. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4343. {
  4344. byte[] bytes = new byte[fileStream.Length];
  4345. fileStream.Read(bytes, 0, bytes.Length);
  4346. fileStream.Close();
  4347. Stream stream = new MemoryStream(bytes);
  4348. while (Zips.Keys.Contains(item.FileName))
  4349. {
  4350. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4351. }
  4352. Zips.Add(item.FileName, stream);
  4353. }
  4354. }
  4355. }
  4356. if (Zips.Count > 0)
  4357. {
  4358. var byts = io.ConvertZipStream(Zips);
  4359. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4360. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4361. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4362. }
  4363. else
  4364. {
  4365. jw.Msg = "暂无生成文件!";
  4366. }
  4367. return Ok(jw);
  4368. }
  4369. /// <summary>
  4370. /// 删除该团组下的指定文件
  4371. /// </summary>
  4372. /// <param name="dto"></param>
  4373. /// <returns></returns>
  4374. [HttpPost]
  4375. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4376. {
  4377. var jw = JsonView(false);
  4378. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4379. if (sing == null)
  4380. {
  4381. jw.Msg = "暂无";
  4382. return Ok(jw);
  4383. }
  4384. if (System.IO.File.Exists(sing.FilePath))
  4385. {
  4386. try
  4387. {
  4388. System.IO.File.Delete(sing.FilePath);
  4389. }
  4390. catch (Exception ex)
  4391. {
  4392. jw.Msg = "删除失败!" + ex.Message;
  4393. return Ok(jw);
  4394. }
  4395. }
  4396. sing.IsDel = 1;
  4397. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4398. sing.DeleteUserId = dto.UserId;
  4399. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4400. jw = JsonView(true, "删除成功!");
  4401. return Ok(jw);
  4402. }
  4403. #endregion
  4404. #region 团组英文资料
  4405. /// <summary>
  4406. /// 查询团组英文所有资料
  4407. /// </summary>
  4408. /// <param name="dto"></param>
  4409. /// <returns></returns>
  4410. [HttpPost]
  4411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4412. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4413. {
  4414. try
  4415. {
  4416. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4417. if (groupData.Code != 0)
  4418. {
  4419. return Ok(JsonView(false, groupData.Msg));
  4420. }
  4421. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4422. }
  4423. catch (Exception ex)
  4424. {
  4425. return Ok(JsonView(false, "程序错误!"));
  4426. throw;
  4427. }
  4428. }
  4429. /// <summary>
  4430. /// 团组英文资料操作(Status:1.新增,2.修改)
  4431. /// </summary>
  4432. /// <param name="dto"></param>
  4433. /// <returns></returns>
  4434. [HttpPost]
  4435. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4436. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4437. {
  4438. try
  4439. {
  4440. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4441. if (groupData.Code != 0)
  4442. {
  4443. return Ok(JsonView(false, groupData.Msg));
  4444. }
  4445. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4446. }
  4447. catch (Exception ex)
  4448. {
  4449. return Ok(JsonView(false, "程序错误!"));
  4450. throw;
  4451. }
  4452. }
  4453. /// <summary>
  4454. /// 团组英文资料Id查询数据
  4455. /// </summary>
  4456. /// <param name="dto"></param>
  4457. /// <returns></returns>
  4458. [HttpPost]
  4459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4460. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4461. {
  4462. try
  4463. {
  4464. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4465. if (_DelegationEnData != null)
  4466. {
  4467. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4468. }
  4469. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4470. }
  4471. catch (Exception ex)
  4472. {
  4473. return Ok(JsonView(false, "程序错误!"));
  4474. throw;
  4475. }
  4476. }
  4477. /// <summary>
  4478. /// 团组英文资料删除
  4479. /// </summary>
  4480. /// <param name="dto"></param>
  4481. /// <returns></returns>
  4482. [HttpPost]
  4483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4484. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4485. {
  4486. try
  4487. {
  4488. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4489. if (!res)
  4490. {
  4491. return Ok(JsonView(false, "删除失败"));
  4492. }
  4493. return Ok(JsonView(true, "删除成功!"));
  4494. }
  4495. catch (Exception ex)
  4496. {
  4497. return Ok(JsonView(false, "程序错误!"));
  4498. throw;
  4499. }
  4500. }
  4501. #endregion
  4502. #region 导出邀请函
  4503. /// <summary>
  4504. /// 导出邀请函页面初始化
  4505. /// </summary>
  4506. /// <param name="dto"></param>
  4507. /// <returns></returns>
  4508. [HttpPost]
  4509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4510. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4511. {
  4512. try
  4513. {
  4514. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4515. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4516. if (dto.DiId == 0)
  4517. {
  4518. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4519. }
  4520. else
  4521. {
  4522. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4523. }
  4524. return Ok(JsonView(true, "查询成功!", new
  4525. {
  4526. deleClient = crm_Deles,
  4527. delegations = grp_Delegations
  4528. }));
  4529. }
  4530. catch (Exception ex)
  4531. {
  4532. return Ok(JsonView(false, "程序错误!"));
  4533. throw;
  4534. }
  4535. }
  4536. /// <summary>
  4537. /// 导出邀请函
  4538. /// </summary>
  4539. /// <param name="dto"></param>
  4540. /// <returns></returns>
  4541. [HttpPost]
  4542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4543. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4544. {
  4545. #region 参数验证
  4546. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4547. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4548. #endregion
  4549. try
  4550. {
  4551. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4552. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4553. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4554. From Grp_TourClientList tcl
  4555. Left Join
  4556. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4557. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4558. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4559. From Crm_DeleClient dc
  4560. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4561. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4562. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4563. Where dc.IsDel = 0) temp
  4564. On temp.DcId =tcl.ClientId
  4565. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4566. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4567. List<string> texts = new List<string>();
  4568. if (datas.Count != 0)
  4569. {
  4570. foreach (TourClientListDetailsView item in datas)
  4571. {
  4572. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4573. {
  4574. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4575. }
  4576. else
  4577. {
  4578. string name = item.LastName + item.FirstName;
  4579. texts.Add(name);
  4580. }
  4581. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4582. {
  4583. if (!transDic.ContainsKey(item.Job))
  4584. {
  4585. texts.Add(item.Job);
  4586. }
  4587. }
  4588. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4589. {
  4590. texts.Add(item.CompanyFullName);
  4591. }
  4592. }
  4593. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4594. if (transData.Count > 0)
  4595. {
  4596. foreach (TranslateResult item in transData)
  4597. {
  4598. if (!transDic.ContainsKey(item.Query))
  4599. {
  4600. transDic.Add(item.Query, item.Translation);
  4601. }
  4602. }
  4603. }
  4604. List<GuestList> list = new List<GuestList>();
  4605. foreach (TourClientListDetailsView dele in datas)
  4606. {
  4607. GuestList guestList = new GuestList();
  4608. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4609. {
  4610. guestList.Name = dele.Pinyin;
  4611. }
  4612. else
  4613. {
  4614. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4615. guestList.Name = Name;
  4616. }
  4617. if (dele.Sex == 0)
  4618. {
  4619. guestList.Sex = "Male";
  4620. }
  4621. else if (dele.Sex == 1)
  4622. {
  4623. guestList.Sex = "Female";
  4624. }
  4625. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4626. if (!string.IsNullOrEmpty(dele.Job))
  4627. {
  4628. guestList.Job = dele.Job;
  4629. }
  4630. list.Add(guestList);
  4631. }
  4632. //载入模板
  4633. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4634. DocumentBuilder builder = new DocumentBuilder(doc);
  4635. //获取word里所有表格
  4636. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4637. //获取所填表格的序数
  4638. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4639. var rowStart = tableOne.Rows[0]; //获取第1行
  4640. //循环赋值
  4641. for (int i = 0; i < list.Count; i++)
  4642. {
  4643. builder.MoveToCell(0, i + 1, 0, 0);
  4644. builder.Write(list[i].Name.ToString());
  4645. builder.MoveToCell(0, i + 1, 1, 0);
  4646. builder.Write(list[i].Sex.ToString());
  4647. builder.MoveToCell(0, i + 1, 2, 0);
  4648. builder.Write(list[i].DOB.ToString());
  4649. builder.MoveToCell(0, i + 1, 3, 0);
  4650. builder.Write(list[i].Job.ToString());
  4651. }
  4652. //删除多余行
  4653. while (tableOne.Rows.Count > list.Count + 1)
  4654. {
  4655. tableOne.Rows.RemoveAt(list.Count + 1);
  4656. }
  4657. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4658. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4659. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4660. doc.Save(filePath);
  4661. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4662. return Ok(JsonView(true, "操作成功!", Url));
  4663. }
  4664. else
  4665. {
  4666. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4667. }
  4668. }
  4669. catch (Exception ex)
  4670. {
  4671. return Ok(JsonView(false, ex.Message));
  4672. throw;
  4673. }
  4674. }
  4675. #endregion
  4676. #region 团组经理模块 出入境费用
  4677. /// <summary>
  4678. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4679. /// </summary>
  4680. /// <returns></returns>
  4681. [HttpPost]
  4682. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4683. public async Task<IActionResult> SetDayAndCostAreaChange()
  4684. {
  4685. try
  4686. {
  4687. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4688. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4689. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4690. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4691. foreach (var item in unite) //处理交集数据
  4692. {
  4693. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4694. }
  4695. foreach (var item in merge) //处理差集数据
  4696. {
  4697. int nationalTravelFeeId = 0;
  4698. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4699. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4700. else
  4701. {
  4702. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4703. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4704. }
  4705. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4706. }
  4707. //只更新dayAndCost 的 nationalTravelFeeId;
  4708. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4709. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4710. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4711. }
  4712. catch (Exception ex)
  4713. {
  4714. return Ok(JsonView(false, ex.Message));
  4715. throw;
  4716. }
  4717. }
  4718. /// <summary>
  4719. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4720. /// </summary>
  4721. /// <returns></returns>
  4722. [HttpPost]
  4723. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4724. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4725. {
  4726. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4727. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4728. //SetDataInfoView
  4729. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4730. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4731. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4732. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4733. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4734. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4735. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4736. //默认币种显示
  4737. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4738. {
  4739. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4740. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4741. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4742. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4743. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4744. };
  4745. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4746. if (_currencyRate.Count > 0)
  4747. {
  4748. foreach (var item in _currencyInfos)
  4749. {
  4750. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4751. if (rateInfo != null)
  4752. {
  4753. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4754. rate1 *= 1.035M;
  4755. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4756. }
  4757. }
  4758. }
  4759. var gj_jobPostIds = new List<int>() { 22, 32 };
  4760. var viewPermissionData = await _sqlSugar.Queryable<Sys_Users>()
  4761. .Where(x => x.IsDel == 0 && ((x.DepId == 7 && gj_jobPostIds.Contains(x.JobPostId)) || x.DepId == 6))
  4762. .Select(x => new { x.Id, Name = x.CnName })
  4763. .ToListAsync();
  4764. return Ok(JsonView(true, "查询成功!", new
  4765. {
  4766. GroupNameData = groupNameData.Data,
  4767. CurrencyData = _CurrencyData,
  4768. WordTypeData = _WordTypeData,
  4769. ExcelTypeData = _ExcelTypeData,
  4770. CurrencyInit = _currencyInfos,
  4771. ViewPermissionData = viewPermissionData
  4772. }));
  4773. }
  4774. /// <summary>
  4775. /// 团组模块 - 出入境费用
  4776. /// 实时汇率 tips
  4777. /// 签证费用 tips
  4778. /// 机票费用 tips
  4779. /// </summary>
  4780. /// <returns></returns>
  4781. [HttpPost]
  4782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4783. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4784. {
  4785. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4786. //默认币种显示
  4787. var _currencyInfos = _currencyInit;
  4788. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4789. List<dynamic> reteInfos = new List<dynamic>();
  4790. if (_currencyRate.Count > 0)
  4791. {
  4792. foreach (var item in _currencyInfos)
  4793. {
  4794. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4795. if (rateInfo != null)
  4796. {
  4797. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4798. decimal rate1 = item.Rate;
  4799. rate1 *= 1.03M;
  4800. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4801. reteInfos.Add(new
  4802. {
  4803. currCode = item.CurrencyCode,
  4804. currName = item.CurrencyName,
  4805. rate = rate2,
  4806. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4807. });
  4808. }
  4809. }
  4810. }
  4811. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4812. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4813. return Ok(JsonView(true, "查询成功!", new
  4814. {
  4815. //GroupNameData = groupNameData.Data,
  4816. visaData = visaData.Data,
  4817. airData = airData.Data,
  4818. reteInfos = reteInfos
  4819. }));
  4820. }
  4821. /// <summary>
  4822. /// 团组模块 - 出入境费用 - Info
  4823. /// </summary>
  4824. /// <returns></returns>
  4825. [HttpPost]
  4826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4827. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4828. {
  4829. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4830. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4831. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4832. }
  4833. /// <summary>
  4834. /// 团组模块 - 出入境费用 - 设置view权限
  4835. /// </summary>
  4836. /// <returns></returns>
  4837. [HttpPost]
  4838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4839. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4840. {
  4841. if (dto.CurrUserId < 1) return Ok(JsonView(false,MsgTips.UserId));
  4842. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4843. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4844. var permissions = new List<Grp_EnterExitCostPermission>();
  4845. foreach (var userId in dto.UserIds)
  4846. {
  4847. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4848. }
  4849. if (permissions.Any())
  4850. {
  4851. _sqlSugar.BeginTran();
  4852. try
  4853. {
  4854. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4855. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4856. if (result < 1)
  4857. {
  4858. _sqlSugar.RollbackTran();
  4859. return Ok(JsonView(false));
  4860. }
  4861. }
  4862. catch (Exception ex)
  4863. {
  4864. _sqlSugar.RollbackTran();
  4865. return Ok(JsonView(false, ex.Message));
  4866. }
  4867. _sqlSugar.CommitTran();
  4868. return Ok(JsonView(true));
  4869. }
  4870. return Ok(JsonView(false));
  4871. }
  4872. /// <summary>
  4873. /// 团组模块 - 出入境费用 - Add And Update
  4874. /// </summary>
  4875. /// <returns></returns>
  4876. [HttpPost]
  4877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4878. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4879. {
  4880. try
  4881. {
  4882. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4883. if (dto.DayOtherPriceData.Any())
  4884. {
  4885. var inserList = dto.DayOtherPriceData
  4886. .Where(x => x.Id == 0)
  4887. .Select(x => new Grp_DayOtherPrice
  4888. {
  4889. Cost = x.Cost,
  4890. Id = x.Id,
  4891. CreateTime = DateTime.Now,
  4892. CreateUserId = dto.UserId,
  4893. Currency = x.Currency,
  4894. Diid = x.DiId,
  4895. Index = x.Index,
  4896. IsDel = 0,
  4897. SetDataId = x.SetDataId,
  4898. SubTotal = x.SubTotal,
  4899. Remark = x.Remark
  4900. })
  4901. .ToList();
  4902. var updateList = dto.DayOtherPriceData
  4903. .Where(x => x.Id != 0)
  4904. .Select(x => new Grp_DayOtherPrice
  4905. {
  4906. Cost = x.Cost,
  4907. Id = x.Id,
  4908. CreateTime = DateTime.Now,
  4909. CreateUserId = dto.UserId,
  4910. Currency = x.Currency,
  4911. Diid = x.DiId,
  4912. Index = x.Index,
  4913. IsDel = 0,
  4914. SetDataId = x.SetDataId,
  4915. SubTotal = x.SubTotal,
  4916. Remark = x.Remark
  4917. })
  4918. .ToList();
  4919. //添加
  4920. _sqlSugar.BeginTran();
  4921. if (inserList.Any())
  4922. {
  4923. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4924. }
  4925. if (updateList.Any())
  4926. {
  4927. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4928. }
  4929. _sqlSugar.CommitTran();
  4930. }
  4931. if (data.Code != 0)
  4932. {
  4933. return Ok(JsonView(false, data.Msg));
  4934. }
  4935. //生成默认文件pdf并且通知人员
  4936. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4937. {
  4938. DiId = dto.DiId,
  4939. ExportType = 1,
  4940. SubTypeId = 1005
  4941. }, "pdf");
  4942. //发送通知
  4943. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4944. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4945. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4946. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4947. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4948. //汇率信息记录
  4949. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4950. return Ok(JsonView(true, data.Msg, data.Data));
  4951. }
  4952. catch (Exception ex)
  4953. {
  4954. return Ok(JsonView(false, ex.Message));
  4955. }
  4956. }
  4957. /// <summary>
  4958. /// 团组模块 - 出入境费用 - Confirm 费用
  4959. /// </summary>
  4960. /// <returns></returns>
  4961. [HttpPost]
  4962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4963. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4964. {
  4965. //TODO:测试完毕需把对应的用户ID更改
  4966. //1、数据表添加字段
  4967. //2、更改字段接口()
  4968. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4969. //3、确认成功 给财务发送消息
  4970. if (_view.Code == 200)
  4971. {
  4972. if (dto.Type == 1)
  4973. {
  4974. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4975. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4976. }
  4977. }
  4978. return Ok(_view);
  4979. }
  4980. /// <summary>
  4981. /// 团组模块 - 出入境费用 - File downlaod
  4982. /// </summary>
  4983. /// <param name="dto"></param>
  4984. /// <returns></returns>
  4985. [HttpPost]
  4986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4987. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4988. {
  4989. try
  4990. {
  4991. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4992. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4993. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4994. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4995. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4996. 3 团组成员名单 1 团组成员名单", ""));
  4997. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  4998. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4999. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  5000. //数据源
  5001. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  5002. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  5003. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  5004. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  5005. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  5006. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  5007. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  5008. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  5009. .Select((x, a, b) => new
  5010. {
  5011. x.Index,
  5012. itemName = a.Name,
  5013. CurrencyStr = b.Name,
  5014. x.Cost,
  5015. x.SubTotal,
  5016. x.Remark
  5017. })
  5018. .OrderBy((x) => x.Index)
  5019. .ToList(); //其他款项费用
  5020. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5021. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5022. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5023. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5024. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5025. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5026. .Select((tcl, dc, cc) => new ClientInfo
  5027. {
  5028. LastName = dc.LastName,
  5029. FirstName = dc.FirstName,
  5030. Sex = dc.Sex,
  5031. Birthday = dc.BirthDay,
  5032. Company = cc.CompanyFullName,
  5033. Job = dc.Job
  5034. })
  5035. .ToList();
  5036. foreach (var item in DeleClientList)
  5037. {
  5038. EncryptionProcessor.DecryptProperties(item);
  5039. }
  5040. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5041. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5042. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5043. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5044. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5045. if (dto.ExportType == 1) //明细表
  5046. {
  5047. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5048. {
  5049. //获取模板
  5050. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5051. //载入模板
  5052. Document doc = new Document(tempPath);
  5053. DocumentBuilder builder = new DocumentBuilder(doc);
  5054. //利用键值对存放数据
  5055. Dictionary<string, string> dic = new Dictionary<string, string>();
  5056. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5057. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5058. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5059. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5060. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5061. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5062. //境内费用(其他费用)
  5063. if (_EnterExitCosts.ChoiceOne == 1)
  5064. {
  5065. string row1_1 = "";
  5066. if (_EnterExitCosts.Visa > 0)
  5067. {
  5068. //insidePayTotal += _EnterExitCosts.Visa;
  5069. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5070. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5071. {
  5072. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5073. }
  5074. }
  5075. string row1_2 = "";
  5076. if (_EnterExitCosts.YiMiao > 0)
  5077. {
  5078. //insidePayTotal += _EnterExitCosts.YiMiao;
  5079. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5080. }
  5081. if (_EnterExitCosts.HeSuan > 0)
  5082. {
  5083. //insidePayTotal += _EnterExitCosts.HeSuan;
  5084. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5085. }
  5086. if (_EnterExitCosts.Service > 0)
  5087. {
  5088. //insidePayTotal += _EnterExitCosts.Service;
  5089. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5090. }
  5091. string row1_3 = "";
  5092. if (_EnterExitCosts.Safe > 0)
  5093. {
  5094. //insidePayTotal += _EnterExitCosts.Safe;
  5095. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5096. }
  5097. if (_EnterExitCosts.Ticket > 0)
  5098. {
  5099. //insidePayTotal += _EnterExitCosts.Ticket;
  5100. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5101. }
  5102. string row1 = "";
  5103. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5104. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5105. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5106. row1 += $"备注:{_EnterExitCosts.Remark}";
  5107. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5108. dic.Add("Row1Str", row1);
  5109. }
  5110. string airTotalStr = string.Empty,
  5111. airPriceStr = string.Empty;
  5112. //经济舱
  5113. if (_EnterExitCosts.SumJJC == 1)
  5114. {
  5115. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5116. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5117. }
  5118. //公务舱
  5119. if (_EnterExitCosts.SumGWC == 1)
  5120. {
  5121. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5122. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5123. }
  5124. //头等舱
  5125. if (_EnterExitCosts.SumTDC == 1)
  5126. {
  5127. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5128. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5129. }
  5130. string twoItemRemark = "备注:";
  5131. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
  5132. {
  5133. twoItemRemark = _EnterExitCosts.TwoItemRemark;
  5134. }
  5135. dic.Add("AirTotalStr", airTotalStr);
  5136. dic.Add("AirPriceStr", airPriceStr);
  5137. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5138. dic.Add("TwoItemRemark", twoItemRemark);
  5139. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5140. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5141. int table1Row = 0,
  5142. table2Row = 0,
  5143. table3Row = 0,
  5144. table4Row = 0,
  5145. table5Row = 0;
  5146. //住宿费
  5147. if (_EnterExitCosts.ChoiceThree == 1)
  5148. {
  5149. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5150. table1Row = dac1.Count;
  5151. #region 填充word表格内容
  5152. for (int i = 0; i < dac1.Count; i++)
  5153. {
  5154. Grp_DayAndCost dac = dac1[i];
  5155. if (dac == null) continue;
  5156. builder.MoveToCell(0, i, 0, 0);
  5157. builder.Write("第" + dac.Days.ToString() + "晚:");
  5158. builder.MoveToCell(0, i, 1, 0);
  5159. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5160. //builder.Write(dac.Place == null ? "" : dac.Place);
  5161. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5162. builder.MoveToCell(0, i, 2, 0);
  5163. builder.Write("费用标准:");
  5164. string curr = "";
  5165. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5166. if (currData != null)
  5167. {
  5168. curr = currData.Name;
  5169. }
  5170. builder.MoveToCell(0, i, 3, 0);
  5171. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5172. builder.MoveToCell(0, i, 4, 0);
  5173. builder.Write("费用小计:");
  5174. builder.MoveToCell(0, i, 5, 0);
  5175. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5176. }
  5177. #endregion
  5178. }
  5179. else dic.Add("SubZS", "0.00");
  5180. //删除多余行
  5181. while (table1.Rows.Count > table1Row)
  5182. {
  5183. table1.Rows.RemoveAt(table1Row);
  5184. }
  5185. //伙食费
  5186. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5187. if (_EnterExitCosts.ChoiceFour == 1)
  5188. {
  5189. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5190. table2Row = dac2.Count;
  5191. #region 填充word表格内容
  5192. for (int i = 0; i < dac2.Count; i++)
  5193. {
  5194. Grp_DayAndCost dac = dac2[i];
  5195. if (dac == null) continue;
  5196. builder.MoveToCell(1, i, 0, 0);
  5197. builder.Write("第" + dac.Days.ToString() + "天:");
  5198. builder.MoveToCell(1, i, 1, 0);
  5199. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5200. builder.MoveToCell(1, i, 2, 0);
  5201. builder.Write("费用标准:");
  5202. string curr = "";
  5203. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5204. if (currData != null)
  5205. {
  5206. curr = currData.Name;
  5207. }
  5208. builder.MoveToCell(1, i, 3, 0);
  5209. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5210. builder.MoveToCell(1, i, 4, 0);
  5211. builder.Write("费用小计:");
  5212. builder.MoveToCell(1, i, 5, 0);
  5213. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5214. }
  5215. #endregion
  5216. }
  5217. else dic.Add("SubHS", "0.00");
  5218. //删除多余行
  5219. while (table2.Rows.Count > table2Row)
  5220. {
  5221. table2.Rows.RemoveAt(table2Row);
  5222. }
  5223. //公杂费
  5224. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5225. if (_EnterExitCosts.ChoiceFive == 1)
  5226. {
  5227. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5228. table3Row = dac3.Count;
  5229. #region 填充word表格内容
  5230. for (int i = 0; i < dac3.Count; i++)
  5231. {
  5232. Grp_DayAndCost dac = dac3[i];
  5233. if (dac == null) continue;
  5234. builder.MoveToCell(2, i, 0, 0);
  5235. builder.Write("第" + dac.Days.ToString() + "天:");
  5236. builder.MoveToCell(2, i, 1, 0);
  5237. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5238. builder.MoveToCell(2, i, 2, 0);
  5239. builder.Write("费用标准:");
  5240. string curr = "";
  5241. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5242. if (currData != null)
  5243. {
  5244. curr = currData.Name;
  5245. }
  5246. builder.MoveToCell(2, i, 3, 0);
  5247. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5248. builder.MoveToCell(2, i, 4, 0);
  5249. builder.Write("费用小计:");
  5250. builder.MoveToCell(2, i, 5, 0);
  5251. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5252. }
  5253. //删除多余行
  5254. while (table3.Rows.Count > table3Row)
  5255. {
  5256. table3.Rows.RemoveAt(table3Row);
  5257. }
  5258. #endregion
  5259. }
  5260. else dic.Add("SubGZF", "0.00");
  5261. //删除多余行
  5262. while (table3.Rows.Count > table3Row)
  5263. {
  5264. table3.Rows.RemoveAt(table3Row);
  5265. }
  5266. //培训费
  5267. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5268. if (_EnterExitCosts.ChoiceSix == 1)
  5269. {
  5270. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5271. dic.Add("SubPX", pxStr);
  5272. table4Row = dac4.Count;
  5273. #region 填充word表格内容
  5274. for (int i = 0; i < dac4.Count; i++)
  5275. {
  5276. Grp_DayAndCost dac = dac4[i];
  5277. if (dac == null) continue;
  5278. builder.MoveToCell(3, i, 0, 0);
  5279. builder.Write("第" + dac.Days.ToString() + "天:");
  5280. builder.MoveToCell(3, i, 1, 0);
  5281. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5282. builder.MoveToCell(3, i, 2, 0);
  5283. builder.Write("费用标准:");
  5284. string curr = "";
  5285. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5286. if (currData != null)
  5287. {
  5288. curr = currData.Name;
  5289. }
  5290. builder.MoveToCell(3, i, 3, 0);
  5291. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5292. builder.MoveToCell(3, i, 4, 0);
  5293. builder.Write("费用小计:");
  5294. builder.MoveToCell(3, i, 5, 0);
  5295. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5296. }
  5297. #endregion
  5298. }
  5299. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  5300. //删除多余行
  5301. while (table4.Rows.Count > table4Row)
  5302. {
  5303. table4.Rows.RemoveAt(table4Row);
  5304. }
  5305. //其他费用
  5306. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5307. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5308. {
  5309. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5310. dic.Add("titleQi", qtStr);
  5311. table5Row = dac5.Count;
  5312. #region 填充word表格内容
  5313. for (int i = 0; i < dac5.Count; i++)
  5314. {
  5315. var dac = dac5[i];
  5316. if (dac == null) continue;
  5317. builder.MoveToCell(4, i, 0, 0);
  5318. builder.Write("第" + dac.Index.ToString() + "项:");
  5319. builder.MoveToCell(4, i, 1, 0);
  5320. builder.Write(dac.itemName);
  5321. builder.MoveToCell(4, i, 2, 0);
  5322. builder.Write("费用标准:");
  5323. builder.MoveToCell(4, i, 3, 0);
  5324. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5325. builder.MoveToCell(4, i, 4, 0);
  5326. builder.Write("费用小计:");
  5327. builder.MoveToCell(4, i, 5, 0);
  5328. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5329. builder.MoveToCell(4, i, 6, 0);
  5330. builder.Write("备注:");
  5331. builder.MoveToCell(4, i, 7, 0);
  5332. builder.Write(dac.Remark);
  5333. }
  5334. #endregion
  5335. }
  5336. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5337. //删除多余行
  5338. while (table5.Rows.Count > table5Row)
  5339. {
  5340. table5.Rows.RemoveAt(table5Row);
  5341. }
  5342. //加上其他费用
  5343. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5344. decimal subJJC = 0.00M,
  5345. subGWC = 0.00M,
  5346. subTDC = 0.00M;
  5347. //经济舱
  5348. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5349. //公务舱
  5350. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5351. //头等舱
  5352. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5353. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5354. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5355. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5356. #region 填充word模板书签内容
  5357. foreach (var key in dic.Keys)
  5358. {
  5359. Bookmark bookmark = doc.Range.Bookmarks[key];
  5360. if (bookmark != null)
  5361. {
  5362. builder.MoveToBookmark(key);
  5363. builder.Write(dic[key]);
  5364. }
  5365. }
  5366. #endregion
  5367. //文件名
  5368. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5369. AsposeHelper.removewatermark_v2180();
  5370. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5371. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5372. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5373. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5374. }
  5375. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5376. {
  5377. //获取模板
  5378. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5379. //载入模板
  5380. Document doc = new Document(tempPath);
  5381. DocumentBuilder builder = new DocumentBuilder(doc);
  5382. Dictionary<string, string> dic = new Dictionary<string, string>();
  5383. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5384. {
  5385. List<string> list = new List<string>();
  5386. try
  5387. {
  5388. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5389. foreach (var item in spilitArr)
  5390. {
  5391. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5392. var depCode = spDotandEmpty[2].Substring(0, 3);
  5393. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5394. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5395. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5396. list.Add(depName);
  5397. list.Add(arrName);
  5398. }
  5399. list = list.Distinct().ToList();
  5400. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5401. }
  5402. catch (Exception)
  5403. {
  5404. dic.Add("ReturnCode", "行程录入不正确!");
  5405. }
  5406. }
  5407. else
  5408. {
  5409. dic.Add("ReturnCode", "未录入行程!");
  5410. }
  5411. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5412. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5413. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5414. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5415. {
  5416. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5417. dic.Add("Day", sp.Days.ToString());
  5418. }
  5419. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5420. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5421. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5422. //dic.Add("Names", Names);
  5423. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5424. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5425. decimal dac1totalPrice = 0.00M;
  5426. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5427. foreach (var dac in dac1)
  5428. {
  5429. if (dac.SubTotal == 0.00M)
  5430. {
  5431. continue;
  5432. }
  5433. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5434. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5435. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5436. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5437. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5438. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5439. builder.Write(currency);//币种
  5440. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5441. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5442. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5443. builder.Write("");//人数
  5444. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5445. builder.Write("");//天数
  5446. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5447. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5448. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5449. decimal rate = 0.00M;
  5450. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5451. builder.Write(rate.ToString("#0.0000"));//汇率
  5452. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5453. decimal rbmPrice = dac.SubTotal;
  5454. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5455. accommodationStartIndex++;
  5456. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5457. }
  5458. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5459. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5460. {
  5461. table1.Rows.RemoveAt(i - 1);
  5462. foodandotherStartIndex--;
  5463. }
  5464. if (dac2.Count == dac3.Count)//国家 币种 金额
  5465. {
  5466. for (int i = 0; i < dac2.Count; i++)
  5467. {
  5468. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5469. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5470. }
  5471. }
  5472. decimal dac2totalPrice = 0.00M;
  5473. foreach (var dac in dac2)
  5474. {
  5475. if (dac.SubTotal == 0)
  5476. {
  5477. continue;
  5478. }
  5479. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5480. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5481. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5482. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5483. builder.Write(currency);//币种
  5484. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5485. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5486. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5487. builder.Write("");//人数
  5488. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5489. builder.Write("");//天数
  5490. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5491. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5492. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5493. decimal rate = 0.00M;
  5494. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5495. builder.Write(rate.ToString("#0.0000"));//汇率
  5496. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5497. decimal rbmPrice = dac.SubTotal;
  5498. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5499. foodandotherStartIndex++;
  5500. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5501. }
  5502. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5503. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5504. {
  5505. table1.Rows.RemoveAt(i - 1);
  5506. }
  5507. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5508. string otherFeeStr = "";
  5509. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5510. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5511. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5512. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5513. foreach (var otherInfo in dac5)
  5514. {
  5515. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5516. }
  5517. #endregion
  5518. if (otherFeeStr.Length > 0)
  5519. {
  5520. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5521. otherFeeStr = $"({otherFeeStr})";
  5522. dic.Add("OtherFeeStr", otherFeeStr);
  5523. }
  5524. //总计
  5525. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5526. //国际旅费
  5527. string outsideAir = string.Empty;
  5528. string allPriceAir = string.Empty;
  5529. if (_EnterExitCosts.SumJJC == 1)
  5530. {
  5531. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5532. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5533. }
  5534. if (_EnterExitCosts.SumGWC == 1)
  5535. {
  5536. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5537. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5538. }
  5539. if (_EnterExitCosts.SumTDC == 1)
  5540. {
  5541. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5542. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5543. }
  5544. dic.Add("InTravelPrice", $"({outsideAir})");
  5545. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5546. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5547. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5548. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5549. foreach (var key in dic.Keys)
  5550. {
  5551. builder.MoveToBookmark(key);
  5552. builder.Write(dic[key]);
  5553. }
  5554. //模板文件名
  5555. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5556. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5557. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5558. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5559. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5560. }
  5561. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5562. {
  5563. //获取模板
  5564. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5565. //载入模板
  5566. WorkbookDesigner designer = new WorkbookDesigner();
  5567. designer.Workbook = new Workbook(tempPath);
  5568. Dictionary<string, string> dic = new Dictionary<string, string>();
  5569. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5570. {
  5571. List<string> list = new List<string>();
  5572. try
  5573. {
  5574. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5575. foreach (var item in spilitArr)
  5576. {
  5577. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5578. var depCode = spDotandEmpty[2].Substring(0, 3);
  5579. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5580. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5581. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5582. list.Add(depName);
  5583. list.Add(arrName);
  5584. }
  5585. list = list.Distinct().ToList();
  5586. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5587. }
  5588. catch (Exception)
  5589. {
  5590. dic.Add("ReturnCode", "行程录入不正确!");
  5591. }
  5592. }
  5593. else
  5594. {
  5595. dic.Add("ReturnCode", "未录入行程!");
  5596. }
  5597. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5598. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5599. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5600. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5601. {
  5602. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5603. dic.Add("Day", sp.Days.ToString());
  5604. }
  5605. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5606. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5607. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5608. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5609. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5610. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5611. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5612. designer.SetDataSource("Name", Names);
  5613. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5614. designer.SetDataSource("Day", dic["Day"] + "天");
  5615. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5616. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5617. int startIndex = 10;
  5618. const int startIndexcopy = 10;
  5619. if (dac2.Count == dac3.Count)//国家 币种 金额
  5620. {
  5621. for (int i = 0; i < dac2.Count; i++)
  5622. {
  5623. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5624. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5625. }
  5626. }
  5627. DataTable dtdac1 = new DataTable();
  5628. List<string> place = new List<string>();
  5629. dtdac1.Columns.AddRange(new DataColumn[] {
  5630. new DataColumn(){ ColumnName = "city"},
  5631. new DataColumn(){ ColumnName = "curr"},
  5632. new DataColumn(){ ColumnName = "criterion"},
  5633. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5634. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5635. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5636. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5637. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5638. });
  5639. DataTable dtdac2 = new DataTable();
  5640. dtdac2.Columns.AddRange(new DataColumn[] {
  5641. new DataColumn(){ ColumnName = "city"},
  5642. new DataColumn(){ ColumnName = "curr"},
  5643. new DataColumn(){ ColumnName = "criterion"},
  5644. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5645. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5646. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5647. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5648. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5649. });
  5650. dtdac1.TableName = "tb1";
  5651. dtdac2.TableName = "tb2";
  5652. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5653. foreach (var item in dac1)
  5654. {
  5655. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5656. if (place.Contains(item.Place))
  5657. {
  5658. continue;
  5659. }
  5660. DataRow row = dtdac1.NewRow();
  5661. row["city"] = item.Place;
  5662. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5663. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5664. row["curr"] = currency;
  5665. row["rate"] = rate.ToString("#0.0000");
  5666. row["criterion"] = item.Cost.ToString("#0.00");
  5667. row["number"] = 1;
  5668. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5669. //row["costRMB"] = rbmPrice;
  5670. dtdac1.Rows.Add(row);
  5671. place.Add(item.Place);
  5672. }
  5673. place = new List<string>();
  5674. foreach (var item in dac2)
  5675. {
  5676. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5677. if (place.Contains(item.Place))
  5678. {
  5679. continue;
  5680. }
  5681. DataRow row = dtdac2.NewRow();
  5682. row["city"] = item.Place;
  5683. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5684. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5685. row["curr"] = currency;
  5686. row["rate"] = rate.ToString("#0.0000");
  5687. row["criterion"] = item.Cost.ToString("#0.00");
  5688. row["number"] = 1;
  5689. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5690. //row["cost"] = item.SubTotal;
  5691. //row["costRMB"] = rbmPrice;
  5692. dtdac2.Rows.Add(row);
  5693. place.Add(item.Place);
  5694. //dac2totalPrice += rbmPrice;
  5695. }
  5696. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5697. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5698. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5699. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5700. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5701. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5702. string cell4Str1 = string.Empty;
  5703. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5704. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5705. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5706. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5707. string cellStr = $" 5.其他费用(";
  5708. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5709. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5710. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5711. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5712. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5713. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5714. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5715. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5716. foreach (var otherInfo in dac5)
  5717. {
  5718. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5719. }
  5720. #endregion
  5721. if (cellStr.Length > 8)
  5722. {
  5723. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5724. }
  5725. cellStr += ")";
  5726. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5727. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5728. decimal pxFee = dac4.Sum(it => it.Cost);
  5729. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5730. string celllastStr1 = "";
  5731. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5732. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5733. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5734. celllastStr1 += $",国际旅费 元";
  5735. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5736. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5737. designer.SetDataSource("cell4Str", cell4Str);
  5738. designer.SetDataSource("cellStr", cellStr);
  5739. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5740. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5741. designer.SetDataSource("celllastStr", celllastStr);
  5742. Workbook wb = designer.Workbook;
  5743. var sheet = wb.Worksheets[0];
  5744. //绑定datatable数据集
  5745. designer.SetDataSource(dtdac1);
  5746. designer.SetDataSource(dtdac2);
  5747. designer.Process();
  5748. var rowStart = dtdac1.Rows.Count;
  5749. while (rowStart > 0)
  5750. {
  5751. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5752. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5753. startIndex++;
  5754. rowStart--;
  5755. }
  5756. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5757. startIndex += 1; //总计行
  5758. rowStart = dtdac2.Rows.Count;
  5759. while (rowStart > 0)
  5760. {
  5761. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5762. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5763. startIndex++;
  5764. rowStart--;
  5765. }
  5766. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5767. wb.CalculateFormula(true);
  5768. //模板文件名
  5769. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5770. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5771. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5772. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5773. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5774. }
  5775. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5776. {
  5777. //获取模板
  5778. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5779. //载入模板
  5780. Document doc = new Document(tempPath);
  5781. DocumentBuilder builder = new DocumentBuilder(doc);
  5782. Dictionary<string, string> dic = new Dictionary<string, string>();
  5783. dic.Add("GroupName", _DelegationInfo.TeamName);
  5784. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5785. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5786. string missionLeaderJob = "";//负责人job
  5787. int groupNumber = 0; //团人数
  5788. if (DeleClientList.Count > 0)
  5789. {
  5790. missionLeader = DeleClientList[0]?.Name ?? "";
  5791. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5792. }
  5793. dic.Add("MissionLeader", missionLeader); //团负责人
  5794. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5795. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5796. #region MyRegion
  5797. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5798. //{
  5799. // List<string> list = new List<string>();
  5800. // try
  5801. // {
  5802. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5803. // foreach (var item in spilitArr)
  5804. // {
  5805. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5806. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5807. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5808. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5809. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5810. // list.Add(depName);
  5811. // list.Add(arrName);
  5812. // }
  5813. // list = list.Distinct().ToList();
  5814. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5815. // }
  5816. // catch (Exception)
  5817. // {
  5818. // dic.Add("ReturnCode", "行程录入不正确!");
  5819. // }
  5820. //}
  5821. //else
  5822. //{
  5823. // dic.Add("ReturnCode", "未录入行程!");
  5824. //}
  5825. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5826. dic.Add("ReturnCode", string.Join("、", countrys));
  5827. #endregion
  5828. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5829. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5830. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5831. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5832. //{
  5833. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5834. // dic.Add("Day", sp.Days.ToString());
  5835. //}
  5836. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5837. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5838. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5839. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5840. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5841. //培训人员名单
  5842. int cultivateRowIndex = 7;
  5843. foreach (var item in DeleClientList)
  5844. {
  5845. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5846. builder.Write(item.Name);
  5847. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5848. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5849. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5850. string birthDay = "";
  5851. if (item.Birthday != null)
  5852. {
  5853. DateTime dt = Convert.ToDateTime(item.Birthday);
  5854. birthDay = $"{dt.Year}.{dt.Month}";
  5855. }
  5856. builder.Write(birthDay);
  5857. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5858. builder.Write(item.Company);
  5859. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5860. builder.Write(item.Job);
  5861. cultivateRowIndex++;
  5862. }
  5863. //删除多余行
  5864. //cultivateRowIndex -= 2;
  5865. int delRows = 10 + 7 - cultivateRowIndex;
  5866. if (delRows > 0)
  5867. {
  5868. for (int i = 0; i < delRows; i++)
  5869. {
  5870. table1.Rows.RemoveAt(cultivateRowIndex);
  5871. //cultivateRowIndex++;
  5872. }
  5873. }
  5874. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5875. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5876. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5877. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5878. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5879. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5880. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5881. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5882. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5883. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5884. //其他费用
  5885. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5886. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5887. //其他费用合计
  5888. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5889. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5890. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5891. //公务舱合计
  5892. //国际旅费
  5893. string outsideJJ = "";
  5894. string allPriceJJ = "";
  5895. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5896. {
  5897. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5898. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5899. }
  5900. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5901. {
  5902. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5903. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5904. }
  5905. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5906. {
  5907. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5908. dic.Add("AirFeeTotal", airFeeTotalStr);
  5909. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5910. dic.Add("FeeTotal", feeTotalStr);
  5911. }
  5912. foreach (var key in dic.Keys)
  5913. {
  5914. builder.MoveToBookmark(key);
  5915. builder.Write(dic[key]);
  5916. }
  5917. //模板文件名
  5918. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5919. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5920. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5921. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5922. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5923. }
  5924. }
  5925. else if (dto.ExportType == 2) //表格
  5926. {
  5927. //利用键值对存放数据
  5928. Dictionary<string, string> dic = new Dictionary<string, string>();
  5929. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5930. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5931. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5932. dic.Add("Day", sp.Days.ToString());
  5933. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5934. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5935. {
  5936. //获取模板
  5937. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5938. //载入模板
  5939. Document doc = new Document(tempPath);
  5940. DocumentBuilder builder = new DocumentBuilder(doc);
  5941. dic.Add("TeamName", _DelegationInfo.TeamName);
  5942. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5943. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5944. string missionLeaderName = "",
  5945. missionLeaderJob = "";
  5946. if (DeleClientList.Count > 0)
  5947. {
  5948. missionLeaderName = DeleClientList[0].Name;
  5949. missionLeaderJob = DeleClientList[0].Job;
  5950. }
  5951. dic.Add("MissionLeaderName", missionLeaderName);
  5952. dic.Add("MissionLeaderJob", missionLeaderJob);
  5953. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5954. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5955. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5956. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5957. int rowCount = 10;//总人数行
  5958. int startRowIndex = 7; //起始行
  5959. for (int i = 0; i < DeleClientList.Count; i++)
  5960. {
  5961. builder.MoveToCell(0, startRowIndex, 0, 0);
  5962. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5963. builder.MoveToCell(0, startRowIndex, 1, 0);
  5964. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5965. builder.Write(sex);//性别
  5966. builder.MoveToCell(0, startRowIndex, 2, 0);
  5967. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5968. builder.MoveToCell(0, startRowIndex, 3, 0);
  5969. builder.Write(DeleClientList[i].Company);//工作单位
  5970. builder.MoveToCell(0, startRowIndex, 4, 0);
  5971. builder.Write(DeleClientList[i].Job);//职务及级别
  5972. builder.MoveToCell(0, startRowIndex, 5, 0);
  5973. builder.Write("");//人员属性
  5974. builder.MoveToCell(0, startRowIndex, 6, 0);
  5975. builder.Write("");//上次出国时间
  5976. startRowIndex++;
  5977. }
  5978. int nullRow = rowCount - DeleClientList.Count;//空行
  5979. for (int i = 0; i < nullRow; i++)
  5980. {
  5981. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5982. }
  5983. foreach (var key in dic.Keys)
  5984. {
  5985. builder.MoveToBookmark(key);
  5986. builder.Write(dic[key]);
  5987. }
  5988. //模板文件名
  5989. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5990. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5991. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5992. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5993. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5994. }
  5995. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5996. {
  5997. //获取模板
  5998. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5999. //载入模板
  6000. Document doc = new Document(tempPath);
  6001. DocumentBuilder builder = new DocumentBuilder(doc);
  6002. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6003. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6004. dic.Add("Names", Names);
  6005. int accommodationRows = 12, foodandotherRows = 12;
  6006. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6007. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6008. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6009. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6010. int accommodationStartIndex = 6;
  6011. decimal dac1totalPrice = 0.00M;
  6012. foreach (var dac in dac1)
  6013. {
  6014. if (dac.SubTotal == 0)
  6015. {
  6016. continue;
  6017. }
  6018. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6019. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6020. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6021. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6022. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6023. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6024. builder.Write(currency);//币种
  6025. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6026. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6027. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6028. builder.Write("");//人数
  6029. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6030. builder.Write("");//天数
  6031. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6032. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6033. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6034. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6035. builder.Write(rate.ToString("#0.0000"));//汇率
  6036. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6037. decimal rbmPrice = rate * dac.SubTotal;
  6038. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6039. accommodationStartIndex++;
  6040. dac1totalPrice += rbmPrice;
  6041. }
  6042. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6043. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6044. builder.Write("小计");
  6045. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6046. builder.Write(dac1totalPrice.ToString("#0.00"));
  6047. accommodationStartIndex++;
  6048. int nullRow = accommodationRows - dac1.Count;
  6049. //删除空行
  6050. //if (nullRow > 0)
  6051. //{
  6052. // int rowIndex = accommodationStartIndex;
  6053. // for (int i = 0; i < nullRow; i++)
  6054. // {
  6055. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6056. // row.Remove();
  6057. // rowIndex++;
  6058. // }
  6059. //}
  6060. if (dac2.Count == dac3.Count)//国家 币种 金额
  6061. {
  6062. for (int i = 0; i < dac2.Count; i++)
  6063. {
  6064. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6065. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6066. }
  6067. }
  6068. int foodandotherStartIndex = 19;//
  6069. decimal dac2totalPrice = 0.00M;
  6070. foreach (var dac in dac2)
  6071. {
  6072. if (dac.SubTotal == 0)
  6073. {
  6074. continue;
  6075. }
  6076. //foodandotherStartIndex = 12;
  6077. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6078. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6079. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6080. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6081. builder.Write(currency);//币种
  6082. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6083. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6084. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6085. builder.Write("");//人数
  6086. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6087. builder.Write("");//天数
  6088. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6089. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6090. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6091. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6092. builder.Write(rate.ToString("#0.0000"));//汇率
  6093. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6094. decimal rbmPrice = rate * dac.SubTotal;
  6095. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6096. foodandotherStartIndex++;
  6097. dac2totalPrice += rbmPrice;
  6098. }
  6099. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6100. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6101. //删除空行
  6102. //if (dac2.Count < foodandotherRows)
  6103. //{
  6104. // while (table2.Rows.Count > dac2.Count)
  6105. // {
  6106. // table2.Rows.RemoveAt(dac2.Count);
  6107. // }
  6108. //}
  6109. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6110. string otherFeeStr = "";
  6111. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6112. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6113. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6114. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6115. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6116. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6117. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6118. foreach (var otherInfo in dac5)
  6119. {
  6120. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6121. }
  6122. #endregion
  6123. if (otherFeeStr.Length > 0)
  6124. {
  6125. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6126. otherFeeStr = $"({otherFeeStr})";
  6127. dic.Add("OtherFeeStr", otherFeeStr);
  6128. }
  6129. foreach (var key in dic.Keys)
  6130. {
  6131. builder.MoveToBookmark(key);
  6132. builder.Write(dic[key]);
  6133. }
  6134. //模板文件名
  6135. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6136. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6137. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6138. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6139. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6140. }
  6141. }
  6142. else if (dto.ExportType == 3)
  6143. {
  6144. if (dto.SubTypeId == 1) //团组成员名单
  6145. {
  6146. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6147. //获取模板
  6148. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6149. //载入模板
  6150. Document doc = new Document(tempPath);
  6151. DocumentBuilder builder = new DocumentBuilder(doc);
  6152. //获取word里所有表格
  6153. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6154. //获取所填表格的序数
  6155. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6156. var rowStart = tableOne.Rows[0]; //获取第1行
  6157. //循环赋值
  6158. for (int i = 0; i < DeleClientList.Count; i++)
  6159. {
  6160. builder.MoveToCell(0, i + 1, 0, 0);
  6161. builder.Write(DeleClientList[i].Name);
  6162. builder.MoveToCell(0, i + 1, 1, 0);
  6163. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6164. builder.Write(sex);
  6165. builder.MoveToCell(0, i + 1, 2, 0);
  6166. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6167. builder.MoveToCell(0, i + 1, 3, 0);
  6168. builder.Write(DeleClientList[i].Company);
  6169. builder.MoveToCell(0, i + 1, 4, 0);
  6170. builder.Write(DeleClientList[i].Job);
  6171. }
  6172. //删除多余行
  6173. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6174. {
  6175. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6176. }
  6177. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6178. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6179. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6180. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6181. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6182. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6183. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6184. }
  6185. }
  6186. return Ok(JsonView(400, "操作失败!", ""));
  6187. }
  6188. catch (Exception ex)
  6189. {
  6190. return Ok(JsonView(400, ex.Message, ""));
  6191. }
  6192. }
  6193. /// <summary>
  6194. /// 获取三公费用标准city
  6195. /// </summary>
  6196. /// <param name="placeData"></param>
  6197. /// <param name="nationalTravelFeeId"></param>
  6198. /// <returns></returns>
  6199. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6200. {
  6201. string _city = string.Empty;
  6202. if (placeData.Count < 1) return _city;
  6203. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6204. if (data == null) return _city;
  6205. string country = data.Country;
  6206. string city = data.City;
  6207. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6208. else _city = city;
  6209. return _city;
  6210. }
  6211. /// <summary>
  6212. /// 团组模块 - 出入境费用 - 明细表导出
  6213. /// </summary>
  6214. /// <returns></returns>
  6215. [HttpPost]
  6216. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6217. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6218. {
  6219. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6220. if (data.Code != 0)
  6221. {
  6222. return Ok(JsonView(false, data.Msg));
  6223. }
  6224. return Ok(JsonView(true, data.Msg, data.Data));
  6225. }
  6226. /// <summary>
  6227. /// 团组模块 - 出入境费用 - 一键清空
  6228. /// </summary>
  6229. /// <returns></returns>
  6230. [HttpPost]
  6231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6232. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6233. {
  6234. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6235. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6236. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6237. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6238. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6239. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6240. .SetColumns(x => new Grp_DayOtherPrice
  6241. {
  6242. IsDel = 1,
  6243. DeleteUserId = dto.UserId,
  6244. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6245. })
  6246. .ExecuteCommandAsync();
  6247. if (_view.Code == 0)
  6248. {
  6249. return Ok(JsonView(true, "操作成功"));
  6250. }
  6251. return Ok(JsonView(false, "操作失败"));
  6252. }
  6253. /// <summary>
  6254. /// 团组模块 - 出入境费用 - 子项删除
  6255. /// </summary>
  6256. /// <returns></returns>
  6257. [HttpPost]
  6258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6259. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6260. {
  6261. try
  6262. {
  6263. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6264. if (data.Code != 0)
  6265. {
  6266. return Ok(JsonView(false, data.Msg));
  6267. }
  6268. return Ok(JsonView(true, "操作成功!", data.Data));
  6269. }
  6270. catch (Exception ex)
  6271. {
  6272. return Ok(JsonView(false, ex.Message));
  6273. }
  6274. }
  6275. /// <summary>
  6276. /// 删除三公其他费用
  6277. /// </summary>
  6278. /// <param name="dto"></param>
  6279. /// <returns></returns>
  6280. [HttpPost]
  6281. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6282. {
  6283. var jw = JsonView(false,"删除失败!");
  6284. var data = new Grp_DayOtherPrice()
  6285. {
  6286. Id = dto.Id,
  6287. IsDel = 1,
  6288. DeleteUserId = dto.DeleteUserId,
  6289. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6290. };
  6291. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6292. if (del > 0)
  6293. {
  6294. jw.Code = 200;
  6295. jw.Msg = "删除成功!";
  6296. }
  6297. return Ok(jw);
  6298. }
  6299. /// <summary>
  6300. /// 团组模块 - 出入境国家费用标准 List
  6301. /// </summary>
  6302. /// <returns></returns>
  6303. [HttpPost]
  6304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6305. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6306. {
  6307. try
  6308. {
  6309. Stopwatch sw = new Stopwatch();
  6310. sw.Start();
  6311. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6312. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6313. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6314. Where gntf.Isdel = 0");
  6315. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6316. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6317. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6318. //foreach (var item in nationalTravel)
  6319. //{
  6320. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6321. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6322. // if (otherData != null)
  6323. // {
  6324. // cityData.Remove(otherData);
  6325. // cityData.Add(otherData);
  6326. // }
  6327. // nationalTravelFeeData1.Add(new
  6328. // {
  6329. // Country = item.Country,
  6330. // CityData = cityData
  6331. // });
  6332. //}
  6333. sw.Stop();
  6334. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6335. }
  6336. catch (Exception ex)
  6337. {
  6338. return Ok(JsonView(false, ex.Message));
  6339. throw;
  6340. }
  6341. }
  6342. /// <summary>
  6343. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6344. /// </summary>
  6345. /// <returns></returns>
  6346. [HttpPost]
  6347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6348. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6349. {
  6350. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6351. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6352. List<string> countryData = new List<string>();
  6353. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6354. countryData = countryData.Distinct().ToList();
  6355. List<dynamic> dataSource = new List<dynamic>();
  6356. foreach (var item in countryData)
  6357. {
  6358. List<string> cityData1 = new List<string>();
  6359. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6360. var countryData2 = new
  6361. {
  6362. CountryName = item,
  6363. CityData = cityData1
  6364. };
  6365. dataSource.Add(countryData2);
  6366. }
  6367. return Ok(JsonView(true, "查询成功!", dataSource));
  6368. }
  6369. /// <summary>
  6370. /// 团组模块 - 出入境国家费用标准 Page List
  6371. /// </summary>
  6372. /// <returns></returns>
  6373. [HttpPost]
  6374. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6375. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6376. {
  6377. int portId = dto.PortType;
  6378. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6379. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6380. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6381. string whereSql = string.Empty;
  6382. if (!string.IsNullOrEmpty(dto.Country))
  6383. {
  6384. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6385. }
  6386. if (!string.IsNullOrEmpty(dto.City))
  6387. {
  6388. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6389. }
  6390. string pageSql = string.Format(@"Select * From (
  6391. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6392. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6393. From Grp_NationalTravelFee gntf
  6394. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6395. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6396. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6397. RefAsync<int> total = 0;
  6398. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6399. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6400. }
  6401. /// <summary>
  6402. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6403. /// </summary>
  6404. /// <returns></returns>
  6405. [HttpPost]
  6406. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6407. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6408. {
  6409. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6410. int portId = dto.PortType;
  6411. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6412. string whereSql = string.Empty;
  6413. if (!string.IsNullOrEmpty(dto.Country))
  6414. {
  6415. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6416. }
  6417. if (!string.IsNullOrEmpty(dto.City))
  6418. {
  6419. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6420. }
  6421. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6422. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6423. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6424. From Grp_NationalTravelFee gntf
  6425. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6426. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6427. Where gntf.Isdel = 0 {0} ", whereSql);
  6428. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6429. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6430. }
  6431. /// <summary>
  6432. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6433. /// </summary>
  6434. /// <returns></returns>
  6435. [HttpPost]
  6436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6437. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6438. {
  6439. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6440. if (data.Code != 0)
  6441. {
  6442. return Ok(JsonView(false, data.Msg));
  6443. }
  6444. return Ok(JsonView(true, "操作成功!", data.Data));
  6445. }
  6446. /// <summary>
  6447. /// 团组模块 - 出入境国家费用标准 - Del
  6448. /// </summary>
  6449. /// <returns></returns>
  6450. [HttpPost]
  6451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6452. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6453. {
  6454. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6455. {
  6456. Id = dto.Id,
  6457. DeleteUserId = dto.DeleteUserId,
  6458. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6459. IsDel = 1
  6460. };
  6461. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6462. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6463. .WhereColumns(it => new { it.Id })
  6464. .ExecuteCommandAsync();
  6465. if (delStatus <= 0)
  6466. {
  6467. return Ok(JsonView(false, "删除失败!"));
  6468. }
  6469. return Ok(JsonView(true, "操作成功!"));
  6470. }
  6471. /// <summary>
  6472. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6473. /// 注:Get 请求Headers 加 Token
  6474. /// </summary>
  6475. /// <param name="groupId"></param>
  6476. /// <returns></returns>
  6477. [HttpGet("{groupId}")]
  6478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6479. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6480. {
  6481. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6482. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6483. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6484. data.ForEach(x =>
  6485. {
  6486. x.CreateUserId = _currUserInfo.UserId;
  6487. });
  6488. if (data.Any())
  6489. {
  6490. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6491. if (add > 0)
  6492. {
  6493. return Ok(JsonView(true, "操作成功!"));
  6494. }
  6495. }
  6496. return Ok(JsonView(false, "未操作!"));
  6497. }
  6498. #endregion
  6499. #region 团组经理模块 出入境费用-草稿
  6500. /// <summary>
  6501. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6502. /// </summary>
  6503. /// <returns></returns>
  6504. [HttpPost]
  6505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6506. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6507. {
  6508. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6509. .Where(x => x.IsDel == 0)
  6510. .OrderByDescending(x => x.CreateTime)
  6511. .Select(x => new { x.Id, x.DraftName })
  6512. .ToListAsync();
  6513. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6514. //SetDataInfoView
  6515. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6516. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6517. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6518. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6519. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6520. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6521. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6522. //默认币种显示
  6523. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  6524. {
  6525. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  6526. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  6527. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  6528. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  6529. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  6530. };
  6531. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6532. if (_currencyRate.Count > 0)
  6533. {
  6534. foreach (var item in _currencyInfos)
  6535. {
  6536. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6537. if (rateInfo != null)
  6538. {
  6539. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6540. rate1 *= 1.035M;
  6541. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6542. }
  6543. }
  6544. }
  6545. var gj_jobPostIds = new List<int>() { 22, 32 };
  6546. var viewPermissionData = await _sqlSugar.Queryable<Sys_Users>()
  6547. .Where(x => x.IsDel == 0 && ((x.DepId == 7 && gj_jobPostIds.Contains(x.JobPostId)) || x.DepId == 6))
  6548. .Select(x => new { x.Id, Name = x.CnName })
  6549. .ToListAsync();
  6550. return Ok(JsonView(true, "查询成功!", new
  6551. {
  6552. DraftNameDatas = draftNameDatas,
  6553. CurrencyData = _CurrencyData,
  6554. WordTypeData = _WordTypeData,
  6555. ExcelTypeData = _ExcelTypeData,
  6556. CurrencyInit = _currencyInfos,
  6557. ViewPermissionData = viewPermissionData
  6558. }));
  6559. }
  6560. /// <summary>
  6561. /// 团组模块 - 出入境费用-草稿
  6562. /// 实时汇率 tips
  6563. /// 签证费用 tips
  6564. /// 机票费用 tips
  6565. /// </summary>
  6566. /// <returns></returns>
  6567. [HttpPost]
  6568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6569. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6570. {
  6571. //var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6572. //默认币种显示
  6573. var _currencyInfos = _currencyInit;
  6574. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6575. List<dynamic> reteInfos = new List<dynamic>();
  6576. if (_currencyRate.Count > 0)
  6577. {
  6578. foreach (var item in _currencyInfos)
  6579. {
  6580. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6581. if (rateInfo != null)
  6582. {
  6583. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6584. decimal rate1 = item.Rate;
  6585. rate1 *= 1.03M;
  6586. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6587. reteInfos.Add(new
  6588. {
  6589. currCode = item.CurrencyCode,
  6590. currName = item.CurrencyName,
  6591. rate = rate2,
  6592. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6593. });
  6594. }
  6595. }
  6596. }
  6597. //var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  6598. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6599. return Ok(JsonView(true, "查询成功!", new
  6600. {
  6601. //GroupNameData = groupNameData.Data,
  6602. //visaData = visaData.Data,
  6603. //airData = airData.Data,
  6604. reteInfos = reteInfos
  6605. }));
  6606. }
  6607. /// <summary>
  6608. /// 团组模块 - 出入境费用-草稿 - Info
  6609. /// </summary>
  6610. /// <returns></returns>
  6611. [HttpPost]
  6612. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6613. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6614. {
  6615. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6616. }
  6617. /// <summary>
  6618. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6619. /// </summary>
  6620. /// <returns></returns>
  6621. [HttpPost]
  6622. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6623. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6624. {
  6625. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6626. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6627. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6628. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6629. foreach (var userId in dto.UserIds)
  6630. {
  6631. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6632. }
  6633. if (permissions.Any())
  6634. {
  6635. _sqlSugar.BeginTran();
  6636. try
  6637. {
  6638. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6639. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6640. if (result < 1)
  6641. {
  6642. _sqlSugar.RollbackTran();
  6643. return Ok(JsonView(false));
  6644. }
  6645. }
  6646. catch (Exception ex)
  6647. {
  6648. _sqlSugar.RollbackTran();
  6649. return Ok(JsonView(false, ex.Message));
  6650. }
  6651. _sqlSugar.CommitTran();
  6652. return Ok(JsonView(true));
  6653. }
  6654. return Ok(JsonView(false));
  6655. }
  6656. /// <summary>
  6657. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6658. /// </summary>
  6659. /// <returns></returns>
  6660. [HttpPost]
  6661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6662. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6663. {
  6664. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6665. if (data.Code != 0)
  6666. {
  6667. return Ok(JsonView(false, data.Msg));
  6668. }
  6669. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6670. //汇率信息记录
  6671. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6672. return Ok(JsonView(true, data.Msg, data.Data));
  6673. }
  6674. /// <summary>
  6675. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6676. /// </summary>
  6677. /// <param name="dto"></param>
  6678. /// <returns></returns>
  6679. [HttpPost]
  6680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6681. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6682. {
  6683. try
  6684. {
  6685. var id = dto.Id;
  6686. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6687. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6688. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6689. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6690. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6691. 3 团组成员名单 1 团组成员名单", ""));
  6692. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6693. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6694. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6695. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6696. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6697. //数据源
  6698. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6699. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6700. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6701. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6702. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6703. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6704. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6705. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6706. .Select((x, a, b) => new
  6707. {
  6708. x.Index,
  6709. itemName = a.Name,
  6710. CurrencyStr = b.Name,
  6711. x.Cost,
  6712. x.SubTotal,
  6713. x.Remark
  6714. })
  6715. .OrderBy((x) => x.Index)
  6716. .ToList(); //其他款项费用
  6717. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6718. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6719. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6720. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6721. if (dto.ExportType == 1) //明细表
  6722. {
  6723. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6724. {
  6725. //获取模板
  6726. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6727. //载入模板
  6728. Document doc = new Document(tempPath);
  6729. DocumentBuilder builder = new DocumentBuilder(doc);
  6730. //利用键值对存放数据
  6731. Dictionary<string, string> dic = new Dictionary<string, string>();
  6732. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6733. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6734. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6735. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6736. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6737. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6738. //境内费用(其他费用)
  6739. if (_EnterExitCosts.ChoiceOne == 1)
  6740. {
  6741. string row1_1 = "";
  6742. if (_EnterExitCosts.Visa > 0)
  6743. {
  6744. //insidePayTotal += _EnterExitCosts.Visa;
  6745. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6746. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6747. {
  6748. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6749. }
  6750. }
  6751. string row1_2 = "";
  6752. if (_EnterExitCosts.YiMiao > 0)
  6753. {
  6754. //insidePayTotal += _EnterExitCosts.YiMiao;
  6755. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6756. }
  6757. if (_EnterExitCosts.HeSuan > 0)
  6758. {
  6759. //insidePayTotal += _EnterExitCosts.HeSuan;
  6760. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6761. }
  6762. if (_EnterExitCosts.Service > 0)
  6763. {
  6764. //insidePayTotal += _EnterExitCosts.Service;
  6765. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6766. }
  6767. string row1_3 = "";
  6768. if (_EnterExitCosts.Safe > 0)
  6769. {
  6770. //insidePayTotal += _EnterExitCosts.Safe;
  6771. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6772. }
  6773. if (_EnterExitCosts.Ticket > 0)
  6774. {
  6775. //insidePayTotal += _EnterExitCosts.Ticket;
  6776. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6777. }
  6778. string row1 = "";
  6779. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6780. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6781. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6782. row1 += $"备注:{_EnterExitCosts.Remark}";
  6783. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6784. dic.Add("Row1Str", row1);
  6785. }
  6786. string airTotalStr = string.Empty,
  6787. airPriceStr = string.Empty;
  6788. //经济舱
  6789. if (_EnterExitCosts.SumJJC == 1)
  6790. {
  6791. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6792. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6793. }
  6794. //公务舱
  6795. if (_EnterExitCosts.SumGWC == 1)
  6796. {
  6797. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6798. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6799. }
  6800. //头等舱
  6801. if (_EnterExitCosts.SumTDC == 1)
  6802. {
  6803. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6804. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6805. }
  6806. string twoItemRemark = "备注:";
  6807. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
  6808. {
  6809. twoItemRemark = _EnterExitCosts.TwoItemRemark;
  6810. }
  6811. dic.Add("AirTotalStr", airTotalStr);
  6812. dic.Add("AirPriceStr", airPriceStr);
  6813. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6814. dic.Add("TwoItemRemark", twoItemRemark);
  6815. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6816. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6817. int table1Row = 0,
  6818. table2Row = 0,
  6819. table3Row = 0,
  6820. table4Row = 0,
  6821. table5Row = 0;
  6822. //住宿费
  6823. if (_EnterExitCosts.ChoiceThree == 1)
  6824. {
  6825. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6826. table1Row = dac1.Count;
  6827. #region 填充word表格内容
  6828. for (int i = 0; i < dac1.Count; i++)
  6829. {
  6830. var dac = dac1[i];
  6831. if (dac == null) continue;
  6832. builder.MoveToCell(0, i, 0, 0);
  6833. builder.Write("第" + dac.Days.ToString() + "晚:");
  6834. builder.MoveToCell(0, i, 1, 0);
  6835. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6836. //builder.Write(dac.Place == null ? "" : dac.Place);
  6837. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6838. builder.MoveToCell(0, i, 2, 0);
  6839. builder.Write("费用标准:");
  6840. string curr = "";
  6841. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6842. if (currData != null)
  6843. {
  6844. curr = currData.Name;
  6845. }
  6846. builder.MoveToCell(0, i, 3, 0);
  6847. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6848. builder.MoveToCell(0, i, 4, 0);
  6849. builder.Write("费用小计:");
  6850. builder.MoveToCell(0, i, 5, 0);
  6851. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6852. }
  6853. #endregion
  6854. }
  6855. else dic.Add("SubZS", "0.00");
  6856. //删除多余行
  6857. while (table1.Rows.Count > table1Row)
  6858. {
  6859. table1.Rows.RemoveAt(table1Row);
  6860. }
  6861. //伙食费
  6862. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6863. if (_EnterExitCosts.ChoiceFour == 1)
  6864. {
  6865. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6866. table2Row = dac2.Count;
  6867. #region 填充word表格内容
  6868. for (int i = 0; i < dac2.Count; i++)
  6869. {
  6870. var dac = dac2[i];
  6871. if (dac == null) continue;
  6872. builder.MoveToCell(1, i, 0, 0);
  6873. builder.Write("第" + dac.Days.ToString() + "天:");
  6874. builder.MoveToCell(1, i, 1, 0);
  6875. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6876. builder.MoveToCell(1, i, 2, 0);
  6877. builder.Write("费用标准:");
  6878. string curr = "";
  6879. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6880. if (currData != null)
  6881. {
  6882. curr = currData.Name;
  6883. }
  6884. builder.MoveToCell(1, i, 3, 0);
  6885. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6886. builder.MoveToCell(1, i, 4, 0);
  6887. builder.Write("费用小计:");
  6888. builder.MoveToCell(1, i, 5, 0);
  6889. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6890. }
  6891. #endregion
  6892. }
  6893. else dic.Add("SubHS", "0.00");
  6894. //删除多余行
  6895. while (table2.Rows.Count > table2Row)
  6896. {
  6897. table2.Rows.RemoveAt(table2Row);
  6898. }
  6899. //公杂费
  6900. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6901. if (_EnterExitCosts.ChoiceFive == 1)
  6902. {
  6903. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6904. table3Row = dac3.Count;
  6905. #region 填充word表格内容
  6906. for (int i = 0; i < dac3.Count; i++)
  6907. {
  6908. var dac = dac3[i];
  6909. if (dac == null) continue;
  6910. builder.MoveToCell(2, i, 0, 0);
  6911. builder.Write("第" + dac.Days.ToString() + "天:");
  6912. builder.MoveToCell(2, i, 1, 0);
  6913. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6914. builder.MoveToCell(2, i, 2, 0);
  6915. builder.Write("费用标准:");
  6916. string curr = "";
  6917. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6918. if (currData != null)
  6919. {
  6920. curr = currData.Name;
  6921. }
  6922. builder.MoveToCell(2, i, 3, 0);
  6923. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6924. builder.MoveToCell(2, i, 4, 0);
  6925. builder.Write("费用小计:");
  6926. builder.MoveToCell(2, i, 5, 0);
  6927. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6928. }
  6929. //删除多余行
  6930. while (table3.Rows.Count > table3Row)
  6931. {
  6932. table3.Rows.RemoveAt(table3Row);
  6933. }
  6934. #endregion
  6935. }
  6936. else dic.Add("SubGZF", "0.00");
  6937. //删除多余行
  6938. while (table3.Rows.Count > table3Row)
  6939. {
  6940. table3.Rows.RemoveAt(table3Row);
  6941. }
  6942. //培训费
  6943. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6944. if (_EnterExitCosts.ChoiceSix == 1)
  6945. {
  6946. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6947. dic.Add("SubPX", pxStr);
  6948. table4Row = dac4.Count;
  6949. #region 填充word表格内容
  6950. for (int i = 0; i < dac4.Count; i++)
  6951. {
  6952. var dac = dac4[i];
  6953. if (dac == null) continue;
  6954. builder.MoveToCell(3, i, 0, 0);
  6955. builder.Write("第" + dac.Days.ToString() + "天:");
  6956. builder.MoveToCell(3, i, 1, 0);
  6957. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6958. builder.MoveToCell(3, i, 2, 0);
  6959. builder.Write("费用标准:");
  6960. string curr = "";
  6961. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6962. if (currData != null)
  6963. {
  6964. curr = currData.Name;
  6965. }
  6966. builder.MoveToCell(3, i, 3, 0);
  6967. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6968. builder.MoveToCell(3, i, 4, 0);
  6969. builder.Write("费用小计:");
  6970. builder.MoveToCell(3, i, 5, 0);
  6971. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6972. }
  6973. #endregion
  6974. }
  6975. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  6976. //删除多余行
  6977. while (table4.Rows.Count > table4Row)
  6978. {
  6979. table4.Rows.RemoveAt(table4Row);
  6980. }
  6981. //其他费用
  6982. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6983. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6984. {
  6985. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6986. dic.Add("titleQi", qtStr);
  6987. table5Row = dac5.Count;
  6988. #region 填充word表格内容
  6989. for (int i = 0; i < dac5.Count; i++)
  6990. {
  6991. var dac = dac5[i];
  6992. if (dac == null) continue;
  6993. builder.MoveToCell(4, i, 0, 0);
  6994. builder.Write("第" + dac.Index.ToString() + "项:");
  6995. builder.MoveToCell(4, i, 1, 0);
  6996. builder.Write(dac.itemName);
  6997. builder.MoveToCell(4, i, 2, 0);
  6998. builder.Write("费用标准:");
  6999. builder.MoveToCell(4, i, 3, 0);
  7000. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7001. builder.MoveToCell(4, i, 4, 0);
  7002. builder.Write("费用小计:");
  7003. builder.MoveToCell(4, i, 5, 0);
  7004. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7005. builder.MoveToCell(4, i, 6, 0);
  7006. builder.Write("备注:");
  7007. builder.MoveToCell(4, i, 7, 0);
  7008. builder.Write(dac.Remark);
  7009. }
  7010. #endregion
  7011. }
  7012. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7013. //删除多余行
  7014. while (table5.Rows.Count > table5Row)
  7015. {
  7016. table5.Rows.RemoveAt(table5Row);
  7017. }
  7018. //加上其他费用
  7019. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7020. decimal subJJC = 0.00M,
  7021. subGWC = 0.00M,
  7022. subTDC = 0.00M;
  7023. //经济舱
  7024. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7025. //公务舱
  7026. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7027. //头等舱
  7028. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7029. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7030. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7031. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7032. #region 填充word模板书签内容
  7033. foreach (var key in dic.Keys)
  7034. {
  7035. Bookmark bookmark = doc.Range.Bookmarks[key];
  7036. if (bookmark != null)
  7037. {
  7038. builder.MoveToBookmark(key);
  7039. builder.Write(dic[key]);
  7040. }
  7041. }
  7042. #endregion
  7043. //文件名
  7044. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7045. strFileName = CommonFun.ValidFileName(strFileName);
  7046. AsposeHelper.removewatermark_v2180();
  7047. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7048. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7049. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7050. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7051. }
  7052. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7053. {
  7054. //获取模板
  7055. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7056. //载入模板
  7057. Document doc = new Document(tempPath);
  7058. DocumentBuilder builder = new DocumentBuilder(doc);
  7059. Dictionary<string, string> dic = new Dictionary<string, string>();
  7060. string returnCodeLabel = string.Empty;
  7061. if (nationalTravelFeeData.Any())
  7062. {
  7063. List<string> list = new List<string>();
  7064. foreach (var item in nationalTravelFeeData)
  7065. {
  7066. list.Add($"{item.Country}({item.City})");
  7067. }
  7068. list = list.Distinct().ToList();
  7069. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7070. }
  7071. var countryLabel = string.Empty;
  7072. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7073. if (countryData.Any())
  7074. {
  7075. countryLabel = string.Join("、", countryData);
  7076. }
  7077. dic.Add("ReturnCodeAir", returnCodeLabel);
  7078. dic.Add("VisitStartDate", "-");
  7079. dic.Add("VisitEndDate", "-");
  7080. dic.Add("Day", "-");
  7081. dic.Add("VisitCountry", countryLabel);
  7082. dic.Add("ClientUnit", "-");
  7083. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7084. //dic.Add("Names", Names);
  7085. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7086. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7087. decimal dac1totalPrice = 0.00M;
  7088. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7089. foreach (var dac in dac1)
  7090. {
  7091. if (dac.SubTotal == 0.00M)
  7092. {
  7093. continue;
  7094. }
  7095. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7096. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7097. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7098. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7099. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7100. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7101. builder.Write(currency);//币种
  7102. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7103. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7104. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7105. builder.Write("");//人数
  7106. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7107. builder.Write("");//天数
  7108. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7109. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7110. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7111. decimal rate = 0.00M;
  7112. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7113. builder.Write(rate.ToString("#0.0000"));//汇率
  7114. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7115. decimal rbmPrice = dac.SubTotal;
  7116. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7117. accommodationStartIndex++;
  7118. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7119. }
  7120. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7121. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7122. {
  7123. table1.Rows.RemoveAt(i - 1);
  7124. foodandotherStartIndex--;
  7125. }
  7126. if (dac2.Count == dac3.Count)//国家 币种 金额
  7127. {
  7128. for (int i = 0; i < dac2.Count; i++)
  7129. {
  7130. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7131. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7132. }
  7133. }
  7134. decimal dac2totalPrice = 0.00M;
  7135. foreach (var dac in dac2)
  7136. {
  7137. if (dac.SubTotal == 0)
  7138. {
  7139. continue;
  7140. }
  7141. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7142. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7143. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7144. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7145. builder.Write(currency);//币种
  7146. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7147. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7148. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7149. builder.Write("");//人数
  7150. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7151. builder.Write("");//天数
  7152. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7153. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7154. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7155. decimal rate = 0.00M;
  7156. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7157. builder.Write(rate.ToString("#0.0000"));//汇率
  7158. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7159. decimal rbmPrice = dac.SubTotal;
  7160. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7161. foodandotherStartIndex++;
  7162. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7163. }
  7164. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7165. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7166. {
  7167. table1.Rows.RemoveAt(i - 1);
  7168. }
  7169. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7170. string otherFeeStr = "";
  7171. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7172. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7173. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7174. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7175. foreach (var otherInfo in dac5)
  7176. {
  7177. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7178. }
  7179. #endregion
  7180. if (otherFeeStr.Length > 0)
  7181. {
  7182. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7183. otherFeeStr = $"({otherFeeStr})";
  7184. dic.Add("OtherFeeStr", otherFeeStr);
  7185. }
  7186. //总计
  7187. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7188. //国际旅费
  7189. string outsideAir = string.Empty;
  7190. string allPriceAir = string.Empty;
  7191. if (_EnterExitCosts.SumJJC == 1)
  7192. {
  7193. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7194. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7195. }
  7196. if (_EnterExitCosts.SumGWC == 1)
  7197. {
  7198. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7199. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7200. }
  7201. if (_EnterExitCosts.SumTDC == 1)
  7202. {
  7203. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7204. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7205. }
  7206. dic.Add("InTravelPrice", $"({outsideAir})");
  7207. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7208. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7209. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7210. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7211. foreach (var key in dic.Keys)
  7212. {
  7213. builder.MoveToBookmark(key);
  7214. builder.Write(dic[key]);
  7215. }
  7216. //模板文件名
  7217. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7218. strFileName = CommonFun.ValidFileName(strFileName);
  7219. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7220. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7221. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7222. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7223. }
  7224. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7225. {
  7226. //获取模板
  7227. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7228. //载入模板
  7229. WorkbookDesigner designer = new WorkbookDesigner();
  7230. designer.Workbook = new Workbook(tempPath);
  7231. Dictionary<string, string> dic = new Dictionary<string, string>();
  7232. string returnCodeLabel = string.Empty;
  7233. if (nationalTravelFeeData.Any())
  7234. {
  7235. List<string> list = new List<string>();
  7236. foreach (var item in nationalTravelFeeData)
  7237. {
  7238. list.Add($"{item.Country}({item.City})");
  7239. }
  7240. list = list.Distinct().ToList();
  7241. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7242. }
  7243. var countryLabel = string.Empty;
  7244. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7245. if (countryData.Any())
  7246. {
  7247. countryLabel = string.Join("、", countryData);
  7248. }
  7249. dic.Add("ReturnCodeAir", returnCodeLabel);
  7250. dic.Add("VisitStartDate", "-");
  7251. dic.Add("VisitEndDate", "-");
  7252. dic.Add("Day", "0");
  7253. dic.Add("VisitCountry", countryLabel);
  7254. dic.Add("ClientUnit", "-");
  7255. designer.SetDataSource("ClientUnit", "-");
  7256. designer.SetDataSource("VisitCountry", countryLabel);
  7257. designer.SetDataSource("Group", "-");
  7258. designer.SetDataSource("ClientUnitTitle", "-");
  7259. designer.SetDataSource("Name", "-");
  7260. designer.SetDataSource("VisitStartDate", "-" );
  7261. designer.SetDataSource("Day", "0");
  7262. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7263. designer.SetDataSource("ReturnCodeAir", "-");
  7264. int startIndex = 10;
  7265. const int startIndexcopy = 10;
  7266. if (dac2.Count == dac3.Count)//国家 币种 金额
  7267. {
  7268. for (int i = 0; i < dac2.Count; i++)
  7269. {
  7270. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7271. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7272. }
  7273. }
  7274. DataTable dtdac1 = new DataTable();
  7275. List<string> place = new List<string>();
  7276. dtdac1.Columns.AddRange(new DataColumn[] {
  7277. new DataColumn(){ ColumnName = "city"},
  7278. new DataColumn(){ ColumnName = "curr"},
  7279. new DataColumn(){ ColumnName = "criterion"},
  7280. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7281. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7282. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7283. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7284. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7285. });
  7286. DataTable dtdac2 = new DataTable();
  7287. dtdac2.Columns.AddRange(new DataColumn[] {
  7288. new DataColumn(){ ColumnName = "city"},
  7289. new DataColumn(){ ColumnName = "curr"},
  7290. new DataColumn(){ ColumnName = "criterion"},
  7291. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7292. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7293. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7294. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7295. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7296. });
  7297. dtdac1.TableName = "tb1";
  7298. dtdac2.TableName = "tb2";
  7299. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7300. foreach (var item in dac1)
  7301. {
  7302. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7303. if (place.Contains(item.Place))
  7304. {
  7305. continue;
  7306. }
  7307. DataRow row = dtdac1.NewRow();
  7308. row["city"] = item.Place;
  7309. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7310. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7311. row["curr"] = currency;
  7312. row["rate"] = rate.ToString("#0.0000");
  7313. row["criterion"] = item.Cost.ToString("#0.00");
  7314. row["number"] = 1;
  7315. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7316. //row["costRMB"] = rbmPrice;
  7317. dtdac1.Rows.Add(row);
  7318. place.Add(item.Place);
  7319. }
  7320. place = new List<string>();
  7321. foreach (var item in dac2)
  7322. {
  7323. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7324. if (place.Contains(item.Place))
  7325. {
  7326. continue;
  7327. }
  7328. DataRow row = dtdac2.NewRow();
  7329. row["city"] = item.Place;
  7330. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7331. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7332. row["curr"] = currency;
  7333. row["rate"] = rate.ToString("#0.0000");
  7334. row["criterion"] = item.Cost.ToString("#0.00");
  7335. row["number"] = 1;
  7336. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7337. //row["cost"] = item.SubTotal;
  7338. //row["costRMB"] = rbmPrice;
  7339. dtdac2.Rows.Add(row);
  7340. place.Add(item.Place);
  7341. //dac2totalPrice += rbmPrice;
  7342. }
  7343. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7344. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7345. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7346. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7347. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  7348. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  7349. string cell4Str1 = string.Empty;
  7350. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  7351. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  7352. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  7353. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7354. string cellStr = $" 5.其他费用(";
  7355. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7356. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7357. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7358. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7359. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7360. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7361. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7362. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7363. foreach (var otherInfo in dac5)
  7364. {
  7365. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7366. }
  7367. #endregion
  7368. if (cellStr.Length > 8)
  7369. {
  7370. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7371. }
  7372. cellStr += ")";
  7373. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7374. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7375. decimal pxFee = dac4.Sum(it => it.Cost);
  7376. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7377. string celllastStr1 = "";
  7378. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  7379. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  7380. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  7381. celllastStr1 += $",国际旅费 元";
  7382. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  7383. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7384. designer.SetDataSource("cell4Str", cell4Str);
  7385. designer.SetDataSource("cellStr", cellStr);
  7386. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7387. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7388. designer.SetDataSource("celllastStr", celllastStr);
  7389. Workbook wb = designer.Workbook;
  7390. var sheet = wb.Worksheets[0];
  7391. //绑定datatable数据集
  7392. designer.SetDataSource(dtdac1);
  7393. designer.SetDataSource(dtdac2);
  7394. designer.Process();
  7395. var rowStart = dtdac1.Rows.Count;
  7396. while (rowStart > 0)
  7397. {
  7398. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7399. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7400. startIndex++;
  7401. rowStart--;
  7402. }
  7403. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7404. startIndex += 1; //总计行
  7405. rowStart = dtdac2.Rows.Count;
  7406. while (rowStart > 0)
  7407. {
  7408. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7409. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7410. startIndex++;
  7411. rowStart--;
  7412. }
  7413. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7414. wb.CalculateFormula(true);
  7415. //模板文件名
  7416. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7417. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7418. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7419. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7420. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7421. }
  7422. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7423. {
  7424. //获取模板
  7425. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7426. //载入模板
  7427. Document doc = new Document(tempPath);
  7428. DocumentBuilder builder = new DocumentBuilder(doc);
  7429. Dictionary<string, string> dic = new Dictionary<string, string>();
  7430. dic.Add("GroupName", "-");
  7431. dic.Add("ClientUnit", "-");
  7432. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7433. string missionLeaderJob = "";//负责人job
  7434. int groupNumber = 0; //团人数
  7435. dic.Add("MissionLeader", "-"); //团负责人
  7436. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7437. dic.Add("GroupNumber", "0"); //团人数
  7438. dic.Add("Day", "0");
  7439. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7440. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7441. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7442. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7443. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7444. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7445. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7446. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7447. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7448. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7449. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7450. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7451. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7452. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7453. //其他费用
  7454. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7455. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7456. //其他费用合计
  7457. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7458. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7459. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7460. //公务舱合计
  7461. //国际旅费
  7462. string outsideJJ = "";
  7463. string allPriceJJ = "";
  7464. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7465. {
  7466. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7467. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7468. }
  7469. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7470. {
  7471. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7472. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7473. }
  7474. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7475. {
  7476. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7477. dic.Add("AirFeeTotal", airFeeTotalStr);
  7478. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7479. dic.Add("FeeTotal", feeTotalStr);
  7480. }
  7481. foreach (var key in dic.Keys)
  7482. {
  7483. builder.MoveToBookmark(key);
  7484. builder.Write(dic[key]);
  7485. }
  7486. //模板文件名
  7487. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7488. strFileName = CommonFun.ValidFileName(strFileName);
  7489. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7490. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7491. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7492. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7493. }
  7494. }
  7495. else if (dto.ExportType == 2) //表格
  7496. {
  7497. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7498. }
  7499. else if (dto.ExportType == 3)
  7500. {
  7501. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7502. }
  7503. return Ok(JsonView(400, "只可导出明细表!", ""));
  7504. }
  7505. catch (Exception ex)
  7506. {
  7507. return Ok(JsonView(400, ex.Message, ""));
  7508. }
  7509. }
  7510. /// <summary>
  7511. /// 获取三公费用标准city
  7512. /// </summary>
  7513. /// <param name="placeData"></param>
  7514. /// <param name="nationalTravelFeeId"></param>
  7515. /// <returns></returns>
  7516. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7517. {
  7518. string _city = string.Empty;
  7519. if (!placeData.Any()) return _city;
  7520. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7521. if (data == null) return _city;
  7522. string country = data.Country;
  7523. string city = data.City;
  7524. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7525. else _city = city;
  7526. return _city;
  7527. }
  7528. /// <summary>
  7529. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7530. /// </summary>
  7531. /// <returns></returns>
  7532. [HttpPost]
  7533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7534. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7535. {
  7536. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7537. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7538. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7539. if (_view.Code == 0)
  7540. {
  7541. return Ok(JsonView(true, "操作成功"));
  7542. }
  7543. return Ok(JsonView(false, "操作失败"));
  7544. }
  7545. /// <summary>
  7546. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7547. /// </summary>
  7548. /// <returns></returns>
  7549. [HttpPost]
  7550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7551. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7552. {
  7553. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7554. if (data.Code != 0)
  7555. {
  7556. return Ok(JsonView(false, data.Msg));
  7557. }
  7558. return Ok(JsonView(true, "操作成功!", data.Data));
  7559. }
  7560. /// <summary>
  7561. /// 三公其他费用草稿 删除
  7562. /// </summary>
  7563. /// <param name="dto"></param>
  7564. /// <returns></returns>
  7565. [HttpPost]
  7566. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7567. {
  7568. var jw = JsonView(false, "删除失败!");
  7569. var data = new Grp_DayOtherPriceDraft()
  7570. {
  7571. Id = dto.Id,
  7572. IsDel = 1,
  7573. DeleteUserId = dto.DeleteUserId,
  7574. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7575. };
  7576. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7577. if (del > 0)
  7578. {
  7579. jw.Code = 200;
  7580. jw.Msg = "删除成功!";
  7581. }
  7582. return Ok(jw);
  7583. }
  7584. /// <summary>
  7585. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7586. /// </summary>
  7587. /// <param name="dto"></param>
  7588. /// <returns></returns>
  7589. [HttpPost]
  7590. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7591. {
  7592. var jw = JsonView(false);
  7593. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7594. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new {x.Id,x.DraftName }).ToListAsync();
  7595. jw.Code = StatusCodes.Status200OK;
  7596. jw.Msg = "操作成功!";
  7597. jw.Data = new { groupNameDatas= groupNameDatas.Data, draftNames = draftDatas };
  7598. return Ok(jw);
  7599. }
  7600. /// <summary>
  7601. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7602. /// </summary>
  7603. /// <param name="dto"></param>
  7604. /// <returns></returns>
  7605. [HttpPost]
  7606. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7607. {
  7608. int userId = dto.UserId,
  7609. portId = dto.PortType,
  7610. groupId = dto.GroupId,
  7611. draftId = dto.DraftId;
  7612. _portTypeData.Add(1);
  7613. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7614. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7615. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7616. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7617. _sqlSugar.BeginTran();
  7618. try
  7619. {
  7620. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7621. if (draftDatas == null)
  7622. {
  7623. _sqlSugar.RollbackTran();
  7624. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7625. }
  7626. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7627. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7628. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7629. newExterData.DiId = groupId;
  7630. newExterData.CreateUserId = userId;
  7631. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7632. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7633. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7634. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7635. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7636. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7637. //数据如果存在执行删除
  7638. if (enterExitCostInfo != null)
  7639. {
  7640. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7641. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7642. .Where(x => x.Id == enterExitCostInfo.Id)
  7643. .ExecuteCommand();
  7644. _sqlSugar.Updateable<Grp_DayAndCost>()
  7645. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7646. .Where(x => x.DiId == groupId)
  7647. .ExecuteCommand();
  7648. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7649. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7650. .Where(x => x.Diid == groupId)
  7651. .ExecuteCommand();
  7652. }
  7653. //执行insert
  7654. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7655. if (insertId < 1)
  7656. {
  7657. _sqlSugar.RollbackTran();
  7658. return Ok(JsonView(false, "草稿数据导入失败!"));
  7659. }
  7660. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7661. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7662. _sqlSugar.CommitTran();
  7663. //执行操作之后
  7664. //生成默认文件pdf并且通知人员
  7665. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7666. {
  7667. DiId = groupId,
  7668. ExportType = 1,
  7669. SubTypeId = 1005
  7670. }, "pdf");
  7671. //发送通知
  7672. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7673. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7674. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7675. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7676. //汇率信息记录
  7677. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7678. return Ok(JsonView(true));
  7679. }
  7680. catch (Exception ex)
  7681. {
  7682. _sqlSugar.RollbackTran();
  7683. return Ok(JsonView(false,ex.Message));
  7684. }
  7685. }
  7686. #endregion
  7687. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7688. /// <summary>
  7689. /// 获取币种基础数据(含逻辑处理)
  7690. /// </summary>
  7691. /// <returns></returns>
  7692. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7693. {
  7694. //默认币种显示
  7695. var _currencyInfos = _currencyInit;
  7696. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7697. if (_currencyRate.Count > 0)
  7698. {
  7699. foreach (var item in _currencyInfos)
  7700. {
  7701. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7702. if (rateInfo != null)
  7703. {
  7704. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  7705. rate1 *= 1.035M;
  7706. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7707. }
  7708. }
  7709. }
  7710. return _currencyInfos;
  7711. }
  7712. /// <summary>
  7713. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7714. /// </summary>
  7715. /// <returns></returns>
  7716. [HttpPost]
  7717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7718. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7719. {
  7720. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7721. //SetDataInfoView
  7722. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7723. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7724. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7725. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7726. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7727. //默认币种显示
  7728. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7729. return Ok(JsonView(true, "查询成功!", new
  7730. {
  7731. WordTypeData = _WordTypeData,
  7732. ExcelTypeData = _ExcelTypeData,
  7733. CurrencyInit = _currencyInfos
  7734. }));
  7735. }
  7736. /// <summary>
  7737. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7738. /// </summary>
  7739. /// <returns></returns>
  7740. [HttpPost]
  7741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7742. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7743. {
  7744. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7745. RefAsync<int> total = 0;
  7746. int diId = 0;
  7747. var status = int.TryParse(dto.GroupName, out diId);
  7748. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  7749. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  7750. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7751. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  7752. .Select(x => new
  7753. {
  7754. Id = x.Id,
  7755. GroupName = x.TeamName
  7756. })
  7757. .OrderByDescending(x => x.Id)
  7758. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7759. return Ok(JsonView(true, "查询成功!", data, total));
  7760. }
  7761. /// <summary>
  7762. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7763. /// </summary>
  7764. /// <returns></returns>
  7765. [HttpPost]
  7766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7767. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7768. {
  7769. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7770. RefAsync<int> total = 0;
  7771. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7772. .Where(x => x.IsDel == 0 && x.STid == 66)
  7773. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7774. .Select(x => new
  7775. {
  7776. id = x.Id,
  7777. name = x.Name,
  7778. remark = x.Remark,
  7779. })
  7780. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7781. return Ok(JsonView(true, "查询成功!", data, total));
  7782. }
  7783. /// <summary>
  7784. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7785. /// </summary>
  7786. /// <returns></returns>
  7787. [HttpPost]
  7788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7789. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7790. {
  7791. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7792. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7793. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7794. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7795. var groupOtherRateData = groupRateData.TeamRates;
  7796. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7797. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7798. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7799. groupOtherRateData = groupOtherRateData
  7800. .Select(x => new TeamRateDescAddCurrencyIdView {
  7801. CurrencyId = x.CurrencyId,
  7802. CurrencyName = x.CurrencyName,
  7803. CurrencyCode = x.CurrencyCode,
  7804. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7805. }).ToList();
  7806. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7807. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData= groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7808. }
  7809. /// <summary>
  7810. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7811. /// </summary>
  7812. /// <returns></returns>
  7813. [HttpPost]
  7814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7815. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7816. {
  7817. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7818. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7819. var tipsData = new List<int>() {1,2,3 };
  7820. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7821. if (dto.TipsType == 1)
  7822. {
  7823. //默认币种显示
  7824. var _currencyInfos = _currencyInit;
  7825. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7826. List<dynamic> reteInfos = new List<dynamic>();
  7827. if (_currencyRate.Count > 0)
  7828. {
  7829. foreach (var item in _currencyInfos)
  7830. {
  7831. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7832. if (rateInfo != null)
  7833. {
  7834. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  7835. decimal rate1 = item.Rate;
  7836. rate1 *= 1.03M;
  7837. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7838. reteInfos.Add(new
  7839. {
  7840. currCode = item.CurrencyCode,
  7841. currName = item.CurrencyName,
  7842. rate = rate2,
  7843. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  7844. });
  7845. }
  7846. }
  7847. }
  7848. return Ok(JsonView(true, "查询成功!", reteInfos));
  7849. }
  7850. else if (dto.TipsType == 2)
  7851. {
  7852. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  7853. return Ok(JsonView(true, "查询成功!", visaData.Data));
  7854. }
  7855. else if (dto.TipsType == 3)
  7856. {
  7857. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  7858. return Ok(JsonView(true, "查询成功!", airData.Data));
  7859. }
  7860. return Ok(JsonView(false));
  7861. }
  7862. /// <summary>
  7863. /// 团组模块 - 出入境国家费用标准-移动端 List
  7864. /// </summary>
  7865. /// <returns></returns>
  7866. [HttpPost]
  7867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7868. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  7869. {
  7870. Stopwatch sw = new Stopwatch();
  7871. sw.Start();
  7872. RefAsync<int> total = 0;
  7873. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7874. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  7875. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  7876. .Where((ntf, sd, u) => ntf.IsDel == 0)
  7877. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  7878. .Select((ntf, sd, u) => new
  7879. {
  7880. Id = ntf.Id,
  7881. Area = $"{ntf.Country}-{ntf.City}",
  7882. Currency = ntf.Currency,
  7883. CurrencyCode = sd.Name,
  7884. CurrencyName = sd.Remark,
  7885. RoomCost = ntf.RoomCost,
  7886. FoodCost = ntf.FoodCost,
  7887. PublicCost = ntf.PublicCost,
  7888. LastUpdateUserId = ntf.LastUpdateUserId,
  7889. LastUpdateUserName = u.CnName,
  7890. LastUpdateTime = ntf.LastUpdateTime,
  7891. })
  7892. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7893. sw.Stop();
  7894. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  7895. }
  7896. /// <summary>
  7897. /// 团组模块 - 出入境费用-移动端 - Info
  7898. /// </summary>
  7899. /// <returns></returns>
  7900. [HttpPost]
  7901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7902. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  7903. {
  7904. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7905. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7906. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  7907. return Ok(data);
  7908. }
  7909. /// <summary>
  7910. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  7911. /// </summary>
  7912. /// <returns></returns>
  7913. [HttpPost]
  7914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7915. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  7916. {
  7917. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7918. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7919. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7920. var mobileInfo = new EnterExitCostMobileParentInfoView();
  7921. mobileInfo.DiId = dto.DiId;
  7922. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  7923. if (eecInfo == null) return Ok(mobileInfo);
  7924. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  7925. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  7926. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  7927. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  7928. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  7929. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  7930. {
  7931. SubId = dac.Id,
  7932. DiId = dac.DiId,
  7933. Type = dac.Type,
  7934. Days = dac.Days,
  7935. NationalTravelFeeId = dac.NationalTravelFeeId,
  7936. Arae = $"{ntf.Country}-{ntf.City}",
  7937. Cost = dac.Cost,
  7938. Currency = dac.Currency,
  7939. CurrencyName = sd.Name,
  7940. SubTotal = dac.SubTotal,
  7941. })
  7942. .ToList();
  7943. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  7944. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  7945. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  7946. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  7947. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  7948. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  7949. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  7950. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  7951. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  7952. //其他款项
  7953. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  7954. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  7955. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  7956. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  7957. .OrderBy((dop, sd1, sd2) => dop.Index)
  7958. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  7959. {
  7960. SubId = dop.Id,
  7961. DiId = dop.Diid,
  7962. Index = dop.Index,
  7963. SetDataId = dop.SetDataId,
  7964. SetDataName = sd1.Name,
  7965. Cost = dop.Cost,
  7966. Currency = dop.Currency,
  7967. CurrencyName = sd2.Remark,
  7968. SubTotal = dop.SubTotal,
  7969. Remark = dop.Remark,
  7970. })
  7971. .ToArray();
  7972. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  7973. return Ok(mobileInfo);
  7974. }
  7975. /// <summary>
  7976. /// 团组模块 - 出入境费用-移动端 - SubInfo
  7977. /// </summary>
  7978. /// <returns></returns>
  7979. [HttpPost]
  7980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7981. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  7982. {
  7983. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7984. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7985. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  7986. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  7987. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7988. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  7989. var subType = dto.SubType;
  7990. if (subType == 1) //1:境内费用
  7991. {
  7992. var oneData = new ChoiceOneMobileSubInfoView()
  7993. {
  7994. Id = eecInfo.Id,
  7995. ChoiceOne = eecInfo.ChoiceOne,
  7996. ChoiceOneTotalCost = eecInfo.InsidePay,
  7997. Visa = eecInfo.Visa,
  7998. VisaRemark = eecInfo.VisaRemark,
  7999. YiMiao = eecInfo.YiMiao,
  8000. HeSuan = eecInfo.HeSuan,
  8001. Service = eecInfo.Service,
  8002. Ticket = eecInfo.Ticket,
  8003. Safe = eecInfo.Safe,
  8004. FirstItemRemark = eecInfo.FirstItemRemark
  8005. };
  8006. return Ok(JsonView(oneData));
  8007. }
  8008. else if (subType == 2) //2:国际旅费
  8009. {
  8010. var twoData = new ChoiceTwoMobileSubInfoView() {
  8011. Id = eecInfo.Id,
  8012. ChoiceTwoJJ = eecInfo.SumJJC,
  8013. OutsideJJPay = eecInfo.OutsideJJPay,
  8014. ChoiceTwoGW = eecInfo.SumGWC,
  8015. OutsideGWPay = eecInfo.OutsideGWPay,
  8016. ChoiceTwoTD = eecInfo.SumTDC,
  8017. OutsideTDPay = eecInfo.OutsideTDPay,
  8018. AirJJ = eecInfo.AirJJ,
  8019. AirGW = eecInfo.AirGW,
  8020. AirTD = eecInfo.AirTD,
  8021. CityTranffic = eecInfo.CityTranffic,
  8022. TwoItemRemark = eecInfo.TwoItemRemark
  8023. };
  8024. return Ok(JsonView(twoData));
  8025. }
  8026. else if (subType == 3) //3:住宿费
  8027. {
  8028. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8029. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8030. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8031. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8032. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8033. {
  8034. SubId = dac.Id,
  8035. DiId = dac.DiId,
  8036. Type = dac.Type,
  8037. Days = dac.Days,
  8038. NationalTravelFeeId = dac.NationalTravelFeeId,
  8039. Arae = $"{ntf.Country}-{ntf.City}",
  8040. Cost = dac.Cost,
  8041. Currency = dac.Currency,
  8042. CurrencyName = sd.Name,
  8043. SubTotal = dac.SubTotal,
  8044. })
  8045. .ToArray();
  8046. var data = new ChoiceMobileSubInfo3To6View() {
  8047. ParentId = eecInfo.Id,
  8048. Choice = eecInfo.ChoiceThree,
  8049. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8050. Details = dayAndCostDatas
  8051. };
  8052. return Ok(JsonView(data));
  8053. }
  8054. else if (subType == 4) //4:伙食费
  8055. {
  8056. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8057. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8058. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8059. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8060. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8061. {
  8062. SubId = dac.Id,
  8063. DiId = dac.DiId,
  8064. Type = dac.Type,
  8065. Days = dac.Days,
  8066. NationalTravelFeeId = dac.NationalTravelFeeId,
  8067. Arae = $"{ntf.Country}-{ntf.City}",
  8068. Cost = dac.Cost,
  8069. Currency = dac.Currency,
  8070. CurrencyName = sd.Name,
  8071. SubTotal = dac.SubTotal,
  8072. })
  8073. .ToArray();
  8074. var data = new ChoiceMobileSubInfo3To6View()
  8075. {
  8076. ParentId = eecInfo.Id,
  8077. Choice = eecInfo.ChoiceFour,
  8078. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8079. Details = dayAndCostDatas
  8080. };
  8081. return Ok(JsonView(data));
  8082. }
  8083. else if (subType == 5) //5:公杂费
  8084. {
  8085. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8086. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8087. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8088. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8089. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8090. {
  8091. SubId = dac.Id,
  8092. DiId = dac.DiId,
  8093. Type = dac.Type,
  8094. Days = dac.Days,
  8095. NationalTravelFeeId = dac.NationalTravelFeeId,
  8096. Arae = $"{ntf.Country}-{ntf.City}",
  8097. Cost = dac.Cost,
  8098. Currency = dac.Currency,
  8099. CurrencyName = sd.Name,
  8100. SubTotal = dac.SubTotal,
  8101. })
  8102. .ToArray();
  8103. var data = new ChoiceMobileSubInfo3To6View()
  8104. {
  8105. ParentId = eecInfo.Id,
  8106. Choice = eecInfo.ChoiceFive,
  8107. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8108. Details = dayAndCostDatas
  8109. };
  8110. return Ok(JsonView(data));
  8111. }
  8112. else if (subType == 6) //6:培训费
  8113. {
  8114. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8115. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8116. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8117. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8118. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8119. {
  8120. SubId = dac.Id,
  8121. DiId = dac.DiId,
  8122. Type = dac.Type,
  8123. Days = dac.Days,
  8124. NationalTravelFeeId = dac.NationalTravelFeeId,
  8125. Arae = $"{ntf.Country}-{ntf.City}",
  8126. Cost = dac.Cost,
  8127. Currency = dac.Currency,
  8128. CurrencyName = sd.Name,
  8129. SubTotal = dac.SubTotal,
  8130. })
  8131. .ToArray();
  8132. var data = new ChoiceMobileSubInfo3To6View()
  8133. {
  8134. ParentId = eecInfo.Id,
  8135. Choice = eecInfo.ChoiceSix,
  8136. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8137. Details = dayAndCostDatas
  8138. };
  8139. return Ok(JsonView(data));
  8140. }
  8141. else if (subType == 7) //7:其他
  8142. {
  8143. //其他款项
  8144. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8145. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8146. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8147. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8148. .OrderBy((dop, sd1, sd2) => dop.Index)
  8149. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8150. {
  8151. SubId = dop.Id,
  8152. DiId = dop.Diid,
  8153. Index = dop.Index,
  8154. SetDataId = dop.SetDataId,
  8155. SetDataName = sd1.Name,
  8156. Cost = dop.Cost,
  8157. Currency = dop.Currency,
  8158. CurrencyName = sd2.Name,
  8159. SubTotal = dop.SubTotal,
  8160. Remark = dop.Remark,
  8161. })
  8162. .ToArray();
  8163. var data = new ChoiceSevenMobileSubInfoView()
  8164. {
  8165. ParentId = eecInfo.Id,
  8166. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8167. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8168. Details = otherData
  8169. };
  8170. return Ok(JsonView(data));
  8171. }
  8172. return Ok(JsonView(false));
  8173. }
  8174. #region op
  8175. /// <summary>
  8176. /// 移动端更新费用消息通知
  8177. /// </summary>
  8178. /// <param name="diid"></param>
  8179. /// <param name="id"></param>
  8180. /// <param name="currUserId"></param>
  8181. private async Task EnterExitCostMobileOpNotice(int diid, int id,int currUserId)
  8182. {
  8183. try
  8184. {
  8185. ////生成默认文件pdf并且通知人员
  8186. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8187. //{
  8188. // DiId = diid,
  8189. // ExportType = 1,
  8190. // SubTypeId = 1005
  8191. //}, "pdf");
  8192. ////发送通知
  8193. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8194. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8195. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8196. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8197. ////汇率信息记录
  8198. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8199. }
  8200. catch (Exception ex)
  8201. {
  8202. //记录日志
  8203. throw;
  8204. }
  8205. }
  8206. /// <summary>
  8207. /// 验证出入境费用数据是否存在
  8208. /// 不存在添加
  8209. /// </summary>
  8210. /// <param name="diId"></param>
  8211. /// <param name="currUserId"></param>
  8212. /// <returns></returns>
  8213. /// <exception cref="CustomException"></exception>
  8214. private async Task<int> EnterExitCostVerifyIsNull(int diId,int currUserId)
  8215. {
  8216. var parentId = 0;
  8217. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8218. if (info != null) parentId = info.Id;
  8219. else
  8220. {
  8221. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8222. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8223. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8224. parentId = addId;
  8225. }
  8226. return parentId;
  8227. }
  8228. /// <summary>
  8229. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8230. /// </summary>
  8231. /// <returns></returns>
  8232. [HttpPost]
  8233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8234. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8235. {
  8236. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8237. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8238. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8239. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8240. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8241. int id = dto.Id;
  8242. if (id <= 0) //add
  8243. {
  8244. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8245. if (add < 1) return Ok(JsonView(false));
  8246. id = add;
  8247. }
  8248. else //update
  8249. {
  8250. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8251. if (upd < 1) return Ok(JsonView(false));
  8252. }
  8253. #region 汇率变更时更改币种相关费用
  8254. var opDayCosts = new List<Grp_DayAndCost>();
  8255. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8256. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8257. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8258. .LeftJoin<Sys_SetData>((dac,sd) => dac.Currency == sd.Id)
  8259. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8260. .Select((dac, sd) => new {
  8261. dac.Id,
  8262. dac.DiId,
  8263. CurrencyCode = sd.Name,
  8264. dac.Cost
  8265. })
  8266. .ToList();
  8267. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8268. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8269. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8270. .Select((dop, sd) => new {
  8271. dop.Id,
  8272. dop.Diid,
  8273. CurrencyCode = sd.Name,
  8274. dop.Cost
  8275. })
  8276. .ToList();
  8277. if (dayCosts.Count > 0)
  8278. {
  8279. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8280. foreach (var dc in new_dayCosts)
  8281. {
  8282. var thisCurrency = dc.Key.ToUpper();
  8283. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8284. if (thisRate == 0.00M) continue;
  8285. foreach (var dcSub in dc)
  8286. {
  8287. opDayCosts.Add(new Grp_DayAndCost() {
  8288. Id = dcSub.Id,
  8289. DiId = dcSub.DiId,
  8290. Cost = dcSub.Cost,
  8291. SubTotal = dcSub.Cost * thisRate,
  8292. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8293. });
  8294. }
  8295. }
  8296. if (opDayCosts.Count > 0)
  8297. {
  8298. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8299. }
  8300. }
  8301. if (dayOtherCosts.Count > 0)
  8302. {
  8303. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8304. foreach (var dc in new_dayOtherCosts)
  8305. {
  8306. var thisCurrency = dc.Key.ToUpper();
  8307. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8308. if (thisRate == 0.00M) continue;
  8309. foreach (var dcSub in dc)
  8310. {
  8311. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8312. {
  8313. Id = dcSub.Id,
  8314. Diid = dcSub.Diid,
  8315. Cost = dcSub.Cost,
  8316. SubTotal = dcSub.Cost * thisRate,
  8317. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8318. });
  8319. }
  8320. }
  8321. if (opDayOtherCosts.Count > 0)
  8322. {
  8323. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8324. }
  8325. }
  8326. #endregion
  8327. //消息通知
  8328. await EnterExitCostMobileOpNotice(dto.DiId, id,dto.CurrUserId);
  8329. //汇率信息记录
  8330. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8331. return Ok(JsonView(new { parentId = id }));
  8332. }
  8333. /// <summary>
  8334. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8335. /// </summary>
  8336. /// <returns></returns>
  8337. [HttpPost]
  8338. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8339. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8340. {
  8341. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8342. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8343. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8344. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8345. int id = dto.Id;
  8346. if (id <= 0) //add
  8347. {
  8348. checkboxInfo.CreateUserId = dto.CurrUserId;
  8349. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8350. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8351. if (add < 1) return Ok(JsonView(false));
  8352. }
  8353. else //update
  8354. {
  8355. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8356. .UpdateColumns(x => new {
  8357. x.ChoiceOne,
  8358. x.ChoiceTwo,
  8359. x.SumJJC,
  8360. x.SumGWC,
  8361. x.SumTDC,
  8362. x.ChoiceThree,
  8363. x.ChoiceFour,
  8364. x.ChoiceFive,
  8365. x.ChoiceSix,
  8366. x.OtherExpenses_Checked
  8367. })
  8368. .Where(x => x.Id == id)
  8369. .ExecuteCommandAsync();
  8370. if (upd < 1) return Ok(JsonView(false));
  8371. }
  8372. return Ok(JsonView(new { parentId = id }));
  8373. }
  8374. /// <summary>
  8375. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8376. /// </summary>
  8377. /// <returns></returns>
  8378. [HttpPost]
  8379. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8380. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8381. {
  8382. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId,isSelected = dto.IsSelected;
  8383. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8384. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8385. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8386. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8387. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8388. var checkboxInfo = new Grp_EnterExitCost() {
  8389. Id = id,
  8390. DiId = diId,
  8391. CreateUserId = currUserId
  8392. };
  8393. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8394. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8395. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8396. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8397. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8398. if (id <= 0) //add
  8399. {
  8400. checkboxInfo.CreateUserId = dto.CurrUserId;
  8401. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8402. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8403. if (add < 1) return Ok(JsonView(false));
  8404. }
  8405. else //update
  8406. {
  8407. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8408. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8409. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8410. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8411. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8412. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8413. .Where(x => x.Id == id)
  8414. .ExecuteCommandAsync();
  8415. if (upd < 1) return Ok(JsonView(false));
  8416. }
  8417. return Ok(JsonView(new { parentId = id }));
  8418. }
  8419. /// <summary>
  8420. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8421. /// </summary>
  8422. /// <returns></returns>
  8423. [HttpPost]
  8424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8425. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8426. {
  8427. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8428. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8429. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8430. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8431. info.FirstItemRemark = dto.FirstItemRemark;
  8432. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8433. int id = dto.Id;
  8434. if (id <= 0) //add
  8435. {
  8436. info.CreateUserId = dto.CurrUserId;
  8437. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8438. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8439. if (add < 1) return Ok(JsonView(false));
  8440. id = add;
  8441. }
  8442. else //update
  8443. {
  8444. var upd = await _sqlSugar.Updateable(info)
  8445. .UpdateColumns(x => new {
  8446. x.ChoiceOne,
  8447. x.InsidePay,
  8448. x.VisaRemark,
  8449. x.Visa,
  8450. x.Service,
  8451. x.Safe,
  8452. x.Ticket,
  8453. x.HeSuan,
  8454. x.YiMiao,
  8455. x.FirstItemRemark
  8456. })
  8457. .Where(x => x.Id == id)
  8458. .ExecuteCommandAsync();
  8459. if (upd < 1) return Ok(JsonView(false));
  8460. }
  8461. //消息通知
  8462. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8463. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8464. }
  8465. /// <summary>
  8466. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8467. /// </summary>
  8468. /// <returns></returns>
  8469. [HttpPost]
  8470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8471. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8472. {
  8473. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8474. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8475. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8476. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8477. info.OutsideJJPay = dto.OutsideJJPay;
  8478. info.OutsideGWPay = dto.OutsideGWPay;
  8479. info.OutsideTDPay = dto.OutsideTDPay;
  8480. info.AirJJ = dto.AirJJ;
  8481. info.AirGW = dto.AirGW;
  8482. info.AirTD = dto.AirTD;
  8483. info.CityTranffic = dto.CityTranffic;
  8484. info.TwoItemRemark = dto.TwoItemRemark;
  8485. info.SumJJC = dto.ChoiceTwoJJ;
  8486. info.SumGWC = dto.ChoiceTwoGW;
  8487. info.SumTDC = dto.ChoiceTwoTD;
  8488. int id = dto.Id;
  8489. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8490. if (id <= 0) //add
  8491. {
  8492. info.CreateUserId = dto.CurrUserId;
  8493. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8494. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8495. if (addId <= 0) return Ok(JsonView(false));
  8496. id = addId;
  8497. }
  8498. else //update
  8499. {
  8500. var upd = await _sqlSugar.Updateable(info)
  8501. .UpdateColumns(x => new {
  8502. x.SumJJC,
  8503. x.OutsideJJPay,
  8504. x.SumGWC,
  8505. x.OutsideGWPay,
  8506. x.SumTDC,
  8507. x.OutsideTDPay,
  8508. x.AirJJ,
  8509. x.AirGW,
  8510. x.AirTD,
  8511. x.CityTranffic,
  8512. x.TwoItemRemark
  8513. })
  8514. .Where(x => x.Id == id)
  8515. .ExecuteCommandAsync();
  8516. if (upd <1) return Ok(JsonView(false));
  8517. }
  8518. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8519. gwcItemTotal = info.AirGW + info.CityTranffic;
  8520. tdcItemTotal = info.AirTD + info.CityTranffic;
  8521. //消息通知
  8522. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8523. return Ok(JsonView(new
  8524. {
  8525. parentId = id,
  8526. choiceTwoJJ = dto.ChoiceTwoJJ,
  8527. jjcItemTotal = jjcItemTotal,
  8528. choiceTwoGW = dto.ChoiceTwoGW,
  8529. gwcItemTotal = gwcItemTotal,
  8530. choiceTwoTD = dto.ChoiceTwoTD,
  8531. tdcItemTotal = tdcItemTotal
  8532. }));
  8533. }
  8534. /// <summary>
  8535. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8536. /// </summary>
  8537. /// <returns></returns>
  8538. [HttpPost]
  8539. [ApiExplorerSettings(IgnoreApi = true)]
  8540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8541. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto 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.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8547. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8548. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8549. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8550. var infos = infos1.Select(x => new Grp_DayAndCost
  8551. {
  8552. Id = x.Id,
  8553. DiId = dto.DiId,
  8554. Type = dto.FeeType,
  8555. Days = x.Days,
  8556. NationalTravelFeeId = x.NationalTravelFeeId,
  8557. Cost = x.Cost,
  8558. Currency = x.Currency,
  8559. SubTotal = x.SubTotal,
  8560. CreateUserId = dto.CurrUserId
  8561. })
  8562. .ToList();
  8563. var adds = infos.Where(x => x.Id <= 0).ToList();
  8564. var upds = infos.Where(x => x.Id > 0).ToList();
  8565. if (adds.Count > 0)
  8566. {
  8567. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8568. if (add < 1) return Ok(JsonView(false));
  8569. }
  8570. if (upds.Count > 0)
  8571. {
  8572. var upd = await _sqlSugar.Updateable(adds)
  8573. .UpdateColumns(x => new
  8574. {
  8575. x.Days,
  8576. x.NationalTravelFeeId,
  8577. x.Cost,
  8578. x.Currency,
  8579. x.SubTotal
  8580. })
  8581. .WhereColumns(x => new { x.Id })
  8582. .ExecuteCommandAsync();
  8583. if (upd < 1) return Ok(JsonView(false));
  8584. }
  8585. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8586. //消息通知
  8587. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8588. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8589. return Ok(JsonView(new { itemTotal = itemTotal }));
  8590. }
  8591. /// <summary>
  8592. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8593. /// </summary>
  8594. /// <returns></returns>
  8595. [HttpPost]
  8596. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8597. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8598. {
  8599. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8600. int subId = dto.SubId, feeType = dto.FeeType;
  8601. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8602. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8603. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8604. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8605. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8606. subInfo.Id = subId;
  8607. subInfo.DiId = dto.DiId;
  8608. if (feeType == 3) subInfo.Type = 1;
  8609. else if (feeType == 4) subInfo.Type = 2;
  8610. else if (feeType == 5) subInfo.Type = 3;
  8611. else if (feeType == 6) subInfo.Type = 4;
  8612. subInfo.CreateUserId = dto.CurrUserId;
  8613. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8614. if (parentId < 1) return Ok(JsonView(false));
  8615. //子表op
  8616. if (subId < 1)
  8617. {
  8618. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8619. if (subAdd < 1) return Ok(JsonView(false));
  8620. }
  8621. else
  8622. {
  8623. var subUpd = await _sqlSugar.Updateable(subInfo)
  8624. .UpdateColumns(x => new
  8625. {
  8626. x.Days,
  8627. x.NationalTravelFeeId,
  8628. x.Cost,
  8629. x.Currency,
  8630. x.SubTotal
  8631. })
  8632. .WhereColumns(x => new { x.Id })
  8633. .ExecuteCommandAsync();
  8634. if (subUpd < 1) return Ok(JsonView(false));
  8635. }
  8636. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8637. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8638. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8639. }
  8640. /// <summary>
  8641. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8642. /// </summary>
  8643. /// <returns></returns>
  8644. [HttpPost]
  8645. [ApiExplorerSettings(IgnoreApi = true)]
  8646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8647. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8648. {
  8649. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8650. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8651. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8652. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8653. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8654. {
  8655. Id = x.Id,
  8656. Diid = dto.DiId,
  8657. SetDataId = x.SetDataId,
  8658. Index = x.Index,
  8659. Cost = x.Cost,
  8660. Currency = x.Currency,
  8661. SubTotal = x.SubTotal,
  8662. CreateUserId = dto.CurrUserId,
  8663. Remark = x.Remark
  8664. }).ToList();
  8665. var adds = infos.Where(x => x.Id <= 0).ToList();
  8666. var upds = infos.Where(x => x.Id > 0).ToList();
  8667. if (adds.Count > 0)
  8668. {
  8669. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8670. if (add < 1) return Ok(JsonView(false));
  8671. }
  8672. if (upds.Count > 0)
  8673. {
  8674. var upd = await _sqlSugar.Updateable(adds)
  8675. .UpdateColumns(x => new
  8676. {
  8677. x.Index,
  8678. x.SetDataId,
  8679. x.Cost,
  8680. x.Currency,
  8681. x.SubTotal,
  8682. x.Remark
  8683. })
  8684. .WhereColumns(x => new { x.Id })
  8685. .ExecuteCommandAsync();
  8686. if (upd < 1) return Ok(JsonView(false));
  8687. }
  8688. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8689. //消息通知
  8690. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8691. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8692. return Ok(JsonView(new { itemTotal = itemTotal }));
  8693. }
  8694. /// <summary>
  8695. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8696. /// </summary>
  8697. /// <returns></returns>
  8698. [HttpPost]
  8699. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8700. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8701. {
  8702. int subId = dto.SubId;
  8703. int diId = dto.Diid;
  8704. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8705. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8706. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8707. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8708. subInfo.Id = subId;
  8709. subInfo.Diid = dto.Diid;
  8710. subInfo.CreateUserId = dto.CurrUserId;
  8711. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8712. if (parentId < 1) return Ok(JsonView(false));
  8713. #region 子表op
  8714. if (subId < 1)//add
  8715. {
  8716. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8717. if (subAdd < 1) return Ok(JsonView(false));
  8718. }
  8719. else //upd
  8720. {
  8721. var subUpd = await _sqlSugar.Updateable(subInfo)
  8722. .UpdateColumns(x => new
  8723. {
  8724. x.Index,
  8725. x.SetDataId,
  8726. x.Cost,
  8727. x.Currency,
  8728. x.SubTotal,
  8729. x.Remark
  8730. })
  8731. .WhereColumns(x => new { x.Id })
  8732. .ExecuteCommandAsync();
  8733. if (subUpd < 1) return Ok(JsonView(false));
  8734. }
  8735. #endregion
  8736. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  8737. //消息通知
  8738. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  8739. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8740. }
  8741. /// <summary>
  8742. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  8743. /// </summary>
  8744. /// <returns></returns>
  8745. [HttpPost]
  8746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8747. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  8748. {
  8749. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8750. if (data.Code != 0)
  8751. {
  8752. return Ok(JsonView(false, data.Msg));
  8753. }
  8754. return Ok(JsonView(true, "操作成功!", data.Data));
  8755. }
  8756. /// <summary>
  8757. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  8758. /// </summary>
  8759. /// <param name="dto"></param>
  8760. /// <returns></returns>
  8761. [HttpPost]
  8762. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  8763. {
  8764. var data = new Grp_DayOtherPrice()
  8765. {
  8766. Id = dto.Id,
  8767. IsDel = 1,
  8768. DeleteUserId = dto.DeleteUserId,
  8769. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8770. };
  8771. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8772. if (del > 0) return Ok(JsonView(true,"删除成功!"));
  8773. return Ok(JsonView(false,"删除失败!"));
  8774. }
  8775. #endregion
  8776. #endregion
  8777. #region 签证费用录入
  8778. /// <summary>
  8779. /// 根据diid查询签证费用列表
  8780. /// </summary>
  8781. /// <param name="dto"></param>
  8782. /// <returns></returns>
  8783. [HttpPost]
  8784. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8785. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  8786. {
  8787. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  8788. if (groupData.Code != 0)
  8789. {
  8790. return Ok(JsonView(false, groupData.Msg));
  8791. }
  8792. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8793. }
  8794. /// <summary>
  8795. /// 根据签证费用Id查询单条数据及c表数据
  8796. /// </summary>
  8797. /// <param name="dto"></param>
  8798. /// <returns></returns>
  8799. [HttpPost]
  8800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8801. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  8802. {
  8803. Result groupData = await _visaPriceRep.PostVisaById(dto);
  8804. if (groupData.Code != 0)
  8805. {
  8806. return Ok(JsonView(false, groupData.Msg));
  8807. }
  8808. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8809. }
  8810. /// <summary>
  8811. /// 签证费用删除
  8812. /// </summary>
  8813. /// <param name="dto"></param>
  8814. /// <returns></returns>
  8815. [HttpPost]
  8816. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8817. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  8818. {
  8819. _sqlSugar.BeginTran();
  8820. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  8821. if (!res)
  8822. {
  8823. _sqlSugar.RollbackTran();
  8824. return Ok(JsonView(false, "删除失败"));
  8825. }
  8826. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  8827. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  8828. .SetColumns(a => new Grp_CreditCardPayment()
  8829. {
  8830. IsDel = 1,
  8831. DeleteUserId = dto.DeleteUserId,
  8832. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8833. })
  8834. .ExecuteCommand();
  8835. if (resSub < 1)
  8836. {
  8837. _sqlSugar.RollbackTran();
  8838. return Ok(JsonView(false, "删除失败"));
  8839. }
  8840. _sqlSugar.CommitTran();
  8841. return Ok(JsonView(true, "删除成功!"));
  8842. }
  8843. /// <summary>
  8844. /// 签证费用录入下拉框初始化
  8845. /// </summary>
  8846. /// <returns></returns>
  8847. [HttpPost]
  8848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8849. public async Task<IActionResult> VisaPriceAddSelect()
  8850. {
  8851. //支付方式
  8852. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  8853. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  8854. //币种
  8855. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  8856. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  8857. //乘客类型
  8858. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  8859. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  8860. //卡类型
  8861. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  8862. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  8863. //代办费类型
  8864. var agencyFeeTypeData = new List<dynamic>() {
  8865. new { id = 0 , Text = "未选择" },
  8866. new { id = 1 , Text = "小公务" },
  8867. new { id = 2 , Text = "大公务" },
  8868. };
  8869. //签证费用标准国家Data
  8870. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  8871. var data = new
  8872. {
  8873. Payment = _Payment,
  8874. CurrencyList = _CurrencyList,
  8875. PassengerType = _PassengerType,
  8876. BankCard = _BankCard,
  8877. AgencyFeeType = agencyFeeTypeData,
  8878. CountryFeeData = visaCountryFeeData
  8879. };
  8880. return Ok(JsonView(true, "查询成功!", data));
  8881. }
  8882. /// <summary>
  8883. /// 签证费用录入操作(Status:1.新增,2.修改)
  8884. /// </summary>
  8885. /// <param name="dto"></param>
  8886. /// <returns></returns>
  8887. [HttpPost]
  8888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8889. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  8890. {
  8891. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  8892. if (groupData.Code != 0)
  8893. {
  8894. return Ok(JsonView(false, groupData.Msg));
  8895. }
  8896. #region 应用推送
  8897. try
  8898. {
  8899. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  8900. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  8901. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8902. //2024-10-21 新增LZ UID
  8903. var userIds = new List<int>() { 21 };
  8904. string title = $"系统通知";
  8905. string content = "";
  8906. var diId = dto.DiId;
  8907. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  8908. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  8909. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  8910. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  8911. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  8912. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  8913. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  8914. }
  8915. catch (Exception ex)
  8916. {
  8917. }
  8918. #endregion
  8919. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8920. }
  8921. #endregion
  8922. #region 签证提成录入
  8923. /// <summary>
  8924. /// 签证提成录入
  8925. /// 基础数据
  8926. /// </summary>
  8927. /// <param name="_dto"></param>
  8928. /// <returns></returns>
  8929. [HttpGet]
  8930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8931. public async Task<IActionResult> VisaCommissionInit()
  8932. {
  8933. return Ok(await _visaCommissionRep.Init());
  8934. }
  8935. /// <summary>
  8936. /// 签证提成录入
  8937. /// Item
  8938. /// </summary>
  8939. /// <param name="_dto"></param>
  8940. /// <returns></returns>
  8941. [HttpPost]
  8942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8943. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  8944. {
  8945. var validator = new VisaCommissionItemDtoValidator();
  8946. var validatorRes = await validator.ValidateAsync(_dto);
  8947. if (!validatorRes.IsValid)
  8948. {
  8949. StringBuilder sb = new StringBuilder();
  8950. foreach (var item in validatorRes.Errors)
  8951. {
  8952. sb.AppendLine(item.ErrorMessage);
  8953. }
  8954. return Ok(JsonView(false, sb.ToString()));
  8955. }
  8956. return Ok(await _visaCommissionRep.Item(_dto));
  8957. }
  8958. /// <summary>
  8959. /// 签证提成录入
  8960. /// Save
  8961. /// </summary>
  8962. /// <param name="_dto"></param>
  8963. /// <returns></returns>
  8964. [HttpPost]
  8965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8966. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  8967. {
  8968. //参数验证
  8969. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  8970. foreach (var item in _dto.Items)
  8971. {
  8972. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  8973. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  8974. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  8975. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  8976. }
  8977. return Ok(await _visaCommissionRep.Save(_dto));
  8978. }
  8979. /// <summary>
  8980. /// 签证提成录入
  8981. /// Create
  8982. /// </summary>
  8983. /// <param name="_dto"></param>
  8984. /// <returns></returns>
  8985. [HttpPost]
  8986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8987. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  8988. {
  8989. var validator = new VisaCommissionCreateDtoValidator();
  8990. var validatorRes = await validator.ValidateAsync(_dto);
  8991. if (!validatorRes.IsValid)
  8992. {
  8993. StringBuilder sb = new StringBuilder();
  8994. foreach (var item in validatorRes.Errors)
  8995. {
  8996. sb.AppendLine(item.ErrorMessage);
  8997. }
  8998. return Ok(JsonView(false, sb.ToString()));
  8999. }
  9000. return Ok(await _visaCommissionRep.Create(_dto));
  9001. }
  9002. /// <summary>
  9003. /// 签证提成录入
  9004. /// Put(编辑)
  9005. /// </summary>
  9006. /// <param name="id"></param>
  9007. /// <param name="_dto"></param>
  9008. /// <returns></returns>
  9009. [HttpPut]
  9010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9011. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  9012. {
  9013. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  9014. var validator = new VisaCommissionCreateDtoValidator();
  9015. var validatorRes = await validator.ValidateAsync(_dto);
  9016. if (!validatorRes.IsValid)
  9017. {
  9018. StringBuilder sb = new StringBuilder();
  9019. foreach (var item in validatorRes.Errors)
  9020. {
  9021. sb.AppendLine(item.ErrorMessage);
  9022. }
  9023. return Ok(JsonView(false, sb.ToString()));
  9024. }
  9025. return Ok(await _visaCommissionRep.Edit(id, _dto));
  9026. }
  9027. /// <summary>
  9028. /// 签证提成录入
  9029. /// Del
  9030. /// </summary>
  9031. /// <param name="id"></param>
  9032. /// <param name="currUserId"></param>
  9033. /// <returns></returns>
  9034. [HttpPost]
  9035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9036. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  9037. {
  9038. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  9039. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  9040. return Ok(await _visaCommissionRep.Del(id, currUserId));
  9041. }
  9042. #endregion
  9043. #region op费用录入
  9044. /// <summary>
  9045. /// 根据diid查询op费用列表
  9046. /// </summary>
  9047. /// <param name="dto"></param>
  9048. /// <returns></returns>
  9049. [HttpPost]
  9050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9051. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  9052. {
  9053. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  9054. if (groupData.Code != 0)
  9055. {
  9056. return Ok(JsonView(false, groupData.Msg));
  9057. }
  9058. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9059. }
  9060. /// <summary>
  9061. /// 根据op费用Id查询单条数据及c表数据
  9062. /// </summary>
  9063. /// <param name="dto"></param>
  9064. /// <returns></returns>
  9065. [HttpPost]
  9066. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9067. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  9068. {
  9069. try
  9070. {
  9071. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  9072. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  9073. var data = new
  9074. {
  9075. CarTouristGuideGround = _groupData,
  9076. CreditCardPayment = _creditCardPayment
  9077. };
  9078. return Ok(JsonView(true, "查询成功!", data));
  9079. }
  9080. catch (Exception ex)
  9081. {
  9082. return Ok(JsonView(false, "程序错误!"));
  9083. }
  9084. }
  9085. /// <summary>
  9086. /// op费用删除
  9087. /// </summary>
  9088. /// <param name="dto"></param>
  9089. /// <returns></returns>
  9090. [HttpPost]
  9091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9092. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  9093. {
  9094. try
  9095. {
  9096. _sqlSugar.BeginTran();
  9097. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  9098. if (!res)
  9099. {
  9100. return Ok(JsonView(false, "删除失败"));
  9101. }
  9102. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  9103. {
  9104. IsDel = 1,
  9105. DeleteUserId = dto.DeleteUserId,
  9106. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9107. }).ExecuteCommandAsync();
  9108. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  9109. {
  9110. IsDel = 1,
  9111. DeleteUserId = dto.DeleteUserId,
  9112. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9113. }).ExecuteCommandAsync();
  9114. #region 删除超支相关数据
  9115. //删除导入的超支数据
  9116. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  9117. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  9118. {
  9119. IsDel = 1,
  9120. DeleteUserId = dto.DeleteUserId,
  9121. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9122. }).ExecuteCommand();
  9123. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  9124. {
  9125. IsDel = 1,
  9126. DeleteUserId = dto.DeleteUserId,
  9127. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9128. }).ExecuteCommand();
  9129. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  9130. {
  9131. IsDel = 1,
  9132. DeleteUserId = dto.DeleteUserId,
  9133. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9134. }).ExecuteCommand();
  9135. #endregion
  9136. _sqlSugar.CommitTran();
  9137. return Ok(JsonView(true, "删除成功!"));
  9138. }
  9139. catch (Exception ex)
  9140. {
  9141. _sqlSugar.RollbackTran();
  9142. return Ok(JsonView(false, "程序错误!" + ex.Message));
  9143. }
  9144. }
  9145. /// <summary>
  9146. /// op费用录入操作(Status:1.新增,2.修改)
  9147. /// </summary>
  9148. /// <param name="dto"></param>
  9149. /// <returns></returns>
  9150. [HttpPost]
  9151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9152. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  9153. {
  9154. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  9155. if (groupData.Code != 0)
  9156. {
  9157. return Ok(JsonView(false, groupData.Msg));
  9158. }
  9159. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9160. }
  9161. /// <summary>
  9162. /// 填写费用详细页面初始化绑定
  9163. /// </summary>
  9164. /// <param name="dto"></param>
  9165. /// <returns></returns>
  9166. [HttpPost]
  9167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9168. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  9169. {
  9170. try
  9171. {
  9172. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  9173. if (groupData.Code != 0)
  9174. {
  9175. return Ok(JsonView(false, groupData.Msg));
  9176. }
  9177. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9178. }
  9179. catch (Exception ex)
  9180. {
  9181. return Ok(JsonView(false, ex.Message));
  9182. }
  9183. }
  9184. /// <summary>
  9185. /// 根据op费用Id查询详细数据
  9186. /// </summary>
  9187. /// <param name="dto"></param>
  9188. /// <returns></returns>
  9189. [HttpPost]
  9190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9191. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  9192. {
  9193. try
  9194. {
  9195. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  9196. if (groupData.Code != 0)
  9197. {
  9198. return Ok(JsonView(false, groupData.Msg));
  9199. }
  9200. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9201. }
  9202. catch (Exception ex)
  9203. {
  9204. return Ok(JsonView(false, ex.Message));
  9205. }
  9206. }
  9207. /// <summary>
  9208. /// OP费用录入填写详情
  9209. /// </summary>
  9210. /// <param name="dto"></param>
  9211. /// <returns></returns>
  9212. [HttpPost]
  9213. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9214. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  9215. {
  9216. try
  9217. {
  9218. #region 参数校验
  9219. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  9220. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  9221. if (di == null) return Ok(JsonView(false, "团组错误!"));
  9222. #endregion
  9223. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  9224. if (groupData.Code != 0)
  9225. {
  9226. return Ok(JsonView(false, groupData.Msg));
  9227. }
  9228. //自动审核
  9229. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  9230. #region 应用推送
  9231. try
  9232. {
  9233. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9234. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9235. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9236. //2024-10-21 新增LZ UID
  9237. var userIds = new List<int>() { 21 };
  9238. string title = $"系统通知";
  9239. var diId = dto.DiId;
  9240. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  9241. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  9242. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  9243. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  9244. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  9245. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  9246. }
  9247. catch (Exception ex)
  9248. {
  9249. }
  9250. #endregion
  9251. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9252. }
  9253. catch (Exception ex)
  9254. {
  9255. return Ok(JsonView(false, ex.Message));
  9256. }
  9257. }
  9258. /// <summary>
  9259. /// 获取三公详细所有城市
  9260. /// </summary>
  9261. /// <returns></returns>
  9262. [HttpGet]
  9263. public IActionResult OpCarCityResult()
  9264. {
  9265. var jw = JsonView(false);
  9266. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  9267. {
  9268. x.Id,
  9269. x.Country,
  9270. x.City,
  9271. }).ToList();
  9272. if (data.Count > 0)
  9273. {
  9274. jw = JsonView(true, "获取成功!", data);
  9275. }
  9276. else
  9277. {
  9278. jw.Msg = "城市数据为空!";
  9279. jw.Data = new string[0];
  9280. }
  9281. return Ok(jw);
  9282. }
  9283. /// <summary>
  9284. /// 导出地接费用明细
  9285. /// </summary>
  9286. /// <param name="dto"></param>
  9287. /// <returns></returns>
  9288. [HttpPost]
  9289. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  9290. {
  9291. var jw = JsonView(false);
  9292. if (dto.Diid < 1)
  9293. {
  9294. jw.Msg = "请输入正确的diid!";
  9295. return Ok(jw);
  9296. }
  9297. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  9298. if (group == null)
  9299. {
  9300. jw.Msg = "未找到团组信息!";
  9301. return Ok(jw);
  9302. }
  9303. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  9304. if (localGuideArr.Count == 0)
  9305. {
  9306. jw.Msg = "该团组暂无地接信息!";
  9307. return Ok(jw);
  9308. }
  9309. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  9310. var overspendSoure = new Dictionary<int, int>
  9311. {
  9312. { 91, 982 }, //车
  9313. { 92 , 1059} ,//导游
  9314. { 994 , 1073}, //翻译
  9315. { 988 , 1074 }, //早餐
  9316. { 93 , 1075 }, //午餐
  9317. { 989 , 1076 }, //晚餐
  9318. };
  9319. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  9320. foreach (var groupArr in localGroup)
  9321. {
  9322. var keyValue = groupArr.Key;
  9323. if (int.TryParse(keyValue, out int cityid))
  9324. {
  9325. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  9326. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  9327. }
  9328. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  9329. foreach (var item in groupArr)
  9330. {
  9331. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  9332. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  9333. new Grp_CarTouristGuideGroundReservationsContentExtend
  9334. {
  9335. Count = a.Count,
  9336. CreateTime = a.CreateTime,
  9337. CreateUserId = a.CreateUserId,
  9338. CTGGRId = a.CTGGRId,
  9339. Currency = a.Currency,
  9340. DatePrice = a.DatePrice,
  9341. DeleteTime = a.DeleteTime,
  9342. DeleteUserId = a.DeleteUserId,
  9343. DiId = a.DiId,
  9344. Id = a.Id,
  9345. IsDel = a.IsDel,
  9346. Price = a.Price,
  9347. PriceContent = a.PriceContent,
  9348. Remark = a.Remark,
  9349. SId = a.SId,
  9350. SidName = b.Name,
  9351. Units = a.Units,
  9352. }
  9353. ).ToList();
  9354. if (content.Count > 0)
  9355. {
  9356. contentArr.Add(content);
  9357. }
  9358. }
  9359. //open excel
  9360. //set excel
  9361. //save excel
  9362. try
  9363. {
  9364. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  9365. IWorkbook workbook;
  9366. if (Path.GetExtension(filePath).ToLower() == ".xls")
  9367. {
  9368. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  9369. }
  9370. else
  9371. {
  9372. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  9373. }
  9374. ISheet sheet = workbook.GetSheetAt(0);
  9375. var rowStartIndex = 2;
  9376. var clounmCount = 10;
  9377. var initStyleRow = sheet.GetRow(2);
  9378. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  9379. //var overspendArrDetail =
  9380. var existsId = new List<CarCompare>();
  9381. var lastElem = arr.Last();
  9382. var thisSid = -1;
  9383. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  9384. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  9385. {
  9386. Name = "未知币种!",
  9387. Remark = "未知币种!",
  9388. };
  9389. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  9390. Action cloneRowFn = () =>
  9391. {
  9392. rowStartIndex++;
  9393. var cloneRow = sheet.CreateRow(rowStartIndex);
  9394. // 复制样式
  9395. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  9396. {
  9397. ICell sourceCell = initStyleRow.GetCell(i);
  9398. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  9399. // 确保单元格存在样式
  9400. if (sourceCell.CellStyle != null)
  9401. {
  9402. targetCell.CellStyle = sourceCell.CellStyle;
  9403. }
  9404. }
  9405. };
  9406. var mergeRow = () =>
  9407. {
  9408. for (int i = 2; i < sheet.LastRowNum; i++)
  9409. {
  9410. var row = sheet.GetRow(i);
  9411. var cellFirst = row.GetCell(0);
  9412. var thisIndex = i + 1;
  9413. while (thisIndex < sheet.LastRowNum)
  9414. {
  9415. var nextRow = sheet.GetRow(thisIndex);
  9416. var nextCellFirst = nextRow.GetCell(0);
  9417. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  9418. {
  9419. thisIndex++;
  9420. }
  9421. else
  9422. {
  9423. break;
  9424. }
  9425. }
  9426. thisIndex--;
  9427. if (thisIndex != i)
  9428. {
  9429. //合并row
  9430. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  9431. i, // 起始行索引(0-based)
  9432. thisIndex, // 结束行索引(0-based)
  9433. 0, // 起始列索引(0-based)
  9434. 0 // 结束列索引(0-based)
  9435. );
  9436. sheet.AddMergedRegion(cellRangeAddress);
  9437. i = thisIndex;
  9438. }
  9439. }
  9440. };
  9441. var chaoshiNumber = 0;
  9442. var totalNumber = 0.00M;
  9443. string lastStr = "";
  9444. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  9445. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  9446. {
  9447. b.IsAuditGM,
  9448. x.Id,
  9449. x.Area,
  9450. b.PayPercentage,
  9451. b.PayMoney,
  9452. }).ToList();
  9453. string yesPayment = "", noPayment = "";
  9454. foreach (var item in queryCarArrByCityAndDiid)
  9455. {
  9456. if (item.IsAuditGM == 1)
  9457. {
  9458. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  9459. }
  9460. else
  9461. {
  9462. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  9463. }
  9464. }
  9465. lastStr = yesPayment + noPayment;
  9466. foreach (var item in arr)
  9467. {
  9468. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  9469. {
  9470. if (thisSid != item.SId)
  9471. {
  9472. if (thisSid == -1)
  9473. {
  9474. thisSid = item.SId;
  9475. }
  9476. else
  9477. {
  9478. //合并小计行
  9479. //创建合并区域的实例
  9480. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  9481. rowStartIndex, // 起始行索引(0-based)
  9482. rowStartIndex, // 结束行索引(0-based)
  9483. 0, // 起始列索引(0-based)
  9484. 3 // 结束列索引(0-based)
  9485. );
  9486. sheet.AddMergedRegion(cellRangeAddress);
  9487. var CellStyle = workbook.CreateCellStyle();
  9488. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9489. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  9490. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  9491. for (int i = 0; i <= clounmCount; i++)
  9492. {
  9493. if (i > 6)
  9494. {
  9495. var CellStyle1 = workbook.CreateCellStyle();
  9496. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9497. IFont Font = workbook.CreateFont(); // 创建字体
  9498. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  9499. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  9500. CellStyle1.SetFont(Font);
  9501. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  9502. }
  9503. else
  9504. {
  9505. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  9506. }
  9507. }
  9508. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  9509. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  9510. //超时合计
  9511. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  9512. //超时数
  9513. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  9514. //超时合计费用
  9515. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  9516. thisSid = item.SId;
  9517. cloneRowFn();
  9518. chaoshiNumber = 0;
  9519. totalNumber = 0;
  9520. }
  9521. }
  9522. IRow row = sheet.GetRow(rowStartIndex);
  9523. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  9524. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  9525. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  9526. if (isOpenOverspendSoure)
  9527. {
  9528. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  9529. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  9530. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  9531. }
  9532. for (int i = 0; i <= clounmCount; i++)
  9533. {
  9534. var cell = row.GetCell(i);
  9535. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  9536. if (cell == null)
  9537. {
  9538. cell = row.CreateCell(i);
  9539. }
  9540. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  9541. fontRed.CloneStyleFrom(cell.CellStyle);
  9542. IFont Font = workbook.CreateFont(); // 创建字体
  9543. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  9544. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  9545. fontRed.SetFont(Font);
  9546. byte[] rgb = new byte[3] { 255, 242, 204 };
  9547. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  9548. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  9549. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  9550. if (workbook is XSSFWorkbook)
  9551. {
  9552. BackgroundColor255_242_204.FillForegroundColor = 0;
  9553. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  9554. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  9555. }
  9556. else
  9557. {
  9558. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  9559. }
  9560. if (i == 1 || i > 6)
  9561. {
  9562. if (i > 6)
  9563. {
  9564. fontRed.FillForegroundColor = 0;
  9565. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  9566. fontRed.FillPattern = FillPattern.SolidForeground;
  9567. }
  9568. cell.CellStyle = fontRed;
  9569. }
  9570. if (i > 2 && i < 7)
  9571. {
  9572. cell.CellStyle = BackgroundColor255_242_204;
  9573. }
  9574. cell.SetCellValue(setCellValue); //写入单元格
  9575. }
  9576. if (overspendSoure.ContainsKey(thisSid))
  9577. {
  9578. var overspendId = overspendSoure[thisSid];
  9579. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  9580. }
  9581. cloneRowFn();
  9582. existsId.Add(new CarCompare
  9583. {
  9584. DataPrice = item.DatePrice.ObjToDate(),
  9585. Sid = item.SId
  9586. });
  9587. }
  9588. if (item.Equals(lastElem))
  9589. {
  9590. //合并小计行
  9591. //创建合并区域的实例
  9592. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  9593. rowStartIndex, // 起始行索引(0-based)
  9594. rowStartIndex, // 结束行索引(0-based)
  9595. 0, // 起始列索引(0-based)
  9596. 3 // 结束列索引(0-based)
  9597. );
  9598. sheet.AddMergedRegion(cellRangeAddress);
  9599. var CellStyle = workbook.CreateCellStyle();
  9600. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9601. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  9602. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  9603. for (int i = 0; i <= clounmCount; i++)
  9604. {
  9605. if (i > 6)
  9606. {
  9607. var CellStyle1 = workbook.CreateCellStyle();
  9608. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9609. IFont Font = workbook.CreateFont(); // 创建字体
  9610. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  9611. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  9612. CellStyle1.SetFont(Font);
  9613. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  9614. }
  9615. else
  9616. {
  9617. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  9618. }
  9619. }
  9620. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  9621. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  9622. //超时合计
  9623. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  9624. //超时数
  9625. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  9626. //超时合计费用
  9627. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  9628. cloneRowFn();
  9629. // 创建合并区域的实例
  9630. cellRangeAddress = new CellRangeAddress(
  9631. rowStartIndex, // 起始行索引(0-based)
  9632. rowStartIndex, // 结束行索引(0-based)
  9633. 0, // 起始列索引(0-based)
  9634. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  9635. );
  9636. // 添加合并区域
  9637. sheet.AddMergedRegion(cellRangeAddress);
  9638. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  9639. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  9640. }
  9641. }
  9642. mergeRow();
  9643. // 保存修改后的Excel文件到新文件
  9644. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  9645. // new FileStream(newFilePath, FileMode.CreateNew)
  9646. using (var stream = new MemoryStream())
  9647. {
  9648. workbook.Write(stream, true);
  9649. stream.Flush();
  9650. stream.Seek(0, SeekOrigin.Begin);
  9651. MemoryStream memoryStream = new MemoryStream();
  9652. stream.CopyTo(memoryStream);
  9653. memoryStream.Seek(0, SeekOrigin.Begin);
  9654. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  9655. }
  9656. workbook.Close();
  9657. workbook.Dispose();
  9658. }
  9659. catch (Exception ex)
  9660. {
  9661. jw.Msg = "出现异常!" + ex.Message;
  9662. return Ok(jw);
  9663. }
  9664. }
  9665. if (Zips.Count > 0)
  9666. {
  9667. IOOperatorHelper io = new IOOperatorHelper();
  9668. var byts = io.ConvertZipStream(Zips);
  9669. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  9670. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  9671. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  9672. }
  9673. else
  9674. {
  9675. jw.Msg = "暂无生成文件!";
  9676. }
  9677. return Ok(jw);
  9678. }
  9679. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  9680. {
  9681. string outStr = string.Empty;
  9682. switch (i)
  9683. {
  9684. case 0:
  9685. outStr = arr[0].SidName;
  9686. break;
  9687. case 1:
  9688. outStr = arr[0].DataPriceStr;
  9689. break;
  9690. case 2:
  9691. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  9692. break;
  9693. case 4:
  9694. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  9695. break;
  9696. case 7:
  9697. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9698. {
  9699. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  9700. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  9701. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  9702. }
  9703. break;
  9704. case 8:
  9705. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9706. {
  9707. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  9708. }
  9709. break;
  9710. case 9:
  9711. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9712. {
  9713. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  9714. }
  9715. break;
  9716. case 10:
  9717. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9718. {
  9719. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  9720. }
  9721. break;
  9722. }
  9723. return outStr;
  9724. }
  9725. #region OP行程单
  9726. /// <summary>
  9727. /// OP行程单初始化
  9728. /// </summary>
  9729. /// <param name="dto"></param>
  9730. /// <returns></returns>
  9731. [HttpPost]
  9732. public IActionResult InitOpTravel(InitOpTravelDto dto)
  9733. {
  9734. var jw = JsonView(false);
  9735. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  9736. var group = groupList.First();
  9737. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  9738. if (group == null)
  9739. {
  9740. jw.Msg = "暂无团组!";
  9741. return Ok(jw);
  9742. }
  9743. group = groupList.Find(x => x.Id == diid);
  9744. if (group == null)
  9745. {
  9746. jw.Msg = "请输入正确的团组ID!";
  9747. return Ok(jw);
  9748. }
  9749. string city = string.Empty;
  9750. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  9751. if (blackCode.Count > 0)
  9752. {
  9753. var black = blackCode.First();
  9754. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  9755. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  9756. if (blackSp.Length > 0)
  9757. {
  9758. try
  9759. {
  9760. var cityArrCode = new List<string>(20);
  9761. foreach (var item in blackSp)
  9762. {
  9763. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  9764. var IndexSelect = itemSp[2];
  9765. var cityArrCodeLength = cityArrCode.Count - 1;
  9766. var startCity = IndexSelect.Substring(0, 3);
  9767. if (cityArrCodeLength > 0)
  9768. {
  9769. var arrEndCity = cityArrCode[cityArrCodeLength];
  9770. if (arrEndCity != startCity)
  9771. {
  9772. cityArrCode.Add(startCity.ToUpper());
  9773. }
  9774. }
  9775. else
  9776. {
  9777. cityArrCode.Add(startCity.ToUpper());
  9778. }
  9779. var endCity = IndexSelect.Substring(3, 3);
  9780. cityArrCode.Add(endCity.ToUpper());
  9781. }
  9782. var cityThree = string.Empty;
  9783. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  9784. cityThree = cityThree.TrimEnd(',');
  9785. if (string.IsNullOrWhiteSpace(cityThree))
  9786. {
  9787. throw new
  9788. Exception("error");
  9789. }
  9790. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  9791. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  9792. foreach (var item in cityArrCode)
  9793. {
  9794. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  9795. if (find != null)
  9796. {
  9797. city += find.City + "/";
  9798. }
  9799. else
  9800. {
  9801. city += item + "三字码未收入/";
  9802. }
  9803. }
  9804. city = city.TrimEnd('/');
  9805. }
  9806. catch (Exception e)
  9807. {
  9808. city = "黑屏代码格式不正确!";
  9809. }
  9810. }
  9811. }
  9812. else
  9813. {
  9814. city = "未录入黑屏代码";
  9815. }
  9816. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  9817. {
  9818. Date = x.Date,
  9819. Days = x.Days,
  9820. Diffgroup = x.Diffgroup,
  9821. Diid = x.Diid,
  9822. Traffic_First = x.Traffic_First,
  9823. Traffic_Second = x.Traffic_Second,
  9824. Trip = x.Trip,
  9825. WeekDay = x.WeekDay,
  9826. Id = x.Id
  9827. }).ToList();
  9828. jw.Data = new
  9829. {
  9830. groupList = groupList.Select(x => new
  9831. {
  9832. x.Id,
  9833. x.TeamName,
  9834. x.TourCode
  9835. }).ToList(),
  9836. groupInfo = new
  9837. {
  9838. group.VisitDays,
  9839. group.TourCode,
  9840. group.VisitPNumber,
  9841. group.TeamName,
  9842. city
  9843. },
  9844. OpTravelList
  9845. };
  9846. jw.Code = 200;
  9847. jw.Msg = "操作成功!";
  9848. return Ok(jw);
  9849. }
  9850. /// <summary>
  9851. /// 删除团组行程单
  9852. /// </summary>
  9853. /// <returns></returns>
  9854. [HttpPost]
  9855. public IActionResult DelTravel(DelOpTravelDto dto)
  9856. {
  9857. var jw = JsonView(false);
  9858. if (dto.UserId <= 0 || dto.Diid <= 0)
  9859. {
  9860. jw.Msg = "请输入正确的参数!";
  9861. return Ok(jw);
  9862. }
  9863. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  9864. .SetColumns(x => new Grp_TravelList
  9865. {
  9866. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  9867. DeleteUserId = dto.UserId,
  9868. IsDel = 1,
  9869. }).ExecuteCommand();
  9870. jw = JsonView(true);
  9871. return Ok(jw);
  9872. }
  9873. /// <summary>
  9874. /// 行程单保存
  9875. /// </summary>
  9876. /// <returns></returns>
  9877. [HttpPost]
  9878. public IActionResult TravelSave(TravelSaveDto dto)
  9879. {
  9880. var jw = JsonView(false);
  9881. if (dto.Arr.Count > 0)
  9882. {
  9883. try
  9884. {
  9885. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  9886. .Where(x => dto.Arr.Select(x=>x.Id).Contains(x.Id))
  9887. .ToList();
  9888. _sqlSugar.BeginTran();
  9889. foreach (var item in dto.Arr)
  9890. {
  9891. if (item.Id == 0)
  9892. {
  9893. throw new Exception("请传入正确的Id");
  9894. }
  9895. //比较上一次的差异
  9896. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  9897. if (findTravel != null)
  9898. {
  9899. item.Trip = item.Trip.Replace("[++]", string.Empty);
  9900. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  9901. item.Trip = CheckStr(findTravel.Trip,item.Trip);
  9902. }
  9903. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  9904. .SetColumns(x => new Grp_TravelList
  9905. {
  9906. Trip = item.Trip
  9907. }).ExecuteCommand();
  9908. }
  9909. _sqlSugar.CommitTran();
  9910. jw = JsonView(true);
  9911. }
  9912. catch (Exception ex)
  9913. {
  9914. _sqlSugar.RollbackTran();
  9915. jw.Msg = "程序异常!" + ex.Message;
  9916. }
  9917. }
  9918. else
  9919. {
  9920. jw.Msg = "请传入正确的参数!";
  9921. }
  9922. return Ok(jw);
  9923. }
  9924. private string CheckStr(string original, string changed)
  9925. {
  9926. // 创建diff_match_patch对象
  9927. var dmp = new diff_match_patch();
  9928. // 计算差异
  9929. List<Diff> diffs = dmp.diff_main(original, changed);
  9930. // 清理和合并差异
  9931. dmp.diff_cleanupSemantic(diffs);
  9932. // 使用StringBuilder构建最终的字符串
  9933. StringBuilder finalString = new StringBuilder();
  9934. // 输出差异结果,并构建变动后的字符串
  9935. foreach (Diff diff in diffs)
  9936. {
  9937. switch (diff.operation)
  9938. {
  9939. case Operation.EQUAL:
  9940. // 相等的部分,直接添加到最终字符串
  9941. finalString.Append(diff.text);
  9942. break;
  9943. case Operation.INSERT:
  9944. // 插入的部分,添加标记并添加到最终字符串
  9945. finalString.Append("[++]" + diff.text + "[++]");
  9946. break;
  9947. case Operation.DELETE:
  9948. // 删除的部分,不添加到最终字符串
  9949. //finalString.Append("[++]" + diff.text + "[++]");
  9950. break;
  9951. }
  9952. }
  9953. // 输出变动后的字符串
  9954. return finalString.ToString();
  9955. }
  9956. public class tagContent
  9957. {
  9958. public DateTime Date { get; set; }
  9959. public string StartTag { get; set; }
  9960. public string EndTag { get; set; }
  9961. public string Content { get; set; }
  9962. public static int tagLength { get { return 3; } }
  9963. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  9964. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  9965. public bool IsFinally { get; set; }
  9966. }
  9967. /// <summary>
  9968. /// 导出行程单
  9969. /// </summary>
  9970. /// <param name="dto"></param>
  9971. /// <returns></returns>
  9972. [HttpPost]
  9973. public IActionResult ExportTravel(ExportTravelDto dto)
  9974. {
  9975. var jw = JsonView(false);
  9976. jw.Data = "";
  9977. int diid = 0;
  9978. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  9979. if (Find == null)
  9980. {
  9981. jw.Msg = "请选择正确的团组!";
  9982. return Ok(jw);
  9983. }
  9984. else
  9985. {
  9986. diid = Find.Id;
  9987. }
  9988. //数据源
  9989. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  9990. DataTable dtBlack = null;
  9991. try
  9992. {
  9993. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  9994. }
  9995. catch (Exception)
  9996. {
  9997. jw.Msg = "机票黑屏代码有误!";
  9998. return Ok(jw);
  9999. }
  10000. string CityStr = string.Empty;
  10001. if (dtBlack.Rows.Count == 0)
  10002. {
  10003. jw.Msg = "机票黑屏代码有误!";
  10004. return Ok(jw);
  10005. }
  10006. else
  10007. {
  10008. foreach (DataRow row in dtBlack.Rows)
  10009. {
  10010. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  10011. {
  10012. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  10013. return Ok(jw);
  10014. }
  10015. }
  10016. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  10017. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  10018. }
  10019. //创建数据源Table
  10020. DataTable dtSource = new DataTable();
  10021. dtSource.Columns.Add("Days", typeof(string));
  10022. dtSource.Columns.Add("Date", typeof(string));
  10023. dtSource.Columns.Add("Week", typeof(string));
  10024. dtSource.Columns.Add("Traffic", typeof(string));
  10025. dtSource.Columns.Add("Trip", typeof(string));
  10026. //获取数据,放到datatable
  10027. foreach (var item in _travelList)
  10028. {
  10029. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty).Replace(tagContent.TagFormat.Item2, string.Empty);
  10030. DataRow dr = dtSource.NewRow();
  10031. dr["Days"] = item.Days;
  10032. dr["Date"] = item.Date;
  10033. dr["Week"] = item.WeekDay;
  10034. dr["Traffic"] = item.Traffic_First
  10035. + "\r\n"
  10036. + item.Traffic_Second;
  10037. dr["Trip"] = item.Trip;
  10038. dtSource.Rows.Add(dr);
  10039. }
  10040. Dictionary<string, string> dic = new Dictionary<string, string>();
  10041. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  10042. dic.Add("City", CityStr);
  10043. dic.Add("Days", Find.VisitDays.ToString());
  10044. dic.Add("DeleCode", Find.TourCode);
  10045. dic.Add("Pnum", Find.VisitPNumber.ToString());
  10046. //模板路径
  10047. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  10048. //载入模板
  10049. Document doc = null;
  10050. DocumentBuilder builder = null;
  10051. try
  10052. {
  10053. //载入模板
  10054. doc = new Document(tempPath);
  10055. builder = new DocumentBuilder(doc);
  10056. }
  10057. catch (Exception)
  10058. {
  10059. jw.Msg = "模板位置不存在!";
  10060. return Ok(jw);
  10061. }
  10062. foreach (var key in dic.Keys)
  10063. {
  10064. Bookmark bookmark = doc.Range.Bookmarks[key];
  10065. if (bookmark != null)
  10066. {
  10067. builder.MoveToBookmark(key);
  10068. builder.Write(dic[key]);
  10069. }
  10070. }
  10071. //获取word里所有表格
  10072. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10073. //获取所填表格的序数
  10074. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10075. try
  10076. {
  10077. //循环赋值
  10078. for (int i = 0; i < dtSource.Rows.Count; i++)
  10079. {
  10080. builder.MoveToCell(0, i + 1, 0, 0);
  10081. builder.Write(dtSource.Rows[i]["Days"].ToString());
  10082. builder.MoveToCell(0, i + 1, 1, 0);
  10083. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  10084. builder.MoveToCell(0, i + 1, 2, 0);
  10085. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  10086. var trip = dtSource.Rows[i]["Trip"].ToString();
  10087. builder.MoveToCell(0, i + 1, 3, 0);
  10088. builder.Write(trip);
  10089. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  10090. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  10091. // 获取特定索引的段落
  10092. Paragraph paragraph = (Paragraph)paragraphs[0];
  10093. Run run = paragraph.Runs[0];
  10094. Aspose.Words.Font font = run.Font;
  10095. font.Name = "黑体";
  10096. //设置双休红色
  10097. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  10098. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  10099. paragraph = (Paragraph)paragraphs[1];
  10100. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  10101. {
  10102. run = paragraph.Runs[0];
  10103. font = run.Font;
  10104. font.Color = Color.Red;
  10105. }
  10106. }
  10107. }
  10108. catch (Exception ex)
  10109. {
  10110. }
  10111. //删除多余行
  10112. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  10113. {
  10114. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  10115. }
  10116. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  10117. if (!Directory.Exists(savePath))
  10118. {
  10119. try
  10120. {
  10121. Directory.CreateDirectory(savePath);
  10122. }
  10123. catch
  10124. {
  10125. }
  10126. }
  10127. string path = savePath + Find.TeamName + "出访日程";
  10128. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  10129. try
  10130. {
  10131. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  10132. string postfix = ".docx";
  10133. if (dto.IsPDF == 1)
  10134. {
  10135. saveFormat = Aspose.Words.SaveFormat.Pdf;
  10136. postfix = ".pdf";
  10137. }
  10138. doc.Save(path + postfix, saveFormat);
  10139. jw = JsonView(true, "导出成功", ftpPath + postfix);
  10140. }
  10141. catch (Exception)
  10142. {
  10143. jw = JsonView(false);
  10144. }
  10145. return Ok(jw);
  10146. }
  10147. /// <summary>
  10148. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  10149. /// </summary>
  10150. /// <param name="num"></param>
  10151. /// <returns></returns>
  10152. string GetNum(string num)
  10153. {
  10154. string str = "";
  10155. switch (num)
  10156. {
  10157. case "1":
  10158. str = "一";
  10159. break;
  10160. case "2":
  10161. str = "二";
  10162. break;
  10163. case "3":
  10164. str = "三";
  10165. break;
  10166. case "4":
  10167. str = "四";
  10168. break;
  10169. case "5":
  10170. str = "五";
  10171. break;
  10172. case "6":
  10173. str = "六";
  10174. break;
  10175. case "7":
  10176. str = "七";
  10177. break;
  10178. case "8":
  10179. str = "八";
  10180. break;
  10181. case "9":
  10182. str = "九";
  10183. break;
  10184. case "10":
  10185. str = "十";
  10186. break;
  10187. case "11":
  10188. str = "十一";
  10189. break;
  10190. case "12":
  10191. str = "十二";
  10192. break;
  10193. case "一":
  10194. str = "1";
  10195. break;
  10196. case "二":
  10197. str = "2";
  10198. break;
  10199. case "三":
  10200. str = "3";
  10201. break;
  10202. case "四":
  10203. str = "4";
  10204. break;
  10205. case "五":
  10206. str = "5";
  10207. break;
  10208. case "六":
  10209. str = "6";
  10210. break;
  10211. case "七":
  10212. str = "7";
  10213. break;
  10214. case "八":
  10215. str = "8";
  10216. break;
  10217. case "九":
  10218. str = "9";
  10219. break;
  10220. case "十":
  10221. str = "10";
  10222. break;
  10223. case "十一":
  10224. str = "11";
  10225. break;
  10226. case "十二":
  10227. str = "12";
  10228. break;
  10229. }
  10230. return str;
  10231. }
  10232. #endregion
  10233. #endregion
  10234. #region 团组成本
  10235. /// <summary>
  10236. /// 团组成本数据初始化
  10237. /// </summary>
  10238. /// <param name="dto"></param>
  10239. /// <returns></returns>
  10240. [HttpPost]
  10241. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  10242. {
  10243. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  10244. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  10245. WHEN COUNT(*) >= 0 THEN 'True'
  10246. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  10247. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  10248. ").ToList(); //团组列表
  10249. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  10250. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  10251. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  10252. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  10253. if (groupinfoValue != null)
  10254. {
  10255. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  10256. var spArr = new string[1] { countryArr };
  10257. if (countryArr.Contains("|"))
  10258. {
  10259. spArr = countryArr.Split("|");
  10260. }
  10261. else if (countryArr.Contains("、"))
  10262. {
  10263. spArr = countryArr.Split("、");
  10264. }
  10265. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  10266. {
  10267. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  10268. if (dbQueryCountry != null)
  10269. {
  10270. visaCountryInfoArr.Add(dbQueryCountry);
  10271. }
  10272. }
  10273. }
  10274. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  10275. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  10276. var create = _GroupCostRepository.
  10277. CreateGroupCostByBlackCode(dto.Diid);
  10278. if (groupCost.Count == 0 && create.Code == 0)
  10279. {
  10280. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  10281. }
  10282. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  10283. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  10284. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  10285. groupCostMap = groupCostMap.Select(x =>
  10286. {
  10287. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  10288. {
  10289. x.Date = dataForamt.ToString("yyyy-MM-dd");
  10290. }
  10291. return x;
  10292. }).ToList();
  10293. //GroupCostParameter.Add(new
  10294. // Grp_GroupCostParameter());
  10295. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  10296. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  10297. return Ok(JsonView(new
  10298. {
  10299. groupList,
  10300. groupInfo,
  10301. groupChecks,
  10302. groupCost = groupCostMap,
  10303. hotelNumber,
  10304. GroupCostParameter = GroupCostParameterMap,
  10305. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  10306. {
  10307. x.VisaCountry,
  10308. x.VisaPrice,
  10309. x.Id,
  10310. }).ToList(),
  10311. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  10312. blackCodeIsTrue = create.Code == 0 ? true : false,
  10313. hotelIsTrue = hotelIsTrue,
  10314. }));
  10315. }
  10316. /// <summary>
  10317. /// 团组成本信息保存
  10318. /// </summary>
  10319. /// <param name="dto"></param>
  10320. /// <returns></returns>
  10321. [HttpPost]
  10322. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  10323. {
  10324. if (dto.Diid <= 0 || dto.Userid <= 0)
  10325. {
  10326. return Ok(JsonView(false));
  10327. }
  10328. JsonView jw = null;
  10329. bool isTrue = false;
  10330. #region 复制团组成本
  10331. //if (dto.Diid == 2581)
  10332. //{
  10333. // dto.Diid = 2599;
  10334. // dto.CheckBoxs.ForEach(x =>
  10335. // {
  10336. // x.Diid = 2599;
  10337. // });
  10338. // dto.GroupCosts.ForEach(x =>
  10339. // {
  10340. // x.Diid = 2599;
  10341. // });
  10342. // dto.CostTypeHotelNumbers.ForEach(x =>
  10343. // {
  10344. // x.Diid = 2599;
  10345. // });
  10346. // dto.GroupCostParameters.ForEach(x =>
  10347. // {
  10348. // x.DiId = 2599;
  10349. // });
  10350. //}
  10351. #endregion
  10352. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  10353. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  10354. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  10355. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  10356. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  10357. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  10358. try
  10359. {
  10360. _sqlSugar.BeginTran();
  10361. isTrue = await _GroupCostRepository.
  10362. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  10363. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  10364. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  10365. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  10366. _sqlSugar.CommitTran();
  10367. jw = JsonView(true, "保存成功!", isTrue);
  10368. }
  10369. catch (Exception)
  10370. {
  10371. _sqlSugar.RollbackTran();
  10372. jw = JsonView(false);
  10373. }
  10374. return Ok(jw);
  10375. }
  10376. /// <summary>
  10377. /// 司兼导数据
  10378. /// </summary>
  10379. /// <param name="dto"></param>
  10380. /// <returns></returns>
  10381. [HttpPost]
  10382. public IActionResult GetCarGuides(CarGuidesDto dto)
  10383. {
  10384. JsonView jw = null;
  10385. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  10386. jw = JsonView(true, "获取成功!", Data);
  10387. return Ok(jw);
  10388. }
  10389. /// <summary>
  10390. /// 导游数据
  10391. /// </summary>
  10392. /// <param name="dto"></param>
  10393. /// <returns></returns>
  10394. [HttpPost]
  10395. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  10396. {
  10397. JsonView jw = null;
  10398. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  10399. // 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
  10400. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  10401. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  10402. jw = JsonView(true, "获取成功!", Data);
  10403. return Ok(jw);
  10404. }
  10405. /// <summary>
  10406. /// 成本车数据
  10407. /// </summary>
  10408. /// <param name="dto"></param>
  10409. /// <returns></returns>
  10410. [HttpPost]
  10411. public IActionResult GetCarInfo(CarGuidesDto dto)
  10412. {
  10413. JsonView jw = null;
  10414. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  10415. jw = JsonView(true, "获取成功!", Data);
  10416. return Ok(jw);
  10417. }
  10418. /// <summary>
  10419. /// 景点数据
  10420. /// </summary>
  10421. /// <param name="dto"></param>
  10422. /// <returns></returns>
  10423. [HttpPost]
  10424. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  10425. {
  10426. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  10427. return Ok(JsonView(true, "获取成功!", Data));
  10428. }
  10429. /// <summary>
  10430. /// 成本通知
  10431. /// </summary>
  10432. /// <param name="dto"></param>
  10433. /// <returns></returns>
  10434. [HttpPost]
  10435. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  10436. {
  10437. if (dto.Diid < 0)
  10438. {
  10439. return Ok(JsonView(false));
  10440. }
  10441. JsonView jw = null;
  10442. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  10443. if (GroupCostParameter != null)
  10444. {
  10445. int IsShare = 0;
  10446. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  10447. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  10448. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  10449. string msg = string.Empty;
  10450. if (isTrue)
  10451. {
  10452. if (IsShare == 0)
  10453. {
  10454. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  10455. }
  10456. else
  10457. {
  10458. #region 企微通知对应岗位用户
  10459. try
  10460. {
  10461. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  10462. }
  10463. catch (Exception ex)
  10464. {
  10465. }
  10466. #endregion
  10467. msg = "通知成功,其他模块操作人员可见此成本信息!";
  10468. }
  10469. jw = JsonView(isTrue, msg, new { IsShare });
  10470. }
  10471. else
  10472. {
  10473. msg = "修改失败!";
  10474. jw = JsonView(isTrue, msg);
  10475. }
  10476. }
  10477. else
  10478. {
  10479. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  10480. }
  10481. return Ok(jw);
  10482. }
  10483. /// <summary>
  10484. /// 导出报价单
  10485. /// </summary>
  10486. /// <param name="dto"></param>
  10487. /// <returns></returns>
  10488. [HttpPost]
  10489. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  10490. {
  10491. if (dto.Diid == 0)
  10492. {
  10493. return Ok(JsonView(false, "请传递团组id"));
  10494. }
  10495. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  10496. if (deleInfo.Code != 0)
  10497. {
  10498. return Ok(JsonView(false, "团组信息查询失败!"));
  10499. }
  10500. var di = deleInfo.Data as DelegationInfoWebView;
  10501. if (di != null)
  10502. {
  10503. di.TeamName = di.TeamName.Replace("|", "、");
  10504. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  10505. //文件名
  10506. string strFileName = di.TeamName + "-收款账单.doc";
  10507. //获取模板
  10508. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  10509. //载入模板
  10510. Document doc = new Document(tmppath);
  10511. decimal TotalPrice = 0.00M;
  10512. string itemStr = string.Empty;
  10513. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  10514. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  10515. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  10516. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  10517. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  10518. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  10519. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  10520. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  10521. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  10522. foreach (var cost in groupCostType)
  10523. {
  10524. var List = cost.ToList();
  10525. if (cost.Key == "A")
  10526. {
  10527. foreach (var ListItem in List)
  10528. {
  10529. if (ListItem.number > 0)
  10530. {
  10531. if (ListItem.code.Contains("TBR"))
  10532. {
  10533. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10534. }
  10535. else
  10536. {
  10537. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10538. }
  10539. TotalPrice += (ListItem.number * ListItem.price);
  10540. }
  10541. }
  10542. }
  10543. else
  10544. {
  10545. itemStr = itemStr.Insert(0, "A段\r\n");
  10546. itemStr += "B段\r\n";
  10547. foreach (var ListItem in List)
  10548. {
  10549. if (ListItem.number > 0)
  10550. {
  10551. if (ListItem.code.Contains("TBR"))
  10552. {
  10553. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10554. }
  10555. else
  10556. {
  10557. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10558. }
  10559. TotalPrice += (ListItem.number * ListItem.price);
  10560. }
  10561. }
  10562. }
  10563. }
  10564. #region 替换Word模板书签内容
  10565. Dictionary<string, string> marks = new Dictionary<string, string>();
  10566. marks.Add("To", di.ClientUnit);//付款方
  10567. marks.Add("ToTel", di.TellPhone);//付款方电话
  10568. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  10569. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  10570. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  10571. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  10572. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  10573. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  10574. marks.Add("PayItemContent", itemStr);//详细信息
  10575. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  10576. #endregion
  10577. ////注
  10578. //if (doc.Range.Bookmarks["Attention"] != null)
  10579. //{
  10580. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  10581. // mark.Text = frList[0].Attention;
  10582. //}
  10583. foreach (var item in marks.Keys)
  10584. {
  10585. if (doc.Range.Bookmarks[item] != null)
  10586. {
  10587. Bookmark mark = doc.Range.Bookmarks[item];
  10588. mark.Text = marks[item];
  10589. }
  10590. }
  10591. byte[] bytes = null;
  10592. using (MemoryStream stream = new MemoryStream())
  10593. {
  10594. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  10595. bytes = stream.ToArray();
  10596. }
  10597. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  10598. return Ok(JsonView(true, "", new
  10599. {
  10600. Data = bytes,
  10601. strFileName,
  10602. }));
  10603. }
  10604. else
  10605. {
  10606. return Ok(JsonView(false, "团组信息不存在!"));
  10607. }
  10608. }
  10609. /// <summary>
  10610. /// 导出团组成本
  10611. /// </summary>
  10612. /// <param name="dto"></param>
  10613. /// <returns></returns>
  10614. [HttpPost]
  10615. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  10616. {
  10617. var jw = JsonView(false);
  10618. if (dto.Diid == 0)
  10619. {
  10620. return Ok(JsonView(false, "请传递团组id"));
  10621. }
  10622. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  10623. if (deleInfo.Code != 0)
  10624. {
  10625. return Ok(JsonView(false, "团组信息查询失败!"));
  10626. }
  10627. var di = deleInfo.Data as DelegationInfoWebView;
  10628. if (di == null)
  10629. {
  10630. return Ok(JsonView(false, "团组信息查询失败!"));
  10631. }
  10632. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  10633. WorkbookDesigner designer = new WorkbookDesigner();
  10634. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  10635. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  10636. for (int i = 0; i < List_GC.Count; i++)
  10637. {
  10638. GroupCost_Excel gc = new GroupCost_Excel();
  10639. gc.Id = List_GC[i].Id;
  10640. gc.Diid = List_GC[i].Diid.ToString();
  10641. gc.DAY = List_GC[i].DAY;
  10642. string week = "";
  10643. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  10644. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  10645. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  10646. gc.ITIN = List_GC[i].ITIN;
  10647. gc.CarType = List_GC[i].CarType;
  10648. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  10649. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  10650. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  10651. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  10652. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  10653. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  10654. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  10655. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  10656. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  10657. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  10658. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  10659. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  10660. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  10661. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  10662. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  10663. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  10664. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  10665. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  10666. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  10667. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  10668. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  10669. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  10670. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  10671. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  10672. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  10673. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  10674. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  10675. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  10676. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  10677. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  10678. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  10679. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  10680. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  10681. List_GC1.Add(gc);
  10682. }
  10683. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  10684. dt.TableName = "TB";
  10685. //报表标题等不用dt的值
  10686. designer.SetDataSource("TeamName", dto.title.TeamName);
  10687. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  10688. designer.SetDataSource("Tax", dto.title.Tax);
  10689. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  10690. designer.SetDataSource("Currency", dto.title.Currency);
  10691. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  10692. designer.SetDataSource("Rate", dto.title.Rate);
  10693. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  10694. var Aparams = hotels.Find(x => x.Type == "Default");
  10695. if (Aparams == null)
  10696. {
  10697. return Ok(jw);
  10698. }
  10699. //酒店数量
  10700. var txtSGRNumber = Aparams.SGR.ToString();
  10701. var txtTBRNumber = Aparams.TBR.ToString();
  10702. var txtJSESNumber = Aparams.JSES.ToString();
  10703. var txtSUITENumbe = Aparams.SUITE.ToString();
  10704. if (dto.costType == "B")
  10705. {
  10706. Aparams = hotels.Find(x => x.Type == "A");
  10707. var Bparams = hotels.Find(x => x.Type == "B");
  10708. if (Aparams == null || Bparams == null)
  10709. {
  10710. return Ok(jw);
  10711. }
  10712. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  10713. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  10714. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  10715. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  10716. }
  10717. designer.SetDataSource("SGRNumber", txtSGRNumber);
  10718. designer.SetDataSource("TBRNumber", txtTBRNumber);
  10719. designer.SetDataSource("JSESNumber", txtJSESNumber);
  10720. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  10721. var ws = designer.Workbook.Worksheets[0];
  10722. int Row = List_GC.Count;
  10723. int startIndex = 11;
  10724. int HideRows = 0;
  10725. List<int> hideRowsList = new List<int>();
  10726. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  10727. #region A段left数据
  10728. var left = dto.leftInfo.Find(x => x.Type == "A");
  10729. if (left == null)
  10730. {
  10731. return Ok(jw);
  10732. }
  10733. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  10734. if (leftBindData != null)
  10735. {
  10736. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  10737. designer.SetDataSource("VisaRS", leftBindData.rs);
  10738. designer.SetDataSource("VisaXS", leftBindData.xs);
  10739. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10740. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10741. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10742. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10743. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10744. }
  10745. else
  10746. {
  10747. hideRowsList.Add(Row + startIndex + HideRows);
  10748. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10749. }
  10750. HideRows += 2;
  10751. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  10752. if (leftBindData != null)
  10753. {
  10754. designer.SetDataSource("BXDRCB", leftBindData.cb);
  10755. designer.SetDataSource("BXRS", leftBindData.rs);
  10756. designer.SetDataSource("BXXS", leftBindData.xs);
  10757. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10758. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10759. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10760. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10761. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10762. }
  10763. else
  10764. {
  10765. hideRowsList.Add(Row + startIndex + HideRows);
  10766. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10767. }
  10768. HideRows += 2;
  10769. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  10770. if (leftBindData != null)
  10771. {
  10772. designer.SetDataSource("HSDRCB", leftBindData.cb);
  10773. designer.SetDataSource("HSRS", leftBindData.rs);
  10774. designer.SetDataSource("HSXS", leftBindData.xs);
  10775. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10776. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10777. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10778. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10779. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10780. }
  10781. else
  10782. {
  10783. hideRowsList.Add(Row + startIndex + HideRows);
  10784. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10785. }
  10786. HideRows += 2;
  10787. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  10788. if (leftBindData != null)
  10789. {
  10790. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  10791. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  10792. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  10793. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10794. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10795. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10796. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10797. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10798. }
  10799. else
  10800. {
  10801. hideRowsList.Add(Row + startIndex + HideRows);
  10802. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10803. }
  10804. HideRows += 2;
  10805. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  10806. if (leftBindData != null)
  10807. {
  10808. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  10809. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  10810. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  10811. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10812. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10813. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10814. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10815. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10816. }
  10817. else
  10818. {
  10819. hideRowsList.Add(Row + startIndex + HideRows);
  10820. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10821. }
  10822. HideRows += 2;
  10823. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  10824. if (leftBindData != null)
  10825. {
  10826. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  10827. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  10828. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  10829. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10830. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10831. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10832. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10833. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10834. }
  10835. else
  10836. {
  10837. hideRowsList.Add(Row + startIndex + HideRows);
  10838. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10839. }
  10840. HideRows += 2;
  10841. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  10842. if (leftBindData != null)
  10843. {
  10844. ////TBR
  10845. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  10846. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  10847. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  10848. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10849. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10850. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10851. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10852. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10853. }
  10854. else
  10855. {
  10856. hideRowsList.Add(Row + startIndex + HideRows);
  10857. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10858. }
  10859. HideRows += 2;
  10860. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  10861. if (leftBindData != null)
  10862. {
  10863. ////SGR
  10864. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  10865. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  10866. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  10867. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10868. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10869. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10870. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10871. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10872. }
  10873. else
  10874. {
  10875. hideRowsList.Add(Row + startIndex + HideRows);
  10876. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10877. }
  10878. HideRows += 2;
  10879. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  10880. if (leftBindData != null)
  10881. {
  10882. ////JS/ES
  10883. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  10884. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  10885. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  10886. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10887. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10888. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10889. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10890. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10891. }
  10892. else
  10893. {
  10894. hideRowsList.Add(Row + startIndex + HideRows);
  10895. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10896. }
  10897. HideRows += 2;
  10898. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  10899. if (leftBindData != null)
  10900. {
  10901. ////SUITE
  10902. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  10903. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  10904. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  10905. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10906. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10907. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10908. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10909. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10910. }
  10911. else
  10912. {
  10913. hideRowsList.Add(Row + startIndex + HideRows);
  10914. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10915. }
  10916. HideRows += 2;
  10917. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  10918. if (leftBindData != null)
  10919. {
  10920. designer.SetDataSource("DJDRCB", leftBindData.cb);
  10921. designer.SetDataSource("DJRS", leftBindData.rs);
  10922. designer.SetDataSource("DJXS", leftBindData.xs);
  10923. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10924. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10925. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10926. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10927. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10928. }
  10929. else
  10930. {
  10931. hideRowsList.Add(Row + startIndex + HideRows);
  10932. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10933. }
  10934. HideRows += 2;
  10935. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  10936. if (leftBindData != null)
  10937. {
  10938. designer.SetDataSource("HCPCB", leftBindData.cb);
  10939. designer.SetDataSource("HCPRS", leftBindData.rs);
  10940. designer.SetDataSource("HCPXS", leftBindData.xs);
  10941. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10942. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10943. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10944. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10945. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10946. }
  10947. else
  10948. {
  10949. hideRowsList.Add(Row + startIndex + HideRows);
  10950. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10951. }
  10952. HideRows += 2;
  10953. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  10954. if (leftBindData != null)
  10955. {
  10956. designer.SetDataSource("CPCB", leftBindData.cb);
  10957. designer.SetDataSource("CPRS", leftBindData.rs);
  10958. designer.SetDataSource("CPXS", leftBindData.xs);
  10959. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10960. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10961. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10962. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10963. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10964. }
  10965. else
  10966. {
  10967. hideRowsList.Add(Row + startIndex + HideRows);
  10968. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10969. }
  10970. HideRows += 2;
  10971. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  10972. if (leftBindData != null)
  10973. {
  10974. designer.SetDataSource("GWDRCD", leftBindData.cb);
  10975. designer.SetDataSource("GWRS", leftBindData.rs);
  10976. designer.SetDataSource("GWXS", leftBindData.xs);
  10977. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10978. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10979. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10980. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10981. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10982. }
  10983. else
  10984. {
  10985. hideRowsList.Add(Row + startIndex + HideRows);
  10986. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10987. }
  10988. HideRows += 2;
  10989. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  10990. if (leftBindData != null)
  10991. {
  10992. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  10993. designer.SetDataSource("LYJRS", leftBindData.rs);
  10994. designer.SetDataSource("LYJXS", leftBindData.xs);
  10995. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10996. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10997. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10998. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10999. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11000. }
  11001. else
  11002. {
  11003. hideRowsList.Add(Row + startIndex + HideRows);
  11004. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  11005. }
  11006. #endregion
  11007. #region A段Right信息
  11008. var right = dto.rightInfo.Find(x => x.Type == "A");
  11009. if (right == null)
  11010. {
  11011. return Ok(jw);
  11012. }
  11013. HideRows += 4;
  11014. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  11015. if (rightBindData != null)
  11016. {
  11017. //经济舱 + 双人间 TBR
  11018. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  11019. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  11020. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11021. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  11022. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11023. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11024. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11025. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11026. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11027. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11028. }
  11029. else
  11030. {
  11031. hideRowsList.Add(Row + startIndex + HideRows);
  11032. }
  11033. HideRows += 2;
  11034. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  11035. if (rightBindData != null)
  11036. {
  11037. //经济舱 + 单人间 SGR
  11038. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  11039. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  11040. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11041. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  11042. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11043. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11044. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11045. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11046. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11047. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11048. }
  11049. else
  11050. {
  11051. hideRowsList.Add(Row + startIndex + HideRows);
  11052. }
  11053. HideRows += 2;
  11054. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  11055. if (rightBindData != null)
  11056. {
  11057. //公务舱 + 单人间 SGR
  11058. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  11059. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  11060. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11061. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  11062. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11063. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11064. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11065. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11066. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11067. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11068. }
  11069. else
  11070. {
  11071. hideRowsList.Add(Row + startIndex + HideRows);
  11072. }
  11073. HideRows += 2;
  11074. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  11075. if (rightBindData != null)
  11076. {
  11077. //公务舱 + 小套房 JSES
  11078. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  11079. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  11080. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11081. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  11082. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11083. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11084. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11085. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11086. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11087. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11088. }
  11089. else
  11090. {
  11091. hideRowsList.Add(Row + startIndex + HideRows);
  11092. }
  11093. HideRows += 2;
  11094. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  11095. if (rightBindData != null)
  11096. {
  11097. //公务舱 + 小套房 JSES
  11098. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  11099. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  11100. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11101. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  11102. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11103. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11104. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11105. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11106. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11107. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11108. }
  11109. else
  11110. {
  11111. hideRowsList.Add(Row + startIndex + HideRows);
  11112. }
  11113. HideRows += 2;
  11114. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  11115. if (rightBindData != null)
  11116. {
  11117. //经济舱 + 大套房
  11118. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  11119. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  11120. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11121. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  11122. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11123. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11124. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11125. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11126. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11127. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11128. }
  11129. else
  11130. {
  11131. hideRowsList.Add(Row + startIndex + HideRows);
  11132. }
  11133. HideRows += 2;
  11134. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  11135. if (rightBindData != null)
  11136. {
  11137. //头等舱 + 小套房 JSES
  11138. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  11139. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  11140. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11141. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  11142. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11143. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11144. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11145. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11146. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11147. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11148. }
  11149. else
  11150. {
  11151. hideRowsList.Add(Row + startIndex + HideRows);
  11152. }
  11153. HideRows += 2;
  11154. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  11155. if (rightBindData != null)
  11156. {
  11157. //头等舱 + 大套房
  11158. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  11159. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  11160. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11161. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  11162. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11163. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11164. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11165. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11166. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11167. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11168. }
  11169. else
  11170. {
  11171. hideRowsList.Add(Row + startIndex + HideRows);
  11172. }
  11173. #endregion
  11174. #region B段标题清空
  11175. designer.SetDataSource("CostBDRCB", "");
  11176. designer.SetDataSource("CostBRS", "");
  11177. designer.SetDataSource("CostBXS", "");
  11178. designer.SetDataSource("CostBZCB", "");
  11179. designer.SetDataSource("CostBDRBJ", "");
  11180. designer.SetDataSource("CostBZBJ", "");
  11181. designer.SetDataSource("CostBDRLR", "");
  11182. designer.SetDataSource("CostBZLR", "");
  11183. designer.SetDataSource("CostBDRCBOM", "");
  11184. designer.SetDataSource("CostBRSOM", "");
  11185. designer.SetDataSource("CostBZCBOM", "");
  11186. designer.SetDataSource("CostBDRBJOM", "");
  11187. designer.SetDataSource("CostBZBJOM", "");
  11188. designer.SetDataSource("CostBDRLROM", "");
  11189. designer.SetDataSource("CostBZLROM", "");
  11190. #endregion
  11191. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  11192. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  11193. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  11194. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  11195. designer.SetDataSource("DJName", "地接(CNY)");
  11196. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  11197. designer.SetDataSource("CPName", "地接-船票(CNY)");
  11198. designer.SetDataSource("GWName", "公务(CNY)");
  11199. designer.SetDataSource("YQHName", "邀请函(CNY)");
  11200. designer.SetDataSource("LYJName", "零用金(CNY)");
  11201. designer.SetDataSource("HSName", "核酸检测(CNY)");
  11202. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  11203. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  11204. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  11205. designer.SetDataSource("BXName", "保险(CNY)");
  11206. designer.SetDataSource("VisaName", "签证(CNY)");
  11207. #region B段基本数据
  11208. if (dto.costType == "B")
  11209. {
  11210. left = dto.leftInfo.Find(x => x.Type == "B");
  11211. if (left == null)
  11212. {
  11213. return Ok(jw);
  11214. }
  11215. #region B段left数据
  11216. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  11217. if (leftBindData != null)
  11218. {
  11219. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  11220. designer.SetDataSource("BHSRS", leftBindData.rs);
  11221. designer.SetDataSource("BHSXS", leftBindData.xs);
  11222. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11223. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11224. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11225. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11226. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11227. }
  11228. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  11229. if (leftBindData != null)
  11230. {
  11231. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  11232. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  11233. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  11234. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11235. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11236. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11237. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11238. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11239. }
  11240. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  11241. if (leftBindData != null)
  11242. {
  11243. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  11244. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  11245. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  11246. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11247. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11248. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11249. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11250. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11251. }
  11252. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  11253. if (leftBindData != null)
  11254. {
  11255. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  11256. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  11257. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  11258. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11259. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11260. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11261. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11262. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11263. }
  11264. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  11265. if (leftBindData != null)
  11266. {
  11267. designer.SetDataSource("BHCPCB", leftBindData.cb);
  11268. designer.SetDataSource("BHCPRS", leftBindData.rs);
  11269. designer.SetDataSource("BHCPXS", leftBindData.xs);
  11270. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11271. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11272. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11273. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11274. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11275. }
  11276. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  11277. if (leftBindData != null)
  11278. {
  11279. designer.SetDataSource("BCPCB", leftBindData.cb);
  11280. designer.SetDataSource("BCPRS", leftBindData.rs);
  11281. designer.SetDataSource("BCPXS", leftBindData.xs);
  11282. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11283. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11284. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11285. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11286. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11287. }
  11288. //TBR
  11289. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  11290. if (leftBindData != null)
  11291. {
  11292. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  11293. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  11294. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  11295. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11296. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11297. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11298. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11299. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11300. }
  11301. //SGR
  11302. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  11303. if (leftBindData != null)
  11304. {
  11305. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  11306. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  11307. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  11308. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11309. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11310. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11311. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11312. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11313. }
  11314. //JS/ES
  11315. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  11316. if (leftBindData != null)
  11317. {
  11318. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  11319. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  11320. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  11321. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11322. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11323. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11324. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11325. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11326. }
  11327. //SUITE
  11328. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  11329. if (leftBindData != null)
  11330. {
  11331. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  11332. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  11333. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  11334. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11335. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11336. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11337. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11338. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11339. }
  11340. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  11341. if (leftBindData != null)
  11342. {
  11343. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  11344. designer.SetDataSource("BDJRS", leftBindData.rs);
  11345. designer.SetDataSource("BDJXS", leftBindData.xs);
  11346. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11347. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11348. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11349. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11350. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11351. }
  11352. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  11353. if (leftBindData != null)
  11354. {
  11355. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  11356. designer.SetDataSource("BGWRS", leftBindData.rs);
  11357. designer.SetDataSource("BGWXS", leftBindData.xs);
  11358. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11359. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11360. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11361. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11362. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11363. }
  11364. #region 优化方案
  11365. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  11366. //excelBind.Add("零用金", new {
  11367. //cb="",
  11368. //rs="",
  11369. //xs ="",
  11370. //zcb = "",
  11371. //});
  11372. #endregion
  11373. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  11374. if (leftBindData != null)
  11375. {
  11376. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  11377. designer.SetDataSource("BLYJRS", leftBindData.rs);
  11378. designer.SetDataSource("BLYJXS", leftBindData.xs);
  11379. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11380. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11381. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11382. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11383. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11384. }
  11385. #endregion
  11386. #region B段Right信息
  11387. right = dto.rightInfo.Find(x => x.Type == "B");
  11388. if (right == null)
  11389. {
  11390. return Ok(jw);
  11391. }
  11392. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  11393. if (rightBindData != null)
  11394. {
  11395. //经济舱 + 双人间 TBR
  11396. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  11397. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  11398. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11399. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  11400. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11401. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11402. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11403. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11404. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11405. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11406. }
  11407. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  11408. if (rightBindData != null)
  11409. {
  11410. //经济舱 + 单人间 SGR
  11411. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  11412. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  11413. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11414. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  11415. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11416. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11417. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11418. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11419. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11420. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11421. }
  11422. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  11423. if (rightBindData != null)
  11424. {
  11425. //公务舱 + 单人间 SGR
  11426. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  11427. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  11428. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11429. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  11430. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11431. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11432. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11433. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11434. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11435. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11436. }
  11437. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  11438. if (rightBindData != null)
  11439. {
  11440. //公务舱 + 小套房 JSES
  11441. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  11442. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  11443. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11444. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  11445. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11446. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11447. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11448. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11449. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11450. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11451. }
  11452. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  11453. if (rightBindData != null)
  11454. {
  11455. //公务舱 + 小套房 JSES
  11456. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  11457. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  11458. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11459. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  11460. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11461. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11462. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11463. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11464. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11465. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11466. }
  11467. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  11468. if (rightBindData != null)
  11469. {
  11470. //经济舱 + 大套房
  11471. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  11472. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  11473. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11474. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  11475. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11476. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11477. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11478. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11479. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11480. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11481. }
  11482. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  11483. if (rightBindData != null)
  11484. {
  11485. //头等舱 + 小套房 JSES
  11486. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  11487. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  11488. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11489. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  11490. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11491. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11492. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11493. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11494. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11495. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11496. }
  11497. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  11498. if (rightBindData != null)
  11499. {
  11500. //头等舱 + 大套房
  11501. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  11502. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  11503. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11504. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  11505. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11506. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11507. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11508. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11509. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11510. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11511. }
  11512. #endregion
  11513. #region 标题
  11514. designer.SetDataSource("CostBDRCB", "单人成本");
  11515. designer.SetDataSource("CostBRS", "人数");
  11516. designer.SetDataSource("CostBXS", "系数");
  11517. designer.SetDataSource("CostBZCB", "总成本");
  11518. designer.SetDataSource("CostBDRBJ", "单人报价");
  11519. designer.SetDataSource("CostBZBJ", "总报价");
  11520. designer.SetDataSource("CostBDRLR", "单人利润");
  11521. designer.SetDataSource("CostBZLR", "总利润");
  11522. designer.SetDataSource("CostBDRCBOM", "单人成本");
  11523. designer.SetDataSource("CostBRSOM", "人数");
  11524. designer.SetDataSource("CostBZCBOM", "总成本");
  11525. designer.SetDataSource("CostBDRBJOM", "单人报价");
  11526. designer.SetDataSource("CostBZBJOM", "总报价");
  11527. designer.SetDataSource("CostBDRLROM", "单人利润");
  11528. designer.SetDataSource("CostBZLROM", "总利润");
  11529. #endregion
  11530. }
  11531. #endregion
  11532. designer.SetDataSource("TzZCB2", TzZCB2);
  11533. designer.SetDataSource("TzZBJ2", TzZBJ2);
  11534. designer.SetDataSource("TzZLR2", TzZLR2);
  11535. string[] dataSourceKeys = new string[]
  11536. {
  11537. "VF",
  11538. "TGS",
  11539. "TGOF",
  11540. "TGM",
  11541. "TGA",
  11542. "TGTF",
  11543. "TGEF",
  11544. "CFM",
  11545. "CFOF",
  11546. "B",
  11547. "L",
  11548. "D",
  11549. "TBR",
  11550. "SGR",
  11551. "JSES",
  11552. "Suite",
  11553. "TV",
  11554. "1L",
  11555. "IF",
  11556. "EF",
  11557. "BRF",
  11558. "TE",
  11559. "TGT",
  11560. "DRVT",
  11561. "PC",
  11562. "TLF",
  11563. "ECT"
  11564. };
  11565. foreach (var item in dataSourceKeys)
  11566. {
  11567. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  11568. if (find != null)
  11569. {
  11570. designer.SetDataSource(item, find.text);
  11571. }
  11572. else
  11573. {
  11574. designer.SetDataSource(item, 0);
  11575. }
  11576. }
  11577. designer.SetDataSource(dt);
  11578. //根据数据源处理生成报表内容
  11579. designer.Process();
  11580. designer.Workbook.Worksheets[0].Name = "清单";
  11581. Worksheet sheet = designer.Workbook.Worksheets[0];
  11582. foreach (var Rowindex in hideRowsList)
  11583. {
  11584. ws.Cells.HideRows(Rowindex, 2);
  11585. }
  11586. byte[] bytes = null;
  11587. string strFileName = di.TeamName + "-团组-成本.xls";
  11588. using (MemoryStream stream = new MemoryStream())
  11589. {
  11590. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  11591. bytes = stream.ToArray();
  11592. }
  11593. return Ok(JsonView(true, "", new
  11594. {
  11595. Data = bytes,
  11596. strFileName,
  11597. }));
  11598. }
  11599. /// <summary>
  11600. /// 导出客户报表
  11601. /// </summary>
  11602. /// <returns></returns>
  11603. [HttpPost]
  11604. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  11605. {
  11606. var jw = JsonView(false);
  11607. if (dto.Diid == 0)
  11608. {
  11609. return Ok(JsonView(false, "请传递团组id"));
  11610. }
  11611. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  11612. if (deleInfo.Code != 0)
  11613. {
  11614. return Ok(JsonView(false, "团组信息查询失败!"));
  11615. }
  11616. var di = deleInfo.Data as DelegationInfoWebView;
  11617. if (di == null)
  11618. {
  11619. return Ok(JsonView(false, "团组信息查询失败!"));
  11620. }
  11621. //文件名
  11622. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  11623. //获取模板
  11624. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  11625. //载入模板
  11626. Document doc = new Document(tmppath);
  11627. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  11628. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  11629. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  11630. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  11631. var AParameter = ParameterList.Find(x => x.CostType == "A");
  11632. var BParameter = ParameterList.Find(x => x.CostType == "B");
  11633. if (AParameter == null)
  11634. {
  11635. return Ok(JsonView(false, "系数不存在!"));
  11636. }
  11637. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  11638. , TzAirDesc, TzZCost;
  11639. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  11640. = TzAirDesc = TzZCost = string.Empty;
  11641. TzNumber = AParameter.CostTypenumber.ToString();
  11642. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  11643. CarGuides1 = dto.CarGuides1;
  11644. Meal = dto.Meal;
  11645. SubsidizedMeals = dto.SubsidizedMeals;
  11646. NightRepair = dto.NightRepair;
  11647. AttractionsTickets = dto.AttractionsTickets;
  11648. MiscellaneousFees = dto.MiscellaneousFees;
  11649. ATip = dto.ATip;
  11650. TzHotelDesc = "";
  11651. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  11652. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  11653. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  11654. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  11655. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  11656. TzAirDesc = "";
  11657. TzZCost = dto.TzZCost;
  11658. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  11659. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  11660. var index = 1;
  11661. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  11662. foreach (var item in TzHotelDescArr)
  11663. {
  11664. if (AinfoArr != null)
  11665. {
  11666. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11667. if (Ainfo != null)
  11668. {
  11669. if (int.Parse(Ainfo.rs) <= 0)
  11670. {
  11671. continue;
  11672. }
  11673. var hotelText = string.Empty;
  11674. switch (item)
  11675. {
  11676. case "SGR":
  11677. hotelText = "单人间";
  11678. break;
  11679. case "JSES":
  11680. hotelText = "小套房";
  11681. break;
  11682. case "SUITE":
  11683. hotelText = "套房";
  11684. break;
  11685. case "TBR":
  11686. hotelText = "双人间";
  11687. break;
  11688. }
  11689. if (item != "TBR")
  11690. {
  11691. 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";
  11692. }
  11693. else
  11694. {
  11695. 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";
  11696. }
  11697. index++;
  11698. }
  11699. }
  11700. }
  11701. index = 1;
  11702. foreach (var item in TzAirDescArr)
  11703. {
  11704. if (AinfoArr != null)
  11705. {
  11706. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11707. if (Ainfo != null)
  11708. {
  11709. if (int.Parse(Ainfo.rs) <= 0)
  11710. {
  11711. continue;
  11712. }
  11713. 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";
  11714. index++;
  11715. }
  11716. }
  11717. }
  11718. if (dto.costType == "B")
  11719. {
  11720. if (BParameter == null)
  11721. {
  11722. return Ok(JsonView(false, "B段系数不存在!"));
  11723. }
  11724. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  11725. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  11726. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  11727. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  11728. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  11729. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  11730. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  11731. foreach (var item in TzHotelDescArr)
  11732. {
  11733. if (AinfoArr != null)
  11734. {
  11735. TzHotelDesc += "B段信息 \r\n";
  11736. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11737. if (Ainfo != null)
  11738. {
  11739. if (int.Parse(Ainfo.rs) <= 0)
  11740. {
  11741. continue;
  11742. }
  11743. var hotelText = string.Empty;
  11744. switch (item)
  11745. {
  11746. case "SGR":
  11747. hotelText = "单人间";
  11748. break;
  11749. case "JSES":
  11750. hotelText = "小套房";
  11751. break;
  11752. case "SUITE":
  11753. hotelText = "套房";
  11754. break;
  11755. case "TBR":
  11756. hotelText = "双人间";
  11757. break;
  11758. }
  11759. if (item != "TBR")
  11760. {
  11761. 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";
  11762. }
  11763. else
  11764. {
  11765. 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";
  11766. }
  11767. index++;
  11768. }
  11769. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  11770. }
  11771. }
  11772. index = 1;
  11773. foreach (var item in TzAirDescArr)
  11774. {
  11775. if (AinfoArr != null)
  11776. {
  11777. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11778. if (Ainfo != null)
  11779. {
  11780. if (int.Parse(Ainfo.rs) <= 0)
  11781. {
  11782. continue;
  11783. }
  11784. 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";
  11785. index++;
  11786. }
  11787. }
  11788. }
  11789. }
  11790. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  11791. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  11792. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  11793. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  11794. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  11795. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  11796. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  11797. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  11798. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  11799. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  11800. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  11801. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  11802. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  11803. DickeyValue.Add("Visa", Visa); // 签证单人报价
  11804. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  11805. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  11806. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  11807. DickeyValue.Add("TzZCost", TzZCost);
  11808. foreach (var key in DickeyValue.Keys)
  11809. {
  11810. if (doc.Range.Bookmarks[key] != null)
  11811. {
  11812. Bookmark mark = doc.Range.Bookmarks[key];
  11813. mark.Text = DickeyValue[key];
  11814. }
  11815. }
  11816. byte[] bytes = null;
  11817. string strFileName = di.TeamName + "-客户报价.doc";
  11818. using (MemoryStream stream = new MemoryStream())
  11819. {
  11820. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  11821. bytes = stream.ToArray();
  11822. }
  11823. return Ok(JsonView(true, "", new
  11824. {
  11825. Data = bytes,
  11826. strFileName,
  11827. }));
  11828. }
  11829. /// <summary>
  11830. /// 团组成本 各模块(酒店,地接,机票)成本提示
  11831. /// </summary>
  11832. /// <param name="dto"></param>
  11833. /// <returns></returns>
  11834. [HttpPost]
  11835. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11836. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  11837. {
  11838. try
  11839. {
  11840. #region 参数验证
  11841. if (dto.DiId < 0)
  11842. {
  11843. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  11844. }
  11845. List<int> cTableIds = new List<int>() {
  11846. 76 ,//酒店预订
  11847. 77 ,//行程
  11848. 79 ,//车/导游地接
  11849. 80 ,//签证
  11850. 81 ,//邀请/公务活
  11851. 82 ,//团组客户保险
  11852. 85 ,//机票预订
  11853. 98 ,//其他款项
  11854. 285 ,//收款退还
  11855. 751 ,//酒店早餐
  11856. 1015 // 超支费用
  11857. };
  11858. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  11859. {
  11860. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  11861. }
  11862. #endregion
  11863. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  11864. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  11865. if (_GroupCostParameters.Count <= 0)
  11866. {
  11867. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  11868. }
  11869. if (_GroupCostParameters[0].IsShare == 0)
  11870. {
  11871. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  11872. }
  11873. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  11874. //处理date为空问题
  11875. if (_GroupCosts.Count > 0)
  11876. {
  11877. for (int i = 0; i < _GroupCosts.Count; i++)
  11878. {
  11879. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  11880. {
  11881. if (i > 0)
  11882. {
  11883. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  11884. }
  11885. }
  11886. }
  11887. }
  11888. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  11889. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  11890. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  11891. string currCode = "";
  11892. #region currCode 验证
  11893. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  11894. if (isInt)
  11895. {
  11896. var currData = currDatas.Find(it => it.Id == intCurrency);
  11897. if (currData != null)
  11898. {
  11899. currCode = currData.Name;
  11900. }
  11901. }
  11902. else
  11903. {
  11904. currCode = _GroupCostParameters[0].Currency.Trim();
  11905. }
  11906. #endregion
  11907. //op,酒店单段模式存储
  11908. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  11909. {
  11910. CurrencyCode = currCode,
  11911. Rate = _GroupCostParameters[0].Rate,
  11912. CostType = _GroupCostParameters[0].CostType,
  11913. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  11914. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  11915. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  11916. };
  11917. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  11918. if (_GroupCostParameters.Count == 2)
  11919. {
  11920. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  11921. }
  11922. foreach (var item in _GroupCostParameters)
  11923. {
  11924. decimal _rate = 1;
  11925. decimal _rate1 = item.Rate;
  11926. decimal _scale = 1;
  11927. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  11928. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  11929. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  11930. //if (userInfo != null)
  11931. //{
  11932. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  11933. // {
  11934. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  11935. // {
  11936. // _scale = 1.00M;
  11937. // }
  11938. // }
  11939. //}
  11940. #endregion
  11941. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  11942. {
  11943. CurrencyCode = currCode,
  11944. Rate = _rate1,
  11945. CostType = item.CostType,
  11946. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  11947. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  11948. CostTypeNumber = item.CostTypenumber
  11949. };
  11950. if (_GroupCostParameters.Count > 1)
  11951. {
  11952. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  11953. }
  11954. else
  11955. {
  11956. modulePromptInfo.CostTypeNumber = item.LYJRS;
  11957. }
  11958. if (dto.CTable == 79)//
  11959. {
  11960. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  11961. modulePromptInfo.TotalCost = item.DJCB;
  11962. }
  11963. List<string> costTypes = new List<string>() { "A", "B" };
  11964. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  11965. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  11966. if (_GroupCostsDuplicates.Count() == 1)
  11967. {
  11968. _GroupCostsTypeData = _GroupCosts;
  11969. }
  11970. else
  11971. {
  11972. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  11973. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  11974. }
  11975. /*
  11976. * 76 酒店预订
  11977. * 77 行程
  11978. * 79 车/导游地接
  11979. * 80 签证
  11980. * 81 邀请/公务活动
  11981. * 82 团组客户保险
  11982. * 85 机票预订
  11983. * 98 其他款项
  11984. * 285 收款退还
  11985. * 751 酒店早餐
  11986. * 1015 超支费用
  11987. */
  11988. switch (dto.CTable)
  11989. {
  11990. case 76: // 酒店预订
  11991. _ModuleSubPromptInfo.AddRange(
  11992. _GroupCostsTypeData.Select(it => new
  11993. {
  11994. it.DAY,
  11995. it.Date,
  11996. it.ACCON,
  11997. it.ITIN,
  11998. it.SGR,
  11999. it.TBR,
  12000. it.JS_ES,
  12001. it.Suite
  12002. })
  12003. );
  12004. break;
  12005. case 79: // 车/导游地接
  12006. _ModuleSubPromptInfo.AddRange(
  12007. _GroupCostsTypeData.Select(it => new
  12008. {
  12009. Date = it.Date, //日期
  12010. CarFee = it.CarCost * _rate * _scale, //车费用
  12011. CarType = it.CarType, //车型
  12012. DriverFee = it.CFS * _rate * _scale, //司机工资
  12013. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  12014. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  12015. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  12016. GuideFee = it.TGS * _rate * _scale, //导游费用
  12017. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  12018. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  12019. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  12020. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  12021. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  12022. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  12023. Breakfast = it.B * _rate * _scale, //早餐费
  12024. Lunch = it.L * _rate * _scale, //午餐费
  12025. Dinner = it.D * _rate * _scale, //晚餐费
  12026. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  12027. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  12028. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  12029. TicketFee = it.EF * _rate * _scale, //门票费
  12030. TicketRemark = it.EFR, //门票费描述
  12031. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  12032. TravelSupplies = it.TE * _rate * _scale, //出行物资
  12033. SpentCash = it.PC * _rate * _scale, //零用金
  12034. LeadersFee = it.TLF * _rate * _scale, //领队费
  12035. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  12036. })
  12037. );
  12038. break;
  12039. case 85: // 机票
  12040. List<dynamic> datas = new List<dynamic>();
  12041. datas.Add(
  12042. new
  12043. {
  12044. AirType = "经济舱",
  12045. AirNum = item.JJCRS,
  12046. AirDRCB = item.JJCCB,
  12047. AirZCB = (item.JJCRS * item.JJCCB)
  12048. }
  12049. );
  12050. datas.Add(
  12051. new
  12052. {
  12053. AirType = "公务舱",
  12054. AirNum = item.GWCRS,
  12055. AirDRCB = item.GWCCB,
  12056. AirZCB = (item.GWCRS * item.GWCCB)
  12057. }
  12058. );
  12059. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  12060. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  12061. modulePromptInfo.Data = new
  12062. {
  12063. airFeeData = datas,
  12064. airInitData = initDatas
  12065. };
  12066. _ModulePromptInfos.Add(modulePromptInfo);
  12067. break;
  12068. default:
  12069. break;
  12070. }
  12071. }
  12072. if (dto.CTable != 85)
  12073. {
  12074. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  12075. _ModulePromptInfos.Add(_ModulePromptInfo);
  12076. }
  12077. _view.ModulePromptInfos = _ModulePromptInfos;
  12078. return Ok(JsonView(true, "操作成功!", _view));
  12079. }
  12080. catch (Exception ex)
  12081. {
  12082. return Ok(JsonView(false, ex.Message));
  12083. }
  12084. }
  12085. /// <summary>
  12086. /// 根据黑屏代码重新生成行程
  12087. /// </summary>
  12088. /// <param name="dto"></param>
  12089. /// <returns></returns>
  12090. [HttpPost]
  12091. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  12092. {
  12093. var jw = JsonView(false);
  12094. var Create = _GroupCostRepository.
  12095. CreateGroupCostByBlackCode(dto.Diid);
  12096. jw.Msg = Create.Msg;
  12097. if (Create.Code == 0)
  12098. {
  12099. jw.Code = 200;
  12100. jw.Data = new
  12101. {
  12102. groupCost = Create.Data,
  12103. blackCodeIsTrue = true
  12104. };
  12105. }
  12106. else
  12107. {
  12108. jw.Code = 400;
  12109. jw.Data = new
  12110. {
  12111. groupCost = Create.Data,
  12112. blackCodeIsTrue = false,
  12113. };
  12114. }
  12115. return Ok(jw);
  12116. }
  12117. /// <summary>
  12118. /// 成本获取OP历史车费用
  12119. /// </summary>
  12120. /// <param name="dto"></param>
  12121. /// <returns></returns>
  12122. [HttpPost]
  12123. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  12124. {
  12125. var jw = JsonView(false);
  12126. try
  12127. {
  12128. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  12129. //获取现有所有车的数据
  12130. if (!dto.Param.IsNullOrWhiteSpace())
  12131. {
  12132. string sql = $@"
  12133. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  12134. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  12135. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  12136. 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
  12137. AND gctggr.ServiceEndTime is not NULL
  12138. ORDER by gctggrc.id DESC
  12139. ";
  12140. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  12141. var numeberResult = await Task.Run(() =>
  12142. {
  12143. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  12144. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  12145. return numberArr;
  12146. });
  12147. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  12148. foreach (var item in numeberResult)
  12149. {
  12150. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  12151. {
  12152. Country = "数据异常!",
  12153. City = string.Empty,
  12154. };
  12155. item.Area = find.Country + " " + find.City;
  12156. }
  12157. dbResult.AddRange(numeberResult);
  12158. if (dto.Param.Contains("、"))
  12159. {
  12160. var sp = dto.Param.Split("、");
  12161. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  12162. .Where(x =>
  12163. {
  12164. return System.Array.Exists(sp, e =>
  12165. {
  12166. bool where = false;
  12167. if (x.Area != null)
  12168. {
  12169. where = x.Area.Contains(e);
  12170. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  12171. {
  12172. return false;
  12173. }
  12174. }
  12175. if (x.PriceName != null && !where)
  12176. {
  12177. where = x.PriceName.Contains(e);
  12178. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  12179. {
  12180. return false;
  12181. }
  12182. }
  12183. return where;
  12184. });
  12185. }).ToList();
  12186. }
  12187. else
  12188. {
  12189. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  12190. .Where(x =>
  12191. {
  12192. bool where = false;
  12193. if (x.Area != null)
  12194. {
  12195. where = x.Area.Contains(dto.Param);
  12196. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  12197. {
  12198. return false;
  12199. }
  12200. }
  12201. if (x.PriceName != null && !where)
  12202. {
  12203. where = x.PriceName.Contains(dto.Param);
  12204. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  12205. {
  12206. return false;
  12207. }
  12208. }
  12209. return where;
  12210. }
  12211. )
  12212. .ToList();
  12213. }
  12214. }
  12215. var view = dbResult.Select(x =>
  12216. {
  12217. decimal dp = 0.00M;
  12218. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  12219. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  12220. if (string.IsNullOrWhiteSpace(x.DatePrice))
  12221. {
  12222. if (startB && endB)
  12223. {
  12224. var timesp = endD.Subtract(startD);
  12225. if ((timesp.Days + 1) != 0)
  12226. {
  12227. dp = x.Price / (timesp.Days + 1);
  12228. }
  12229. }
  12230. }
  12231. else
  12232. {
  12233. dp = x.Price;
  12234. }
  12235. return new
  12236. {
  12237. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  12238. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  12239. x.Area,
  12240. x.id,
  12241. price = x.Price.ToString("F2"),
  12242. x.PriceName,
  12243. x.PriceContent,
  12244. x.TeamName,
  12245. x.DatePrice,
  12246. dayPrice = dp.ToString("F2"),
  12247. };
  12248. }).OrderByDescending(x => x.id).ToList();
  12249. jw = JsonView(true, "获取成功!", view);
  12250. }
  12251. catch (Exception e)
  12252. {
  12253. jw = JsonView(false, e.Message);
  12254. }
  12255. return Ok(jw);
  12256. }
  12257. #endregion
  12258. #region 酒店预订 新 雷怡 2023-12-28 17:45
  12259. /// <summary>
  12260. /// 酒店预订
  12261. /// 酒店费用列表 根据团组Id查询
  12262. /// </summary>
  12263. /// <param name="_dto"></param>
  12264. /// <returns></returns>
  12265. [HttpPost]
  12266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12267. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  12268. {
  12269. #region 参数验证
  12270. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12271. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12272. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12273. #region 团组操作权限验证 76 酒店预定模块
  12274. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12275. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12276. #endregion
  12277. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12278. #region 页面操作权限验证
  12279. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12280. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12281. #endregion
  12282. #endregion
  12283. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  12284. }
  12285. /// <summary>
  12286. /// 酒店预订
  12287. /// 基础数据
  12288. /// </summary>
  12289. /// <param name="_dto"></param>
  12290. /// <returns></returns>
  12291. [HttpPost]
  12292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12293. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  12294. {
  12295. #region 参数验证
  12296. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12297. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12298. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12299. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12300. #region 页面操作权限验证
  12301. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12302. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12303. #endregion
  12304. #region 团组操作权限验证 76 酒店预定模块
  12305. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12306. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12307. #endregion
  12308. #endregion
  12309. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  12310. }
  12311. /// <summary>
  12312. /// 酒店预订
  12313. /// 创建 入住卷号码
  12314. /// </summary>
  12315. /// <param name="_dto"></param>
  12316. /// <returns></returns>
  12317. [HttpPost]
  12318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12319. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  12320. {
  12321. #region 参数验证
  12322. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12323. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12324. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12325. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12326. #region 页面操作权限验证
  12327. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12328. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12329. #endregion
  12330. #region 团组操作权限验证 76 酒店预定模块
  12331. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12332. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12333. #endregion
  12334. #endregion
  12335. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  12336. if (data.Code != 0)
  12337. {
  12338. return Ok(JsonView(false, data.Msg));
  12339. }
  12340. return Ok(JsonView(true, data.Msg, data.Data));
  12341. }
  12342. /// <summary>
  12343. /// 酒店预订
  12344. /// 详情
  12345. /// </summary>
  12346. /// <param name="_dto"></param>
  12347. /// <returns></returns>
  12348. [HttpPost]
  12349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12350. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  12351. {
  12352. #region 参数验证
  12353. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  12354. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12355. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  12356. #region 团组操作权限验证 76 酒店预定模块
  12357. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12358. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12359. #endregion
  12360. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12361. #region 页面操作权限验证
  12362. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12363. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12364. #endregion
  12365. #endregion
  12366. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  12367. }
  12368. /// <summary>
  12369. /// 酒店预订
  12370. /// Add Or Edit
  12371. /// </summary>
  12372. /// <param name="_dto"></param>
  12373. /// <returns></returns>
  12374. [HttpPost]
  12375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12376. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  12377. {
  12378. #region 参数验证
  12379. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12380. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12381. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12382. #region 团组操作权限验证 76 酒店预定模块
  12383. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12384. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12385. #endregion
  12386. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12387. #region 页面操作权限验证
  12388. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12389. if (_dto.Id == 0) // Add
  12390. {
  12391. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  12392. }
  12393. else if (_dto.Id > 1) // Edit
  12394. {
  12395. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  12396. }
  12397. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  12398. #endregion
  12399. #endregion
  12400. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  12401. if (_view.Code != 200)
  12402. {
  12403. return Ok(_view);
  12404. }
  12405. #region 成本无酒店价格数据进入超支
  12406. _sqlSugar.BeginTran();
  12407. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  12408. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  12409. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  12410. for (int i = 0; i < groupCost.Count; i++)
  12411. {
  12412. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  12413. {
  12414. groupCost[i].Date = groupCost[i - 1].Date;
  12415. }
  12416. }
  12417. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  12418. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  12419. List<Fin_GroupExtraCostDto_OP>();
  12420. if (start_Bool && end_Bool)
  12421. {
  12422. while (start_Time < end_Time)
  12423. {
  12424. foreach (var item in groupCost_Grp)
  12425. {
  12426. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  12427. {
  12428. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  12429. {
  12430. extraCostList.Add(new
  12431. Fin_GroupExtraCostDto_OP
  12432. {
  12433. Area = _dto.AreaId,
  12434. coefficient = 1.5M,
  12435. createUser = _dto.UserId,
  12436. currency = _dto.CardPriceCurrency,
  12437. diId = _dto.DiId,
  12438. ManagerConfirm = 0,
  12439. SupervisorConfirm = 0,
  12440. SYsupervisorConfirm = 0,
  12441. editType = 1,
  12442. PortType = 1,
  12443. price = _dto.CardPrice,
  12444. PriceCount = 1,
  12445. priceType = 1027,
  12446. priceDetailType = 1044,
  12447. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  12448. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  12449. });
  12450. }
  12451. }
  12452. }
  12453. start_Time = start_Time.AddDays(1);
  12454. }
  12455. }
  12456. if (extraCostList.Any())
  12457. {
  12458. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  12459. }
  12460. _sqlSugar.CommitTran();
  12461. #endregion
  12462. #region 应用推送
  12463. try
  12464. {
  12465. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  12466. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  12467. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  12468. var diId = _dto.DiId;
  12469. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12470. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12471. #region 操作记录
  12472. var opInfo = new Crm_TableOperationRecord() {
  12473. TableName = "Grp_HotelReservations",
  12474. PortType = _dto.PortType,
  12475. DataId = hotelId,
  12476. CreateUserId = _dto.UserId
  12477. };
  12478. var opStatus = OperationEnum.NoOperation;
  12479. if (_dto.Id<1) //添加操作
  12480. {
  12481. opInfo.OperationItem = OperationEnum.Add;
  12482. }
  12483. else if (_dto.Id > 0)
  12484. {
  12485. opInfo.OperationItem = OperationEnum.Edit;
  12486. }
  12487. string opRemark = string.Empty;
  12488. if (ccpInfo != null)
  12489. {
  12490. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  12491. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  12492. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  12493. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  12494. }
  12495. opInfo.Remark = opRemark;
  12496. await _tableorRep.AddAsync(opInfo);
  12497. #endregion
  12498. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  12499. //2024-10-21 新增LZ UID
  12500. var userIds = new List<int>() { 21 };
  12501. string title = $"费用审核";
  12502. string content = "";
  12503. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12504. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12505. try
  12506. {
  12507. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  12508. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  12509. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  12510. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  12511. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  12512. }
  12513. catch (Exception ex )
  12514. {
  12515. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  12516. }
  12517. }
  12518. catch (Exception ex)
  12519. {
  12520. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  12521. }
  12522. try
  12523. {
  12524. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  12525. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  12526. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  12527. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12528. //自动审核
  12529. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  12530. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  12531. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  12532. //2024-10-21 新增LZ UID
  12533. var userIds = new List<int>() { 21 };
  12534. string title = $"系统通知";
  12535. var diId = _dto.DiId;
  12536. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12537. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12538. string content = "";
  12539. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12540. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12541. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12542. }
  12543. catch (Exception ex)
  12544. {
  12545. }
  12546. #endregion
  12547. return Ok(_view);
  12548. }
  12549. /// <summary>
  12550. /// 酒店自动审核测试
  12551. /// Add Or Edit
  12552. /// </summary>
  12553. /// <param name="_dto"></param>
  12554. /// <returns></returns>
  12555. [HttpPost]
  12556. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12557. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  12558. {
  12559. #region 应用推送
  12560. try
  12561. {
  12562. //自动审核
  12563. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  12564. }
  12565. catch (Exception ex)
  12566. {
  12567. return Ok(JsonView(false, "操作失败"));
  12568. }
  12569. #endregion
  12570. return Ok(JsonView(false, "操作成功"));
  12571. }
  12572. /// <summary>
  12573. /// 酒店预订
  12574. /// Del
  12575. /// </summary>
  12576. /// <param name="_dto"></param>
  12577. /// <returns></returns>
  12578. [HttpPost]
  12579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12580. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  12581. {
  12582. #region 参数验证
  12583. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12584. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12585. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12586. #region 团组操作权限验证 76 酒店预定模块
  12587. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12588. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12589. #endregion
  12590. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12591. #region 页面操作权限验证
  12592. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12593. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  12594. #endregion
  12595. #endregion
  12596. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  12597. #region 操作记录
  12598. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  12599. {
  12600. TableName = "Grp_HotelReservations",
  12601. PortType = _dto.PortType,
  12602. OperationItem = OperationEnum.Del,
  12603. DataId = _dto.Id,
  12604. CreateUserId = _dto.UserId
  12605. });
  12606. #endregion
  12607. return Ok(data);
  12608. }
  12609. /// <summary>
  12610. /// 酒店预订
  12611. /// 生成VOUCHER
  12612. /// 2024.05.06 之前版本
  12613. /// </summary>
  12614. /// <param name="_dto"></param>
  12615. /// <returns></returns>
  12616. [HttpPost]
  12617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12618. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  12619. {
  12620. try
  12621. {
  12622. #region 参数验证
  12623. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12624. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12625. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12626. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  12627. #region 团组操作权限验证 76 酒店预定模块
  12628. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12629. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12630. #endregion
  12631. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12632. #region 页面操作权限验证
  12633. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12634. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12635. #endregion
  12636. #endregion
  12637. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  12638. //判断数据是否完整
  12639. if (hr != null)
  12640. {
  12641. if (!string.IsNullOrEmpty(hr.DetermineNo))
  12642. {
  12643. string strFileName = "HotelStatement/";
  12644. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  12645. if (dele != null)
  12646. strFileName += dele.TourCode;
  12647. //载入模板
  12648. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  12649. Document doc = new Document(sss);
  12650. DocumentBuilder builder = new DocumentBuilder(doc);
  12651. #region 替换Word模板书签内容
  12652. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  12653. //入住卷预定号码
  12654. if (doc.Range.Bookmarks["VNO"] != null)
  12655. {
  12656. Bookmark mark = doc.Range.Bookmarks["VNO"];
  12657. mark.Text = hr.CheckNumber;
  12658. }
  12659. //酒店时间
  12660. if (doc.Range.Bookmarks["Date"] != null)
  12661. {
  12662. Bookmark mark = doc.Range.Bookmarks["Date"];
  12663. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  12664. }
  12665. //团号
  12666. if (doc.Range.Bookmarks["TNo"] != null)
  12667. {
  12668. Bookmark mark = doc.Range.Bookmarks["TNo"];
  12669. mark.Text = dele.TourCode;
  12670. }
  12671. //预定号码
  12672. if (doc.Range.Bookmarks["BookingId"] != null)
  12673. {
  12674. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  12675. mark.Text = hr.ReservationsNo;
  12676. }
  12677. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  12678. {
  12679. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  12680. mark.Text = hr.DetermineNo;
  12681. }
  12682. //酒店城市
  12683. if (doc.Range.Bookmarks["City"] != null)
  12684. {
  12685. Bookmark mark = doc.Range.Bookmarks["City"];
  12686. mark.Text = hr.City;
  12687. }
  12688. //酒店名称
  12689. if (doc.Range.Bookmarks["HName"] != null)
  12690. {
  12691. Bookmark mark = doc.Range.Bookmarks["HName"];
  12692. mark.Text = hr.HotelName;
  12693. }
  12694. //酒店地址
  12695. if (doc.Range.Bookmarks["Address"] != null)
  12696. {
  12697. Bookmark mark = doc.Range.Bookmarks["Address"];
  12698. mark.Text = hr.HotelAddress;
  12699. }
  12700. //酒店电话
  12701. if (doc.Range.Bookmarks["Tel"] != null)
  12702. {
  12703. Bookmark mark = doc.Range.Bookmarks["Tel"];
  12704. mark.Text = hr.HotelTel;
  12705. }
  12706. //酒店传真
  12707. if (doc.Range.Bookmarks["Fax"] != null)
  12708. {
  12709. Bookmark mark = doc.Range.Bookmarks["Fax"];
  12710. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  12711. {
  12712. mark.Text = hr.HotelFax;
  12713. }
  12714. }
  12715. //入住时间
  12716. if (doc.Range.Bookmarks["CIn"] != null)
  12717. {
  12718. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  12719. Bookmark mark = doc.Range.Bookmarks["CIn"];
  12720. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  12721. }
  12722. //退房时间
  12723. if (doc.Range.Bookmarks["COut"] != null)
  12724. {
  12725. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  12726. Bookmark mark = doc.Range.Bookmarks["COut"];
  12727. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  12728. }
  12729. //客户名称
  12730. if (doc.Range.Bookmarks["GName"] != null)
  12731. {
  12732. string guestName = "";
  12733. string[] clients = new string[] { };
  12734. if (hr.GuestName.Contains(","))
  12735. {
  12736. clients = hr.GuestName.Split(",");
  12737. }
  12738. else
  12739. {
  12740. clients = new string[] { hr.GuestName };
  12741. }
  12742. List<int> clientIds_int = new List<int>();
  12743. if (clients.Length > 0)
  12744. {
  12745. foreach (var item in clients)
  12746. {
  12747. if (item.IsNumeric())
  12748. {
  12749. clientIds_int.Add(int.Parse(item));
  12750. }
  12751. }
  12752. }
  12753. if (clientIds_int.Count > 0)
  12754. {
  12755. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  12756. foreach (var client in _clientDatas)
  12757. {
  12758. //男
  12759. if (client.Sex == 0) guestName += $"Mr.";
  12760. //女
  12761. else if (client.Sex == 1) guestName += $"Ms.";
  12762. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  12763. {
  12764. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  12765. }
  12766. //guestName += $"{client.Pinyin},";
  12767. }
  12768. if (guestName.Length > 0)
  12769. {
  12770. guestName = guestName.Substring(0, guestName.Length - 1);
  12771. }
  12772. }
  12773. else
  12774. {
  12775. guestName = hr.GuestName;
  12776. }
  12777. Bookmark mark = doc.Range.Bookmarks["GName"];
  12778. mark.Text = guestName;
  12779. }
  12780. //房间介绍
  12781. if (doc.Range.Bookmarks["ROOM"] != null)
  12782. {
  12783. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  12784. mark.Text = hr.RoomExplanation;
  12785. }
  12786. //报价描述
  12787. if (doc.Range.Bookmarks["NOTE"] != null)
  12788. {
  12789. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  12790. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  12791. if (ss != null)
  12792. mark.Text = ss.Name;
  12793. }
  12794. //入住时间
  12795. if (doc.Range.Bookmarks["CheckIn"] != null)
  12796. {
  12797. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  12798. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  12799. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  12800. }
  12801. //退房时间
  12802. if (doc.Range.Bookmarks["CheckOut"] != null)
  12803. {
  12804. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  12805. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  12806. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  12807. }
  12808. //日期
  12809. if (doc.Range.Bookmarks["DT"] != null)
  12810. {
  12811. Bookmark mark = doc.Range.Bookmarks["DT"];
  12812. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  12813. }
  12814. //名称
  12815. if (doc.Range.Bookmarks["VName"] != null)
  12816. {
  12817. Bookmark mark = doc.Range.Bookmarks["VName"];
  12818. mark.Text = hr.HotelName;
  12819. }
  12820. //号码
  12821. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  12822. {
  12823. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  12824. mark.Text = hr.CheckNumber;
  12825. }
  12826. #endregion
  12827. strFileName += "VOUCHER.doc";
  12828. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  12829. doc.Save(fileDir);
  12830. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  12831. return Ok(JsonView(true, "操作成功!", Url));
  12832. }
  12833. else
  12834. {
  12835. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  12836. }
  12837. }
  12838. else
  12839. {
  12840. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  12841. }
  12842. }
  12843. catch (Exception ex)
  12844. {
  12845. return Ok(JsonView(false, ex.Message));
  12846. }
  12847. }
  12848. /// <summary>
  12849. /// 酒店预订
  12850. /// 生成VOUCHER
  12851. /// 2024.05.06 之后版本
  12852. /// </summary>
  12853. /// <param name="_dto"></param>
  12854. /// <returns></returns>
  12855. [HttpPost]
  12856. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12857. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  12858. {
  12859. #region 参数验证
  12860. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  12861. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12862. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  12863. #region 团组操作权限验证 76 酒店预定模块
  12864. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12865. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  12866. #endregion
  12867. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12868. #region 页面操作权限验证
  12869. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12870. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12871. #endregion
  12872. #endregion
  12873. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  12874. //判断数据是否完整
  12875. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  12876. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12877. string strFileName = "HotelStatement/";
  12878. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12879. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  12880. #region 数据处理
  12881. List<int> guestIds = new List<int>();
  12882. int index = 0;
  12883. foreach (var item in hrDtas)
  12884. {
  12885. if (item.GuestName.Contains(","))
  12886. {
  12887. string[] guestIdArr = item.GuestName.Split(',');
  12888. foreach (var guestIdStr in guestIdArr)
  12889. {
  12890. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  12891. if (guestBool)
  12892. {
  12893. guestIds.Add(guestId);
  12894. }
  12895. }
  12896. }
  12897. else guestNames += item.GuestName;
  12898. var voucherInfo = new HotelVoucherInfoView()
  12899. {
  12900. HotelName = item.HotelName,
  12901. CheckInDate = item.CheckInDate,
  12902. CheckOutDate = item.CheckOutDate,
  12903. ConfirmationNumber = item.DetermineNo.Trim(),
  12904. RoomType = item.RoomExplanation
  12905. };
  12906. vouchers.Add(voucherInfo);
  12907. }
  12908. if (guestIds.Count > 0)
  12909. {
  12910. guestIds = guestIds.Distinct().ToList();
  12911. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  12912. if (guestDatas.Count > 0)
  12913. {
  12914. guestNames = "";
  12915. foreach (var guest in guestDatas)
  12916. {
  12917. string guestName = "";
  12918. if (guest.Sex == 0) guestName += @"MR.";
  12919. else if (guest.Sex == 1) guestName += @"MS.";
  12920. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  12921. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  12922. guestNames += @$"{guestName.Trim()}、";
  12923. }
  12924. if (guestNames.Length > 0)
  12925. {
  12926. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  12927. }
  12928. }
  12929. }
  12930. #endregion
  12931. //载入模板
  12932. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  12933. Document doc = new Document(sss);
  12934. DocumentBuilder builder = new DocumentBuilder(doc);
  12935. if (doc.Range.Bookmarks["GuestName"] != null)
  12936. {
  12937. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  12938. mark.Text = guestNames;
  12939. }
  12940. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12941. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  12942. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  12943. for (int i = 1; i <= vouchers.Count; i++)
  12944. {
  12945. HotelVoucherInfoView hviv = vouchers[i - 1];
  12946. builder.MoveToCell(0, i, 0, 0);
  12947. builder.Write(hviv.HotelName);
  12948. builder.MoveToCell(0, i, 1, 0);
  12949. builder.Write(hviv.CheckInDate);
  12950. builder.MoveToCell(0, i, 2, 0);
  12951. builder.Write(hviv.CheckOutDate);
  12952. builder.MoveToCell(0, i, 3, 0);
  12953. builder.Write(hviv.RoomType);
  12954. builder.MoveToCell(0, i, 4, 0);
  12955. builder.Write(hviv.ConfirmationNumber);
  12956. }
  12957. //删除多余行
  12958. int currRowIndex = vouchers.Count + 1;
  12959. int delRows = 21 - currRowIndex;
  12960. if (delRows > 0)
  12961. {
  12962. for (int i = 0; i < delRows; i++)
  12963. {
  12964. table.Rows.RemoveAt(currRowIndex);
  12965. //cultivateRowIndex++;
  12966. }
  12967. }
  12968. strFileName += "VOUCHER.docx";
  12969. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  12970. doc.Save(fileDir);
  12971. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  12972. return Ok(JsonView(true, "操作成功!", Url));
  12973. }
  12974. /// <summary>
  12975. /// 酒店预订
  12976. /// 生成VOUCHER 批量生成
  12977. /// New
  12978. /// </summary>
  12979. /// <param name="_dto"></param>
  12980. /// <returns></returns>
  12981. [HttpPost]
  12982. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12983. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  12984. {
  12985. #region 参数验证
  12986. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  12987. if (_dto.PageId < 1) _dto.PageId = 28;
  12988. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  12989. #region 团组操作权限验证 76 酒店预定模块
  12990. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12991. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  12992. #endregion
  12993. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12994. #region 页面操作权限验证
  12995. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12996. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12997. #endregion
  12998. #endregion
  12999. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  13000. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  13001. .OrderBy(x => x.CheckInDate)
  13002. .ToListAsync();
  13003. //判断数据是否完整
  13004. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  13005. string strFileName = "HotelStatement/";
  13006. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  13007. if (dele != null)
  13008. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  13009. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  13010. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  13011. .Where(it => it.IsDel == 0)
  13012. .ToListAsync();
  13013. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  13014. for (int i = 0; i < hrDtas.Count; i++)
  13015. {
  13016. string guestNames = string.Empty;
  13017. List<int> guestIds = new List<int>();
  13018. var item = hrDtas[i];
  13019. //处理客户姓名
  13020. if (item.GuestName.Contains(","))
  13021. {
  13022. string[] guestIdArr = item.GuestName.Split(',');
  13023. foreach (var guestIdStr in guestIdArr)
  13024. if (int.TryParse(guestIdStr, out int guestId))
  13025. guestIds.Add(guestId);
  13026. }
  13027. else
  13028. {
  13029. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  13030. if (guestIdBool)
  13031. {
  13032. guestIds.Add(guestId);
  13033. }
  13034. //NaN
  13035. if (item.GuestName.Contains("NaN"))
  13036. {
  13037. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  13038. }
  13039. }
  13040. if (guestIds.Count > 0)
  13041. {
  13042. guestIds = guestIds.Distinct().ToList();
  13043. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  13044. if (guestDatas1.Count > 0)
  13045. {
  13046. guestNames = "";
  13047. foreach (var guest in guestDatas1)
  13048. {
  13049. string guestName = "";
  13050. if (guest.Sex == 0) guestName += @"MR.";
  13051. else if (guest.Sex == 1) guestName += @"MS.";
  13052. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  13053. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  13054. guestNames += @$"{guestName.Trim()}、";
  13055. }
  13056. if (guestNames.Length > 0)
  13057. {
  13058. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  13059. }
  13060. }
  13061. }
  13062. //if (!string.IsNullOrEmpty(guestNames))
  13063. //{
  13064. hrDtas[i].GuestName = guestNames;
  13065. //}
  13066. }
  13067. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  13068. Document doc = new Document();
  13069. DocumentBuilder builder = new DocumentBuilder(doc);
  13070. try
  13071. {
  13072. builder.MoveToDocumentStart();
  13073. foreach (var item in hrDtas)
  13074. {
  13075. //标题
  13076. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  13077. builder.ParagraphFormat.LineSpacing = 1;
  13078. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13079. builder.ParagraphFormat.Style.Font.Size = 9;
  13080. builder.ParagraphFormat.Style.Font.Bold = true;
  13081. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  13082. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  13083. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  13084. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  13085. builder.ParagraphFormat.LineSpacing = 1;
  13086. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13087. builder.ParagraphFormat.Style.Font.Size = 9;
  13088. builder.ParagraphFormat.Style.Font.Bold = true;
  13089. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  13090. builder.StartTable();
  13091. // 设置边框颜色
  13092. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  13093. //设置边框样式
  13094. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  13095. //表格
  13096. #region 第一行
  13097. builder.InsertCell();
  13098. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13099. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13100. //builder.CellFormat.AllowAutoFit = false;
  13101. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13102. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13103. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13104. builder.CellFormat.WrapText = true; //自动换行
  13105. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13106. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  13107. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13108. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13109. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13110. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13111. builder.Write("TOUR NO:");
  13112. builder.InsertCell();
  13113. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13114. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13115. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13116. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13117. builder.ParagraphFormat.Style.Font.Bold = false;
  13118. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13119. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13120. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13121. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13122. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13123. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13124. builder.Write($"{dele?.TourCode ?? "-"}");
  13125. builder.InsertCell();
  13126. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13127. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13128. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13129. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13130. builder.ParagraphFormat.Style.Font.Bold = false;
  13131. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13132. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13133. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13134. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13135. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13136. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13137. builder.Write($"CITY:");
  13138. builder.InsertCell();
  13139. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13140. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13141. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13142. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13143. builder.ParagraphFormat.Style.Font.Bold = false;
  13144. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13145. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13146. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13147. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13148. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13149. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13150. builder.Write($"{item.City}");
  13151. builder.EndRow();
  13152. #endregion
  13153. #region 第二行
  13154. builder.InsertCell();
  13155. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13156. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13157. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13158. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13159. builder.ParagraphFormat.Style.Font.Bold = false;
  13160. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13161. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13162. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13163. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13164. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13165. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13166. builder.Write("CONFIRMATION NO:");
  13167. builder.InsertCell();
  13168. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13169. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13170. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13171. builder.ParagraphFormat.Style.Font.Bold = false;
  13172. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13173. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13174. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13175. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13176. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13177. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13178. builder.CellFormat.VerticalMerge = CellMerge.None;
  13179. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13180. builder.Write($"{item.DetermineNo}");
  13181. builder.InsertCell();
  13182. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13183. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13184. builder.InsertCell();
  13185. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13186. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13187. builder.EndRow();
  13188. #endregion
  13189. #region 第三行
  13190. builder.InsertCell();
  13191. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13192. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13193. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13194. builder.ParagraphFormat.Style.Font.Bold = false;
  13195. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13196. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13197. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13198. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13199. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13200. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13201. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13202. builder.Write($"HOTEL NAME:");
  13203. builder.InsertCell();
  13204. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13205. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13206. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13207. builder.ParagraphFormat.Style.Font.Bold = false;
  13208. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13209. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13210. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13211. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13212. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13213. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13214. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13215. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13216. builder.Write($"{item.HotelName}");
  13217. builder.InsertCell();
  13218. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13219. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13220. builder.InsertCell();
  13221. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13222. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13223. builder.EndRow();
  13224. #endregion
  13225. #region 第四行
  13226. builder.InsertCell();
  13227. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13228. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13229. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13230. builder.ParagraphFormat.Style.Font.Bold = false;
  13231. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13232. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13233. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13234. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13235. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13236. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13237. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13238. builder.Write($"HOTEL ADDRESS:");
  13239. builder.InsertCell();
  13240. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13241. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13242. builder.ParagraphFormat.Style.Font.Size = 8;
  13243. builder.ParagraphFormat.Style.Font.Bold = false;
  13244. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13245. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13246. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13247. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13248. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13249. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13250. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13251. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13252. builder.Write($"{item.HotelAddress}");
  13253. builder.InsertCell();
  13254. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13255. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13256. builder.InsertCell();
  13257. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13258. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13259. builder.EndRow();
  13260. #endregion
  13261. #region 第五行
  13262. builder.InsertCell();
  13263. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13264. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13265. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13266. builder.ParagraphFormat.Style.Font.Bold = false;
  13267. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13268. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13269. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13270. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13271. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13272. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13273. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13274. builder.Write("TEL:");
  13275. builder.InsertCell();
  13276. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13277. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13278. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13279. builder.ParagraphFormat.Style.Font.Bold = false;
  13280. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13281. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13282. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13283. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13284. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13285. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13286. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13287. builder.Write($"{item.HotelTel}");
  13288. builder.InsertCell();
  13289. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13290. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13291. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13292. builder.ParagraphFormat.Style.Font.Bold = false;
  13293. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13294. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13295. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13296. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13297. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13298. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13299. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13300. builder.Write($"FAX:");
  13301. builder.InsertCell();
  13302. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13303. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13304. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13305. builder.ParagraphFormat.Style.Font.Bold = false;
  13306. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13307. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13308. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13309. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13310. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13311. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13312. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13313. builder.Write($"{item.HotelFax}");
  13314. builder.EndRow();
  13315. #endregion
  13316. #region 第六行
  13317. builder.InsertCell();
  13318. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13319. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13320. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13321. builder.ParagraphFormat.Style.Font.Bold = false;
  13322. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13323. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13324. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13325. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13326. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13327. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13328. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13329. builder.Write("CHECK IN:");
  13330. builder.InsertCell();
  13331. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13332. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13333. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13334. builder.ParagraphFormat.Style.Font.Bold = false;
  13335. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13336. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13337. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13338. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13339. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13340. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13341. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13342. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  13343. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  13344. builder.Write($"{checkInStr}");
  13345. builder.InsertCell();
  13346. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13347. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13348. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13349. builder.ParagraphFormat.Style.Font.Bold = false;
  13350. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13351. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13352. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13353. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13354. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13355. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13356. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13357. builder.Write($"CHECK OUT:");
  13358. builder.InsertCell();
  13359. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13360. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13361. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13362. builder.ParagraphFormat.Style.Font.Bold = false;
  13363. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13364. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13365. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13366. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13367. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13368. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13369. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13370. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  13371. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  13372. builder.Write($"{checkOutStr}");
  13373. builder.EndRow();
  13374. #endregion
  13375. #region 第七行
  13376. builder.InsertCell();
  13377. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13378. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13379. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13380. builder.ParagraphFormat.Style.Font.Bold = false;
  13381. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13382. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13383. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13384. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13385. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13386. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13387. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13388. builder.Write($"GUEST NAME:");
  13389. builder.InsertCell();
  13390. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13391. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13392. builder.ParagraphFormat.Style.Font.Size = 8;
  13393. builder.ParagraphFormat.Style.Font.Bold = false;
  13394. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13395. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13396. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13397. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13398. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13399. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13400. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13401. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13402. builder.Write($"{item.GuestName}");
  13403. builder.InsertCell();
  13404. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13405. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13406. builder.InsertCell();
  13407. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13408. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13409. builder.EndRow();
  13410. #endregion
  13411. #region 第八行
  13412. builder.InsertCell();
  13413. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13414. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13415. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13416. builder.ParagraphFormat.Style.Font.Bold = false;
  13417. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13418. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13419. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13420. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13421. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13422. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13423. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13424. builder.Write($"ROOM TYPE:");
  13425. builder.InsertCell();
  13426. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13427. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13428. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13429. builder.ParagraphFormat.Style.Font.Bold = false;
  13430. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13431. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13432. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13433. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13434. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13435. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13436. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13437. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13438. builder.Write($"{item.RoomExplanation}");
  13439. builder.InsertCell();
  13440. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13441. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13442. builder.InsertCell();
  13443. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13444. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13445. builder.EndRow();
  13446. #endregion
  13447. #region 第九行
  13448. builder.InsertCell();
  13449. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13450. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13451. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13452. builder.ParagraphFormat.Style.Font.Bold = false;
  13453. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13454. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13455. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13456. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13457. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13458. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13459. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13460. builder.Write($"NOTE:");
  13461. builder.InsertCell();
  13462. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13463. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13464. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13465. builder.ParagraphFormat.Style.Font.Bold = false;
  13466. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13467. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13468. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13469. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13470. 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.");
  13471. builder.InsertCell();
  13472. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13473. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13474. builder.InsertCell();
  13475. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13476. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13477. builder.EndRow();
  13478. #endregion
  13479. builder.EndTable();
  13480. //换行
  13481. builder.Writeln("");
  13482. builder.Writeln("");
  13483. }
  13484. #region 获取文档中的所有表格 设置文字自适应
  13485. // 获取文档中的所有表格。
  13486. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13487. {
  13488. // 遍历表格中的所有行。
  13489. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13490. {
  13491. foreach (Cell cell in row.Cells)
  13492. {
  13493. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  13494. cellFormat.Width = 0;
  13495. }
  13496. }
  13497. }
  13498. #endregion
  13499. #region 设置页眉
  13500. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  13501. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  13502. if (System.IO.File.Exists(voucherHeaderPath))
  13503. {
  13504. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  13505. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  13506. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  13507. Shape shape = builder.InsertImage(imageBytes);
  13508. // 调整图片位置
  13509. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  13510. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  13511. shape.Top = 50; // 将图片距离页眉上边缘的距离
  13512. shape.Left = 0; // 将图片距离页面左边缘的距离
  13513. shape.Width = 81; // 设置图片宽度
  13514. shape.Height = 36; // 设置图片高度
  13515. }
  13516. //靠右
  13517. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  13518. //// 设置页脚上下边距
  13519. //builder.PageSetup.HeaderDistance = 42;
  13520. // 添加页眉线
  13521. Aspose.Words.Border borderHeader = null;
  13522. try
  13523. {
  13524. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  13525. }
  13526. catch (Exception e)
  13527. {
  13528. // TODO Auto-generated catch block
  13529. //e.printStackTrace();
  13530. }
  13531. borderHeader.Shadow = true;
  13532. borderHeader.DistanceFromText = 2;
  13533. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  13534. #endregion
  13535. }
  13536. catch (Exception ex)
  13537. {
  13538. }
  13539. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  13540. doc.Save(fileDir);
  13541. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  13542. return Ok(JsonView(true, "操作成功!", Url));
  13543. }
  13544. /// <summary>
  13545. /// 酒店预订
  13546. /// 生成 预定成本 Excel
  13547. /// </summary>
  13548. /// <param name="_dto"></param>
  13549. /// <returns></returns>
  13550. [HttpPost]
  13551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13552. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  13553. {
  13554. #region 参数验证
  13555. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  13556. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  13557. if (!vadalitorRes.IsValid)
  13558. {
  13559. var errors = new StringBuilder();
  13560. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  13561. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  13562. }
  13563. #region 团组操作权限验证 76 酒店预定模块
  13564. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13565. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13566. #endregion
  13567. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13568. #region 页面操作权限验证
  13569. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13570. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  13571. #endregion
  13572. #endregion
  13573. decimal _rate = 1.00M;
  13574. string _currency = string.Empty;
  13575. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  13576. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  13577. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  13578. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  13579. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  13580. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  13581. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  13582. if (_GroupCostParameter == null)
  13583. {
  13584. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  13585. bool isIntType = int.TryParse(_currency, out int currId);
  13586. if (isIntType)
  13587. {
  13588. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  13589. }
  13590. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  13591. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  13592. if (currInfo == null)
  13593. {
  13594. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  13595. }
  13596. else _rate = currInfo.Rate;
  13597. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  13598. {
  13599. _rate = _GroupCostParameter.Rate;
  13600. }
  13601. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  13602. string strFileName = "HotelStatement/";
  13603. string guestNames = ""; //格式Mr.xxx Ms.xxx
  13604. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  13605. var rateDatas = new List<dynamic>();
  13606. #region 数据处理
  13607. foreach (var item in hrDtas)
  13608. {
  13609. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  13610. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  13611. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  13612. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  13613. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  13614. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  13615. {
  13616. continue;
  13617. }
  13618. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  13619. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  13620. string singleRoomFeeStr = string.Empty,
  13621. doubleRoomFeeStr = string.Empty,
  13622. suiteRoomFeeStr = string.Empty,
  13623. otherRoomFeeStr = string.Empty,
  13624. payMoneyStr = string.Empty,
  13625. cardPriceStr = string.Empty;
  13626. if (roomCurr.Equals("CNY"))
  13627. {
  13628. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  13629. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  13630. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  13631. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  13632. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  13633. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  13634. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  13635. }
  13636. else
  13637. {
  13638. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  13639. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  13640. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  13641. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  13642. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  13643. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  13644. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13645. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13646. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13647. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13648. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  13649. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  13650. if (ccpPaymentCurrency.Equals("CNY"))
  13651. {
  13652. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  13653. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  13654. }
  13655. else
  13656. {
  13657. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  13658. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  13659. }
  13660. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  13661. if (hotelcardPriceCurrency.Equals("CNY"))
  13662. {
  13663. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  13664. }
  13665. else
  13666. {
  13667. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  13668. }
  13669. }
  13670. string breakfastPriceStr = string.Empty,
  13671. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  13672. governmentRentStr = string.Empty,
  13673. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  13674. cityTaxStr = string.Empty,
  13675. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  13676. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  13677. if (!string.IsNullOrEmpty(breakfastCurrency1))
  13678. {
  13679. if (breakfastCurrency1.Equals("CNY"))
  13680. {
  13681. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  13682. }
  13683. else
  13684. {
  13685. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  13686. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  13687. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  13688. }
  13689. }
  13690. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  13691. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  13692. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  13693. {
  13694. if (governmentRentCurrency.Equals("CNY"))
  13695. {
  13696. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  13697. }
  13698. else
  13699. {
  13700. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  13701. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  13702. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  13703. }
  13704. }
  13705. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  13706. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  13707. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  13708. {
  13709. if (cityTaxStrCurrency1.Equals("CNY"))
  13710. {
  13711. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  13712. }
  13713. else
  13714. {
  13715. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  13716. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  13717. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  13718. }
  13719. }
  13720. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  13721. int payDId = roomInfo?.PayDId ?? 0;
  13722. pcfds.Add(new HotelReservations_PCFD_View()
  13723. {
  13724. City = item.City,
  13725. HotelName = item.HotelName,
  13726. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  13727. // SingleRoomCount = item.SingleRoomCount,
  13728. SingleRoomPrice = singleRoomFeeStr,
  13729. // DoubleRoomCount = item.DoubleRoomCount,
  13730. DoubleRoomPrice = doubleRoomFeeStr,
  13731. //SuiteRoomCount = item.SuiteRoomCount,
  13732. SuiteRoomPrice = suiteRoomFeeStr,
  13733. OtherRoomPrice = otherRoomFeeStr,
  13734. //OtherRoomCount = item.OtherRoomCount,
  13735. BreakfastPrice = breakfastPriceStr,
  13736. GovernmentRent = governmentRentStr,
  13737. CityTax = cityTaxStr,
  13738. RoomExplanation = item.RoomExplanation,
  13739. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  13740. PayTime = roomInfo?.ConsumptionDate,
  13741. BankNo = roomInfo?.BankNo,
  13742. PayMoney = payMoneyStr,
  13743. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  13744. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  13745. CardPrice = cardPriceStr,
  13746. Remark = ccpInfo.Remark
  13747. });
  13748. }
  13749. #endregion
  13750. //载入模板
  13751. WorkbookDesigner designer = new WorkbookDesigner();
  13752. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  13753. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  13754. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  13755. designer.SetDataSource("TourNo", groupInfo.TourCode);
  13756. var rateDatas1 = rateDatas.Distinct();
  13757. var rateStr = string.Empty;
  13758. foreach (var item in rateDatas1)
  13759. {
  13760. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  13761. }
  13762. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  13763. designer.SetDataSource("Opertor", userInfo.CnName);
  13764. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  13765. dt.TableName = "ViewMyHotelReservations";
  13766. designer.SetDataSource(dt);
  13767. designer.Process();
  13768. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  13769. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  13770. designer.Workbook.Save(serverPath);
  13771. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  13772. #region 删除指定行
  13773. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  13774. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  13775. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  13776. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  13777. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  13778. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  13779. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  13780. cssIndex = dt.Columns["CityTax"].Ordinal,
  13781. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  13782. remarkIndex = dt.Columns["Remark"].Ordinal;
  13783. //删除指定列
  13784. foreach (DataRow item in dt.Rows)
  13785. {
  13786. string singleStr = item["SingleRoomPrice"].ToString();
  13787. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  13788. if (containsDigitButNotZero1) singleDel = false;
  13789. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  13790. string doubleStr = item["DoubleRoomPrice"].ToString();
  13791. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  13792. if (containsDigitButNotZero2) doubleDel = false;
  13793. string suiteStr = item["SuiteRoomPrice"].ToString();
  13794. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  13795. if (containsDigitButNotZero3) suiteDel = false;
  13796. string otherStr = item["OtherRoomPrice"].ToString();
  13797. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  13798. if (containsDigitButNotZero4) otherDel = false;
  13799. string zcStr = item["BreakfastPrice"].ToString();
  13800. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  13801. if (containsDigitButNotZero5) zcDel = false;
  13802. string dsStr = item["GovernmentRent"].ToString();
  13803. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  13804. if (containsDigitButNotZero6) dsDel = false;
  13805. string cssStr = item["CityTax"].ToString();
  13806. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  13807. if (containsDigitButNotZero7) cssDel = false;
  13808. string cpStr = item["ConsumptionPatterns"].ToString();
  13809. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  13810. string remarkStr = item["Remark"].ToString();
  13811. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  13812. }
  13813. DeleteColumn(serverPath, remarkIndex, remarkDel);
  13814. DeleteColumn(serverPath, cpIndex, cpDel);
  13815. DeleteColumn(serverPath, dsIndex, dsDel);
  13816. DeleteColumn(serverPath, cssIndex, cssDel);
  13817. DeleteColumn(serverPath, zcIndex, zcDel);
  13818. DeleteColumn(serverPath, otherIndex, otherDel);
  13819. DeleteColumn(serverPath, suiteIndex, suiteDel);
  13820. DeleteColumn(serverPath, doubleIndex, doubleDel);
  13821. DeleteColumn(serverPath, singleIndex, singleDel);
  13822. #endregion
  13823. //只保留第一个表格
  13824. DeleteSheet(serverPath);
  13825. return Ok(JsonView(true, "操作成功", url = rst));
  13826. }
  13827. else
  13828. {
  13829. _currency = _GroupCostParameter.Currency;
  13830. bool isIntType = int.TryParse(_currency, out int currId);
  13831. if (isIntType)
  13832. {
  13833. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  13834. }
  13835. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  13836. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  13837. if (currInfo == null)
  13838. {
  13839. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  13840. }
  13841. if (!_currency.ToUpper().Equals("CNY"))
  13842. {
  13843. _rate = _GroupCostParameter.Rate;
  13844. }
  13845. _rate = currInfo.Rate;
  13846. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  13847. string strFileName = "HotelStatement/";
  13848. string guestNames = ""; //格式Mr.xxx Ms.xxx
  13849. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  13850. #region 数据处理
  13851. foreach (var item in hrDtas)
  13852. {
  13853. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  13854. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  13855. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  13856. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  13857. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  13858. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  13859. string singleRoomFeeStr = string.Empty,
  13860. doubleRoomFeeStr = string.Empty,
  13861. suiteRoomFeeStr = string.Empty,
  13862. otherRoomFeeStr = string.Empty,
  13863. payMoneyStr = string.Empty,
  13864. cardPriceStr = string.Empty;
  13865. if (roomCurr.Equals(_currency))
  13866. {
  13867. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  13868. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  13869. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  13870. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  13871. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  13872. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  13873. }
  13874. else
  13875. {
  13876. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  13877. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  13878. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  13879. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  13880. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  13881. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  13882. }
  13883. string breakfastPriceStr = string.Empty,
  13884. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  13885. governmentRentStr = string.Empty,
  13886. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  13887. cityTaxStrStr = string.Empty,
  13888. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  13889. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  13890. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  13891. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  13892. int payDId = roomInfo?.PayDId ?? 0;
  13893. pcfds.Add(new HotelReservations_PCFD_View()
  13894. {
  13895. City = item.City,
  13896. HotelName = item.HotelName,
  13897. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  13898. // SingleRoomCount = item.SingleRoomCount,
  13899. SingleRoomPrice = singleRoomFeeStr,
  13900. // DoubleRoomCount = item.DoubleRoomCount,
  13901. DoubleRoomPrice = doubleRoomFeeStr,
  13902. //SuiteRoomCount = item.SuiteRoomCount,
  13903. SuiteRoomPrice = suiteRoomFeeStr,
  13904. OtherRoomPrice = otherRoomFeeStr,
  13905. //OtherRoomCount = item.OtherRoomCount,
  13906. BreakfastPrice = breakfastPriceStr,
  13907. GovernmentRent = governmentRentStr,
  13908. CityTax = cityTaxStrStr,
  13909. RoomExplanation = item.RoomExplanation,
  13910. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  13911. PayTime = roomInfo?.ConsumptionDate,
  13912. BankNo = roomInfo?.BankNo,
  13913. PayMoney = payMoneyStr,
  13914. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  13915. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  13916. CardPrice = cardPriceStr,
  13917. Remark = ccpInfo.Remark
  13918. });
  13919. }
  13920. #endregion
  13921. //载入模板
  13922. WorkbookDesigner designer = new WorkbookDesigner();
  13923. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  13924. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  13925. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  13926. designer.SetDataSource("TourNo", groupInfo.TourCode);
  13927. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  13928. designer.SetDataSource("Opertor", userInfo.CnName);
  13929. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  13930. dt.TableName = "ViewMyHotelReservations";
  13931. designer.SetDataSource(dt);
  13932. designer.Process();
  13933. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  13934. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  13935. designer.Workbook.Save(serverPath);
  13936. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  13937. #region 删除指定行
  13938. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  13939. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  13940. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  13941. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  13942. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  13943. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  13944. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  13945. cssIndex = dt.Columns["CityTax"].Ordinal,
  13946. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  13947. remarkIndex = dt.Columns["Remark"].Ordinal;
  13948. //删除指定列
  13949. foreach (DataRow item in dt.Rows)
  13950. {
  13951. string singleStr = item["SingleRoomPrice"].ToString();
  13952. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  13953. if (containsDigitButNotZero1) singleDel = false;
  13954. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  13955. string doubleStr = item["DoubleRoomPrice"].ToString();
  13956. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  13957. if (containsDigitButNotZero2) doubleDel = false;
  13958. string suiteStr = item["SuiteRoomPrice"].ToString();
  13959. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  13960. if (containsDigitButNotZero3) suiteDel = false;
  13961. string otherStr = item["OtherRoomPrice"].ToString();
  13962. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  13963. if (containsDigitButNotZero4) otherDel = false;
  13964. string zcStr = item["BreakfastPrice"].ToString();
  13965. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  13966. if (containsDigitButNotZero5) zcDel = false;
  13967. string dsStr = item["GovernmentRent"].ToString();
  13968. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  13969. if (containsDigitButNotZero6) dsDel = false;
  13970. string cssStr = item["CityTax"].ToString();
  13971. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  13972. if (containsDigitButNotZero7) cssDel = false;
  13973. string cpStr = item["ConsumptionPatterns"].ToString();
  13974. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  13975. string remarkStr = item["Remark"].ToString();
  13976. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  13977. }
  13978. DeleteColumn(serverPath, remarkIndex, remarkDel);
  13979. DeleteColumn(serverPath, cpIndex, cpDel);
  13980. DeleteColumn(serverPath, dsIndex, dsDel);
  13981. DeleteColumn(serverPath, cssIndex, cssDel);
  13982. DeleteColumn(serverPath, zcIndex, zcDel);
  13983. DeleteColumn(serverPath, otherIndex, otherDel);
  13984. DeleteColumn(serverPath, suiteIndex, suiteDel);
  13985. DeleteColumn(serverPath, doubleIndex, doubleDel);
  13986. DeleteColumn(serverPath, singleIndex, singleDel);
  13987. #endregion
  13988. //只保留第一个表格
  13989. DeleteSheet(serverPath);
  13990. return Ok(JsonView(true, "操作成功", url = rst));
  13991. }
  13992. return Ok(JsonView(false));
  13993. }
  13994. /// <summary>
  13995. /// 删除指定列
  13996. /// </summary>
  13997. /// <param name="file"></param>
  13998. /// <param name="columnIndex"></param>
  13999. /// <param name="isDel"></param>
  14000. private void DeleteColumn(string file, int columnIndex, bool isDel)
  14001. {
  14002. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  14003. //wb.Save(file);
  14004. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  14005. if (sheet1 != null)
  14006. {
  14007. if (isDel)
  14008. {
  14009. Cells cells = sheet1.Cells;
  14010. cells.DeleteColumn(columnIndex);
  14011. }
  14012. }
  14013. wb.Save(file);
  14014. }
  14015. /// <summary>
  14016. /// 删除sheet
  14017. /// </summary>
  14018. /// <param name="file"></param>
  14019. /// <param name="sheetName"></param>
  14020. private void DeleteSheet(string file, string sheetName = "")
  14021. {
  14022. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  14023. //wb.Save(file);
  14024. List<string> sheets = new List<string>();
  14025. foreach (var item in wb.Worksheets)
  14026. {
  14027. sheets.Add(item.Name);
  14028. }
  14029. if (sheets.Count > 0)
  14030. {
  14031. sheets.RemoveAt(0);//不删除第一个sheet
  14032. foreach (var item in sheets)
  14033. {
  14034. wb.Worksheets.RemoveAt(item);
  14035. }
  14036. }
  14037. wb.Save(file);
  14038. }
  14039. /// <summary>
  14040. /// 酒店预订
  14041. /// 确认单
  14042. /// </summary>
  14043. /// <param name="_dto"></param>
  14044. /// <returns></returns>
  14045. [HttpPost]
  14046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14047. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  14048. {
  14049. try
  14050. {
  14051. #region 参数验证
  14052. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14053. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14054. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14055. #region 团组操作权限验证 76 酒店预定模块
  14056. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14057. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14058. #endregion
  14059. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14060. #region 页面操作权限验证
  14061. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14062. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14063. #endregion
  14064. #endregion
  14065. //团组信息
  14066. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  14067. //酒店数据
  14068. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  14069. if (listhoteldata.Count < 0)
  14070. {
  14071. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  14072. }
  14073. //利datatable存储
  14074. DataTable dt = new DataTable();
  14075. dt.Columns.Add("CheckInDate", typeof(string));
  14076. dt.Columns.Add("City", typeof(string));
  14077. dt.Columns.Add("Hotel", typeof(string));
  14078. dt.Columns.Add("Room", typeof(string));
  14079. for (int i = 0; i < listhoteldata.Count; i++)
  14080. {
  14081. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  14082. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  14083. while (dayStart < dayEnd)
  14084. {
  14085. string temp = "";
  14086. DataRow row = dt.NewRow();
  14087. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  14088. row["City"] = listhoteldata[i].City;
  14089. row["Hotel"] = listhoteldata[i].HotelName;
  14090. if (listhoteldata[i].SingleRoomCount > 0)
  14091. {
  14092. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  14093. }
  14094. if (listhoteldata[i].DoubleRoomCount > 0)
  14095. {
  14096. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  14097. }
  14098. if (listhoteldata[i].SuiteRoomCount > 0)
  14099. {
  14100. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  14101. }
  14102. if (listhoteldata[i].OtherRoomCount > 0)
  14103. {
  14104. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  14105. }
  14106. row["Room"] = temp;
  14107. dt.Rows.Add(row);
  14108. dayStart = dayStart.AddDays(1);
  14109. }
  14110. }
  14111. Dictionary<string, string> dic = new Dictionary<string, string>();
  14112. dic.Add("Dele", di.TeamName);
  14113. dic.Add("City", di.VisitCountry);
  14114. //模板路径
  14115. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  14116. //载入模板
  14117. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  14118. DocumentBuilder builder = new DocumentBuilder(doc);
  14119. foreach (var key in dic.Keys)
  14120. {
  14121. builder.MoveToBookmark(key);
  14122. builder.Write(dic[key]);
  14123. }
  14124. //获取word里所有表格
  14125. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14126. //获取所填表格的序数
  14127. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14128. var rowStart = tableOne.Rows[0]; //获取第1行
  14129. //循环赋值
  14130. for (int i = 0; i < dt.Rows.Count; i++)
  14131. {
  14132. builder.MoveToCell(0, i + 1, 0, 0);
  14133. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  14134. builder.MoveToCell(0, i + 1, 1, 0);
  14135. builder.Write(dt.Rows[i]["City"].ToString());
  14136. builder.MoveToCell(0, i + 1, 2, 0);
  14137. builder.Write(dt.Rows[i]["Hotel"].ToString());
  14138. builder.MoveToCell(0, i + 1, 3, 0);
  14139. builder.Write(dt.Rows[i]["Room"].ToString());
  14140. }
  14141. //删除多余行
  14142. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  14143. {
  14144. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  14145. }
  14146. string strFileName = di.TeamName + "酒店确认单.doc";
  14147. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  14148. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  14149. return Ok(JsonView(true, "成功", url));
  14150. }
  14151. catch (Exception ex)
  14152. {
  14153. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  14154. }
  14155. }
  14156. #endregion
  14157. #region 团组状态
  14158. /// <summary>
  14159. /// 团组状态列表 Page
  14160. /// </summary>
  14161. /// <param name="dto">团组列表请求dto</param>
  14162. /// <returns></returns>
  14163. [HttpPost]
  14164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14165. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  14166. {
  14167. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  14168. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  14169. {
  14170. string sqlWhere = string.Empty;
  14171. if (dto.IsSure == 0) //未完成
  14172. {
  14173. sqlWhere += string.Format(@" And IsSure = 0");
  14174. }
  14175. else if (dto.IsSure == 1) //已完成
  14176. {
  14177. sqlWhere += string.Format(@" And IsSure = 1");
  14178. }
  14179. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  14180. {
  14181. string tj = dto.SearchCriteria;
  14182. 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}%')",
  14183. tj, tj, tj, tj, tj);
  14184. }
  14185. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  14186. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  14187. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  14188. From (
  14189. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  14190. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  14191. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  14192. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  14193. From Grp_DelegationInfo gdi
  14194. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  14195. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  14196. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  14197. Where gdi.IsDel = 0 {0}
  14198. ) temp ", sqlWhere);
  14199. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  14200. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  14201. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  14202. }
  14203. else
  14204. {
  14205. return Ok(JsonView(false, "查询失败"));
  14206. }
  14207. }
  14208. /// <summary>
  14209. /// 团组状态
  14210. /// 设置操作完成
  14211. /// </summary>
  14212. /// <param name="dto">团组列表请求dto</param>
  14213. /// <returns></returns>
  14214. [HttpPost]
  14215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14216. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  14217. {
  14218. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  14219. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  14220. {
  14221. Id = dto.Id,
  14222. IsSure = 1
  14223. };
  14224. var result = await _sqlSugar.Updateable(_DelegationInfo)
  14225. .UpdateColumns(it => new { it.IsSure })
  14226. .WhereColumns(it => new { it.Id })
  14227. .ExecuteCommandAsync();
  14228. if (result > 0)
  14229. {
  14230. return Ok(JsonView(true, "操作完成!"));
  14231. }
  14232. return Ok(JsonView(false, "操作失败!"));
  14233. }
  14234. #endregion
  14235. #region 保险费用录入
  14236. /// <summary>
  14237. /// 根据团组Id查询保险费用列表
  14238. /// </summary>
  14239. /// <param name="dto"></param>
  14240. /// <returns></returns>
  14241. [HttpPost]
  14242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14243. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  14244. {
  14245. Result groupData = await _customersRep.CustomersByDiId(dto);
  14246. if (groupData.Code != 0)
  14247. {
  14248. return Ok(JsonView(false, groupData.Msg));
  14249. }
  14250. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14251. }
  14252. /// <summary>
  14253. /// 根据保险费用Id查询保险费用详细
  14254. /// </summary>
  14255. /// <param name="dto"></param>
  14256. /// <returns></returns>
  14257. [HttpPost]
  14258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14259. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  14260. {
  14261. try
  14262. {
  14263. Result groupData = await _customersRep.CustomersById(dto);
  14264. if (groupData.Code != 0)
  14265. {
  14266. return Ok(JsonView(false, groupData.Msg));
  14267. }
  14268. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14269. }
  14270. catch (Exception ex)
  14271. {
  14272. return Ok(JsonView(false, ex.Message));
  14273. }
  14274. }
  14275. /// <summary>
  14276. /// 保险费用录入页面初始化绑定
  14277. /// </summary>
  14278. /// <param name="dto"></param>
  14279. /// <returns></returns>
  14280. [HttpPost]
  14281. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14282. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  14283. {
  14284. try
  14285. {
  14286. Result groupData = await _customersRep.CustomersInitialize(dto);
  14287. if (groupData.Code != 0)
  14288. {
  14289. return Ok(JsonView(false, groupData.Msg));
  14290. }
  14291. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14292. }
  14293. catch (Exception ex)
  14294. {
  14295. return Ok(JsonView(false, ex.Message));
  14296. }
  14297. }
  14298. /// <summary>
  14299. /// 保险费用操作(Status:1.新增,2.修改)
  14300. /// </summary>
  14301. /// <param name="dto"></param>
  14302. /// <returns></returns>
  14303. [HttpPost]
  14304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14305. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  14306. {
  14307. Result groupData = await _customersRep.OpCustomers(dto);
  14308. if (groupData.Code != 0)
  14309. {
  14310. return Ok(JsonView(false, groupData.Msg));
  14311. }
  14312. #region 应用推送
  14313. try
  14314. {
  14315. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  14316. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  14317. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  14318. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14319. //自动审核
  14320. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  14321. //2024-10-21 新增LZ UID
  14322. var userIds = new List<int>() { 21 };
  14323. string title = $"系统通知";
  14324. var diId = dto.DiId;
  14325. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14326. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14327. string content = "";
  14328. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14329. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14330. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14331. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  14332. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  14333. }
  14334. catch (Exception ex)
  14335. {
  14336. }
  14337. #endregion
  14338. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14339. }
  14340. /// <summary>
  14341. /// 保险文件上传
  14342. /// </summary>
  14343. /// <param name="file"></param>
  14344. /// <returns></returns>
  14345. [HttpPost]
  14346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14347. public async Task<IActionResult> UploadCus(IFormFile file)
  14348. {
  14349. try
  14350. {
  14351. if (file != null)
  14352. {
  14353. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  14354. //文件名称
  14355. string projectFileName = file.FileName;
  14356. //上传的文件的路径
  14357. string filePath = "";
  14358. if (!Directory.Exists(fileDir))
  14359. {
  14360. Directory.CreateDirectory(fileDir);
  14361. }
  14362. //上传的文件的路径
  14363. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  14364. using (FileStream fs = System.IO.File.Create(filePath))
  14365. {
  14366. file.CopyTo(fs);
  14367. fs.Flush();
  14368. }
  14369. return Ok(JsonView(true, "上传成功!", projectFileName));
  14370. }
  14371. else
  14372. {
  14373. return Ok(JsonView(false, "上传失败!"));
  14374. }
  14375. }
  14376. catch (Exception ex)
  14377. {
  14378. return Ok(JsonView(false, "程序错误!"));
  14379. throw;
  14380. }
  14381. }
  14382. /// <summary>
  14383. /// 保险删除指定文件
  14384. /// </summary>
  14385. /// <param name="dto"></param>
  14386. /// <returns></returns>
  14387. [HttpPost]
  14388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14389. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  14390. {
  14391. try
  14392. {
  14393. string filePath = "";
  14394. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  14395. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  14396. //int id = 0;
  14397. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  14398. // 删除该文件
  14399. try
  14400. {
  14401. System.IO.File.Delete(filePath);
  14402. 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()
  14403. {
  14404. Attachment = "",
  14405. }).ExecuteCommandAsync();
  14406. if (result != 0)
  14407. {
  14408. return Ok(JsonView(true, "成功!"));
  14409. }
  14410. else
  14411. {
  14412. return Ok(JsonView(false, "失败!"));
  14413. }
  14414. }
  14415. catch (Exception)
  14416. {
  14417. 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()
  14418. {
  14419. Attachment = "",
  14420. }).ExecuteCommandAsync();
  14421. if (result != 0)
  14422. {
  14423. return Ok(JsonView(true, "成功!"));
  14424. }
  14425. else
  14426. {
  14427. return Ok(JsonView(false, "失败!"));
  14428. }
  14429. }
  14430. }
  14431. catch (Exception ex)
  14432. {
  14433. return Ok(JsonView(false, "程序错误!"));
  14434. throw;
  14435. }
  14436. }
  14437. /// <summary>
  14438. /// 保险费用操作(删除)
  14439. /// </summary>
  14440. /// <param name="dto"></param>
  14441. /// <returns></returns>
  14442. [HttpPost]
  14443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14444. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  14445. {
  14446. try
  14447. {
  14448. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  14449. if (!res)
  14450. {
  14451. return Ok(JsonView(false, "删除失败"));
  14452. }
  14453. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  14454. {
  14455. IsDel = 1,
  14456. DeleteUserId = dto.DeleteUserId,
  14457. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14458. }).ExecuteCommandAsync();
  14459. return Ok(JsonView(true, "删除成功!"));
  14460. }
  14461. catch (Exception ex)
  14462. {
  14463. return Ok(JsonView(false, "程序错误!"));
  14464. throw;
  14465. }
  14466. }
  14467. #endregion
  14468. #region 接团客户名单 PageId 104
  14469. /// <summary>
  14470. /// 接团客户名单
  14471. /// 迁移数据(慎用!)
  14472. /// </summary>
  14473. /// <param name="dto"></param>
  14474. /// <returns></returns>
  14475. [HttpPost]
  14476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14477. public async Task<IActionResult> PostTourClientListChange()
  14478. {
  14479. try
  14480. {
  14481. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  14482. //var groupClinetData1
  14483. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  14484. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  14485. int updateCount = 0;
  14486. if (oldOAClientList.Count > 0)
  14487. {
  14488. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  14489. _sqlSugar.BeginTran();
  14490. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  14491. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  14492. foreach (var item in oldOAClientList)
  14493. {
  14494. int comId = 0;
  14495. string format = "yyyy-MM-dd HH:mm:ss";
  14496. string data11 = "1990-01-01 00:00";
  14497. var data1 = IsValidDate(item.OPdate, format);
  14498. if (data1) data11 = item.OPdate;
  14499. //客户公司验证
  14500. if (!string.IsNullOrEmpty(item.Company))
  14501. {
  14502. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  14503. if (clientComInfo == null) // add
  14504. {
  14505. var addInfo = new Crm_CustomerCompany()
  14506. {
  14507. CompanyAbbreviation = "",
  14508. CompanyFullName = item.Company,
  14509. Address = "",
  14510. PostCodes = "",
  14511. LastedOpUserId = item.OPer,
  14512. LastedOpDt = Convert.ToDateTime(data11),
  14513. CreateUserId = item.OPer,
  14514. CreateTime = Convert.ToDateTime(data11),
  14515. IsDel = 0
  14516. };
  14517. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  14518. if (comId1 > 0) comId = comId1;
  14519. }
  14520. else comId = clientComInfo.Id;
  14521. }
  14522. //客户人员验证
  14523. int clientId = 0;
  14524. string name = item.LastName + item.Name;
  14525. if (!string.IsNullOrEmpty(name))
  14526. {
  14527. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  14528. if (clientInfo == null)
  14529. {
  14530. DateTime? dateTime = null;
  14531. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  14532. if (isDt) dateTime = birthDayDt;
  14533. var addInfo1 = new Crm_DeleClient()
  14534. {
  14535. CrmCompanyId = comId,
  14536. DiId = -1,
  14537. LastName = item.LastName,
  14538. FirstName = item.Name,
  14539. OldName = "",
  14540. Pinyin = item.Pinyin,
  14541. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  14542. Marriage = 0,
  14543. Phone = item.Phone,
  14544. Job = item.Job,
  14545. BirthDay = dateTime
  14546. };
  14547. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  14548. if (clientId1 > 0) clientId = clientId1;
  14549. }
  14550. else clientId = clientInfo.Id;
  14551. }
  14552. if (clientId < 1)
  14553. {
  14554. continue;
  14555. }
  14556. int airType = 0;
  14557. if (item.AirType == "超经舱") airType = 459;
  14558. else if (item.AirType == "公务舱") airType = 458;
  14559. else if (item.AirType == "经济舱") airType = 460;
  14560. else if (item.AirType == "其他") airType = 565;
  14561. else if (item.AirType == "头等舱") airType = 457;
  14562. var _TourClientListEntity = new Grp_TourClientList()
  14563. {
  14564. DiId = item.Diid,
  14565. ClientId = clientId,
  14566. CreateUserId = item.OPer,
  14567. CreateTime = Convert.ToDateTime(data11),
  14568. Remark = item.Remark,
  14569. IsDel = item.Isdel,
  14570. ShippingSpaceTypeId = airType,
  14571. ShippingSpaceSpecialNeeds = item.AirRemark,
  14572. HotelSpecialNeeds = item.RoomType
  14573. };
  14574. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  14575. if (_TourClientList > 0)
  14576. {
  14577. updateCount++;
  14578. }
  14579. }
  14580. _sqlSugar.CommitTran();
  14581. }
  14582. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  14583. }
  14584. catch (Exception ex)
  14585. {
  14586. _sqlSugar.RollbackTran();
  14587. return Ok(JsonView(false, ex.Message));
  14588. }
  14589. return Ok(JsonView(true));
  14590. }
  14591. private bool IsValidDate(string dateString, string format)
  14592. {
  14593. DateTime dateValue;
  14594. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  14595. return valid;
  14596. }
  14597. /// <summary>
  14598. /// 接团客户名单
  14599. /// 根据团组Id查询List
  14600. /// </summary>
  14601. /// <param name="dto"></param>
  14602. /// <returns></returns>
  14603. [HttpPost]
  14604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14605. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  14606. {
  14607. #region 参数验证
  14608. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  14609. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  14610. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  14611. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14612. #region 页面操作权限验证
  14613. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14614. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14615. #endregion
  14616. #endregion
  14617. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  14618. if (viewData.Code != 0)
  14619. {
  14620. return Ok(JsonView(false, viewData.Msg));
  14621. }
  14622. return Ok(JsonView(viewData.Data));
  14623. }
  14624. /// <summary>
  14625. /// 接团客户名单
  14626. /// 基础数据 Init
  14627. /// </summary>
  14628. /// <param name="_dto"></param>
  14629. /// <returns></returns>
  14630. [HttpPost]
  14631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14632. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  14633. {
  14634. #region 参数验证
  14635. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14636. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14637. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14638. #region 页面操作权限验证
  14639. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14640. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14641. #endregion
  14642. #endregion
  14643. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  14644. }
  14645. /// <summary>
  14646. /// 接团客户名单
  14647. /// 根据 Id查询 Details
  14648. /// </summary>
  14649. /// <param name="_dto"></param>
  14650. /// <returns></returns>
  14651. [HttpPost]
  14652. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14653. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  14654. {
  14655. #region 参数验证
  14656. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14657. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14658. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  14659. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14660. #region 页面操作权限验证
  14661. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14662. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14663. #endregion
  14664. #endregion
  14665. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  14666. if (viewData.Code != 0)
  14667. {
  14668. return Ok(JsonView(false, viewData.Msg));
  14669. }
  14670. return Ok(JsonView(viewData.Data));
  14671. }
  14672. /// <summary>
  14673. /// 接团客户名单
  14674. /// Add Or Edit
  14675. /// </summary>
  14676. /// <param name="_dto"></param>
  14677. /// <returns></returns>
  14678. [HttpPost]
  14679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14680. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  14681. {
  14682. #region 参数验证
  14683. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14684. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14685. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  14686. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14687. #region 页面操作权限验证
  14688. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14689. if (_dto.Id == 0) //添加
  14690. {
  14691. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14692. }
  14693. else if (_dto.Id >= 0) //修改
  14694. {
  14695. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  14696. }
  14697. #endregion
  14698. #endregion
  14699. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  14700. if (viewData.Code != 0)
  14701. {
  14702. return Ok(JsonView(false, viewData.Msg));
  14703. }
  14704. return Ok(JsonView(true));
  14705. }
  14706. /// <summary>
  14707. /// 接团客户名单
  14708. /// json字符串 AddMultiple(添加多个)
  14709. /// </summary>
  14710. /// <param name="_dto"></param>
  14711. /// <returns></returns>
  14712. [HttpPost]
  14713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14714. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  14715. {
  14716. #region 参数验证
  14717. string jsonLabel = _dto.JsonLabel;
  14718. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14719. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14720. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14721. #region 页面操作权限验证
  14722. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14723. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14724. #endregion
  14725. #endregion
  14726. var request = new TourClientListAddMultipleDto();
  14727. request.DiId = _dto.DiId;
  14728. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  14729. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  14730. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  14731. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  14732. var infos = new List<TourClientListInfo>();
  14733. foreach (var data in datas)
  14734. {
  14735. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  14736. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  14737. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  14738. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  14739. {
  14740. continue;
  14741. }
  14742. infos.Add(new TourClientListInfo() {
  14743. IsAccompany = 1,
  14744. LastName = lastName,
  14745. FirstName = firstName,
  14746. Pinyin = lastNameEn + @"/" + firstNameEn,
  14747. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女")? 1:2,
  14748. CompanyFullName = data.CompanyFullName,
  14749. Job = data.Job
  14750. });
  14751. }
  14752. if (infos.Any())
  14753. {
  14754. var viewData = await _tourClientListRep._AddMultiple(request);
  14755. if (viewData.Code != 0)
  14756. {
  14757. return Ok(JsonView(false, viewData.Msg));
  14758. }
  14759. return Ok(JsonView(true));
  14760. }
  14761. return Ok(JsonView(false));
  14762. }
  14763. /// <summary>
  14764. /// 接团客户名单
  14765. /// AddMultiple(添加多个)
  14766. /// </summary>
  14767. /// <param name="_dto"></param>
  14768. /// <returns></returns>
  14769. [HttpPost]
  14770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14771. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  14772. {
  14773. #region 参数验证
  14774. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14775. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14776. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14777. #region 页面操作权限验证
  14778. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14779. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14780. #endregion
  14781. #endregion
  14782. var viewData = await _tourClientListRep._AddMultiple(_dto);
  14783. if (viewData.Code != 0)
  14784. {
  14785. return Ok(JsonView(false, viewData.Msg));
  14786. }
  14787. return Ok(JsonView(true));
  14788. }
  14789. /// <summary>
  14790. /// 接团客户名单
  14791. /// Del
  14792. /// </summary>
  14793. /// <param name="_dto"></param>
  14794. /// <returns></returns>
  14795. [HttpPost]
  14796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14797. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  14798. {
  14799. #region 参数验证
  14800. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14801. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14802. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14803. #region 页面操作权限验证
  14804. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14805. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14806. #endregion
  14807. #endregion
  14808. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  14809. if (viewData.Code != 0)
  14810. {
  14811. return Ok(JsonView(false, viewData.Msg));
  14812. }
  14813. return Ok(JsonView(true));
  14814. }
  14815. /// <summary>
  14816. /// 接团客户名单
  14817. /// 文件下载 客户名单
  14818. /// </summary>
  14819. /// <param name="_dto"></param>
  14820. /// <returns></returns>
  14821. [HttpPost]
  14822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14823. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  14824. {
  14825. #region 参数验证
  14826. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14827. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14828. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  14829. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14830. #region 页面操作权限验证
  14831. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14832. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14833. #endregion
  14834. #endregion
  14835. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  14836. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  14837. From Grp_TourClientList tcl
  14838. Left Join
  14839. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  14840. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  14841. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  14842. From Crm_DeleClient dc
  14843. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  14844. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  14845. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  14846. Where dc.IsDel = 0) temp
  14847. On temp.DcId =tcl.ClientId
  14848. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  14849. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  14850. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  14851. //载入模板
  14852. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  14853. if (_dto.Language == 1)
  14854. {
  14855. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  14856. }
  14857. //载入模板
  14858. var doc = new Document(tempPath);
  14859. DocumentBuilder builder = new DocumentBuilder(doc);
  14860. //获取word里所有表格
  14861. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14862. //获取所填表格的序数
  14863. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14864. var rowStart = tableOne.Rows[0]; //获取第1行
  14865. if (_dto.Language == 0)
  14866. {
  14867. //循环赋值
  14868. for (int i = 0; i < DcList.Count; i++)
  14869. {
  14870. EncryptionProcessor.DecryptProperties(DcList[i]);
  14871. builder.MoveToCell(0, i + 1, 0, 0);
  14872. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  14873. builder.MoveToCell(0, i + 1, 1, 0);
  14874. int sex = DcList[i].Sex;
  14875. string sexStr = string.Empty;
  14876. if (sex == 0) sexStr = "男";
  14877. else if (sex == 1) sexStr = "女";
  14878. else sexStr = "未设置";
  14879. builder.Write(sexStr);
  14880. builder.MoveToCell(0, i + 1, 2, 0);
  14881. string birthDay = DcList[i].BirthDay;
  14882. string birthDayStr = string.Empty;
  14883. if (!string.IsNullOrEmpty(birthDay))
  14884. {
  14885. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  14886. }
  14887. builder.Write(birthDayStr);
  14888. builder.MoveToCell(0, i + 1, 3, 0);
  14889. string company = "";
  14890. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  14891. {
  14892. company = DcList[i].CompanyFullName.ToString();
  14893. }
  14894. builder.Write(company);
  14895. builder.MoveToCell(0, i + 1, 4, 0);
  14896. builder.Write(DcList[i].Job);
  14897. }
  14898. }
  14899. else if (_dto.Language == 1)
  14900. {
  14901. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  14902. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  14903. List<string> transArrayStr = new List<string>();
  14904. string transStrRes1 = "";
  14905. for (int i = 0; i < DcList.Count; i++)
  14906. {
  14907. var dc = DcList[i];
  14908. EncryptionProcessor.DecryptProperties(dc);
  14909. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  14910. if (dc.Job.Equals("暂无")) dc.Job = "-";
  14911. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  14912. if (DcList.Count - 1 == i) transStrRes1 += str1;
  14913. else transStrRes1 += $"{str1}|";
  14914. }
  14915. //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";
  14916. string transStrRes = "";
  14917. if (transStrRes1.Length > 0)
  14918. {
  14919. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  14920. }
  14921. //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
  14922. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  14923. //List<string> transArray = new List<string> { };
  14924. List<TranslateInfo> transArray = new List<TranslateInfo>();
  14925. if (transStrRes.Contains("|"))
  14926. {
  14927. string[] transArray1 = transStrRes.Split('|');
  14928. if (transArray1.Length > 0)
  14929. {
  14930. foreach (var item in transArray1)
  14931. {
  14932. if (item.Contains("&"))
  14933. {
  14934. string[] transArray2 = item.Split('&');
  14935. int index = 0;
  14936. string companyName = "", job = "";
  14937. if (transArray2.Length > 0)
  14938. {
  14939. bool success = int.TryParse(transArray2[0].Trim(), out index);
  14940. if (1 < transArray2.Length) companyName = transArray2[1];
  14941. if (2 < transArray2.Length) job = transArray2[2];
  14942. }
  14943. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  14944. }
  14945. }
  14946. }
  14947. }
  14948. //循环赋值
  14949. for (int i = 0; i < DcList.Count; i++)
  14950. {
  14951. string PYName = "";
  14952. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  14953. {
  14954. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  14955. string PY_First = DcList[i].Pinyin.Split('/')[1];
  14956. PYName = PY_First + " " + PY_Last;
  14957. }
  14958. else
  14959. {
  14960. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  14961. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  14962. PYName = PY_First + " " + PY_Last;
  14963. }
  14964. builder.MoveToCell(0, i + 1, 0, 0);
  14965. builder.Write(PYName);
  14966. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  14967. builder.MoveToCell(0, i + 1, 1, 0);
  14968. builder.Write(sex);
  14969. DateTime birthDt;
  14970. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  14971. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  14972. builder.MoveToCell(0, i + 1, 2, 0);
  14973. builder.Write(birthday);
  14974. string company = string.Empty, job = string.Empty;
  14975. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  14976. if (dcTransInfo != null)
  14977. {
  14978. company = dcTransInfo.CompanyName;
  14979. job = dcTransInfo.Job;
  14980. }
  14981. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  14982. {
  14983. //查询对照表
  14984. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  14985. if (tempCec != null)
  14986. {
  14987. company = tempCec.enName;
  14988. }
  14989. //翻译
  14990. else
  14991. {
  14992. }
  14993. }
  14994. builder.MoveToCell(0, i + 1, 3, 0);
  14995. builder.Write(company);
  14996. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  14997. {
  14998. //查询对照表
  14999. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  15000. if (tempPec != null)
  15001. {
  15002. job = tempPec.enName;
  15003. }
  15004. //翻译
  15005. else
  15006. {
  15007. }
  15008. }
  15009. builder.MoveToCell(0, i + 1, 4, 0);
  15010. builder.Write(job);
  15011. }
  15012. }
  15013. //删除多余行
  15014. while (tableOne.Rows.Count > DcList.Count + 1)
  15015. {
  15016. tableOne.Rows.RemoveAt(DcList.Count + 1);
  15017. }
  15018. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  15019. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  15020. doc.Save(fileDir);
  15021. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  15022. return Ok(JsonView(true, "操作成功!", Url));
  15023. }
  15024. private class TranslateInfo
  15025. {
  15026. public int Index { get; set; }
  15027. public string CompanyName { get; set; }
  15028. public string Job { get; set; }
  15029. }
  15030. #endregion
  15031. #region 团组倒推表
  15032. /// <summary>
  15033. /// 倒推表基础数据
  15034. /// Init
  15035. /// </summary>
  15036. /// <param name="dto"></param>
  15037. /// <returns></returns>
  15038. [HttpPost]
  15039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15040. public async Task<IActionResult> PostInvertedListInit()
  15041. {
  15042. var viewData = await _invertedListRep._Init();
  15043. if (viewData.Code != 0)
  15044. {
  15045. return Ok(JsonView(false, viewData.Msg));
  15046. }
  15047. return Ok(JsonView(viewData.Data));
  15048. }
  15049. /// <summary>
  15050. /// 倒推表
  15051. /// Info
  15052. /// </summary>
  15053. /// <param name="dto"></param>
  15054. /// <returns></returns>
  15055. [HttpPost]
  15056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15057. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  15058. {
  15059. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  15060. if (viewData.Code != 0)
  15061. {
  15062. return Ok(JsonView(false, viewData.Msg));
  15063. }
  15064. return Ok(JsonView(viewData.Data));
  15065. }
  15066. /// <summary>
  15067. /// 倒推表
  15068. /// Create
  15069. /// </summary>
  15070. /// <param name="dto"></param>
  15071. /// <returns></returns>
  15072. [HttpPost]
  15073. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15074. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  15075. {
  15076. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  15077. if (viewData.Code != 0)
  15078. {
  15079. return Ok(JsonView(false, viewData.Msg));
  15080. }
  15081. return Ok(JsonView(viewData.Data));
  15082. }
  15083. /// <summary>
  15084. /// 倒推表
  15085. /// Update
  15086. /// </summary>
  15087. /// <param name="dto"></param>
  15088. /// <returns></returns>
  15089. [HttpPost]
  15090. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15091. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  15092. {
  15093. var viewData = await _invertedListRep._Update(dto);
  15094. if (viewData.Code != 0)
  15095. {
  15096. return Ok(JsonView(false, viewData.Msg));
  15097. }
  15098. return Ok(JsonView(viewData.Data));
  15099. }
  15100. /// <summary>
  15101. /// 倒推表
  15102. /// File Download
  15103. /// </summary>
  15104. /// <param name="dto"></param>
  15105. /// <returns></returns>
  15106. [HttpPost]
  15107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15108. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  15109. {
  15110. var info2 = await _invertedListRep._Info(1, dto.DiId);
  15111. if (info2.Code != 0)
  15112. {
  15113. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  15114. }
  15115. var info1 = info2.Data as InvertedListInfoView;
  15116. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  15117. string teamName = "";
  15118. if (info != null) teamName = info.TeamName;
  15119. //载入模板
  15120. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  15121. DocumentBuilder builder = new DocumentBuilder(doc);
  15122. //利用键值对存放数据
  15123. Dictionary<string, string> dic = new Dictionary<string, string>();
  15124. dic.Add("TeamName", teamName);
  15125. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  15126. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  15127. dic.Add("BPRemark", info1.ApprovalDataRemark);
  15128. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  15129. dic.Add("SQRemark", info1.ApprovalRemark);
  15130. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  15131. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  15132. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  15133. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  15134. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  15135. dic.Add("QZRemark", info1.VisaInformationRemark);
  15136. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  15137. dic.Add("SQQZRemark", info1.SendVisaRemark);
  15138. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  15139. dic.Add("CQRemark", info1.IssueVisaRemark);
  15140. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  15141. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  15142. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  15143. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  15144. #region 填充word模板书签内容
  15145. foreach (var key in dic.Keys)
  15146. {
  15147. builder.MoveToBookmark(key);
  15148. builder.Write(dic[key]);
  15149. }
  15150. #endregion
  15151. var fileDir = AppSettingsHelper.Get("WordBasePath");
  15152. string fileName = $"{teamName}团出行准备流程表.doc";
  15153. string filePath = fileDir + $@"InvertedList/{fileName}";
  15154. doc.Save(filePath);
  15155. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  15156. return Ok(JsonView(true, "操作成功!", Url));
  15157. }
  15158. #endregion
  15159. #region 三公签证费用(签证费、代办费)
  15160. /// <summary>
  15161. /// 三公签证费用(签证费、代办费)
  15162. /// List
  15163. /// </summary>
  15164. /// <returns></returns>
  15165. [HttpPost]
  15166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15167. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  15168. {
  15169. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  15170. if (_view.Code != 0)
  15171. {
  15172. return Ok(JsonView(false, _view.Msg));
  15173. }
  15174. return Ok(JsonView(true, "操作成功!", _view.Data));
  15175. }
  15176. /// <summary>
  15177. /// 三公签证费用(签证费、代办费)
  15178. /// Add Or Update
  15179. /// </summary>
  15180. /// <returns></returns>
  15181. [HttpPost]
  15182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15183. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  15184. {
  15185. var _view = await _visaFeeInfoRep._Update(_dto);
  15186. if (_view.Code != 0)
  15187. {
  15188. return Ok(JsonView(false, _view.Msg));
  15189. }
  15190. return Ok(JsonView(true, _view.Msg));
  15191. }
  15192. #endregion
  15193. #region 酒店询价
  15194. /// <summary>
  15195. /// 酒店询价
  15196. /// Init
  15197. /// </summary>
  15198. /// <param name="dto"></param>
  15199. /// <returns></returns>
  15200. [HttpPost]
  15201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15202. public async Task<IActionResult> PostHotelInquiryInit()
  15203. {
  15204. var res = await _hotelInquiryRep._Init();
  15205. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15206. return Ok(JsonView(true, res.Msg, res.Data));
  15207. }
  15208. /// <summary>
  15209. /// 酒店询价
  15210. /// page Item
  15211. /// </summary>
  15212. /// <param name="_dto"></param>
  15213. /// <returns></returns>
  15214. [HttpPost]
  15215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15216. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  15217. {
  15218. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  15219. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15220. var view = res.Data as PageDataViewBase;
  15221. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  15222. }
  15223. /// <summary>
  15224. /// 酒店询价
  15225. /// info
  15226. /// </summary>
  15227. /// <param name="_dto"></param>
  15228. /// <returns></returns>
  15229. [HttpPost]
  15230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15231. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  15232. {
  15233. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  15234. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15235. return Ok(JsonView(true, res.Msg, res.Data));
  15236. }
  15237. /// <summary>
  15238. /// 酒店询价
  15239. /// Add Or Edit
  15240. /// </summary>
  15241. /// <param name="_dto"></param>
  15242. /// <returns></returns>
  15243. [HttpPost]
  15244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15245. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  15246. {
  15247. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  15248. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15249. return Ok(JsonView(true, res.Msg, res.Data));
  15250. }
  15251. /// <summary>
  15252. /// 酒店询价
  15253. /// Del
  15254. /// </summary>
  15255. /// <param name="_dto"></param>
  15256. /// <returns></returns>
  15257. [HttpPost]
  15258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15259. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  15260. {
  15261. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  15262. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15263. return Ok(JsonView(true, res.Msg, res.Data));
  15264. }
  15265. #endregion
  15266. #region 下载匹配op行程单
  15267. /// <summary>
  15268. /// 匹配op行程单
  15269. /// Init
  15270. /// </summary>
  15271. /// <param name="dto">团组列表请求dto</param>
  15272. /// <returns></returns>
  15273. [HttpPost]
  15274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15275. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  15276. {
  15277. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  15278. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  15279. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  15280. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  15281. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  15282. .Where(it => it.IsDel == 0)
  15283. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  15284. .OrderByDescending(it => it.CreateUserId)
  15285. .ToList();
  15286. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  15287. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  15288. var diids = groupInfos.Select(it => it.Id).ToList();
  15289. List<string> countrys = new List<string>();
  15290. foreach (var item in country)
  15291. {
  15292. var data = _groupRepository.FormartTeamName(item);
  15293. var dataArray = _groupRepository.GroupSplitCountry(data);
  15294. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  15295. }
  15296. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  15297. List<string> areaArray = new List<string>(); //GetGroupCityLine
  15298. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  15299. foreach (var item in areaItem)
  15300. {
  15301. string areaStr = item.Value;
  15302. if (!string.IsNullOrEmpty(areaStr))
  15303. {
  15304. string[] str1 = areaStr.Split("-");
  15305. if (str1.Length > 0)
  15306. {
  15307. areaArray.AddRange(str1);
  15308. }
  15309. }
  15310. }
  15311. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  15312. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  15313. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  15314. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  15315. .ToList();
  15316. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  15317. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  15318. .Where(it => countriesIds.Contains(it.Id))
  15319. .Select(it => new { it.Id, Name = it.Name_CN })
  15320. .ToList();
  15321. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  15322. .Select(it => it.TeamName).ToList();
  15323. stopwatch.Stop();
  15324. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  15325. }
  15326. ///// <summary>
  15327. ///// 匹配op行程单
  15328. ///// Init 查询区域数据
  15329. ///// </summary>
  15330. ///// <param name="dto">团组列表请求dto</param>
  15331. ///// <returns></returns>
  15332. //[HttpPost]
  15333. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15334. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  15335. //{
  15336. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  15337. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  15338. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  15339. // if (string.IsNullOrEmpty(countriesDataStr))
  15340. // {
  15341. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  15342. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  15343. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  15344. // }
  15345. // else
  15346. // {
  15347. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  15348. // }
  15349. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  15350. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  15351. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  15352. // List<dynamic> childList = new List<dynamic>();
  15353. // int parentId = dto.CountriesId;
  15354. // if (provinceData.Count > 1)
  15355. // {
  15356. // foreach (var item1 in provinceData)
  15357. // {
  15358. // List<dynamic> childList1 = new List<dynamic>();
  15359. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  15360. // foreach (var item2 in citiesData1)
  15361. // {
  15362. // List<dynamic> childList2 = new List<dynamic>();
  15363. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  15364. // foreach (var item3 in countiesData1)
  15365. // {
  15366. // childList2.Add(new
  15367. // {
  15368. // id = item3.Id,
  15369. // parentId = item2.Id,
  15370. // level = "district",
  15371. // name = item3.Name_CN,
  15372. // });
  15373. // }
  15374. // childList1.Add(new
  15375. // {
  15376. // id = item2.Id,
  15377. // parentId = item1.Id,
  15378. // level = "city",
  15379. // name = item2.Name_CN,
  15380. // childList = childList2
  15381. // });
  15382. // }
  15383. // childList.Add(new
  15384. // {
  15385. // id = item1.Id,
  15386. // parentId = parentId,
  15387. // level = "province",
  15388. // name = item1.Name_CN,
  15389. // childList = childList1
  15390. // });
  15391. // }
  15392. // //城市
  15393. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  15394. // foreach (var item2 in citiesData2)
  15395. // {
  15396. // List<dynamic> childList22 = new List<dynamic>();
  15397. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  15398. // foreach (var item3 in countiesData1)
  15399. // {
  15400. // childList22.Add(new
  15401. // {
  15402. // id = item3.Id,
  15403. // parentId = item2.Id,
  15404. // level = "district",
  15405. // name = item3.Name_CN,
  15406. // });
  15407. // }
  15408. // childList.Add(new
  15409. // {
  15410. // id = item2.Id,
  15411. // parentId = parentId,
  15412. // level = "city",
  15413. // name = item2.Name_CN,
  15414. // childList = childList22
  15415. // });
  15416. // }
  15417. // }
  15418. // else
  15419. // {
  15420. // foreach (var item2 in citiesData)
  15421. // {
  15422. // string cname = item2.Name_CN;
  15423. // List<dynamic> childList1 = new List<dynamic>();
  15424. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  15425. // foreach (var item3 in countiesData1)
  15426. // {
  15427. // childList1.Add(new
  15428. // {
  15429. // Id = item3.Id,
  15430. // parentId = item2.Id,
  15431. // level = "district",
  15432. // name = item3.Name_CN
  15433. // });
  15434. // }
  15435. // childList.Add(new
  15436. // {
  15437. // id = item2.Id,
  15438. // parentId = parentId,
  15439. // level = "city",
  15440. // name = item2.Name_CN,
  15441. // childList = childList1
  15442. // });
  15443. // }
  15444. // }
  15445. // stopwatch.Stop();
  15446. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  15447. //}
  15448. /// <summary>
  15449. /// 匹配op行程单
  15450. /// 接团信息列表 Page
  15451. /// </summary>
  15452. /// <param name="dto">团组列表请求dto</param>
  15453. /// <returns></returns>
  15454. [HttpPost]
  15455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15456. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  15457. {
  15458. var swatch = new Stopwatch();
  15459. swatch.Start();
  15460. #region 参数验证
  15461. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15462. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  15463. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15464. #region 页面操作权限验证
  15465. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  15466. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  15467. #endregion
  15468. #endregion
  15469. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  15470. {
  15471. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  15472. string sqlWhere = "";
  15473. if (!string.IsNullOrEmpty(dto.Country))
  15474. {
  15475. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  15476. }
  15477. if (!string.IsNullOrEmpty(dto.Area))
  15478. {
  15479. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  15480. }
  15481. if (!string.IsNullOrEmpty(dto.TeamName))
  15482. {
  15483. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  15484. }
  15485. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  15486. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  15487. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  15488. swatch.Stop();
  15489. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  15490. }
  15491. else
  15492. {
  15493. return Ok(JsonView(false, "查询失败"));
  15494. }
  15495. }
  15496. /// <summary>
  15497. /// 匹配op行程单
  15498. /// 行程单下载
  15499. /// </summary>
  15500. /// <param name="dto">团组列表请求dto</param>
  15501. /// <returns></returns>
  15502. [HttpPost]
  15503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15504. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  15505. {
  15506. #region 参数验证
  15507. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15508. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  15509. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15510. #region 页面操作权限验证
  15511. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  15512. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  15513. #endregion
  15514. #endregion
  15515. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  15516. {
  15517. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  15518. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  15519. }
  15520. else
  15521. {
  15522. return Ok(JsonView(false, "下载失败!"));
  15523. }
  15524. }
  15525. #endregion
  15526. #region 国家信息 数据 注释
  15527. //[HttpPost]
  15528. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  15529. //{
  15530. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  15531. // foreach (var item in dto)
  15532. // {
  15533. // infos.Add(new Grp_GroupsTaskAssignment()
  15534. // {
  15535. // DIId = item,
  15536. // CTId = 82,
  15537. // UId = 248,
  15538. // IsEnable = 1,
  15539. // CreateUserId = 233,
  15540. // CreateTime = DateTime.Now,
  15541. // IsDel = 0
  15542. // });
  15543. // infos.Add(new Grp_GroupsTaskAssignment()
  15544. // {
  15545. // DIId = item,
  15546. // CTId = 82,
  15547. // UId = 286,
  15548. // IsEnable = 1,
  15549. // CreateUserId = 233,
  15550. // CreateTime = DateTime.Now,
  15551. // IsDel = 0
  15552. // });
  15553. // }
  15554. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  15555. // return Ok("操作成功");
  15556. //}
  15557. //public class paramJsonDto
  15558. //{
  15559. // public List<CountriesInfo> str { get; set; }
  15560. //}
  15561. //[HttpPost]
  15562. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  15563. //{
  15564. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  15565. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  15566. // List<Sys_Cities> cities = new List<Sys_Cities>();
  15567. // List<Sys_Cities> districts = new List<Sys_Cities>();
  15568. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  15569. // _sqlSugar.BeginTran();
  15570. // int countitiesIndex = 0;
  15571. // foreach (var item in dto.str)
  15572. // {
  15573. // dynamic data = item.c;
  15574. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  15575. // if (data != null)
  15576. // {
  15577. // countitiesIndex++;
  15578. // foreach (var item1 in data)
  15579. // {
  15580. // string cnname = item1.cn;
  15581. // string enname = item1.en;
  15582. // Sys_Cities provinceInfo = new Sys_Cities()
  15583. // {
  15584. // CountriesId = countriesId,
  15585. // Name_CN = cnname,
  15586. // Name_EN = enname,
  15587. // ParentId = 0,
  15588. // IsCapital = 1,
  15589. // CreateUserId = 208,
  15590. // CreateTime = DateTime.Now,
  15591. // IsDel = 0
  15592. // };
  15593. // if (item1.lv == "province") //省份
  15594. // {
  15595. // provinceInfo.Level = 1;
  15596. // int provinceId = 0;
  15597. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  15598. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  15599. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  15600. // var data1 = item1.c;
  15601. // foreach (var item2 in data1)
  15602. // {
  15603. // if (item2.lv == "city")
  15604. // {
  15605. // string citycnname = item2.cn;
  15606. // string cityenname = item2.en;
  15607. // Sys_Cities cityInfo = new Sys_Cities()
  15608. // {
  15609. // CountriesId = countriesId,
  15610. // ParentId = provinceId,
  15611. // Level = 2,
  15612. // Name_CN = citycnname,
  15613. // Name_EN = cityenname,
  15614. // IsCapital = 1,
  15615. // CreateUserId = 208,
  15616. // CreateTime = DateTime.Now,
  15617. // IsDel = 0
  15618. // };
  15619. // if (item2.c != null)
  15620. // {
  15621. // int cityId = 0;
  15622. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  15623. // if (citiesInfo != null) cityId = citiesInfo.Id;
  15624. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  15625. // foreach (var item3 in item2.c)
  15626. // {
  15627. // if (item3.lv == "district")
  15628. // {
  15629. // var districtInfo = new Sys_Cities()
  15630. // {
  15631. // CountriesId = countriesId,
  15632. // Name_CN = item3.cn,
  15633. // Name_EN = item3.en,
  15634. // Level = 3,
  15635. // ParentId = cityId,
  15636. // IsCapital = 1,
  15637. // CreateUserId = 208,
  15638. // CreateTime = DateTime.Now,
  15639. // IsDel = 0
  15640. // };
  15641. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  15642. // //{
  15643. // districts.Add(districtInfo);
  15644. // //}
  15645. // }
  15646. // }
  15647. // }
  15648. // else
  15649. // {
  15650. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  15651. // //{
  15652. // cities.Add(cityInfo);
  15653. // //}
  15654. // }
  15655. // }
  15656. // }
  15657. // }
  15658. // else if (item1.lv == "city")//城市
  15659. // {
  15660. // provinceInfo.Level = 2;
  15661. // if (item1.c != null)
  15662. // {
  15663. // int cityId = 0;
  15664. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  15665. // if (citiesInfo != null) cityId = citiesInfo.Id;
  15666. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  15667. // foreach (var item3 in item1.c)
  15668. // {
  15669. // if (item3.lv == "district")
  15670. // {
  15671. // var districtInfo = new Sys_Cities()
  15672. // {
  15673. // CountriesId = countriesId,
  15674. // Name_CN = item3.cn,
  15675. // Name_EN = item3.en,
  15676. // Level = 3,
  15677. // ParentId = cityId,
  15678. // IsCapital = 1,
  15679. // CreateUserId = 208,
  15680. // CreateTime = DateTime.Now,
  15681. // IsDel = 0
  15682. // };
  15683. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  15684. // //{
  15685. // districts.Add(districtInfo);
  15686. // //}
  15687. // }
  15688. // }
  15689. // }
  15690. // else
  15691. // {
  15692. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  15693. // //{
  15694. // cities.Add(provinceInfo);
  15695. // //}
  15696. // }
  15697. // }
  15698. // }
  15699. // }
  15700. // }
  15701. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  15702. // cities = cities.Distinct().ToList();
  15703. // districts = districts.Distinct().ToList();
  15704. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  15705. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  15706. // cities.AddRange(districts);
  15707. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  15708. // //_sqlSugar.RollbackTran();
  15709. // _sqlSugar.CommitTran();
  15710. // return Ok(JsonView(false, "操作成功!"));
  15711. //}
  15712. //[HttpPost]
  15713. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  15714. //{
  15715. // List<CountitiesInfo> infos = dto.MyProperty;
  15716. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  15717. // _sqlSugar.BeginTran();
  15718. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  15719. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  15720. // foreach (var item in infos)
  15721. // {
  15722. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  15723. // if (countryInfo != null)
  15724. // {
  15725. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  15726. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  15727. // if (cityInfo1 != null)
  15728. // {
  15729. // cityInfo1.IsCapital = 0;
  15730. // cityInfos.Add(cityInfo1);
  15731. // }
  15732. // }
  15733. // }
  15734. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  15735. // .UpdateColumns(it => it.IsCapital)
  15736. // .WhereColumns(it => it.Id)
  15737. // .ExecuteCommand();
  15738. // //_sqlSugar.RollbackTran();
  15739. // _sqlSugar.CommitTran();
  15740. // return Ok(JsonView(false, "操作成功!"));
  15741. //}
  15742. //public class CounrtiesDto
  15743. //{
  15744. // public List<CountitiesInfo> MyProperty { get; set; }
  15745. //}
  15746. //public class CountitiesInfo
  15747. //{
  15748. // /// <summary>
  15749. // /// 圣约翰
  15750. // /// </summary>
  15751. // public string capital_name_chinese { get; set; }
  15752. // /// <summary>
  15753. // ///
  15754. // /// </summary>
  15755. // public string capital_name { get; set; }
  15756. // /// <summary>
  15757. // ///
  15758. // /// </summary>
  15759. // public string country_type { get; set; }
  15760. // /// <summary>
  15761. // /// 安提瓜和巴布达
  15762. // /// </summary>
  15763. // public string country_name_chinese { get; set; }
  15764. // /// <summary>
  15765. // /// 安提瓜和巴布达
  15766. // /// </summary>
  15767. // public string country_name_chinese_short { get; set; }
  15768. // /// <summary>
  15769. // /// 安提瓜和巴布达
  15770. // /// </summary>
  15771. // public string country_name_chinese_UN { get; set; }
  15772. // /// <summary>
  15773. // ///
  15774. // /// </summary>
  15775. // public string country_name_english_abbreviation { get; set; }
  15776. // /// <summary>
  15777. // ///
  15778. // /// </summary>
  15779. // public string country_name_english_formal { get; set; }
  15780. // /// <summary>
  15781. // ///
  15782. // /// </summary>
  15783. // public string country_name_english_UN { get; set; }
  15784. // /// <summary>
  15785. // ///
  15786. // /// </summary>
  15787. // public string continent_name { get; set; }
  15788. // /// <summary>
  15789. // ///
  15790. // /// </summary>
  15791. // public string subregion_name { get; set; }
  15792. // /// <summary>
  15793. // ///
  15794. // /// </summary>
  15795. // public string country_code2 { get; set; }
  15796. // /// <summary>
  15797. // ///
  15798. // /// </summary>
  15799. // public string country_code3 { get; set; }
  15800. // /// <summary>
  15801. // ///
  15802. // /// </summary>
  15803. // public string phone_code { get; set; }
  15804. //}
  15805. //public class CountriesInfo : BasicInfo
  15806. //{
  15807. // public List<CitiesInfo> c { get; set; }
  15808. //}
  15809. //public class CitiesInfo : BasicInfo
  15810. //{
  15811. // public List<AreaInfo> c { get; set; }
  15812. //}
  15813. //public class AreaInfo : BasicInfo
  15814. //{
  15815. // public List<AreaInfo> c { get; set; }
  15816. //}
  15817. //public class BasicInfo
  15818. //{
  15819. // public string code { get; set; }
  15820. // public string cn { get; set; }
  15821. // public string lv { get; set; }
  15822. // public string en { get; set; }
  15823. //}
  15824. #endregion
  15825. #region 查看邀请方
  15826. /// <summary>
  15827. /// 查看邀请方
  15828. /// 邀请方信息 Init
  15829. /// </summary>
  15830. /// <param name="dto"></param>
  15831. /// <returns></returns>
  15832. [HttpPost]
  15833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15834. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  15835. {
  15836. string sqlWhere = string.Empty;
  15837. if (!string.IsNullOrEmpty(dto.Search))
  15838. {
  15839. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  15840. }
  15841. string sql = string.Format($@"Select
  15842. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  15843. Id,
  15844. UnitName
  15845. From Res_InvitationOfficialActivityData
  15846. Where IsDel = 0
  15847. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  15848. RefAsync<int> total = 0;
  15849. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15850. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  15851. }
  15852. /// <summary>
  15853. /// 查看邀请方
  15854. /// 国家信息 Init
  15855. /// </summary>
  15856. /// <param name="dto"></param>
  15857. /// <returns></returns>
  15858. [HttpPost]
  15859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15860. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  15861. {
  15862. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  15863. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  15864. var diids = groupInfos.Select(it => it.Id).ToList();
  15865. List<string> countrys = new List<string>();
  15866. foreach (var item in country)
  15867. {
  15868. var data = _groupRepository.FormartTeamName(item);
  15869. var dataArray = _groupRepository.GroupSplitCountry(data);
  15870. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  15871. }
  15872. countrys = countrys.Distinct().ToList();
  15873. for (int i = 0; i < countrys.Count; i++)
  15874. {
  15875. string item = countrys[i];
  15876. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  15877. {
  15878. countrys.Remove(item);
  15879. i--;
  15880. }
  15881. }
  15882. RefAsync<int> total = 0;
  15883. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  15884. .Where(it => countrys.Contains(it.Name_CN))
  15885. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  15886. .Select(it => new { id = it.Id, name = it.Name_CN })
  15887. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15888. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  15889. }
  15890. /// <summary>
  15891. /// 查看邀请方
  15892. /// 城市信息 Init
  15893. /// </summary>
  15894. /// <param name="dto"></param>
  15895. /// <returns></returns>
  15896. [HttpPost]
  15897. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15898. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  15899. {
  15900. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  15901. RefAsync<int> total = 0;
  15902. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  15903. .Where(it => it.CountriesId == dto.CountiesId)
  15904. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  15905. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  15906. .Select(it => new { id = it.Id, name = it.Name_CN })
  15907. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15908. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  15909. }
  15910. /// <summary>
  15911. /// 查看邀请方
  15912. /// 团组名称 Init
  15913. /// </summary>
  15914. /// <param name="dto"></param>
  15915. /// <returns></returns>
  15916. [HttpPost]
  15917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15918. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  15919. {
  15920. var watch = new Stopwatch();
  15921. watch.Start();
  15922. RefAsync<int> total = 0;
  15923. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  15924. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  15925. .Where((oa, di) => oa.IsDel == 0)
  15926. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  15927. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  15928. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  15929. .Distinct()
  15930. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15931. watch.Stop();
  15932. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  15933. }
  15934. /// <summary>
  15935. /// 查看邀请方
  15936. /// 团组 & 邀请方信息
  15937. /// </summary>
  15938. /// <param name="dto"></param>
  15939. /// <returns></returns>
  15940. [HttpPost]
  15941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15942. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  15943. {
  15944. var watch = new Stopwatch();
  15945. watch.Start();
  15946. RefAsync<int> total = 0;
  15947. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  15948. .AS("Grp_DelegationInfo")
  15949. .Includes(x => x.InvitingInfos)
  15950. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  15951. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  15952. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  15953. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  15954. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  15955. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  15956. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15957. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  15958. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  15959. infos.ForEach(x =>
  15960. {
  15961. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  15962. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  15963. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  15964. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  15965. });
  15966. watch.Stop();
  15967. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  15968. }
  15969. #endregion
  15970. #region 报批行程
  15971. /// <summary>
  15972. /// 报批行程初始化
  15973. /// </summary>
  15974. /// <param name="dto"></param>
  15975. /// <returns></returns>
  15976. [HttpPost]
  15977. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  15978. {
  15979. const int chiNumber = 5;
  15980. var jw = JsonView(false);
  15981. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  15982. var group = groupList.First();
  15983. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  15984. group = groupList.First(x => x.Id == diid);
  15985. if (group == null)
  15986. {
  15987. jw.Msg = "暂无团组!";
  15988. return Ok(jw);
  15989. }
  15990. var data = new
  15991. {
  15992. groupList = groupList.Select(x => new
  15993. {
  15994. x.TeamName,
  15995. x.Id
  15996. }),
  15997. content = new ArrayList(),
  15998. groupInfo = new
  15999. {
  16000. group.VisitDays,
  16001. group.TourCode,
  16002. group.VisitPNumber,
  16003. group.TeamName,
  16004. group.Id,
  16005. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  16006. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  16007. },
  16008. };
  16009. var resultArr = new ArrayList();
  16010. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  16011. if (content.Count == 0)
  16012. {
  16013. var stay = "-";
  16014. var cityPath = "-";
  16015. //添加城市路径以及住宿地
  16016. //黑屏代码数据
  16017. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  16018. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  16019. {
  16020. jw = JsonView(true, "黑屏代码有误!", data);
  16021. return Ok(jw);
  16022. }
  16023. foreach (DataRow row in dtBlack.Rows)
  16024. {
  16025. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  16026. {
  16027. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  16028. return Ok(jw);
  16029. }
  16030. }
  16031. //黑屏代码获取时间区间
  16032. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  16033. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  16034. _sqlSugar.BeginTran();
  16035. for (int i = 0; i < timeArr.Count; i++)
  16036. {
  16037. stay = "-";
  16038. cityPath = "-";
  16039. DateTime NewData = DateTime.Parse(timeArr[i]);
  16040. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  16041. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  16042. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  16043. if (tbSelect.Length > 0)
  16044. {
  16045. List<string> threeCodeStr = new List<string>();
  16046. foreach (var item in tbSelect)
  16047. {
  16048. var threeCode = item["Three"].ToString() ?? "";
  16049. if (threeCode.Length == 6)
  16050. {
  16051. var start = threeCode.Substring(0, 3);
  16052. var end = threeCode.Substring(3, 3);
  16053. if (threeCodeStr.Count == 0)
  16054. {
  16055. threeCodeStr.Add(start);
  16056. threeCodeStr.Add(end);
  16057. }
  16058. else
  16059. {
  16060. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  16061. {
  16062. threeCodeStr.Add(end);
  16063. }
  16064. else
  16065. {
  16066. threeCodeStr.Add(start);
  16067. threeCodeStr.Add(end);
  16068. }
  16069. }
  16070. }
  16071. }
  16072. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  16073. var last = threeCodeStr.Last();
  16074. foreach (var item in threeCodeStr)
  16075. {
  16076. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  16077. if (item.Equals(last))
  16078. {
  16079. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  16080. }
  16081. }
  16082. cityPath = cityPath.Trim('-');
  16083. }
  16084. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  16085. appro.Diid = diid ?? -1;
  16086. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  16087. appro.Id = thisId;
  16088. appro.CreateUserId = dto.UserId;
  16089. appro.CreateTime = DateTime.Now;
  16090. content.Add(appro);
  16091. }
  16092. _sqlSugar.CommitTran();
  16093. }
  16094. foreach (var x in content)
  16095. {
  16096. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  16097. if (chiList.Count < chiNumber)
  16098. {
  16099. for (int i = chiList.Count; i < chiNumber; i++)
  16100. {
  16101. chiList.Add(new Grp_ApprovalTravelDetails());
  16102. }
  16103. }
  16104. resultArr.Add(new
  16105. {
  16106. x.Id,
  16107. x.Date,
  16108. x.Diid,
  16109. chiList = chiList.Select(x1 => new
  16110. {
  16111. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  16112. x1.Details,
  16113. x1.ParentId,
  16114. x1.Id
  16115. })
  16116. });
  16117. }
  16118. data = data with
  16119. {
  16120. content = resultArr,
  16121. };
  16122. jw = JsonView(true, "获取成功!", data);
  16123. return Ok(jw);
  16124. }
  16125. /// <summary>
  16126. /// 报批行程删除
  16127. /// </summary>
  16128. /// <param name="dto"></param>
  16129. /// <returns></returns>
  16130. [HttpPost]
  16131. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  16132. {
  16133. var jw = JsonView(false);
  16134. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  16135. if (group == null)
  16136. {
  16137. jw.Msg = "团组参数有误!";
  16138. return Ok(jw);
  16139. }
  16140. try
  16141. {
  16142. _sqlSugar.BeginTran();
  16143. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  16144. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  16145. {
  16146. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  16147. DeleteUserId = dto.uesrId,
  16148. IsDel = 1
  16149. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  16150. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  16151. {
  16152. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  16153. DeleteUserId = dto.uesrId,
  16154. IsDel = 1
  16155. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  16156. _sqlSugar.CommitTran();
  16157. jw = JsonView(true, "删除成功");
  16158. }
  16159. catch (Exception ex)
  16160. {
  16161. jw = JsonView(false, ex.Message);
  16162. }
  16163. return Ok(jw);
  16164. }
  16165. /// <summary>
  16166. /// 报批行程保存
  16167. /// </summary>
  16168. /// <param name="dto"></param>
  16169. /// <returns></returns>
  16170. [HttpPost]
  16171. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  16172. {
  16173. var jw = JsonView(false);
  16174. var Find = dto.Arr.Find(x => x.id == 0);
  16175. if (Find != null)
  16176. {
  16177. jw.Msg = "生成的ID为0!";
  16178. return Ok(jw);
  16179. }
  16180. foreach (var item in dto.Arr)
  16181. {
  16182. foreach (var chi in item.chiList)
  16183. {
  16184. if (chi.parentId == 0)
  16185. {
  16186. chi.parentId = item.id;
  16187. }
  16188. }
  16189. }
  16190. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  16191. _sqlSugar.BeginTran();
  16192. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  16193. {
  16194. var parentIds = dto.Arr.Select(x => x.id).ToList();
  16195. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  16196. {
  16197. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  16198. DeleteUserId = dto.UserId,
  16199. IsDel = 1
  16200. }).ExecuteCommand();
  16201. }
  16202. try
  16203. {
  16204. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  16205. {
  16206. CreateTime = DateTime.Now,
  16207. CreateUserId = dto.UserId,
  16208. Details = x.details,
  16209. ParentId = x.parentId,
  16210. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  16211. Remark = "",
  16212. IsDel = 0
  16213. }).ToList()).ExecuteCommand();
  16214. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  16215. {
  16216. Id = x.id,
  16217. Details = x.details,
  16218. ParentId = x.parentId,
  16219. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  16220. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  16221. {
  16222. Details = x.Details,
  16223. ParentId = x.ParentId,
  16224. Time = x.Time
  16225. }).ExecuteCommand();
  16226. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  16227. {
  16228. Id = x.id,
  16229. Date = x.date,
  16230. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  16231. {
  16232. Date = x.Date
  16233. }).ExecuteCommand();
  16234. _sqlSugar.CommitTran();
  16235. jw = JsonView(true, "保存成功!");
  16236. }
  16237. catch (Exception ex)
  16238. {
  16239. _sqlSugar.RollbackTran();
  16240. jw = JsonView(false, "保存失败!" + ex.Message);
  16241. }
  16242. return Ok(jw);
  16243. }
  16244. /// <summary>
  16245. /// 报批行程生成
  16246. /// </summary>
  16247. /// <param name="dto"></param>
  16248. /// <returns></returns>
  16249. [HttpPost]
  16250. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  16251. {
  16252. var jw = JsonView(false);
  16253. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  16254. if (group == null)
  16255. {
  16256. jw.Msg = "暂无该团组!";
  16257. return Ok(jw);
  16258. }
  16259. //黑屏代码数据
  16260. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  16261. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  16262. {
  16263. jw.Msg = "黑屏代码有误!";
  16264. return Ok(jw);
  16265. }
  16266. foreach (DataRow row in dtBlack.Rows)
  16267. {
  16268. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  16269. {
  16270. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  16271. return Ok(jw);
  16272. }
  16273. }
  16274. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  16275. var resultArr = new ArrayList();
  16276. if (officialActivitiesArr.Count == 0)
  16277. {
  16278. jw.Msg = "暂无公务出访信息!";
  16279. return Ok(jw);
  16280. }
  16281. try
  16282. {
  16283. _sqlSugar.BeginTran();
  16284. DeleteApprovalJourney(new
  16285. Domain.Dtos.Groups.DeleteApprovalJourney
  16286. {
  16287. Diid = dto.Diid,
  16288. uesrId = dto.Userid
  16289. });
  16290. var stay = "-";
  16291. var cityPath = "-";
  16292. //添加城市路径以及住宿地
  16293. //黑屏代码获取时间区间
  16294. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  16295. var empty = "【未收入该三字码!请机票同事录入】";
  16296. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  16297. for (int i = 0; i < timeArr.Count; i++)
  16298. {
  16299. stay = "-";
  16300. cityPath = "-";
  16301. var chiarr = new List<Grp_ApprovalTravelDetails>();
  16302. DateTime NewData = DateTime.Parse(timeArr[i]);
  16303. 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();
  16304. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  16305. if (tbSelect.Length > 0)
  16306. {
  16307. List<string> threeCodeStr = new List<string>();
  16308. bool isTrade = false;
  16309. string trip = string.Empty;
  16310. var rowLast = tbSelect.Last();
  16311. var rowFirst = tbSelect.First();
  16312. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  16313. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  16314. var takeOffTime = DateTime.Parse(timeArr[i]);
  16315. var fallToTime = DateTime.Parse(timeArr[i]);
  16316. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  16317. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  16318. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  16319. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  16320. foreach (var item in tbSelect)
  16321. {
  16322. var start = string.Empty;
  16323. var end = string.Empty;
  16324. var threeCode = item["Three"].ToString() ?? "";
  16325. if (threeCode.Length == 6)
  16326. {
  16327. start = threeCode.Substring(0, 3);
  16328. end = threeCode.Substring(3, 3);
  16329. if (threeCodeStr.Count == 0)
  16330. {
  16331. threeCodeStr.Add(start);
  16332. threeCodeStr.Add(end);
  16333. }
  16334. else
  16335. {
  16336. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  16337. {
  16338. threeCodeStr.Add(end);
  16339. }
  16340. else
  16341. {
  16342. threeCodeStr.Add(start);
  16343. threeCodeStr.Add(end);
  16344. }
  16345. }
  16346. }
  16347. //处理机票信息
  16348. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  16349. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  16350. if (start_Object == null)
  16351. {
  16352. start_Object = new Res_ThreeCode()
  16353. {
  16354. AirPort = empty,
  16355. AirPort_En = empty,
  16356. City = empty,
  16357. Country = empty,
  16358. Four = empty,
  16359. Three = empty,
  16360. };
  16361. }
  16362. if (end_Object == null)
  16363. {
  16364. end_Object = new Res_ThreeCode()
  16365. {
  16366. AirPort = empty,
  16367. AirPort_En = empty,
  16368. City = empty,
  16369. Country = empty,
  16370. Four = empty,
  16371. Three = empty,
  16372. };
  16373. }
  16374. //机型判断
  16375. string airModel = item["AirModel"].ToString();
  16376. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  16377. string flightTime = item["FlightTime"].ToString();
  16378. if (flightTime!.Contains(":"))
  16379. {
  16380. flightTime = flightTime.Replace(":", "小时");
  16381. flightTime += "分钟";
  16382. }
  16383. if (flightTime.Contains("H"))
  16384. {
  16385. flightTime = flightTime.Replace("H", "小时");
  16386. }
  16387. if (flightTime.Contains("M"))
  16388. {
  16389. flightTime = flightTime.Replace("M", "分钟");
  16390. }
  16391. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  16392. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  16393. {
  16394. flightTime = flightDataTime.Hour > 0
  16395. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  16396. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  16397. ? flightDataTime.Minute.ToString() + "分钟" : "";
  16398. }
  16399. //航班号
  16400. string flightcode = item["Fliagtcode"].ToString();
  16401. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  16402. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  16403. if (aircompany == null)
  16404. {
  16405. aircompany = new Res_AirCompany
  16406. {
  16407. CnName = hsEmpty,
  16408. EnName = hsEmpty,
  16409. ShortCode = hsEmpty,
  16410. };
  16411. }
  16412. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  16413. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  16414. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  16415. if (isTrade)
  16416. {
  16417. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  16418. }
  16419. else
  16420. {
  16421. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  16422. }
  16423. }
  16424. chiarr.Add(new Grp_ApprovalTravelDetails
  16425. {
  16426. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  16427. CreateTime = DateTime.Now,
  16428. CreateUserId = dto.Userid,
  16429. ParentId = 0,
  16430. Details = trip
  16431. });
  16432. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  16433. var last = threeCodeStr.Last();
  16434. foreach (var item in threeCodeStr)
  16435. {
  16436. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  16437. if (item.Equals(last))
  16438. {
  16439. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  16440. }
  16441. }
  16442. cityPath = cityPath.Trim('-');
  16443. }
  16444. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  16445. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  16446. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  16447. appro.Diid = dto.Diid;
  16448. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  16449. appro.Id = thisId;
  16450. appro.CreateUserId = dto.Userid;
  16451. appro.CreateTime = DateTime.Now;
  16452. foreach (var item in gwinfo)
  16453. {
  16454. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  16455. chi.Details = "拜访" + item.Client;
  16456. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  16457. {
  16458. chi.Details += "," + item.ReqSample;
  16459. }
  16460. chi.ParentId = thisId;
  16461. chi.Time = item.Time;
  16462. chiarr.Add(chi);
  16463. }
  16464. if (chiarr.Count < 5)
  16465. {
  16466. for (int j = chiarr.Count; j < 5; j++)
  16467. {
  16468. chiarr.Add(new
  16469. Grp_ApprovalTravelDetails());
  16470. }
  16471. }
  16472. resultArr.Add(new
  16473. {
  16474. appro.Id,
  16475. appro.Date,
  16476. appro.Diid,
  16477. chiList = chiarr.Select(x1 => new
  16478. {
  16479. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  16480. x1.Details,
  16481. x1.ParentId,
  16482. x1.Id
  16483. })
  16484. });
  16485. }
  16486. _sqlSugar.CommitTran();
  16487. jw = JsonView(true, "生成成功!", resultArr);
  16488. }
  16489. catch (Exception ex)
  16490. {
  16491. jw.Code = 400;
  16492. jw.Msg = "生成失败!" + ex.Message;
  16493. }
  16494. return Ok(jw);
  16495. }
  16496. /// <summary>
  16497. /// 报批行程word导出
  16498. /// </summary>
  16499. /// <param name="dto"></param>
  16500. /// <returns></returns>
  16501. [HttpPost]
  16502. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  16503. {
  16504. var jw = JsonView(false);
  16505. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  16506. if (group == null)
  16507. {
  16508. jw.Msg = "暂无该团组!";
  16509. return Ok(jw);
  16510. }
  16511. //模板路径
  16512. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  16513. //载入模板
  16514. Document doc = new Document(tempPath);
  16515. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16516. //获取所填表格的序数
  16517. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16518. Aspose.Words.Tables.Row titleRowClone = null;
  16519. Aspose.Words.Tables.Row CenterRowClone = null;
  16520. int index = 0;
  16521. int indexChi = 0;
  16522. int SetIndex = 0;
  16523. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  16524. //获取数据,放到datatable
  16525. foreach (var item in ApprovalTravelArr)
  16526. {
  16527. if (index > 0)
  16528. {
  16529. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  16530. tableOne.AppendChild(titleRowClone);
  16531. }
  16532. var textTime = item.Date;
  16533. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  16534. SetCells(tableOne, doc, SetIndex, 0, textTime);
  16535. SetIndex++;
  16536. if (ChiRep.Count > 0)
  16537. {
  16538. foreach (var itemChi in ChiRep)
  16539. {
  16540. var txtTime = itemChi.Time;
  16541. var txtDetail = itemChi.Details;
  16542. if (indexChi > 0)
  16543. {
  16544. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  16545. tableOne.AppendChild(CenterRowClone);
  16546. }
  16547. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  16548. {
  16549. SetCells(tableOne, doc, SetIndex, 0, "");
  16550. SetCells(tableOne, doc, SetIndex, 1, "");
  16551. indexChi++;
  16552. SetIndex++;
  16553. break;
  16554. }
  16555. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  16556. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  16557. indexChi++;
  16558. SetIndex++;
  16559. }
  16560. }
  16561. else
  16562. {
  16563. if (indexChi > 0)
  16564. {
  16565. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  16566. tableOne.AppendChild(CenterRowClone);
  16567. }
  16568. SetCells(tableOne, doc, SetIndex, 0, "");
  16569. SetCells(tableOne, doc, SetIndex, 1, "");
  16570. indexChi++;
  16571. SetIndex++;
  16572. }
  16573. index++;
  16574. }
  16575. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  16576. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  16577. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  16578. jw.Code = 200;
  16579. jw.Msg = "";
  16580. return Ok(jw);
  16581. }
  16582. private string intToString(int numberVal)
  16583. {
  16584. string numberval = numberVal.ToString();
  16585. Dictionary<char, string> Number = new Dictionary<char, string>();
  16586. Number.Add('1', "一");
  16587. Number.Add('2', "二");
  16588. Number.Add('3', "三");
  16589. Number.Add('4', "四");
  16590. Number.Add('5', "五");
  16591. Number.Add('6', "六");
  16592. Number.Add('7', "七");
  16593. Number.Add('8', "八");
  16594. Number.Add('9', "九");
  16595. string stringNumberVal = string.Empty;
  16596. for (int i = 0; i < numberval.Length; i++)
  16597. {
  16598. if (i == 0)
  16599. {
  16600. stringNumberVal += Number[numberval[i]];
  16601. }
  16602. else if (i >= 1)
  16603. {
  16604. if (numberval[i] == '0')
  16605. {
  16606. stringNumberVal = "十";
  16607. }
  16608. else
  16609. {
  16610. stringNumberVal += "十" + Number[numberval[i]];
  16611. }
  16612. }
  16613. }
  16614. return stringNumberVal;
  16615. }
  16616. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  16617. {
  16618. //获取table中的某个单元格,从0开始
  16619. Cell lshCell = table.Rows[rows].Cells[cells];
  16620. //将单元格中段落移除
  16621. foreach (Node item in lshCell.Paragraphs)
  16622. {
  16623. lshCell.Paragraphs.Remove(item);
  16624. }
  16625. if (val.Contains("\r\n"))
  16626. {
  16627. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  16628. foreach (var item in spArr)
  16629. {
  16630. //新建一个段落
  16631. Paragraph p = new Paragraph(doc);
  16632. var r = new Run(doc, item);
  16633. //把设置的值赋给之前新建的段落
  16634. p.AppendChild(r);
  16635. //将此段落加到单元格内
  16636. lshCell.AppendChild(p);
  16637. }
  16638. }
  16639. else
  16640. {
  16641. //新建一个段落
  16642. Paragraph p = new Paragraph(doc);
  16643. var r = new Run(doc, val);
  16644. //把设置的值赋给之前新建的段落
  16645. p.AppendChild(r);
  16646. //将此段落加到单元格内
  16647. lshCell.AppendChild(p);
  16648. }
  16649. }
  16650. [HttpPost]
  16651. public async Task<IActionResult> ServerHttp(string paramStr)
  16652. {
  16653. paramStr = paramStr.TrimEnd('\'');
  16654. paramStr = paramStr.TrimStart('\'');
  16655. JsonView jw = JsonView(false);
  16656. JObject param = JObject.Parse(paramStr);
  16657. if (!param.ContainsKey("url"))
  16658. {
  16659. jw.Msg = "url null";
  16660. return Ok(jw);
  16661. }
  16662. string url = param["url"]!.ToString();
  16663. var methon = "get";
  16664. Dictionary<string, string> headValues = null;
  16665. string bodyStr = string.Empty;
  16666. if (param.ContainsKey("methon"))
  16667. {
  16668. methon = param["methon"]!.ToString().ToLower();
  16669. }
  16670. if (param.ContainsKey("header"))
  16671. {
  16672. var header = param["header"]!.ToString();
  16673. JObject headerJobject = JObject.Parse(header);
  16674. headValues = new Dictionary<string, string>();
  16675. foreach (JProperty item in headerJobject.Properties())
  16676. {
  16677. var value = item.Value.ToString();
  16678. var head = item.Path;
  16679. headValues.Add(head, value);
  16680. }
  16681. }
  16682. HttpClient client = new HttpClient();
  16683. string responseString = string.Empty;
  16684. StringContent content = null;
  16685. if (headValues != null)
  16686. {
  16687. foreach (var item in headValues.Keys)
  16688. {
  16689. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  16690. {
  16691. if (param.ContainsKey("body"))
  16692. {
  16693. bodyStr = param["body"]!.ToString();
  16694. }
  16695. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  16696. }
  16697. else
  16698. {
  16699. client.DefaultRequestHeaders.Add(item, headValues[item]);
  16700. }
  16701. }
  16702. }
  16703. try
  16704. {
  16705. if (methon == "get")
  16706. {
  16707. responseString = await client.GetStringAsync(url);
  16708. }
  16709. else if (methon == "post")
  16710. {
  16711. var request = new HttpRequestMessage(HttpMethod.Post, url)
  16712. {
  16713. Content = content
  16714. };
  16715. var response = await client.SendAsync(request);
  16716. try
  16717. {
  16718. Stream responseStream = await response.Content.ReadAsStreamAsync();
  16719. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  16720. {
  16721. using (StreamReader reader = new StreamReader(gzipStream))
  16722. {
  16723. responseString = await reader.ReadToEndAsync();
  16724. }
  16725. }
  16726. }
  16727. catch (Exception)
  16728. {
  16729. responseString = await response.Content.ReadAsStringAsync();
  16730. }
  16731. }
  16732. else
  16733. {
  16734. responseString = "methon error";
  16735. }
  16736. jw = JsonView(true, "success", responseString);
  16737. }
  16738. catch (Exception ex)
  16739. {
  16740. jw.Msg = "error " + ex.Message;
  16741. jw.Data = ex.StackTrace;
  16742. }
  16743. finally
  16744. {
  16745. client.Dispose();
  16746. }
  16747. return Ok(jw);
  16748. }
  16749. #endregion
  16750. #region 团组接待意见调查
  16751. /// <summary>
  16752. /// 团组接待意见调查 - 信息管理
  16753. /// 基础数据(团组)
  16754. /// </summary>
  16755. /// <param name="dto"></param>
  16756. /// <returns></returns>
  16757. [HttpGet]
  16758. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16759. public async Task<IActionResult> OpinionaireInit()
  16760. {
  16761. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  16762. .Select(x => new
  16763. {
  16764. x.Id,
  16765. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  16766. })
  16767. .OrderByDescending(x => x.Id)
  16768. .ToListAsync();
  16769. return Ok(JsonView(groupData, groupData.Count));
  16770. }
  16771. /// <summary>
  16772. /// 团组接待意见调查 - 信息管理
  16773. /// 列表
  16774. /// </summary>
  16775. /// <param name="groupId"></param>
  16776. /// <returns></returns>
  16777. [HttpGet("{groupId}")]
  16778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16779. public async Task<IActionResult> OpinionaireManageList(int groupId)
  16780. {
  16781. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  16782. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  16783. .Select(x => new
  16784. {
  16785. x.Id,
  16786. x.TourGuideName,
  16787. x.CityName,
  16788. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  16789. x.CreateTime
  16790. })
  16791. .OrderBy(x => x.Id)
  16792. .ToListAsync();
  16793. return Ok(JsonView(data));
  16794. }
  16795. /// <summary>
  16796. /// 团组接待意见调查 - 信息管理
  16797. /// 保存
  16798. /// </summary>
  16799. /// <param name="dto"></param>
  16800. /// <returns></returns>
  16801. [HttpPost]
  16802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16803. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  16804. {
  16805. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  16806. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  16807. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  16808. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  16809. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  16810. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  16811. _opinionaireRep.BeginTran();
  16812. if (addData != null && addData.Count > 0)
  16813. {
  16814. foreach (var item in addData)
  16815. {
  16816. item.CreateUserId = currUserInfo.UserId;
  16817. item.DiId = dto.DiId;
  16818. }
  16819. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  16820. }
  16821. if (updData != null && updData.Count > 0)
  16822. {
  16823. var upd = await _opinionaireRep._sqlSugar
  16824. .Updateable(updData)
  16825. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  16826. .WhereColumns(x => new { x.Id })
  16827. .ExecuteCommandAsync();
  16828. }
  16829. _opinionaireRep.CommitTran();
  16830. return Ok(JsonView("操作成功!"));
  16831. }
  16832. /// <summary>
  16833. /// 团组接待意见调查 - 信息管理
  16834. /// 删除
  16835. /// </summary>
  16836. /// <param name="id"></param>
  16837. /// <returns></returns>
  16838. [HttpDelete("{id}")]
  16839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16840. public async Task<IActionResult> OpinionaireManageDel(int id)
  16841. {
  16842. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  16843. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  16844. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  16845. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  16846. if (!del) return Ok(JsonView("操作失败!"));
  16847. return Ok(JsonView("操作成功!"));
  16848. }
  16849. /// <summary>
  16850. /// 团组接待意见调查 - 用户
  16851. /// 列表
  16852. /// </summary>
  16853. /// <param name="id"></param>
  16854. /// <returns></returns>
  16855. [HttpGet("{diId}")]
  16856. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16857. public async Task<IActionResult> OpinionaireUserList(int diId)
  16858. {
  16859. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  16860. var sql = string.Format(@"
  16861. SELECT
  16862. o.Id,
  16863. o.DiId,
  16864. di.TeamName AS 'GroupName',
  16865. di.VisitPNumber AS 'PeopleNumber',
  16866. di.ClientName AS 'LeadGroup',
  16867. di.VisitCountry AS 'Travel',
  16868. di.VisitDays AS 'Days',
  16869. o.CityName,
  16870. o.TourGuideName,
  16871. o.Catering,
  16872. o.CateringReason,
  16873. o.Stay,
  16874. o.StayReason,
  16875. o.[Route],
  16876. o.RouteReason,
  16877. o.OfficialActivity,
  16878. o.OfficialActivityReason,
  16879. o.TourGuide,
  16880. o.TourGuideReason,
  16881. o.[Translate],
  16882. o.TranslateReason,
  16883. o.Trip,
  16884. o.TripReason,
  16885. o.ESFileName,
  16886. o.SignatureDate,
  16887. o.Remark
  16888. FROM
  16889. Grp_Opinionaire o
  16890. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  16891. WHERE
  16892. o.IsDel = 0
  16893. AND o.DiId = {0}
  16894. ORDER BY
  16895. o.Id ASC", diId);
  16896. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  16897. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  16898. return Ok(JsonView(data));
  16899. }
  16900. /// <summary>
  16901. /// 团组接待意见调查 - 用户
  16902. /// 保存
  16903. /// </summary>
  16904. /// <param name="id"></param>
  16905. /// <returns></returns>
  16906. [HttpPost]
  16907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16908. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  16909. {
  16910. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  16911. foreach (var item in dto)
  16912. {
  16913. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  16914. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  16915. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  16916. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  16917. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  16918. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  16919. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  16920. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  16921. }
  16922. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  16923. if (!Directory.Exists(filePathBase))
  16924. {
  16925. Directory.CreateDirectory(filePathBase);
  16926. }
  16927. #region 上传文件
  16928. var filePaths = new List<string>();
  16929. foreach (var item in dto)
  16930. {
  16931. var file = item.File;
  16932. // 将文件保存到指定位置
  16933. var filePath = Path.Combine(filePathBase, file.FileName);
  16934. using (var stream = new FileStream(filePath, FileMode.Create))
  16935. {
  16936. await file.CopyToAsync(stream);
  16937. }
  16938. //验证文件是否上传成功
  16939. if (!System.IO.File.Exists(filePath))
  16940. {
  16941. foreach (var filePathStr in filePaths)
  16942. {
  16943. System.IO.File.Delete(filePathStr);
  16944. }
  16945. return Ok(JsonView(false, "文件上传失败!"));
  16946. }
  16947. item.ESFileName = file.FileName;
  16948. }
  16949. #endregion
  16950. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  16951. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  16952. .UpdateColumns(x => new
  16953. {
  16954. x.Catering,
  16955. x.CateringReason,
  16956. x.Stay,
  16957. x.StayReason,
  16958. x.Route,
  16959. x.RouteReason,
  16960. x.OfficialActivity,
  16961. x.OfficialActivityReason,
  16962. x.TourGuide,
  16963. x.TourGuideReason,
  16964. x.Translate,
  16965. x.TranslateReason,
  16966. x.Trip,
  16967. x.TripReason,
  16968. x.ESFileName,
  16969. x.SignatureDate,
  16970. x.Remark
  16971. })
  16972. .WhereColumns(x => new { x.Id })
  16973. .ExecuteCommandAsync();
  16974. if (upd < 1)
  16975. {
  16976. foreach (var filePathStr in filePaths)
  16977. {
  16978. System.IO.File.Delete(filePathStr);
  16979. }
  16980. return Ok(JsonView(false));
  16981. }
  16982. return Ok(JsonView(true));
  16983. }
  16984. #endregion
  16985. // /// <summary>
  16986. // ///
  16987. // /// </summary>
  16988. // /// <param name="_dto"></param>
  16989. // /// <returns></returns>
  16990. // [HttpPost]
  16991. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16992. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  16993. // {
  16994. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  16995. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  16996. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  16997. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  16998. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  16999. // dic_psg.Add("客人", 974);
  17000. // dic_psg.Add("司机", 975);
  17001. // dic_psg.Add("导游", 976);
  17002. // dic_psg.Add("公司内部人员", 977);
  17003. // dic_psg.Add("司机/导游/公司内部人员", 978);
  17004. // foreach (var item in list_visa)
  17005. // {
  17006. // Grp_VisaInfo temp = new Grp_VisaInfo();
  17007. // temp.Id = item.Id;
  17008. // temp.DIId = item.DIId;
  17009. // temp.VisaClient = item.VisaClient;
  17010. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  17011. // temp.VisaCurrency = item.VisaCurrency;
  17012. // temp.IsThird = item.IsThird;
  17013. // if (dic_psg.ContainsKey(item.PassengerType))
  17014. // {
  17015. // temp.PassengerType = dic_psg[item.PassengerType];
  17016. // }
  17017. // else {
  17018. // temp.PassengerType = -1;
  17019. // }
  17020. // temp.VisaNumber = item.VisaNumber;
  17021. // temp.VisaFreeNumber = item.VisaFreeNumber;
  17022. // temp.CreateUserId = item.Operators;
  17023. // DateTime dt_ct;
  17024. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  17025. // if (b_ct)
  17026. // {
  17027. // temp.CreateTime = dt_ct;
  17028. // }
  17029. // else
  17030. // {
  17031. // temp.CreateTime = DateTime.Now;
  17032. // }
  17033. // temp.DeleteTime = "";
  17034. // temp.DeleteUserId = 0;
  17035. // temp.Remark = item.Remark;
  17036. // if (string.IsNullOrEmpty(temp.Remark)) {
  17037. // temp.Remark = "";
  17038. // }
  17039. // temp.IsDel = item.IsDel;
  17040. // temp.VisaDescription = item.VisaAttachment;
  17041. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  17042. //([Id]
  17043. // ,[DIId]
  17044. // ,[VisaClient]
  17045. // ,[VisaPrice]
  17046. // ,[VisaCurrency]
  17047. // ,[IsThird]
  17048. // ,[PassengerType]
  17049. // ,[VisaNumber]
  17050. // ,[VisaFreeNumber]
  17051. // ,[CreateUserId]
  17052. // ,[CreateTime]
  17053. // ,[DeleteTime]
  17054. // ,[DeleteUserId]
  17055. // ,[Remark]
  17056. // ,[IsDel]
  17057. // ,[visaDescription])
  17058. // VALUES
  17059. // ({0},{1},'{2}',{3},{4}
  17060. //,{5},{6},{7},{8},{9}
  17061. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  17062. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  17063. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  17064. //);
  17065. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  17066. // }
  17067. // return Ok(JsonView(true, "操作成功!"));
  17068. // }
  17069. /// <summary>
  17070. /// 123132123
  17071. /// </summary>
  17072. /// <param name="_dto"></param>
  17073. /// <returns></returns>
  17074. [HttpPost]
  17075. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17076. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  17077. {
  17078. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  17079. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  17080. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  17081. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  17082. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  17083. dicDetail.Add(789, 1034);
  17084. dicDetail.Add(790, 1035);
  17085. dicDetail.Add(791, 1036);
  17086. dicDetail.Add(792, 1037);
  17087. dicDetail.Add(793, 1038);
  17088. dicDetail.Add(794, 1039);
  17089. dicDetail.Add(795, 1040);
  17090. dicDetail.Add(796, 1041);
  17091. dicDetail.Add(797, 1042);
  17092. dicDetail.Add(798, 1043);
  17093. dicDetail.Add(801, 1044);
  17094. dicDetail.Add(802, 1045);
  17095. dicDetail.Add(803, 1046);
  17096. Dictionary<int, int> dic = new Dictionary<int, int>();
  17097. dic.Add(806, 1027);
  17098. dic.Add(807, 1028);
  17099. dic.Add(808, 1029);
  17100. dic.Add(809, 1030);
  17101. dic.Add(810, 1031);
  17102. dic.Add(811, 1032);
  17103. dic.Add(812, 1033);
  17104. foreach (var item in list_visa)
  17105. {
  17106. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  17107. temp.Coefficient = item.coefficient;
  17108. DateTime dtCrt;
  17109. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  17110. if (b1)
  17111. {
  17112. temp.CreateTime = dtCrt;
  17113. }
  17114. else
  17115. {
  17116. temp.CreateTime = DateTime.Now;
  17117. }
  17118. temp.CreateUserId = item.Operators;
  17119. temp.DeleteTime = "";
  17120. temp.DeleteUserId = 0;
  17121. temp.DiId = int.Parse(item.DIID);
  17122. temp.FilePath = item.FilePath;
  17123. temp.IsDel = item.IsDel;
  17124. temp.Price = item.Price;
  17125. temp.PriceCount = 1;
  17126. temp.PriceCurrency = item.Currency;
  17127. int detailId = 0;
  17128. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  17129. {
  17130. detailId = dicDetail[item.PriceTypeDetail];
  17131. }
  17132. temp.PriceDetailType = detailId;
  17133. temp.PriceDt = DateTime.Now;
  17134. temp.PriceName = item.PriceName;
  17135. temp.PriceSum = item.Price;
  17136. int tid = 0;
  17137. if (dic.ContainsKey(item.PriceType))
  17138. {
  17139. tid = dic[item.PriceType];
  17140. }
  17141. temp.PriceType = tid;
  17142. temp.Remark = item.Remark;
  17143. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  17144. }
  17145. return Ok(JsonView(true, "操作成功!"));
  17146. }
  17147. [HttpPost]
  17148. public IActionResult TimeTest()
  17149. {
  17150. var jw = JsonView(false, "error");
  17151. _sqlSugar.BeginTran();
  17152. try
  17153. {
  17154. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  17155. .Select(x => new Crm_NewClientData
  17156. {
  17157. Id = x.Id,
  17158. Client = x.Client,
  17159. Contact = x.Contact,
  17160. Location = x.Location,
  17161. })
  17162. .ToList();
  17163. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x=>x.Id).ToList();
  17164. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  17165. Stopwatch stopwatch = new Stopwatch();
  17166. // 开始计时
  17167. stopwatch.Start();
  17168. foreach (var item in clientList)
  17169. {
  17170. EncryptionProcessor.DecryptProperties(item);
  17171. }
  17172. stopwatch.Stop();
  17173. jw.Code = 200;
  17174. jw.Data = stopwatch.ElapsedMilliseconds;
  17175. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  17176. }
  17177. catch (Exception ex)
  17178. {
  17179. jw.Code = 400;
  17180. jw.Msg = ex.Message;
  17181. }
  17182. return Ok(jw);
  17183. }
  17184. }
  17185. }