GroupsController.cs 939 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Microsoft.AspNetCore.SignalR;
  7. using Microsoft.EntityFrameworkCore.Query.Internal;
  8. using NPOI.HSSF.UserModel;
  9. using NPOI.SS.UserModel;
  10. using NPOI.SS.Util;
  11. using NPOI.XSSF.UserModel;
  12. using OASystem.API.Middlewares;
  13. using OASystem.API.OAMethodLib;
  14. using OASystem.API.OAMethodLib.APNs;
  15. using OASystem.API.OAMethodLib.File;
  16. using OASystem.API.OAMethodLib.Hub.HubClients;
  17. using OASystem.API.OAMethodLib.Hub.Hubs;
  18. using OASystem.API.OAMethodLib.JuHeAPI;
  19. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  20. using OASystem.Domain.AesEncryption;
  21. using OASystem.Domain.Dtos.CRM;
  22. using OASystem.Domain.Dtos.FileDto;
  23. using OASystem.Domain.Dtos.Financial;
  24. using OASystem.Domain.Dtos.Groups;
  25. using OASystem.Domain.Entities.Customer;
  26. using OASystem.Domain.Entities.Financial;
  27. using OASystem.Domain.Entities.Groups;
  28. using OASystem.Domain.ViewModels.Financial;
  29. using OASystem.Domain.ViewModels.Groups;
  30. using OASystem.Infrastructure.Repositories.CRM;
  31. using OASystem.Infrastructure.Repositories.Financial;
  32. using OASystem.Infrastructure.Repositories.Groups;
  33. using OfficeOpenXml;
  34. using Org.BouncyCastle.Asn1.Ocsp;
  35. using Org.BouncyCastle.Utilities.Encoders;
  36. using Quartz.Util;
  37. using SqlSugar.Extensions;
  38. using System.Collections;
  39. using System.Data;
  40. using System.Diagnostics;
  41. using System.Globalization;
  42. using System.IO.Compression;
  43. using static OASystem.API.OAMethodLib.JWTHelper;
  44. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  45. using Bookmark = Aspose.Words.Bookmark;
  46. using Cell = Aspose.Words.Tables.Cell;
  47. using Table = Aspose.Words.Tables.Table;
  48. namespace OASystem.API.Controllers
  49. {
  50. /// <summary>
  51. /// 团组相关
  52. /// </summary>
  53. //[Authorize]
  54. [Route("api/[controller]/[action]")]
  55. public class GroupsController : ControllerBase
  56. {
  57. private readonly ILogger<GroupsController> _logger;
  58. private readonly GrpScheduleRepository _grpScheduleRep;
  59. private readonly IMapper _mapper;
  60. private readonly DelegationInfoRepository _groupRepository;
  61. private readonly TaskAssignmentRepository _taskAssignmentRep;
  62. private readonly AirTicketResRepository _airTicketResRep;
  63. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  64. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  65. private readonly DelegationEnDataRepository _delegationEnDataRep;
  66. private readonly DelegationVisaRepository _delegationVisaRep;
  67. private readonly VisaPriceRepository _visaPriceRep;
  68. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  69. private readonly HotelPriceRepository _hotelPriceRep;
  70. private readonly CustomersRepository _customersRep;
  71. private readonly MessageRepository _message;
  72. private readonly SqlSugarClient _sqlSugar;
  73. private readonly TourClientListRepository _tourClientListRep;
  74. private readonly TeamRateRepository _teamRateRep;
  75. #region 成本相关
  76. private readonly CheckBoxsRepository _checkBoxs;
  77. private readonly GroupCostRepository _GroupCostRepository;
  78. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  79. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  80. #endregion
  81. private readonly SetDataRepository _setDataRep;
  82. private string url;
  83. private string path;
  84. private readonly EnterExitCostRepository _enterExitCostRep;
  85. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  86. private readonly UsersRepository _usersRep;
  87. private readonly IJuHeApiService _juHeApi;
  88. private readonly InvertedListRepository _invertedListRep;
  89. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  90. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  91. private readonly ThreeCodeRepository _threeCodeRepository;
  92. private readonly HotelInquiryRepository _hotelInquiryRep;
  93. private readonly FeeAuditRepository _feeAuditRep;
  94. private readonly VisaCommissionRepository _visaCommissionRep;
  95. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  96. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  97. private readonly List<CurrencyInfo> _currencyInit;
  98. private readonly List<int> _portTypeData;
  99. private readonly TableOperationRecordRepository _tableorRep;
  100. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  101. private readonly RestaurantRepository _restaurantRep;
  102. /// <summary>
  103. /// 构造函数
  104. /// </summary>
  105. /// <param name="logger"></param>
  106. /// <param name="mapper"></param>
  107. /// <param name="hubContext"></param>
  108. /// <param name="sqlSugar"></param>
  109. /// <param name="grpScheduleRep"></param>
  110. /// <param name="groupRepository"></param>
  111. /// <param name="taskAssignmentRep"></param>
  112. /// <param name="airTicketResRep"></param>
  113. /// <param name="decreasePaymentsRep"></param>
  114. /// <param name="InvitationOfficialActivitiesRep"></param>
  115. /// <param name="delegationEnDataRep"></param>
  116. /// <param name="enterExitCostRep"></param>
  117. /// <param name="delegationVisaRep"></param>
  118. /// <param name="message"></param>
  119. /// <param name="visaPriceRep"></param>
  120. /// <param name="carTouristGuideGroundRep"></param>
  121. /// <param name="checkBoxs"></param>
  122. /// <param name="GroupCostRepository"></param>
  123. /// <param name="CostTypeHotelNumberRepository"></param>
  124. /// <param name="GroupCostParameterRepository"></param>
  125. /// <param name="hotelPriceRep"></param>
  126. /// <param name="customersRep"></param>
  127. /// <param name="setDataRep"></param>
  128. /// <param name="tourClientListRep"></param>
  129. /// <param name="teamRateRep"></param>
  130. /// <param name="usersRep"></param>
  131. /// <param name="juHeApi"></param>
  132. /// <param name="invertedListRep"></param>
  133. /// <param name="visaFeeInfoRep"></param>
  134. /// <param name="ticketBlackCodeRep"></param>
  135. /// <param name="hotelInquiryRep"></param>
  136. /// <param name="threeCodeRepository"></param>
  137. /// <param name="feeAuditRep"></param>
  138. /// <param name="visaCommissionRep"></param>
  139. /// <param name="ffrRep"></param>
  140. /// <param name="opinionaireRep"></param>
  141. /// <param name="tableorRep"></param>
  142. /// <param name="enterExitCostDraftRep"></param>
  143. /// <param name="restaurantRep"></param>
  144. public GroupsController(
  145. ILogger<GroupsController> logger,
  146. IMapper mapper,
  147. IHubContext<ChatHub, IChatClient> hubContext,
  148. SqlSugarClient sqlSugar,
  149. GrpScheduleRepository grpScheduleRep,
  150. DelegationInfoRepository groupRepository,
  151. TaskAssignmentRepository taskAssignmentRep,
  152. AirTicketResRepository airTicketResRep,
  153. DecreasePaymentsRepository decreasePaymentsRep,
  154. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  155. DelegationEnDataRepository delegationEnDataRep,
  156. EnterExitCostRepository enterExitCostRep,
  157. DelegationVisaRepository delegationVisaRep,
  158. MessageRepository message,
  159. VisaPriceRepository visaPriceRep,
  160. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  161. CheckBoxsRepository checkBoxs,
  162. GroupCostRepository GroupCostRepository,
  163. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  164. GroupCostParameterRepository GroupCostParameterRepository,
  165. HotelPriceRepository hotelPriceRep,
  166. CustomersRepository customersRep,
  167. SetDataRepository setDataRep,
  168. TourClientListRepository tourClientListRep,
  169. TeamRateRepository teamRateRep,
  170. UsersRepository usersRep, IJuHeApiService juHeApi,
  171. InvertedListRepository invertedListRep,
  172. VisaFeeInfoRepository visaFeeInfoRep,
  173. TicketBlackCodeRepository ticketBlackCodeRep,
  174. HotelInquiryRepository hotelInquiryRep,
  175. ThreeCodeRepository threeCodeRepository,
  176. FeeAuditRepository feeAuditRep,
  177. VisaCommissionRepository visaCommissionRep,
  178. ForeignReceivablesRepository ffrRep,
  179. OpinionaireRepository opinionaireRep,
  180. TableOperationRecordRepository tableorRep,
  181. EnterExitCostDraftRepository enterExitCostDraftRep,
  182. RestaurantRepository restaurantRep
  183. )
  184. {
  185. _logger = logger;
  186. _mapper = mapper;
  187. _grpScheduleRep = grpScheduleRep;
  188. _groupRepository = groupRepository;
  189. _taskAssignmentRep = taskAssignmentRep;
  190. _airTicketResRep = airTicketResRep;
  191. _sqlSugar = sqlSugar;
  192. url = AppSettingsHelper.Get("ExcelBaseUrl");
  193. path = AppSettingsHelper.Get("ExcelBasePath");
  194. if (!System.IO.Directory.Exists(path))
  195. {
  196. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  197. }
  198. _decreasePaymentsRep = decreasePaymentsRep;
  199. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  200. _delegationEnDataRep = delegationEnDataRep;
  201. _enterExitCostRep = enterExitCostRep;
  202. _delegationVisaRep = delegationVisaRep;
  203. _message = message;
  204. _visaPriceRep = visaPriceRep;
  205. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  206. _checkBoxs = checkBoxs;
  207. _GroupCostRepository = GroupCostRepository;
  208. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  209. _GroupCostParameterRepository = GroupCostParameterRepository;
  210. _hotelPriceRep = hotelPriceRep;
  211. _customersRep = customersRep;
  212. _setDataRep = setDataRep;
  213. _tourClientListRep = tourClientListRep;
  214. _teamRateRep = teamRateRep;
  215. _hubContext = hubContext;
  216. _usersRep = usersRep;
  217. _juHeApi = juHeApi;
  218. _invertedListRep = invertedListRep;
  219. _visaFeeInfoRep = visaFeeInfoRep;
  220. _ticketBlackCodeRep = ticketBlackCodeRep;
  221. _hotelInquiryRep = hotelInquiryRep;
  222. _threeCodeRepository = threeCodeRepository;
  223. _feeAuditRep = feeAuditRep;
  224. _visaCommissionRep = visaCommissionRep;
  225. _ffrRep = ffrRep;
  226. _opinionaireRep = opinionaireRep;
  227. _currencyInit = new List<CurrencyInfo>()
  228. {
  229. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  230. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  231. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  232. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  233. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  234. };
  235. _portTypeData = new List<int>() { 2, 3 };
  236. _tableorRep = tableorRep;
  237. _enterExitCostDraftRep = enterExitCostDraftRep;
  238. _restaurantRep = restaurantRep;
  239. }
  240. #region 流程管控
  241. /// <summary>
  242. /// 获取团组流程管控信息
  243. /// </summary>
  244. /// <param name="paras">参数Json字符串</param>
  245. /// <returns></returns>
  246. [HttpPost]
  247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  248. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  249. {
  250. if (string.IsNullOrEmpty(_jsonDto.Paras))
  251. {
  252. return Ok(JsonView(false, "参数为空"));
  253. }
  254. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  255. if (_ScheduleDto != null)
  256. {
  257. if (_ScheduleDto.SearchType == 2)//获取列表
  258. {
  259. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  260. return Ok(JsonView(_grpScheduleViewList));
  261. }
  262. else//获取对象
  263. {
  264. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  265. if (_grpScheduleView != null)
  266. {
  267. return Ok(JsonView(_grpScheduleView));
  268. }
  269. }
  270. }
  271. else
  272. {
  273. return Ok(JsonView(false, "参数反序列化失败"));
  274. }
  275. return Ok(JsonView(false, "暂无数据!"));
  276. }
  277. /// <summary>
  278. /// 修改团组流程管控详细表数据
  279. /// </summary>
  280. /// <param name="paras"></param>
  281. /// <returns></returns>
  282. [HttpPost]
  283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  284. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  285. {
  286. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  287. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  288. .SetColumns(it => it.Duty == _detail.Duty)
  289. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  290. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  291. .SetColumns(it => it.JobContent == _detail.JobContent)
  292. .SetColumns(it => it.Remark == _detail.Remark)
  293. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  294. .Where(s => s.Id == dto.Id)
  295. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  296. .ExecuteCommandAsync();
  297. if (result > 0)
  298. {
  299. return Ok(JsonView(true, "保存成功!"));
  300. }
  301. return Ok(JsonView(false, "保存失败!"));
  302. }
  303. /// <summary>
  304. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  305. /// </summary>
  306. /// <param name="dto"></param>
  307. /// <returns></returns>
  308. [HttpPost]
  309. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  310. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  311. {
  312. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  313. _detail.IsDel = 1;
  314. _detail.DeleteUserId = dto.Duty;
  315. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  316. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  317. .SetColumns(it => it.IsDel == _detail.IsDel)
  318. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  319. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  320. .Where(it => it.Id == dto.Id)
  321. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  322. //.WhereColumns(s => s.Id == dto.Id)
  323. .ExecuteCommandAsync();
  324. if (result > 0)
  325. {
  326. return Ok(JsonView(true, "删除成功!"));
  327. }
  328. return Ok(JsonView(false, "删除失败!"));
  329. }
  330. /// <summary>
  331. /// 增加团组流程管控详细表数据
  332. /// </summary>
  333. /// <param name="dto"></param>
  334. /// <returns></returns>
  335. [HttpPost]
  336. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  337. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  338. {
  339. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  340. if (DateTime.Now < _detail.ExpectBeginDt)
  341. {
  342. _detail.StepStatus = 0;
  343. }
  344. else
  345. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  346. _detail.StepStatus = 1;
  347. }
  348. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  349. if (result > 0)
  350. {
  351. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  352. return Ok(JsonView(true, "添加成功!", _result));
  353. }
  354. return Ok(JsonView(false, "添加失败!"));
  355. }
  356. #endregion
  357. #region 团组基本信息
  358. /// <summary>
  359. /// 接团信息列表
  360. /// </summary>
  361. /// <param name="dto">团组列表请求dto</param>
  362. /// <returns></returns>
  363. [HttpPost]
  364. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  365. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  366. {
  367. var groupData = await _groupRepository.GetGroupList(dto);
  368. if (groupData.Code != 0)
  369. {
  370. return Ok(JsonView(false, groupData.Msg));
  371. }
  372. return Ok(JsonView(groupData.Data));
  373. }
  374. /// <summary>
  375. /// 分页查询团组列表
  376. /// </summary>
  377. /// <param name="dto"></param>
  378. /// <returns></returns>
  379. [HttpPost]
  380. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  381. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  382. {
  383. var watch = new Stopwatch();
  384. watch.Start();
  385. RefAsync<int> total = 0;
  386. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  387. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  388. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  389. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  390. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  391. .Distinct()
  392. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  393. watch.Stop();
  394. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  395. }
  396. /// <summary>
  397. /// 接团信息列表 Page
  398. /// </summary>
  399. /// <param name="dto">团组列表请求dto</param>
  400. /// <returns></returns>
  401. [HttpPost]
  402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  403. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  404. {
  405. #region 参数验证
  406. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  407. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  408. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  409. #region 页面操作权限验证
  410. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  411. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  412. #endregion
  413. #endregion
  414. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  415. {
  416. string sqlWhere = string.Empty;
  417. if (dto.IsSure == 0) //未完成
  418. {
  419. sqlWhere += string.Format(@" And IsSure = 0");
  420. }
  421. else if (dto.IsSure == 1) //已完成
  422. {
  423. sqlWhere += string.Format(@" And IsSure = 1");
  424. }
  425. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  426. {
  427. string tj = dto.SearchCriteria;
  428. 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}%')",
  429. tj, tj, tj, tj, tj);
  430. }
  431. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  432. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  433. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  434. JietuanOperator,IsSure,CreateTime,IsBid
  435. From (
  436. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  437. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  438. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  439. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  440. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  441. From Grp_DelegationInfo gdi
  442. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  443. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  444. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  445. Where gdi.IsDel = 0 {0}
  446. ) temp", sqlWhere);
  447. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  448. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  449. #region 处理所属部门
  450. /*
  451. * 1.sq 和 gyy 等显示 市场部
  452. * 2.王鸽和主管及张总还有管理员号统一国交部
  453. * 2-1. 4 管理员 ,21 张海麟
  454. */
  455. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  456. List<int> userIds1 = new List<int>() { 4, 21 };
  457. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  458. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  459. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  460. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  461. .ToList();
  462. foreach (var item in _DelegationList)
  463. {
  464. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  465. }
  466. #endregion
  467. var _view = new
  468. {
  469. PageFuncAuth = pageFunAuthView,
  470. Data = _DelegationList
  471. };
  472. return Ok(JsonView(true, "查询成功!", _view, total));
  473. }
  474. else
  475. {
  476. return Ok(JsonView(false, "查询失败"));
  477. }
  478. }
  479. /// <summary>
  480. /// 团组列表
  481. /// </summary>
  482. /// <returns></returns>
  483. [HttpPost]
  484. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  485. {
  486. #region 参数验证
  487. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  488. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  489. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  490. #region 页面操作权限验证
  491. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  492. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  493. #endregion
  494. #endregion
  495. if (dto.PortType != 1 && dto.PortType != 2)
  496. {
  497. return Ok(JsonView(false, "查询失败!"));
  498. }
  499. string orderbyStr = "order by gdi.CreateTime Desc";
  500. string sqlWhere = string.Empty;
  501. if (dto.IsSure == 0) //未完成
  502. {
  503. sqlWhere += string.Format(@" And IsSure = 0");
  504. }
  505. else if (dto.IsSure == 1) //已完成
  506. {
  507. sqlWhere += string.Format(@" And IsSure = 1");
  508. }
  509. //团组类型
  510. if (dto.TeamDid > 0)
  511. {
  512. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  513. }
  514. //团组名称
  515. if (!string.IsNullOrEmpty(dto.TeamName))
  516. {
  517. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  518. }
  519. //客户名称
  520. if (!string.IsNullOrEmpty(dto.ClientName))
  521. {
  522. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  523. }
  524. //客户单位
  525. if (!string.IsNullOrEmpty(dto.ClientUnit))
  526. {
  527. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  528. }
  529. //出访时间
  530. if (!string.IsNullOrEmpty(dto.visitDataTime))
  531. {
  532. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  533. orderbyStr = "order by gdi.VisitDate";
  534. }
  535. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  536. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  537. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  538. JietuanOperator,IsSure,CreateTime
  539. From (
  540. Select row_number() over({0}) as Row_Number,
  541. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  542. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  543. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  544. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  545. From Grp_DelegationInfo gdi
  546. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  547. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  548. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  549. Where gdi.IsDel = 0 {1}
  550. ) temp ", orderbyStr, sqlWhere);
  551. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  552. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  553. #region 处理所属部门
  554. /*
  555. * 1.sq 和 gyy 等显示 市场部
  556. * 2.王鸽和主管及张总还有管理员号统一国交部
  557. * 2-1. 4 管理员 ,21 张海麟
  558. */
  559. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  560. List<int> userIds1 = new List<int>() { 4, 21 };
  561. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  562. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  563. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  564. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  565. .ToList();
  566. foreach (var item in _DelegationList)
  567. {
  568. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  569. }
  570. #endregion
  571. var _view = new
  572. {
  573. PageFuncAuth = pageFunAuthView,
  574. Data = _DelegationList
  575. };
  576. return Ok(JsonView(true, "查询成功!", _view, total));
  577. }
  578. /// <summary>
  579. /// 接团信息详情
  580. /// </summary>
  581. /// <param name="dto">团组info请求dto</param>
  582. /// <returns></returns>
  583. [HttpPost]
  584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  585. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  586. {
  587. var groupData = await _groupRepository.GetGroupInfo(dto);
  588. if (groupData.Code != 0)
  589. {
  590. return Ok(JsonView(false, groupData.Msg));
  591. }
  592. return Ok(JsonView(groupData.Data));
  593. }
  594. /// <summary>
  595. /// 接团信息 编辑添加
  596. /// 基础信息数据源
  597. /// </summary>
  598. /// <param name="dto"></param>
  599. /// <returns></returns>
  600. [HttpPost]
  601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  602. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  603. {
  604. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  605. if (groupData.Code != 0)
  606. {
  607. return Ok(JsonView(false, groupData.Msg));
  608. }
  609. return Ok(JsonView(groupData.Data));
  610. }
  611. /// <summary>
  612. /// 接团信息 操作(增改)
  613. /// </summary>
  614. /// <param name="dto"></param>
  615. /// <returns></returns>
  616. [HttpPost]
  617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  618. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  619. {
  620. // 创建 Stopwatch 实例
  621. Stopwatch stopwatch = Stopwatch.StartNew();
  622. decimal ffrPrice = 0.00M;
  623. DateTime? visitDt = null;
  624. if (dto.Status == 2)
  625. {
  626. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  627. if (groupInfo != null)
  628. {
  629. ffrPrice = groupInfo.PaymentMoney;
  630. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  631. }
  632. }
  633. var groupData = await _groupRepository.GroupOperation(dto);
  634. if (groupData.Code != 0)
  635. {
  636. return Ok(JsonView(false, groupData.Msg));
  637. }
  638. int diId = 0;
  639. try
  640. {
  641. //添加时 默认加入团组汇率
  642. if (dto.Status == 1) //添加
  643. {
  644. diId = groupData.Data;
  645. //添加默认币种
  646. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  647. //默认分配权限
  648. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  649. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  650. var _managerIds = new List<int>() { 22, 32, 21 };
  651. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  652. if (userIds.Count > 0)
  653. {
  654. userIds.Add(208);
  655. //创建团组管控
  656. GroupStepForDelegation.CreateWorkStep(diId);
  657. //发送消息
  658. string groupName = dto.TeamName;
  659. string createGroupUser = string.Empty;
  660. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  661. if (userInfo != null) createGroupUser = userInfo.CnName;
  662. string title = $"系统通知";
  663. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  664. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  665. }
  666. //默认创建倒推表
  667. await _invertedListRep._Create(dto.UserId, diId);
  668. }
  669. else if (dto.Status == 2)
  670. {
  671. diId = dto.Id;
  672. }
  673. #region 签证人员团组时间通知
  674. #region 计算出访起止时间
  675. var startTime = new DateTime();
  676. var endTime = new DateTime();
  677. if (DateTime.TryParse(dto.VisitDate, out startTime))
  678. {
  679. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  680. }
  681. #endregion
  682. #endregion
  683. #region 团组操作默认添加/修改收款账单
  684. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  685. {
  686. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  687. .Where(x => x.IsDel == 0 &&
  688. x.Diid == diId &&
  689. x.Remark.Equals("预付款")
  690. )
  691. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  692. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  693. .FirstAsync();
  694. ffrInfo = new Fin_ForeignReceivables()
  695. {
  696. Diid = diId,
  697. PriceName = dto.ClientUnit,
  698. Price = dto.PaymentMoney,
  699. Count = 1,
  700. Unit = $"元",
  701. ItemSumPrice = dto.PaymentMoney,
  702. Rate = 1.0000M,
  703. Currency = 836,
  704. AddingWay = 0,
  705. CreateUserId = dto.UserId,
  706. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  707. Remark = $"预付款"
  708. };
  709. if (ffrInfo == null) //Add
  710. {
  711. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  712. }
  713. else //修改
  714. {
  715. await _sqlSugar.Updateable(ffrInfo)
  716. .UpdateColumns(x => new
  717. {
  718. x.PriceName,
  719. x.Price,
  720. x.ItemSumPrice,
  721. x.CreateTime,
  722. x.CreateUserId
  723. })
  724. .WhereColumns(x => x.Id)
  725. .ExecuteCommandAsync();
  726. }
  727. }
  728. #endregion
  729. if (diId > 0)
  730. {
  731. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  732. }
  733. // 停止计时
  734. stopwatch.Stop();
  735. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  736. }
  737. catch (Exception ex)
  738. {
  739. // 停止计时
  740. stopwatch.Stop();
  741. Logs("[response]" + JsonConvert.SerializeObject(dto));
  742. Logs(ex.Message);
  743. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  744. }
  745. // 停止计时
  746. stopwatch.Stop();
  747. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  748. }
  749. /// <summary>
  750. /// 接团流程操作(增改)
  751. /// 安卓端使用 建团时添加客户名单
  752. /// </summary>
  753. /// <param name="dto"></param>
  754. /// <returns></returns>
  755. [HttpPost]
  756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  757. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  758. {
  759. #region 参数验证
  760. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  761. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  762. #region 页面操作权限验证
  763. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  764. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  765. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  766. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  767. #endregion
  768. #endregion
  769. try
  770. {
  771. //_sqlSugar.BeginTran();
  772. decimal ffrPrice = 0.00M;
  773. DateTime? visitDt = null;
  774. if (dto.Status == 2)
  775. {
  776. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  777. if (groupInfo != null)
  778. {
  779. ffrPrice = groupInfo.PaymentMoney;
  780. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  781. }
  782. }
  783. var _dto = new GroupOperationDto();
  784. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  785. var groupData = await _groupRepository.GroupOperation(_dto);
  786. if (groupData.Code != 0)
  787. {
  788. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  789. }
  790. int diId = 0;
  791. //添加时 默认加入团组汇率
  792. if (dto.Status == 1) //添加
  793. {
  794. diId = groupData.Data;
  795. //添加默认币种
  796. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  797. //默认分配权限
  798. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  799. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  800. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  801. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  802. if (userIds.Count > 0)
  803. {
  804. userIds.Add(208);
  805. //创建团组管控
  806. GroupStepForDelegation.CreateWorkStep(diId);
  807. //发送消息
  808. string groupName = dto.TeamName;
  809. string createGroupUser = string.Empty;
  810. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  811. if (userInfo != null) createGroupUser = userInfo.CnName;
  812. string title = $"系统通知";
  813. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  814. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  815. }
  816. #region 应用推送
  817. try
  818. {
  819. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  820. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  821. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  822. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  823. {
  824. List<string> userList = new List<string>() { users.QiyeChatUserId };
  825. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  826. }
  827. }
  828. catch (Exception ex)
  829. {
  830. }
  831. #endregion
  832. //默认创建倒推表
  833. await _invertedListRep._Create(dto.UserId, diId);
  834. }
  835. if (dto.Status == 2)
  836. {
  837. diId = dto.Id;
  838. if (diId == 0)
  839. {
  840. //_sqlSugar.RollbackTran();
  841. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  842. }
  843. }
  844. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  845. if (viewData.Code != 0)
  846. {
  847. //_sqlSugar.RollbackTran();
  848. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  849. }
  850. #region 团组操作默认添加/修改收款账单
  851. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  852. {
  853. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  854. .Where(x => x.IsDel == 0 &&
  855. x.Diid == diId &&
  856. x.Remark.Equals("预付款")
  857. )
  858. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  859. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  860. .FirstAsync();
  861. ffrInfo = new Fin_ForeignReceivables()
  862. {
  863. Diid = diId,
  864. PriceName = dto.ClientUnit,
  865. Price = dto.PaymentMoney,
  866. Count = 1,
  867. Unit = $"元",
  868. ItemSumPrice = dto.PaymentMoney,
  869. Rate = 1.0000M,
  870. Currency = 836,
  871. AddingWay = 0,
  872. CreateUserId = dto.UserId,
  873. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  874. Remark = $"预付款"
  875. };
  876. if (ffrInfo == null) //Add
  877. {
  878. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  879. }
  880. else //修改
  881. {
  882. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  883. .UpdateColumns(x => new
  884. {
  885. x.PriceName,
  886. x.Price,
  887. x.ItemSumPrice,
  888. x.CreateTime,
  889. x.CreateUserId
  890. })
  891. .WhereColumns(x => x.Id)
  892. .ExecuteCommandAsync();
  893. }
  894. }
  895. #endregion
  896. #region 签证人员团组时间通知
  897. #region 计算出访起止时间
  898. var startTime = new DateTime();
  899. var endTime = new DateTime();
  900. if (DateTime.TryParse(dto.VisitDate, out startTime))
  901. {
  902. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  903. }
  904. #endregion
  905. if (diId > 0)
  906. {
  907. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  908. }
  909. #endregion
  910. //_sqlSugar.CommitTran();
  911. return Ok(JsonView(true, "添加成功"));
  912. }
  913. catch (Exception ex)
  914. {
  915. _sqlSugar.RollbackTran();
  916. return Ok(JsonView(false, ex.Message));
  917. }
  918. }
  919. /// <summary>
  920. /// 接团流程操作(增改)
  921. /// 安卓端使用 建团时添加客户名单
  922. /// </summary>
  923. /// <param name="dto"></param>
  924. /// <returns></returns>
  925. [HttpPost]
  926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  927. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  928. {
  929. #region 参数验证
  930. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  931. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  932. #region 页面操作权限验证
  933. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  934. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  935. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  936. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  937. #endregion
  938. #endregion
  939. _sqlSugar.BeginTran();
  940. decimal ffrPrice = 0.00M;
  941. DateTime? visitDt = null;
  942. if (dto.Status == 2)
  943. {
  944. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  945. if (groupInfo != null)
  946. {
  947. ffrPrice = groupInfo.PaymentMoney;
  948. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  949. }
  950. }
  951. var _dto = new GroupOperationDto();
  952. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  953. var groupData = await _groupRepository.GroupOperation(_dto);
  954. if (groupData.Code != 0)
  955. {
  956. _sqlSugar.RollbackTran();
  957. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  958. }
  959. try
  960. {
  961. int diId = 0;
  962. //添加时 默认加入团组汇率
  963. if (dto.Status == 1) //添加
  964. {
  965. diId = groupData.Data;
  966. //添加默认币种
  967. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  968. //默认分配权限
  969. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  970. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  971. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  972. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  973. if (userIds.Count > 0)
  974. {
  975. userIds.Add(208);
  976. //创建团组管控
  977. GroupStepForDelegation.CreateWorkStep(diId);
  978. //发送消息
  979. string groupName = dto.TeamName;
  980. string createGroupUser = string.Empty;
  981. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  982. if (userInfo != null) createGroupUser = userInfo.CnName;
  983. string title = $"系统通知";
  984. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  985. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  986. }
  987. #region 应用推送
  988. try
  989. {
  990. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  991. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  992. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  993. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  994. {
  995. List<string> userList = new List<string>() { users.QiyeChatUserId };
  996. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  997. }
  998. }
  999. catch (Exception ex)
  1000. {
  1001. _sqlSugar.CommitTran();
  1002. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1003. }
  1004. #endregion
  1005. //默认创建倒推表
  1006. await _invertedListRep._Create(dto.UserId, diId);
  1007. }
  1008. else if (dto.Status == 2)
  1009. {
  1010. diId = dto.Id;
  1011. if (diId == 0)
  1012. {
  1013. _sqlSugar.RollbackTran();
  1014. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1015. }
  1016. }
  1017. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1018. if (viewData.Code != 0)
  1019. {
  1020. _sqlSugar.RollbackTran();
  1021. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1022. }
  1023. #region 团组操作默认添加/修改收款账单
  1024. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1025. {
  1026. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1027. .Where(x => x.IsDel == 0 &&
  1028. x.Diid == diId &&
  1029. x.Remark.Equals("预付款")
  1030. )
  1031. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1032. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1033. .FirstAsync();
  1034. ffrInfo = new Fin_ForeignReceivables()
  1035. {
  1036. Diid = diId,
  1037. PriceName = dto.ClientUnit,
  1038. Price = dto.PaymentMoney,
  1039. Count = 1,
  1040. Unit = $"元",
  1041. ItemSumPrice = dto.PaymentMoney,
  1042. Rate = 1.0000M,
  1043. Currency = 836,
  1044. AddingWay = 0,
  1045. CreateUserId = dto.UserId,
  1046. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1047. Remark = $"预付款"
  1048. };
  1049. if (ffrInfo == null) //Add
  1050. {
  1051. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1052. }
  1053. else //修改
  1054. {
  1055. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1056. .UpdateColumns(x => new
  1057. {
  1058. x.PriceName,
  1059. x.Price,
  1060. x.ItemSumPrice,
  1061. x.CreateTime,
  1062. x.CreateUserId
  1063. })
  1064. .WhereColumns(x => x.Id)
  1065. .ExecuteCommandAsync();
  1066. }
  1067. }
  1068. #endregion
  1069. #region 签证人员团组时间通知
  1070. #region 计算出访起止时间
  1071. var startTime = new DateTime();
  1072. var endTime = new DateTime();
  1073. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1074. {
  1075. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1076. }
  1077. #endregion
  1078. if (diId > 0)
  1079. {
  1080. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1081. }
  1082. #endregion
  1083. _sqlSugar.CommitTran();
  1084. return Ok(JsonView(true));
  1085. }
  1086. catch (Exception ex)
  1087. {
  1088. _sqlSugar.RollbackTran();
  1089. return Ok(JsonView(false, ex.Message));
  1090. }
  1091. }
  1092. /// <summary>
  1093. /// 接团信息 操作(删除)
  1094. /// </summary>
  1095. /// <param name="dto"></param>
  1096. /// <returns></returns>
  1097. [HttpPost]
  1098. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1099. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1100. {
  1101. var diId = dto.Id;
  1102. if (diId < 1) return Ok(JsonView(false,MsgTips.Id));
  1103. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1104. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1105. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1106. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1107. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1108. #endregion
  1109. var groupData = await _groupRepository.GroupDel(dto);
  1110. if (groupData.Code != 0)
  1111. {
  1112. return Ok(JsonView(false, groupData.Msg));
  1113. }
  1114. return Ok(JsonView(true));
  1115. }
  1116. /// <summary>
  1117. /// 获取团组销售报价号
  1118. /// 团组添加时 使用
  1119. /// </summary>
  1120. /// <returns></returns>
  1121. [HttpPost]
  1122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1123. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1124. {
  1125. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1126. if (groupData.Code != 0)
  1127. {
  1128. return Ok(JsonView(false, groupData.Msg));
  1129. }
  1130. object salesQuoteNo = new
  1131. {
  1132. SalesQuoteNo = groupData.Data
  1133. };
  1134. return Ok(JsonView(salesQuoteNo));
  1135. }
  1136. /// <summary>
  1137. /// 设置确认出团
  1138. /// </summary>
  1139. /// <param name="dto"></param>
  1140. /// <returns></returns>
  1141. [HttpPost]
  1142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1143. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1144. {
  1145. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1146. if (groupData.Code != 0)
  1147. {
  1148. return Ok(JsonView(false, groupData.Msg));
  1149. }
  1150. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1151. #region OA消息推送
  1152. try
  1153. {
  1154. string groupName = groupInfo.TeamName;
  1155. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1156. string title = $"系统通知";
  1157. string content = $"团组[{groupName}]已确认出团!";
  1158. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1159. }
  1160. catch (Exception ex)
  1161. {
  1162. }
  1163. #endregion
  1164. #region 应用推送
  1165. try
  1166. {
  1167. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1168. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1169. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1170. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1171. {
  1172. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1173. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1174. }
  1175. }
  1176. catch (Exception ex)
  1177. {
  1178. }
  1179. #endregion
  1180. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1181. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1182. }
  1183. /// <summary>
  1184. /// 获取团组名称data And 签证国别Data
  1185. /// </summary>
  1186. /// <param name="dto"></param>
  1187. /// <returns></returns>
  1188. [HttpPost]
  1189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1190. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1191. {
  1192. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1193. if (groupData.Code != 0)
  1194. {
  1195. return Ok(JsonView(false, groupData.Msg));
  1196. }
  1197. return Ok(JsonView(groupData.Data));
  1198. }
  1199. /// <summary>
  1200. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1201. /// </summary>
  1202. /// <returns></returns>
  1203. [HttpPost]
  1204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1205. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1206. {
  1207. try
  1208. {
  1209. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1210. if (groupData.Code != 0)
  1211. {
  1212. return Ok(JsonView(false, groupData.Msg));
  1213. }
  1214. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1215. }
  1216. catch (Exception ex)
  1217. {
  1218. return Ok(JsonView(false, "程序错误!"));
  1219. throw;
  1220. }
  1221. }
  1222. /// <summary>
  1223. /// 团组清单 Excel
  1224. /// </summary>
  1225. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1226. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1227. /// <returns></returns>
  1228. [HttpGet]
  1229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1230. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1231. {
  1232. DateTime _beginDt, _endDt;
  1233. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1234. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1235. if (!beginBool && !endBool)
  1236. {
  1237. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1238. }
  1239. string sql = string.Format(@"
  1240. SELECT
  1241. ROW_NUMBER,
  1242. Id,
  1243. SalesQuoteNo,
  1244. TourCode,
  1245. TeamTypeId,
  1246. TeamType,
  1247. TeamLevId,
  1248. TeamLev,
  1249. TeamName,
  1250. ClientName,
  1251. ClientUnit,
  1252. VisitDate,
  1253. VisitDays,
  1254. VisitPNumber,
  1255. JietuanOperatorId,
  1256. JietuanOperator,
  1257. IsSure,
  1258. CreateUserName,
  1259. IsBid
  1260. FROM
  1261. (
  1262. SELECT
  1263. ROW_NUMBER() OVER(
  1264. ORDER BY
  1265. gdi.CreateTime Desc
  1266. ) AS ROW_NUMBER,
  1267. gdi.Id,
  1268. SalesQuoteNo,
  1269. TourCode,
  1270. ssd.Id TeamTypeId,
  1271. ssd.Name TeamType,
  1272. ssd1.Id TeamLevId,
  1273. ssd1.Name TeamLev,
  1274. TeamName,
  1275. ClientName,
  1276. ClientUnit,
  1277. VisitDate,
  1278. VisitDays,
  1279. VisitPNumber,
  1280. JietuanOperator JietuanOperatorId,
  1281. su.CnName JietuanOperator,
  1282. IsSure,
  1283. gdi.CreateTime,
  1284. su1.CnName As CreateUserName,
  1285. gdi.IsBid
  1286. FROM
  1287. Grp_DelegationInfo gdi
  1288. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1289. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1290. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1291. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1292. WHERE
  1293. gdi.IsDel = 0
  1294. AND gdi.IsBid = 0
  1295. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1296. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1297. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1298. #region 处理所属部门
  1299. /*
  1300. * 1.sq 和 gyy 等显示 市场部
  1301. * 2.王鸽和主管及张总还有管理员号统一国交部
  1302. * 2-1. 4 管理员 ,21 张海麟
  1303. */
  1304. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1305. List<int> userIds1 = new List<int>() { 4, 21 };
  1306. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1307. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1308. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1309. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1310. .ToListAsync();
  1311. var droupIds = groupList.Select(it => it.Id).ToList();
  1312. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1313. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1314. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1315. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1316. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1317. {
  1318. DiId = tcl.DiId,
  1319. LastName = dc.LastName,
  1320. FirstName = dc.FirstName,
  1321. Sex = dc.Sex,
  1322. Birthday = dc.BirthDay,
  1323. Company = cc.CompanyFullName,
  1324. Job = dc.Job,
  1325. CreateTime = tcl.CreateTime,
  1326. })
  1327. .ToList();
  1328. foreach (var item in groupList)
  1329. {
  1330. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1331. string groupFirstName = "";
  1332. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1333. if (currDatas.Any())
  1334. {
  1335. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1336. }
  1337. item.GroupFirst = groupFirstName;
  1338. }
  1339. #endregion
  1340. #region Excel
  1341. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1342. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1343. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1344. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1345. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1346. //载入模板
  1347. WorkbookDesigner designer = new WorkbookDesigner();
  1348. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1349. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1350. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1351. dt.TableName = "GroupList";
  1352. designer.SetDataSource(dt);
  1353. designer.Process();
  1354. if (!Directory.Exists(savePath))
  1355. {
  1356. Directory.CreateDirectory(savePath);
  1357. }
  1358. string serverPath = $"{savePath}{fileName}";
  1359. designer.Workbook.Save(serverPath);
  1360. string rst = $"{servicePath}{ftpPath}{fileName}";
  1361. #endregion
  1362. return Ok(JsonView(true, "操作成功!", rst));
  1363. }
  1364. #endregion
  1365. #region 团组&签证
  1366. /// <summary>
  1367. /// 根据团组Id获取签证客户信息List
  1368. /// </summary>
  1369. /// <param name="dto">请求dto</param>
  1370. /// <returns></returns>
  1371. [HttpPost]
  1372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1373. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1374. {
  1375. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1376. if (groupData.Code != 0)
  1377. {
  1378. return Ok(JsonView(false, groupData.Msg));
  1379. }
  1380. return Ok(JsonView(groupData.Data));
  1381. }
  1382. /// <summary>
  1383. /// IOS获取团组签证拍照上传进度01(团组列表)
  1384. /// </summary>
  1385. /// <param name="dto">请求dto</param>
  1386. /// <returns></returns>
  1387. [HttpPost]
  1388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1389. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1390. {
  1391. if (dto == null)
  1392. {
  1393. return Ok(JsonView(false, "参数为空"));
  1394. }
  1395. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1396. return Ok(JsonView(visaList));
  1397. }
  1398. /// <summary>
  1399. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1400. /// </summary>
  1401. /// <returns></returns>
  1402. [HttpPost]
  1403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1404. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1405. {
  1406. if (dto == null)
  1407. {
  1408. return Ok(JsonView(false, "请求错误:"));
  1409. }
  1410. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1411. return Ok(JsonView(list));
  1412. }
  1413. /// <summary>
  1414. /// IOS获取团组签证拍照上传进度03(相册)
  1415. /// </summary>
  1416. /// <returns></returns>
  1417. [HttpPost]
  1418. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1419. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1420. {
  1421. if (dto == null)
  1422. {
  1423. return Ok(JsonView(false, "请求错误:"));
  1424. }
  1425. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1426. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1427. list.ForEach(s => s.url = url);
  1428. return Ok(JsonView(list));
  1429. }
  1430. /// <summary>
  1431. /// IOS获取团组签证拍照上传进度04(图片上传)
  1432. /// </summary>
  1433. /// <param name="dto"></param>
  1434. /// <returns></returns>
  1435. [HttpPost]
  1436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1437. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1438. {
  1439. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1440. //if (!string.IsNullOrEmpty(result))
  1441. //{
  1442. //}
  1443. //else {
  1444. // return Ok(JsonView(false, "上传失败"));
  1445. //}
  1446. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1447. int sucNum = 0;
  1448. try
  1449. {
  1450. foreach (var item in dto.base64DataList)
  1451. {
  1452. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1453. string result = decodeBase64ToImage(item, imageName);
  1454. if (!string.IsNullOrEmpty(result))
  1455. {
  1456. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1457. pic.CreateUserId = dto.CreateUserId;
  1458. pic.PicName = imageName;
  1459. pic.PicPath = result;
  1460. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1461. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1462. if (insertResult > 0)
  1463. {
  1464. sucNum++;
  1465. }
  1466. }
  1467. }
  1468. }
  1469. catch (Exception ex)
  1470. {
  1471. return Ok(JsonView(false, ex.Message));
  1472. }
  1473. string msg = string.Format(@"成功上传{0}张", sucNum);
  1474. return Ok(JsonView(true, msg));
  1475. }
  1476. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1477. {
  1478. string filename = "";//声明一个string类型的相对路径
  1479. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1480. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1481. try//会有异常抛出,try,catch一下
  1482. {
  1483. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1484. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1485. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1486. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1487. //文件名称
  1488. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1489. //上传的文件的路径
  1490. string filePath = "";
  1491. if (!Directory.Exists(fileDir))
  1492. {
  1493. Directory.CreateDirectory(fileDir);
  1494. }
  1495. //上传的文件的路径
  1496. filePath = fileDir + filename;
  1497. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1498. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1499. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1500. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1501. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1502. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1503. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1504. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1505. bitmap.Dispose();
  1506. }
  1507. catch (Exception e)
  1508. {
  1509. string massage = e.Message;
  1510. Logs("IOS图片上传Error:" + massage);
  1511. //filename = e.Message;
  1512. }
  1513. return filename;//返回相对路径
  1514. }
  1515. /// <summary>
  1516. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1517. /// </summary>
  1518. /// <param name="dto"></param>
  1519. /// <returns></returns>
  1520. [HttpPost]
  1521. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1522. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1523. {
  1524. if (dto == null)
  1525. {
  1526. return Ok(JsonView(false, "请求错误:"));
  1527. }
  1528. string msg = "参数错误";
  1529. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1530. {
  1531. try
  1532. {
  1533. //_delegationVisaRep.BeginTran();
  1534. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1535. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1536. .Where(s => s.Id == dto.visaProgressCustomerId)
  1537. .ExecuteCommandAsync();
  1538. if (updCount > 0 && dto.publishCode == 1)
  1539. {
  1540. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1541. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1542. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1543. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1544. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1545. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1546. if (groupData == null)
  1547. {
  1548. _delegationVisaRep.RollbackTran();
  1549. }
  1550. string title = string.Format(@"[签证进度更新]");
  1551. string content = string.Format(@"测试文本");
  1552. bool rst = await _message.AddMsg(new MessageDto()
  1553. {
  1554. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1555. IssuerId = dto.publisher,
  1556. Title = title,
  1557. Content = content,
  1558. ReleaseTime = DateTime.Now,
  1559. UIdList = new List<int> {
  1560. 234
  1561. }
  1562. });
  1563. if (rst)
  1564. {
  1565. return Ok(JsonView(true, "发送通知成功"));
  1566. }
  1567. }
  1568. //_delegationVisaRep.CommitTran();
  1569. }
  1570. catch (Exception)
  1571. {
  1572. //_delegationVisaRep.RollbackTran();
  1573. }
  1574. }
  1575. return Ok(JsonView(true, msg));
  1576. }
  1577. #endregion
  1578. #region 团组任务分配
  1579. /// <summary>
  1580. /// 团组任务分配初始化
  1581. /// </summary>
  1582. /// <param name="dto"></param>
  1583. /// <returns></returns>
  1584. [HttpPost]
  1585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1586. public async Task<IActionResult> GetTaskAssignmen()
  1587. {
  1588. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1589. if (groupData.Code != 0)
  1590. {
  1591. return Ok(JsonView(false, groupData.Msg));
  1592. }
  1593. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1594. }
  1595. /// <summary>
  1596. /// 团组任务分配查询
  1597. /// </summary>
  1598. /// <param name="dto"></param>
  1599. /// <returns></returns>
  1600. [HttpPost]
  1601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1602. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1603. {
  1604. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1605. if (groupData.Code != 0)
  1606. {
  1607. return Ok(JsonView(false, groupData.Msg));
  1608. }
  1609. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1610. }
  1611. /// <summary>
  1612. /// 团组任务分配操作
  1613. /// </summary>
  1614. /// <param name="dto"></param>
  1615. /// <returns></returns>
  1616. [HttpPost]
  1617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1618. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1619. {
  1620. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1621. if (groupData.Code != 0)
  1622. {
  1623. return Ok(JsonView(false, groupData.Msg));
  1624. }
  1625. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1626. }
  1627. /// <summary>
  1628. /// 团组任务分配
  1629. /// 批量分配
  1630. /// 查询团组
  1631. /// </summary>
  1632. /// <param name="dto"></param>
  1633. /// <returns></returns>
  1634. [HttpPost]
  1635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1636. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1637. {
  1638. //参数验证
  1639. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1640. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1641. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1642. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1643. }
  1644. /// <summary>
  1645. /// 团组任务分配
  1646. /// 批量分配
  1647. /// </summary>
  1648. /// <param name="dto"></param>
  1649. /// <returns></returns>
  1650. [HttpPost]
  1651. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1652. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1653. {
  1654. //参数验证
  1655. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1656. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1657. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1658. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1659. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1660. }
  1661. #endregion
  1662. #region 团组费用审核
  1663. /// <summary>
  1664. /// 费用审核
  1665. /// 团组列表 Page
  1666. /// </summary>
  1667. /// <param name="_dto">团组列表请求dto</param>
  1668. /// <returns></returns>
  1669. [HttpPost]
  1670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1671. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1672. {
  1673. #region 参数验证
  1674. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1675. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1676. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1677. #region 页面操作权限验证
  1678. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1679. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1680. #endregion
  1681. #endregion
  1682. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1683. {
  1684. string sqlWhere = string.Empty;
  1685. if (_dto.IsSure == 0) //未完成
  1686. {
  1687. sqlWhere += string.Format(@" And IsSure = 0");
  1688. }
  1689. else if (_dto.IsSure == 1) //已完成
  1690. {
  1691. sqlWhere += string.Format(@" And IsSure = 1");
  1692. }
  1693. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1694. {
  1695. string tj = _dto.SearchCriteria;
  1696. 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}%')",
  1697. tj, tj, tj, tj, tj);
  1698. }
  1699. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1700. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1701. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1702. From (
  1703. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1704. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1705. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1706. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1707. From Grp_DelegationInfo gdi
  1708. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1709. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1710. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1711. Where gdi.IsDel = 0 {0}
  1712. ) temp ", sqlWhere);
  1713. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1714. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1715. var _view = new
  1716. {
  1717. PageFuncAuth = pageFunAuthView,
  1718. Data = _DelegationList
  1719. };
  1720. return Ok(JsonView(true, "查询成功!", _view, total));
  1721. }
  1722. else
  1723. {
  1724. return Ok(JsonView(false, "查询失败"));
  1725. }
  1726. }
  1727. /// <summary>
  1728. /// 获取团组费用审核
  1729. /// </summary>
  1730. /// <param name="paras">参数Json字符串</param>
  1731. /// <returns></returns>
  1732. [HttpPost]
  1733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1734. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1735. {
  1736. try
  1737. {
  1738. #region 参数验证
  1739. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1740. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1741. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1742. #region 页面操作权限验证
  1743. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1744. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1745. #endregion
  1746. #endregion
  1747. var _view = new Grp_CreditCardPaymentView();
  1748. var clientNameList = getSimplClientList(_dto.DiId);
  1749. #region 费用清单
  1750. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1751. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1752. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1753. var entityList = _groupRepository .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1754. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1755. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1756. /*
  1757. * 76://酒店预订
  1758. */
  1759. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1760. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1761. /*
  1762. * 79://车/导游地接
  1763. */
  1764. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1765. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1766. /*
  1767. * 80: //签证
  1768. */
  1769. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1770. /*
  1771. *81: //邀请/公务活动
  1772. */
  1773. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1774. /*
  1775. * 82: //团组客户保险
  1776. */
  1777. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1778. /*
  1779. * Lable = 85 机票预订
  1780. */
  1781. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1782. /*
  1783. * 85 机票预定
  1784. */
  1785. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1786. /*
  1787. * 98 其他款项
  1788. */
  1789. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1790. /*
  1791. * 285:收款退还
  1792. */
  1793. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1794. /*
  1795. * 1015: //超支费用
  1796. */
  1797. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1798. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1799. /*
  1800. * 币种信息
  1801. */
  1802. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1803. /*
  1804. * 车/导游地接 费用类型
  1805. */
  1806. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1807. /*
  1808. * 车/导游地接 费用类型
  1809. */
  1810. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  1811. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1812. /*
  1813. * 用户信息
  1814. */
  1815. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  1816. /*
  1817. * 费用模块
  1818. */
  1819. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  1820. string priceModule = string.Empty;
  1821. if (sdPriceName != null)
  1822. {
  1823. priceModule = sdPriceName.Name;
  1824. }
  1825. /*
  1826. * 成本信息
  1827. */
  1828. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1829. decimal _groupRate = 0.0000M;
  1830. string _groupCurrencyCode = "-";
  1831. if (groupCost != null)
  1832. {
  1833. _groupRate = groupCost.Rate;
  1834. if (int.TryParse(groupCost.Currency, out int _currency))
  1835. {
  1836. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1837. }
  1838. else _groupCurrencyCode = groupCost.Currency;
  1839. }
  1840. string costContentSql = $"Select * From Grp_GroupCost";
  1841. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1842. //处理日期为空的天数
  1843. for (int i = 0; i < groupCostDetails.Count; i++)
  1844. if (i != 0)
  1845. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1846. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1847. /*
  1848. * 处理详情数据
  1849. */
  1850. foreach (var entity in entityList)
  1851. {
  1852. var _detail = new Grp_CreditCardPaymentDetailView();
  1853. _detail.Id = entity.Id;
  1854. _detail.PriceName = priceModule;
  1855. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1856. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1857. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1858. //处理金额
  1859. if (entity.CTable == 1015)
  1860. {
  1861. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1862. if (czInfo != null)
  1863. {
  1864. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1865. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1866. }
  1867. }
  1868. /*
  1869. * 应付款金额
  1870. */
  1871. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1872. string PaymentCurrency_WaitPay = "Unknown";
  1873. string hotelCurrncyCode = "Unknown";
  1874. string hotelCurrncyName = "Unknown";
  1875. if (sdPaymentCurrency_WaitPay != null)
  1876. {
  1877. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1878. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1879. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1880. if (hotelCurrncyCode.Equals("CNY"))
  1881. {
  1882. entity.DayRate = 1.0000M;
  1883. }
  1884. }
  1885. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1886. /*
  1887. * 此次付款金额
  1888. */
  1889. decimal CurrPayStr = 0.00M,
  1890. OriginalCurrPay = 0.00M;
  1891. if (entity.PayPercentage == 0)
  1892. {
  1893. if (entity.PayThenMoney != 0)
  1894. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1895. }
  1896. else
  1897. {
  1898. if (entity.PayMoney != 0)
  1899. {
  1900. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1901. }
  1902. }
  1903. //if (_dto.Label == 79)
  1904. //{
  1905. // string original = string.Empty;
  1906. // if (hotelCurrncyCode.Equals("CNY"))
  1907. // {
  1908. // OriginalCurrPay = CurrPayStr;
  1909. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1910. // }
  1911. // else
  1912. // {
  1913. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1914. // //760 EUR(7600.00 CNY)
  1915. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1916. // }
  1917. //}
  1918. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1919. string original = string.Empty;
  1920. if (hotelCurrncyCode.Equals("CNY"))
  1921. {
  1922. OriginalCurrPay = CurrPayStr;
  1923. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1924. }
  1925. else
  1926. {
  1927. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1928. //760 EUR(7600.00 CNY)
  1929. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1930. }
  1931. /*
  1932. * 剩余尾款
  1933. */
  1934. decimal BalanceStr = 0;
  1935. if (CurrPayStr != 0)
  1936. {
  1937. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1938. BalanceStr = 0;
  1939. else
  1940. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1941. }
  1942. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1943. /*
  1944. * Bus名称
  1945. */
  1946. _detail.BusName = "待增加";
  1947. /*
  1948. *费用所属
  1949. */
  1950. switch (entity.CTable)
  1951. {
  1952. case 76://酒店预订
  1953. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1954. if (hotelReservations != null)
  1955. {
  1956. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1957. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1958. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1959. string roomFeeStr = "", roomFeestr1 = "";
  1960. //是否比较房型价格
  1961. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1962. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1963. roomFeeStr += $"<br/>";
  1964. var roomTotal = 0.00M;
  1965. if (hotelReservations.SingleRoomPrice > 0)
  1966. {
  1967. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1968. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1969. __isSingle = true;
  1970. roomTotal += fee;
  1971. }
  1972. if (hotelReservations.DoubleRoomPrice > 0)
  1973. {
  1974. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1975. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1976. __isDouble = true;
  1977. roomTotal += fee;
  1978. }
  1979. if (hotelReservations.SuiteRoomPrice > 0)
  1980. {
  1981. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  1982. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1983. __isSuite = true;
  1984. roomTotal += fee;
  1985. }
  1986. if (hotelReservations.OtherRoomPrice > 0)
  1987. {
  1988. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  1989. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1990. __isOther = true;
  1991. roomTotal += fee;
  1992. }
  1993. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  1994. else roomFeeStr += " 0.00 * 0";
  1995. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1996. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1997. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1998. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1999. /*
  2000. * 费用类型
  2001. * 1:房费
  2002. * 2:早餐
  2003. * 3:地税
  2004. * 4:城市税
  2005. * </summary>
  2006. */
  2007. //地税
  2008. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2009. if (governmentRentData != null)
  2010. {
  2011. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2012. governmentRentFee = governmentRentData.Price;
  2013. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2014. if (governmentRentCurrData != null)
  2015. {
  2016. governmentRentCode = governmentRentCurrData.Name;
  2017. governmentRentName = $"({governmentRentCurrData.Remark})";
  2018. }
  2019. }
  2020. //城市税
  2021. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2022. if (cityTaxData != null)
  2023. {
  2024. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2025. cityTaxFee = cityTaxData.Price;
  2026. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2027. if (cityTaxCurrData != null)
  2028. {
  2029. cityTaxCode = cityTaxCurrData.Name;
  2030. cityTaxName = $"({cityTaxCurrData.Remark})";
  2031. }
  2032. }
  2033. //酒店早餐
  2034. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2035. if (breakfastData != null)
  2036. {
  2037. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2038. breakfastFee = breakfastData.Price;
  2039. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2040. if (breakfastCurrData != null)
  2041. {
  2042. breakfastCode = breakfastCurrData.Name;
  2043. breakfastName = $"({breakfastCurrData.Remark})";
  2044. }
  2045. }
  2046. //房间费用
  2047. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2048. if (roomData != null)
  2049. {
  2050. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2051. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2052. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2053. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2054. roomFee = roomData.Price;
  2055. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2056. if (roomCurrData != null)
  2057. {
  2058. roomCode = roomCurrData.Name;
  2059. roomName = $"({roomCurrData.Remark})";
  2060. }
  2061. }
  2062. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2063. string hotelCostStr = "";
  2064. decimal hotelCsotTotal = 0.00M;
  2065. if (groupCost != null)
  2066. {
  2067. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2068. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2069. }
  2070. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2071. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2072. string hotelCost_day = "";
  2073. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2074. foreach (var item in hotelCostDetails1)
  2075. {
  2076. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2077. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2078. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2079. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2080. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2081. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2082. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2083. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2084. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2085. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2086. hotelCost_day += @$"<br/>";
  2087. }
  2088. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2089. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2090. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2091. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2092. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2093. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2094. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2095. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2096. $"房间说明: {hotelReservations.Remark} <br/>" +
  2097. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2098. $"{hotelBreakfastStr}" +
  2099. $"{hotelGovernmentRentStr}" +
  2100. $"{hotelCityTaxStr}";
  2101. _detail.PriceNameContent = hotelReservations.HotelName;
  2102. }
  2103. break;
  2104. case 79://车/导游地接
  2105. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2106. if (touristGuideGroundReservations != null)
  2107. {
  2108. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2109. {
  2110. _detail.BusName = touristGuideGroundReservations.BusName;
  2111. }
  2112. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2113. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2114. //if (isInt)
  2115. //{
  2116. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2117. // if (cityInfo != null)
  2118. // {
  2119. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2120. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2121. // if (carFeeItem != null)
  2122. // {
  2123. // nameContent += $@"({carFeeItem.Name})";
  2124. // }
  2125. // _detail.PriceNameContent = nameContent;
  2126. // }
  2127. //}
  2128. //else
  2129. //{
  2130. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2131. //}
  2132. var touristGuideGroundReservationsContents =
  2133. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2134. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2135. foreach (var item in touristGuideGroundReservationsContents)
  2136. {
  2137. string typeName = "Unknown";
  2138. string carCurrencyCode = "Unknown";
  2139. string carCurrencyName = "Unknown";
  2140. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2141. if (carTypeData != null) typeName = carTypeData.Name;
  2142. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2143. if (currencyData != null)
  2144. {
  2145. carCurrencyCode = currencyData.Name;
  2146. carCurrencyName = currencyData.Remark;
  2147. }
  2148. //op、成本 币种是否一致
  2149. bool IsCurrencyAgreement = false;
  2150. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2151. string opCostStr = string.Empty;
  2152. decimal opCostTypePrice = 0.00M;
  2153. #region 处理成本各项费用
  2154. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2155. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2156. if (opCost.Count > 0)
  2157. {
  2158. switch (item.SId)
  2159. {
  2160. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2161. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2162. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2163. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2164. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2165. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2166. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2167. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2168. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2169. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2170. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2171. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2172. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2173. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2174. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2175. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2176. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2177. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2178. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2179. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2180. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2181. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2182. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2183. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2184. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2185. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2186. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2187. }
  2188. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2189. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2190. }
  2191. #endregion
  2192. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2193. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2194. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2195. $"{opTypeStr} {opCostStr}<br/>" +
  2196. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2197. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2198. }
  2199. _detail.PriceMsgContent = priceMsg;
  2200. }
  2201. break;
  2202. case 80: //签证
  2203. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2204. if (visaInfo != null)
  2205. {
  2206. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2207. _detail.PriceNameContent = visaInfo.VisaDescription;
  2208. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2209. }
  2210. break;
  2211. case 81: //邀请/公务活动
  2212. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2213. if (_ioa != null)
  2214. {
  2215. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2216. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2217. sendCurrName = "Unknown", //快递费用币种 Name
  2218. sendCurrCode = "Unknown", //快递费用币种 Code
  2219. eventsCurrName = "Unknown", //公务活动费币种 Name
  2220. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2221. translateCurrName = "Unknown", //公务翻译费 Name
  2222. translateCurrCode = "Unknown"; //公务翻译费 Code
  2223. #region 处理费用币种
  2224. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2225. if (inviteCurrData != null)
  2226. {
  2227. inviteCurrName = inviteCurrData.Remark;
  2228. inviteCurrCode = inviteCurrData.Name;
  2229. }
  2230. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2231. if (sendCurrData != null)
  2232. {
  2233. sendCurrName = sendCurrData.Remark;
  2234. sendCurrCode = sendCurrData.Name;
  2235. }
  2236. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2237. if (eventsCurrData != null)
  2238. {
  2239. eventsCurrName = eventsCurrData.Remark;
  2240. eventsCurrCode = eventsCurrData.Name;
  2241. }
  2242. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2243. if (translateCurrData != null)
  2244. {
  2245. translateCurrName = translateCurrData.Remark;
  2246. translateCurrCode = translateCurrData.Name;
  2247. }
  2248. #endregion
  2249. _detail.PriceNameContent = _ioa.InviterArea;
  2250. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2251. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2252. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2253. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2254. $@"备注:" + _ioa.Remark + "<br/>";
  2255. }
  2256. break;
  2257. case 82: //团组客户保险
  2258. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2259. if (customers != null)
  2260. {
  2261. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2262. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2263. }
  2264. break;
  2265. case 85: //机票预订
  2266. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2267. if (jpRes != null)
  2268. {
  2269. string FlightsDescription = jpRes.FlightsDescription;
  2270. string PriceDescription = jpRes.PriceDescription;
  2271. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2272. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2273. }
  2274. break;
  2275. case 98://其他款项
  2276. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2277. if (gdpRes != null)
  2278. {
  2279. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2280. _detail.PriceNameContent = gdpRes.PriceName;
  2281. }
  2282. break;
  2283. case 285://收款退还
  2284. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2285. if (refundAndOtherMoney != null)
  2286. {
  2287. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2288. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2289. }
  2290. break;
  2291. case 751://酒店早餐
  2292. break;
  2293. case 1015://超支费用
  2294. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2295. if (groupExtraCost != null)
  2296. {
  2297. _detail.PriceNameContent = groupExtraCost.PriceName;
  2298. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2299. }
  2300. break;
  2301. default:
  2302. break;
  2303. }
  2304. /*
  2305. * 申请人
  2306. */
  2307. string operatorName = " - ";
  2308. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2309. if (_opUser != null)
  2310. {
  2311. operatorName = _opUser.CnName;
  2312. }
  2313. _detail.OperatorName = operatorName;
  2314. /*
  2315. * 审核人
  2316. */
  2317. string auditOperatorName = "Unknown";
  2318. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2319. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2320. else
  2321. {
  2322. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2323. if (_adUser != null)
  2324. {
  2325. auditOperatorName = _adUser.CnName;
  2326. }
  2327. }
  2328. _detail.AuditOperatorName = auditOperatorName;
  2329. /*
  2330. * 超预算比例
  2331. */
  2332. string overBudgetStr = "";
  2333. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2334. else if (entity.ExceedBudget == 0)
  2335. {
  2336. if (entity.CTable == 76 || entity.CTable == 79)
  2337. {
  2338. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2339. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2340. }
  2341. else
  2342. {
  2343. overBudgetStr = "未超预算";
  2344. }
  2345. }
  2346. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2347. _detail.OverBudget = overBudgetStr;
  2348. decimal auditFee = 0.00M; //已审核金额 人名币
  2349. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2350. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2351. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2352. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2353. {
  2354. auditedFeeOriginal = entity.PayMoney;
  2355. auditFee = CurrPayStr;
  2356. }
  2357. else if (entity.IsAuditGM == 0)
  2358. {
  2359. unAuditFeeCNY = CurrPayStr;
  2360. unAuditFeeOriginal = OriginalCurrPay;
  2361. OriginalCurrPay = 0.00M;
  2362. }
  2363. /*
  2364. * 费用总计
  2365. */
  2366. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2367. {
  2368. CurrencyId = entity.PaymentCurrency,
  2369. CurrencyName = PaymentCurrency_WaitPay,
  2370. AmountPayable = entity.PayMoney,
  2371. ThisPayment = OriginalCurrPay,
  2372. BalancePayment = BalanceStr,
  2373. AuditedFunds = auditFee,
  2374. AuditedFundsOriginal = auditedFeeOriginal,
  2375. UnAuditFundsCNY = unAuditFeeCNY,
  2376. UnAuditFundsOriginal = unAuditFeeOriginal
  2377. });
  2378. _detail.IsAuditGM = entity.IsAuditGM;
  2379. detailList.Add(_detail);
  2380. }
  2381. #endregion
  2382. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2383. /*
  2384. * 下方描述处理
  2385. */
  2386. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2387. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2388. if (ccpCurrencyPrice != null)
  2389. {
  2390. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2391. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2392. }
  2393. else
  2394. {
  2395. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2396. }
  2397. string amountPayableStr = string.Format(@"应付款总金额: ");
  2398. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2399. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2400. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2401. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2402. foreach (var item in nonDuplicat)
  2403. {
  2404. var currencyName = item.CurrencyName;
  2405. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2406. if (strs.Count > 0)
  2407. {
  2408. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2409. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2410. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2411. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2412. //单独处理此次付款金额
  2413. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2414. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2415. //单独处理已审核费用
  2416. //if (item.CurrencyId == 836) //人民币
  2417. //{
  2418. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2419. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2420. //}
  2421. //else
  2422. //{
  2423. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2424. //}
  2425. if (currencyName.Equals("CNY"))
  2426. {
  2427. //已审核费用
  2428. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2429. //未审核费用
  2430. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2431. }
  2432. else
  2433. {
  2434. //已审核费用
  2435. 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"));
  2436. //未审核费用
  2437. 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"));
  2438. }
  2439. }
  2440. }
  2441. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2442. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2443. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2444. _view.TotalStr4 = $"{auditedFundsStr.Substring(0, auditedFundsStr.Length - 1)}<br/>{unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1)}";
  2445. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2446. var _view1 = new
  2447. {
  2448. PageFuncAuth = pageFunAuthView,
  2449. Data = _view
  2450. };
  2451. return Ok(JsonView(_view1));
  2452. }
  2453. catch (Exception ex)
  2454. {
  2455. return Ok(JsonView(false, ex.Message));
  2456. }
  2457. }
  2458. /// <summary>
  2459. /// 费用审核
  2460. /// 修改团组费用审核状态
  2461. /// </summary>
  2462. /// <param name="_dto">参数Json字符串</param>
  2463. /// <returns></returns>
  2464. [HttpPost]
  2465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2466. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2467. {
  2468. #region 参数验证
  2469. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2470. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2471. #endregion
  2472. #region 页面操作权限验证
  2473. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2474. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2475. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2476. #endregion
  2477. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2478. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2479. DateTime dtNow = DateTime.Now;
  2480. _groupRepository.BeginTran();
  2481. int rst = 0;
  2482. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2483. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2484. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2485. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2486. List<dynamic> msgDatas = new List<dynamic>();
  2487. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2488. foreach (var item in idList)
  2489. {
  2490. int CreditId = int.Parse(item);
  2491. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2492. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2493. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2494. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2495. .Where(s => s.Id == CreditId)
  2496. .ExecuteCommandAsync();
  2497. if (result < 1)
  2498. {
  2499. rst = -1;
  2500. _groupRepository.RollbackTran();
  2501. return Ok(JsonView(false, "操作失败并回滚!"));
  2502. }
  2503. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2504. if (creditData != null)
  2505. {
  2506. #region 应用通知配置
  2507. try
  2508. {
  2509. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2510. }
  2511. catch (Exception ex)
  2512. {
  2513. }
  2514. #endregion
  2515. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2516. string groupNameStr = string.Empty;
  2517. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2518. if (groupData != null) groupNameStr = groupData.TeamName;
  2519. string creditTypeStr = string.Empty;
  2520. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2521. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2522. string creditCurrency = string.Empty;
  2523. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2524. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2525. if (creditCurrency.Equals("CNY"))
  2526. {
  2527. creditData.DayRate = 1.0000M;
  2528. }
  2529. if (creditData.PayPercentage == 0.00M)
  2530. {
  2531. creditData.PayPercentage = 100M;
  2532. }
  2533. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2534. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2535. string msgContent = "";
  2536. if (creditCurrency.Equals("CNY"))
  2537. {
  2538. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2539. }
  2540. else
  2541. {
  2542. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2543. }
  2544. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2545. }
  2546. }
  2547. if (rst == 0)
  2548. {
  2549. _groupRepository.CommitTran();
  2550. foreach (var item in msgDatas)
  2551. {
  2552. //发送消息
  2553. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2554. }
  2555. #region 应用推送
  2556. try
  2557. {
  2558. foreach (var ccpId in dic_ccp_user.Keys)
  2559. {
  2560. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2561. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2562. }
  2563. }
  2564. catch (Exception)
  2565. {
  2566. }
  2567. #endregion
  2568. return Ok(JsonView(true, "操作成功!"));
  2569. }
  2570. return Ok(JsonView(false, "操作失败!"));
  2571. }
  2572. #endregion
  2573. #region 机票费用录入
  2574. /// <summary>
  2575. /// 机票录入当前登录人可操作团组
  2576. /// </summary>
  2577. /// <param name="dto"></param>
  2578. /// <returns></returns>
  2579. [HttpPost]
  2580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2581. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2582. {
  2583. try
  2584. {
  2585. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2586. if (groupData.Code != 0)
  2587. {
  2588. return Ok(JsonView(false, groupData.Msg));
  2589. }
  2590. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2591. }
  2592. catch (Exception ex)
  2593. {
  2594. return Ok(JsonView(false, "程序错误!"));
  2595. throw;
  2596. }
  2597. }
  2598. /// <summary>
  2599. /// 机票费用录入列表
  2600. /// </summary>
  2601. /// <param name="dto"></param>
  2602. /// <returns></returns>
  2603. [HttpPost]
  2604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2605. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2606. {
  2607. try
  2608. {
  2609. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2610. if (groupData.Code != 0)
  2611. {
  2612. return Ok(JsonView(false, groupData.Msg));
  2613. }
  2614. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2615. }
  2616. catch (Exception ex)
  2617. {
  2618. return Ok(JsonView(false, ex.Message));
  2619. throw;
  2620. }
  2621. }
  2622. /// <summary>
  2623. /// 根据id查询费用录入信息
  2624. /// </summary>
  2625. /// <param name="dto"></param>
  2626. /// <returns></returns>
  2627. [HttpPost]
  2628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2629. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2630. {
  2631. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2632. if (groupData.Code != 0)
  2633. {
  2634. return Ok(JsonView(false, groupData.Msg));
  2635. }
  2636. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2637. }
  2638. /// <summary>
  2639. /// 机票费用录入操作(Status:1.新增,2.修改)
  2640. /// </summary>
  2641. /// <param name="dto"></param>
  2642. /// <returns></returns>
  2643. [HttpPost]
  2644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2645. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2646. {
  2647. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2648. if (groupData.Code != 0)
  2649. {
  2650. return Ok(JsonView(false, groupData.Msg));
  2651. }
  2652. #region 应用推送
  2653. try
  2654. {
  2655. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2656. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2657. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2658. //2024-10-21 新增LZ UID
  2659. var userIds = new List<int>() { 21 };
  2660. string title = $"系统通知";
  2661. string content = "";
  2662. var diId = dto.AirTicketResOpData.DiId;
  2663. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2664. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2665. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2666. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2667. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2668. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2669. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2670. }
  2671. catch (Exception ex)
  2672. {
  2673. }
  2674. #endregion
  2675. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2676. }
  2677. /// <summary>
  2678. /// 根据舱位类型查询接团客户名单信息
  2679. /// </summary>
  2680. /// <param name="dto"></param>
  2681. /// <returns></returns>
  2682. [HttpPost]
  2683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2684. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2685. {
  2686. try
  2687. {
  2688. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2689. if (crm_Groups.Count != 0)
  2690. {
  2691. List<dynamic> Customer = new List<dynamic>();
  2692. foreach (var item in crm_Groups)
  2693. {
  2694. var data = new
  2695. {
  2696. Id = item.Id,
  2697. Pinyin = item.Pinyin,
  2698. Name = item.LastName + item.FirstName
  2699. };
  2700. Customer.Add(data);
  2701. }
  2702. return Ok(JsonView(true, "查询成功!", Customer));
  2703. }
  2704. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2705. }
  2706. catch (Exception ex)
  2707. {
  2708. return Ok(JsonView(false, "程序错误!"));
  2709. throw;
  2710. }
  2711. }
  2712. /// <summary>
  2713. /// 根据团号获取客户信息
  2714. /// </summary>
  2715. /// <param name="dto"></param>
  2716. /// <returns></returns>
  2717. [HttpPost]
  2718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2719. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2720. {
  2721. var jw = JsonView(false);
  2722. if (dto.DIID < 1)
  2723. {
  2724. jw.Msg += "请输入正确的diid";
  2725. return Ok(jw);
  2726. }
  2727. var arr = getSimplClientList(dto.DIID);
  2728. jw = JsonView(true, "获取成功!", arr);
  2729. return Ok(jw);
  2730. }
  2731. private List<SimplClientInfo> getSimplClientList(int diId)
  2732. {
  2733. 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);
  2734. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2735. foreach (var item in arr)
  2736. {
  2737. EncryptionProcessor.DecryptProperties(item);
  2738. }
  2739. return arr;
  2740. }
  2741. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2742. {
  2743. string result = origin;
  2744. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2745. {
  2746. string[] temparr = origin.Split(',');
  2747. string fistrStr = temparr[0];
  2748. int count = temparr.Count();
  2749. int tempId;
  2750. bool success = int.TryParse(fistrStr, out tempId);
  2751. if (success)
  2752. {
  2753. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2754. if (tempInfo != null)
  2755. {
  2756. if (count > 1)
  2757. {
  2758. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2759. }
  2760. else
  2761. {
  2762. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2763. }
  2764. }
  2765. }
  2766. }
  2767. return result;
  2768. }
  2769. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2770. {
  2771. string result = origin;
  2772. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2773. {
  2774. string[] temparr = origin.Split(',');
  2775. result = "";
  2776. foreach (var item in temparr)
  2777. {
  2778. int tempId;
  2779. bool success = int.TryParse(item, out tempId);
  2780. if (success)
  2781. {
  2782. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2783. if (tempInfo != null)
  2784. {
  2785. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2786. }
  2787. }
  2788. }
  2789. }
  2790. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2791. return result;
  2792. }
  2793. /// <summary>
  2794. /// 机票费用录入,删除
  2795. /// </summary>
  2796. /// <param name="dto"></param>
  2797. /// <returns></returns>
  2798. [HttpPost]
  2799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2800. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2801. {
  2802. try
  2803. {
  2804. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2805. if (res)
  2806. {
  2807. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2808. {
  2809. IsDel = 1,
  2810. DeleteUserId = dto.DeleteUserId,
  2811. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2812. }).ExecuteCommandAsync();
  2813. return Ok(JsonView(true, "删除成功!"));
  2814. }
  2815. return Ok(JsonView(false, "删除失败!"));
  2816. }
  2817. catch (Exception ex)
  2818. {
  2819. return Ok(JsonView(false, "程序错误!"));
  2820. throw;
  2821. }
  2822. }
  2823. /// <summary>
  2824. /// 导出机票录入报表
  2825. /// </summary>
  2826. /// <param name="dto"></param>
  2827. /// <returns></returns>
  2828. [HttpPost]
  2829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2830. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2831. {
  2832. try
  2833. {
  2834. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2835. if (groupData.Code != 0)
  2836. {
  2837. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2838. }
  2839. else
  2840. {
  2841. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2842. if (AirTicketReservations.Count != 0)
  2843. {
  2844. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2845. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2846. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2847. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2848. WorkbookDesigner designer = new WorkbookDesigner();
  2849. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2850. decimal countCost = 0;
  2851. foreach (var item in AirTicketReservations)
  2852. {
  2853. #region 处理客人姓名
  2854. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2855. item.ClientName = clientNames;
  2856. #endregion
  2857. if (item.BankType == "其他")
  2858. {
  2859. item.BankNo = "--";
  2860. }
  2861. else
  2862. {
  2863. if (!string.IsNullOrEmpty(item.BankType))
  2864. {
  2865. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2866. }
  2867. }
  2868. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2869. item.Price = System.Decimal.Round(item.Price, 2);
  2870. countCost += Convert.ToDecimal(item.Price);
  2871. }
  2872. designer.SetDataSource("Export", AirTicketReservations);
  2873. designer.SetDataSource("ExportDiCode", diCode);
  2874. designer.SetDataSource("ExportDiName", diName);
  2875. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2876. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2877. designer.Process();
  2878. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2879. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2880. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2881. return Ok(JsonView(true, "成功", url = rst));
  2882. }
  2883. else
  2884. {
  2885. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2886. }
  2887. }
  2888. }
  2889. catch (Exception ex)
  2890. {
  2891. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2892. throw;
  2893. }
  2894. }
  2895. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2896. /// <summary>
  2897. /// 行程单导出
  2898. /// </summary>
  2899. /// <param name="dto"></param>
  2900. /// <returns></returns>
  2901. [HttpPost]
  2902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2903. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2904. {
  2905. try
  2906. {
  2907. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2908. if (groupData.Code != 0)
  2909. {
  2910. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2911. }
  2912. else
  2913. {
  2914. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2915. if (dto.Language == "CN")
  2916. {
  2917. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2918. DocumentBuilder builder = new DocumentBuilder(doc);
  2919. int tableIndex = 0;//表格索引
  2920. //得到文档中的第一个表格
  2921. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2922. foreach (var item in _AirTicketReservations)
  2923. {
  2924. #region 处理固定数据
  2925. string[] FlightsCode = item.FlightsCode.Split('/');
  2926. if (FlightsCode.Length != 0)
  2927. {
  2928. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2929. if (_AirCompany != null)
  2930. {
  2931. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2932. }
  2933. else
  2934. {
  2935. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2936. }
  2937. }
  2938. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2939. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2940. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2941. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2942. string name = "";
  2943. foreach (string clientName in nameArray)
  2944. {
  2945. if (!name.Contains(clientName))
  2946. {
  2947. name += clientName + ",";
  2948. }
  2949. }
  2950. if (!string.IsNullOrWhiteSpace(name))
  2951. {
  2952. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2953. }
  2954. else
  2955. {
  2956. table.Range.Bookmarks["ClientName"].Text = "--";
  2957. }
  2958. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2959. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2960. table.Range.Bookmarks["JointTicket"].Text = "--";
  2961. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2962. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2963. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2964. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2965. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2966. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2967. #endregion
  2968. #region 循环数据处理
  2969. List<AirInfo> airs = new List<AirInfo>();
  2970. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2971. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2972. for (int i = 0; i < FlightsCode.Length; i++)
  2973. {
  2974. AirInfo air = new AirInfo();
  2975. string[] tempstr = DayArray[i]
  2976. .Replace("\r\n", string.Empty)
  2977. .Replace("\\r\\n", string.Empty)
  2978. .TrimStart().TrimEnd()
  2979. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2980. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2981. string starCity = "";
  2982. if (star_Three != null)
  2983. {
  2984. starCity = star_Three.AirPort;
  2985. }
  2986. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2987. string EndCity = "";
  2988. if (End_Three != null)
  2989. {
  2990. EndCity = End_Three.AirPort;
  2991. }
  2992. air.Destination = starCity + "/" + EndCity;
  2993. air.Flight = FlightsCode[i];
  2994. air.SeatingClass = item.CTypeName;
  2995. string dateTime = tempstr[2];
  2996. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2997. air.FlightDate = DateTemp;
  2998. air.DepartureTime = tempstr[5];
  2999. air.LandingTime = tempstr[6];
  3000. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3001. air.TicketStatus = "--";
  3002. air.Luggage = "--";
  3003. air.DepartureTerminal = "--";
  3004. air.LandingTerminal = "--";
  3005. airs.Add(air);
  3006. }
  3007. int row = 13;
  3008. for (int i = 0; i < airs.Count; i++)
  3009. {
  3010. if (airs.Count > 2)
  3011. {
  3012. for (int j = 0; j < airs.Count - 2; j++)
  3013. {
  3014. var CopyRow = table.Rows[12].Clone(true);
  3015. table.Rows.Add(CopyRow);
  3016. }
  3017. }
  3018. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3019. int index = 0;
  3020. foreach (PropertyInfo property in properties)
  3021. {
  3022. string value = property.GetValue(airs[i]).ToString();
  3023. Cell ishcel0 = table.Rows[row].Cells[index];
  3024. Paragraph p = new Paragraph(doc);
  3025. string s = value;
  3026. p.AppendChild(new Run(doc, s));
  3027. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3028. ishcel0.AppendChild(p);
  3029. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3030. index++;
  3031. }
  3032. row++;
  3033. }
  3034. #endregion
  3035. Paragraph lastParagraph = new Paragraph(doc);
  3036. //第一个表格末尾加段落
  3037. table.ParentNode.InsertAfter(lastParagraph, table);
  3038. //复制第一个表格
  3039. Table cloneTable = (Table)table.Clone(true);
  3040. //在文档末尾段落后面加入复制的表格
  3041. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3042. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3043. {
  3044. int rownewsIndex = 13;
  3045. for (int i = 0; i < 2; i++)
  3046. {
  3047. var CopyRow = table.Rows[12].Clone(true);
  3048. table.Rows.RemoveAt(13);
  3049. table.Rows.Add(CopyRow);
  3050. rownewsIndex++;
  3051. }
  3052. }
  3053. else
  3054. {
  3055. table.Rows.RemoveAt(12);
  3056. }
  3057. cloneTable.Rows.RemoveAt(12);
  3058. }
  3059. if (_AirTicketReservations.Count != 0)
  3060. {
  3061. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3062. if (FlightsCode.Length != 0)
  3063. {
  3064. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3065. if (_AirCompany != null)
  3066. {
  3067. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3068. }
  3069. else
  3070. {
  3071. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3072. }
  3073. }
  3074. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3075. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3076. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3077. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3078. string name = "";
  3079. foreach (string clientName in nameArray)
  3080. {
  3081. if (!name.Contains(clientName))
  3082. {
  3083. name += clientName + ",";
  3084. }
  3085. }
  3086. if (!string.IsNullOrWhiteSpace(name))
  3087. {
  3088. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3089. }
  3090. else
  3091. {
  3092. table.Range.Bookmarks["ClientName"].Text = "--";
  3093. }
  3094. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3095. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3096. table.Range.Bookmarks["JointTicket"].Text = "--";
  3097. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3098. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3099. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3100. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3101. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3102. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3103. }
  3104. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3105. //保存合并后的文档
  3106. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3107. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3108. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3109. return Ok(JsonView(true, "成功!", rst));
  3110. }
  3111. else
  3112. {
  3113. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3114. DocumentBuilder builder = new DocumentBuilder(doc);
  3115. int tableIndex = 0;//表格索引
  3116. //得到文档中的第一个表格
  3117. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3118. List<string> texts = new List<string>();
  3119. foreach (var item in _AirTicketReservations)
  3120. {
  3121. string[] FlightsCode = item.FlightsCode.Split('/');
  3122. if (FlightsCode.Length != 0)
  3123. {
  3124. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3125. if (_AirCompany != null)
  3126. {
  3127. if (!transDic.ContainsKey(_AirCompany.CnName))
  3128. {
  3129. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3130. }
  3131. }
  3132. else
  3133. {
  3134. if (!transDic.ContainsKey("--"))
  3135. {
  3136. transDic.Add("--", "--");
  3137. }
  3138. }
  3139. }
  3140. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3141. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3142. string name = "";
  3143. foreach (string clientName in nameArray)
  3144. {
  3145. name += clientName + ",";
  3146. }
  3147. if (!texts.Contains(name))
  3148. {
  3149. texts.Add(name);
  3150. }
  3151. List<AirInfo> airs = new List<AirInfo>();
  3152. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3153. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3154. for (int i = 0; i < FlightsCode.Length; i++)
  3155. {
  3156. AirInfo air = new AirInfo();
  3157. string[] tempstr = DayArray[i]
  3158. .Replace("\r\n", string.Empty)
  3159. .Replace("\\r\\n", string.Empty)
  3160. .TrimStart().TrimEnd()
  3161. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3162. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3163. if (star_Three != null)
  3164. {
  3165. if (!transDic.ContainsKey(star_Three.AirPort))
  3166. {
  3167. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3168. }
  3169. }
  3170. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3171. if (End_Three != null)
  3172. {
  3173. if (!transDic.ContainsKey(End_Three.AirPort))
  3174. {
  3175. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3176. }
  3177. }
  3178. if (!texts.Contains(item.CTypeName))
  3179. {
  3180. texts.Add(item.CTypeName);
  3181. }
  3182. }
  3183. }
  3184. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3185. if (transData.Count > 0)
  3186. {
  3187. foreach (TranslateResult item in transData)
  3188. {
  3189. if (!transDic.ContainsKey(item.Query))
  3190. {
  3191. transDic.Add(item.Query, item.Translation);
  3192. }
  3193. }
  3194. }
  3195. foreach (var item in _AirTicketReservations)
  3196. {
  3197. #region 处理固定数据
  3198. string[] FlightsCode = item.FlightsCode.Split('/');
  3199. if (FlightsCode.Length != 0)
  3200. {
  3201. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3202. if (_AirCompany != null)
  3203. {
  3204. string str = "--";
  3205. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3206. if (!string.IsNullOrEmpty(translateResult))
  3207. {
  3208. str = translateResult;
  3209. str = _airTicketResRep.Processing(str);
  3210. }
  3211. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3212. }
  3213. else
  3214. {
  3215. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3216. }
  3217. }
  3218. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3219. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3220. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3221. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3222. string names = "";
  3223. foreach (string clientName in nameArray)
  3224. {
  3225. names += clientName + ",";
  3226. }
  3227. if (!string.IsNullOrWhiteSpace(names))
  3228. {
  3229. string str = "--";
  3230. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3231. if (!string.IsNullOrEmpty(translateResult))
  3232. {
  3233. str = translateResult;
  3234. str = _airTicketResRep.Processing(str);
  3235. }
  3236. table.Range.Bookmarks["ClientName"].Text = str;
  3237. }
  3238. else
  3239. {
  3240. table.Range.Bookmarks["ClientName"].Text = "--";
  3241. }
  3242. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3243. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3244. table.Range.Bookmarks["JointTicket"].Text = "--";
  3245. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3246. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3247. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3248. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3249. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3250. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3251. #endregion
  3252. #region 循环数据处理
  3253. List<AirInfo> airs = new List<AirInfo>();
  3254. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3255. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3256. for (int i = 0; i < FlightsCode.Length; i++)
  3257. {
  3258. AirInfo air = new AirInfo();
  3259. string[] tempstr = DayArray[i]
  3260. .Replace("\r\n", string.Empty)
  3261. .Replace("\\r\\n", string.Empty)
  3262. .TrimStart().TrimEnd()
  3263. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3264. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3265. string starCity = "";
  3266. if (star_Three != null)
  3267. {
  3268. string str2 = "--";
  3269. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3270. if (!string.IsNullOrEmpty(translateResult2))
  3271. {
  3272. str2 = translateResult2;
  3273. str2 = _airTicketResRep.Processing(str2);
  3274. }
  3275. starCity = str2;
  3276. }
  3277. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3278. string EndCity = "";
  3279. if (End_Three != null)
  3280. {
  3281. string str1 = "--";
  3282. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3283. if (!string.IsNullOrEmpty(translateResult1))
  3284. {
  3285. str1 = translateResult1;
  3286. str1 = _airTicketResRep.Processing(str1);
  3287. }
  3288. EndCity = str1;
  3289. }
  3290. air.Destination = starCity + "/" + EndCity;
  3291. air.Flight = FlightsCode[i];
  3292. string str = "--";
  3293. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3294. if (!string.IsNullOrEmpty(translateResult))
  3295. {
  3296. str = translateResult;
  3297. str = _airTicketResRep.Processing(str);
  3298. }
  3299. air.SeatingClass = str;
  3300. string dateTime = tempstr[2];
  3301. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3302. air.FlightDate = DateTemp;
  3303. air.DepartureTime = tempstr[5];
  3304. air.LandingTime = tempstr[6];
  3305. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3306. air.TicketStatus = "--";
  3307. air.Luggage = "--";
  3308. air.DepartureTerminal = "--";
  3309. air.LandingTerminal = "--";
  3310. airs.Add(air);
  3311. }
  3312. int row = 13;
  3313. for (int i = 0; i < airs.Count; i++)
  3314. {
  3315. if (airs.Count > 2)
  3316. {
  3317. for (int j = 0; j < airs.Count - 2; j++)
  3318. {
  3319. var CopyRow = table.Rows[12].Clone(true);
  3320. table.Rows.Add(CopyRow);
  3321. }
  3322. }
  3323. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3324. int index = 0;
  3325. foreach (PropertyInfo property in properties)
  3326. {
  3327. string value = property.GetValue(airs[i]).ToString();
  3328. Cell ishcel0 = table.Rows[row].Cells[index];
  3329. Paragraph p = new Paragraph(doc);
  3330. string s = value;
  3331. p.AppendChild(new Run(doc, s));
  3332. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3333. ishcel0.AppendChild(p);
  3334. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3335. //ishcel0.CellFormat.VerticalAlignment=
  3336. index++;
  3337. }
  3338. row++;
  3339. }
  3340. #endregion
  3341. Paragraph lastParagraph = new Paragraph(doc);
  3342. //第一个表格末尾加段落
  3343. table.ParentNode.InsertAfter(lastParagraph, table);
  3344. //复制第一个表格
  3345. Table cloneTable = (Table)table.Clone(true);
  3346. //在文档末尾段落后面加入复制的表格
  3347. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3348. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3349. {
  3350. int rownewsIndex = 13;
  3351. for (int i = 0; i < 2; i++)
  3352. {
  3353. var CopyRow = table.Rows[12].Clone(true);
  3354. table.Rows.RemoveAt(13);
  3355. table.Rows.Add(CopyRow);
  3356. rownewsIndex++;
  3357. }
  3358. }
  3359. else
  3360. {
  3361. table.Rows.RemoveAt(12);
  3362. }
  3363. cloneTable.Rows.RemoveAt(12);
  3364. }
  3365. if (_AirTicketReservations.Count != 0)
  3366. {
  3367. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3368. if (FlightsCode.Length != 0)
  3369. {
  3370. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3371. if (_AirCompany != null)
  3372. {
  3373. string str = "--";
  3374. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3375. if (!string.IsNullOrEmpty(translateResult))
  3376. {
  3377. str = translateResult;
  3378. str = _airTicketResRep.Processing(str);
  3379. }
  3380. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3381. }
  3382. else
  3383. {
  3384. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3385. }
  3386. }
  3387. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3388. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3389. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3390. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3391. string names = "";
  3392. foreach (string clientName in nameArray)
  3393. {
  3394. names += clientName + ",";
  3395. }
  3396. if (!string.IsNullOrWhiteSpace(names))
  3397. {
  3398. string str = "--";
  3399. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3400. if (!string.IsNullOrEmpty(translateResult))
  3401. {
  3402. str = translateResult;
  3403. str = _airTicketResRep.Processing(str);
  3404. }
  3405. table.Range.Bookmarks["ClientName"].Text = str;
  3406. }
  3407. else
  3408. {
  3409. table.Range.Bookmarks["ClientName"].Text = "--";
  3410. }
  3411. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3412. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3413. table.Range.Bookmarks["JointTicket"].Text = "--";
  3414. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3415. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3416. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3417. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3418. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3419. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3420. }
  3421. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3422. //保存合并后的文档
  3423. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3424. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3425. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3426. return Ok(JsonView(true, "成功!", rst));
  3427. }
  3428. }
  3429. }
  3430. catch (Exception ex)
  3431. {
  3432. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3433. throw;
  3434. }
  3435. }
  3436. #endregion
  3437. #region 团组增减款项 --> 其他款项
  3438. /// <summary>
  3439. /// 团组增减款项下拉框绑定
  3440. /// </summary>
  3441. /// <param name="dto"></param>
  3442. /// <returns></returns>
  3443. [HttpPost]
  3444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3445. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3446. {
  3447. #region 参数验证
  3448. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3449. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3450. #endregion
  3451. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3452. }
  3453. /// <summary>
  3454. /// 根据团组Id查询团组增减款项
  3455. /// </summary>
  3456. /// <param name="dto"></param>
  3457. /// <returns></returns>
  3458. [HttpPost]
  3459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3460. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3461. {
  3462. #region 参数验证
  3463. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3464. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3465. #endregion
  3466. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3467. }
  3468. /// <summary>
  3469. /// 团组增减款项操作(Status:1.新增,2.修改)
  3470. /// </summary>
  3471. /// <param name="dto"></param>
  3472. /// <returns></returns>
  3473. [HttpPost]
  3474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3475. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3476. {
  3477. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3478. if (groupData.Code != 200)
  3479. {
  3480. return Ok(JsonView(false, groupData.Msg));
  3481. }
  3482. #region 应用推送
  3483. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3484. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3485. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3486. //自动审核
  3487. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3488. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3489. //2024-10-21 新增LZ UID
  3490. var userIds = new List<int>() { 21 };
  3491. string title = $"系统通知";
  3492. string content = "";
  3493. var diId = dto.DiId;
  3494. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3495. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3496. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3497. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3498. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3499. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3500. #endregion
  3501. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3502. }
  3503. /// <summary>
  3504. /// 团组增减款项操作 删除
  3505. /// </summary>
  3506. /// <param name="dto"></param>
  3507. /// <returns></returns>
  3508. [HttpPost]
  3509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3510. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3511. {
  3512. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3513. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3514. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3515. if (res.Code == 0)
  3516. {
  3517. return Ok(JsonView(true, "删除成功!"));
  3518. }
  3519. return Ok(JsonView(false, "删除失败!"));
  3520. }
  3521. /// <summary>
  3522. /// 根据团组增减款项Id查询
  3523. /// </summary>
  3524. /// <param name="dto"></param>
  3525. /// <returns></returns>
  3526. [HttpPost]
  3527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3528. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3529. {
  3530. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3531. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3532. }
  3533. /// <summary>
  3534. /// 查询供应商名称
  3535. /// </summary>
  3536. /// <param name="dto"></param>
  3537. /// <returns></returns>
  3538. [HttpPost]
  3539. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3540. {
  3541. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3542. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3543. ?? new List<Grp_DecreasePayments>();
  3544. dbResult = dbResult.Distinct(new
  3545. ProductComparer()).ToList();
  3546. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3547. {
  3548. x.Id,
  3549. x.SupplierAddress,
  3550. x.SupplierArea,
  3551. x.SupplierContact,
  3552. x.SupplierContactNumber,
  3553. x.SupplierEmail,
  3554. x.SupplierName,
  3555. x.SupplierSocialAccount,
  3556. x.SupplierTypeId,
  3557. }).ToList());
  3558. return Ok(jw);
  3559. }
  3560. /// <summary>
  3561. /// 团组增减款项 OTA匹配
  3562. /// </summary>
  3563. /// <param name="file"></param>
  3564. /// <returns></returns>
  3565. [HttpPost]
  3566. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3567. {
  3568. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3569. string fileName = file.FileName;
  3570. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3571. {
  3572. return Ok(JsonView(false, "请上传Excel文件!"));
  3573. }
  3574. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3575. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3576. if (!Directory.Exists(path))
  3577. {
  3578. Directory.CreateDirectory(path);
  3579. }
  3580. var filePath = @$"{path}/{fileName}";
  3581. //保存文件
  3582. using (FileStream fs = System.IO.File.Create(filePath))
  3583. {
  3584. file.CopyTo(fs);
  3585. fs.Flush();
  3586. }
  3587. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3588. //读取ExcelFile
  3589. DataTable dt = ConvertExcelToDataTable(filePath);
  3590. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3591. dt.TableName = "TB";
  3592. //修改table列名
  3593. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3594. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3595. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3596. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3597. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3598. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3599. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3600. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3601. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3602. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3603. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3604. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3605. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3606. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3607. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3608. var otaOrderNos = new List<string>();
  3609. foreach (DataRow item in dt.Rows)
  3610. {
  3611. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3612. }
  3613. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3614. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3615. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3616. .Select((dp, di) => new
  3617. {
  3618. dp.PriceName,
  3619. dp.OTAOrderNo,
  3620. dp.FeeTotal,
  3621. di.TeamName,
  3622. })
  3623. .ToListAsync();
  3624. foreach (DataRow item in dt.Rows)
  3625. {
  3626. var otaOrderNo = item["OTAOrderNo"].ToString();
  3627. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3628. if (oaData == null) continue;
  3629. item["GroupName"] = oaData.TeamName;
  3630. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3631. }
  3632. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3633. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3634. List<DataTable> datas = new List<DataTable>();
  3635. datas.Add(dt);
  3636. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3637. return Ok(JsonView(true, "操作成功", new { url = url }));
  3638. }
  3639. #region
  3640. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3641. {
  3642. // 创建Workbook对象
  3643. Workbook workbook = new Workbook(excelFilePath);
  3644. // 获取第一个工作表
  3645. Worksheet worksheet = workbook.Worksheets[0];
  3646. // 将工作表转换为DataTable
  3647. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3648. return dataTable;
  3649. }
  3650. #endregion
  3651. #endregion
  3652. #region 文件上传、删除
  3653. /// <summary>
  3654. /// region 文件上传 可以带参数
  3655. /// </summary>
  3656. /// <param name="file"></param>
  3657. /// <returns></returns>
  3658. [HttpPost]
  3659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3660. public async Task<IActionResult> UploadProject(IFormFile file)
  3661. {
  3662. //var TypeName = Request.Headers["TypeName"].ToString();
  3663. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3664. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3665. ////文件名称
  3666. //string projectFileName = file.FileName;
  3667. ////上传的文件的路径
  3668. //string filePath = $"{fileDir}/{projectFileName}";
  3669. //if (TypeName == "A")//A代表团组增减款项
  3670. //{
  3671. // filePath = fileDir + $@"\团组增减款项相关文件";
  3672. // if (!Directory.Exists(filePath))
  3673. // {
  3674. // Directory.CreateDirectory(filePath);
  3675. // }
  3676. // //上传的文件的路径
  3677. // filePath += $@"\{projectFileName}";
  3678. //}
  3679. //else if (TypeName == "B")//B代表商邀相关文件
  3680. //{
  3681. // //上传的文件的路径
  3682. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3683. // if (!Directory.Exists(filePath))
  3684. // {
  3685. // Directory.CreateDirectory(filePath);
  3686. // }
  3687. // //上传的文件的路径
  3688. // filePath = $@"\{projectFileName}";
  3689. //}
  3690. //try
  3691. //{
  3692. // using (FileStream fs = System.IO.File.Create(filePath))
  3693. // {
  3694. // file.CopyTo(fs);
  3695. // fs.Flush();
  3696. // }
  3697. //}
  3698. //catch (Exception ex)
  3699. //{
  3700. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3701. //}
  3702. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3703. try
  3704. {
  3705. var TypeName = Request.Headers["TypeName"].ToString();
  3706. if (file != null)
  3707. {
  3708. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3709. //文件名称
  3710. string projectFileName = file.FileName;
  3711. //上传的文件的路径
  3712. string filePath = $"{fileDir}/{projectFileName}";
  3713. if (TypeName == "A")//A代表团组增减款项
  3714. {
  3715. if (!Directory.Exists(fileDir))
  3716. {
  3717. Directory.CreateDirectory(fileDir);
  3718. }
  3719. //上传的文件的路径
  3720. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3721. }
  3722. else if (TypeName == "B")//B代表商邀相关文件
  3723. {
  3724. if (!Directory.Exists(fileDir))
  3725. {
  3726. Directory.CreateDirectory(fileDir);
  3727. }
  3728. //上传的文件的路径
  3729. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3730. }
  3731. using (FileStream fs = System.IO.File.Create(filePath))
  3732. {
  3733. file.CopyTo(fs);
  3734. fs.Flush();
  3735. }
  3736. return Ok(JsonView(true, "上传成功!", projectFileName));
  3737. }
  3738. else
  3739. {
  3740. return Ok(JsonView(false, "上传失败!"));
  3741. }
  3742. }
  3743. catch (Exception ex)
  3744. {
  3745. return Ok(JsonView(false, "程序错误!"));
  3746. }
  3747. }
  3748. /// <summary>
  3749. /// 删除指定文件
  3750. /// </summary>
  3751. /// <param name="dto"></param>
  3752. /// <returns></returns>
  3753. [HttpPost]
  3754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3755. public async Task<IActionResult> DelFile(DelFileDto dto)
  3756. {
  3757. try
  3758. {
  3759. var TypeName = Request.Headers["TypeName"].ToString();
  3760. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3761. string filePath = "";
  3762. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3763. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3764. int id = 0;
  3765. if (TypeName == "A")
  3766. {
  3767. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3768. // 删除该文件
  3769. System.IO.File.Delete(filePath);
  3770. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3771. .Where(a => a.Id == dto.Id)
  3772. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3773. .ExecuteCommandAsync();
  3774. }
  3775. else if (TypeName == "B")
  3776. {
  3777. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3778. // 删除该文件
  3779. System.IO.File.Delete(filePath);
  3780. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3781. if (info != null)
  3782. {
  3783. string[] files = new string[] { };
  3784. if (!string.IsNullOrEmpty(info.Attachment))
  3785. {
  3786. try
  3787. {
  3788. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3789. }
  3790. catch (Exception)
  3791. {
  3792. files = new List<string>() { info.Attachment }.ToArray();
  3793. }
  3794. }
  3795. if (files.Length > 0)
  3796. {
  3797. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3798. string filePath2 = string.Empty;
  3799. if (files1.Length > 0)
  3800. {
  3801. filePath2 = JsonConvert.SerializeObject(files1);
  3802. }
  3803. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3804. .Where(a => a.Id == dto.Id)
  3805. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3806. .ExecuteCommandAsync();
  3807. }
  3808. }
  3809. }
  3810. if (id != 0)
  3811. {
  3812. return Ok(JsonView(true, "成功!"));
  3813. }
  3814. else
  3815. {
  3816. return Ok(JsonView(false, "失败!"));
  3817. }
  3818. }
  3819. catch (Exception ex)
  3820. {
  3821. return Ok(JsonView(false, "程序错误!"));
  3822. throw;
  3823. }
  3824. }
  3825. /// <summary>
  3826. /// 文件上传多个文件 可以带参数
  3827. /// </summary>
  3828. /// <param name="file"></param>
  3829. /// <returns></returns>
  3830. [HttpPost]
  3831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3832. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3833. {
  3834. try
  3835. {
  3836. var TypeName = Request.Headers["TypeName"].ToString();
  3837. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3838. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3839. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3840. var filePahts = new List<string>();
  3841. foreach (var file in files)
  3842. {
  3843. //文件名称
  3844. string projectFileName = file.FileName;
  3845. //上传的文件的路径
  3846. string filePath = $"{fileDir}/{projectFileName}";
  3847. if (TypeName == "A")//A代表团组增减款项
  3848. {
  3849. if (!Directory.Exists(fileDir))
  3850. {
  3851. Directory.CreateDirectory(fileDir);
  3852. }
  3853. //上传的文件的路径
  3854. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3855. }
  3856. else if (TypeName == "B")//B代表商邀相关文件
  3857. {
  3858. if (!Directory.Exists(fileDir))
  3859. {
  3860. Directory.CreateDirectory(fileDir);
  3861. }
  3862. //上传的文件的路径
  3863. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3864. }
  3865. using (FileStream fs = System.IO.File.Create(filePath))
  3866. {
  3867. file.CopyTo(fs);
  3868. fs.Flush();
  3869. }
  3870. filePahts.Add(projectFileName);
  3871. }
  3872. return Ok(JsonView(true, "上传成功!", filePahts));
  3873. }
  3874. catch (Exception ex)
  3875. {
  3876. return Ok(JsonView(false, "程序错误!"));
  3877. }
  3878. }
  3879. #endregion
  3880. #region 商邀费用录入
  3881. /// <summary>
  3882. /// 根据团组Id查询商邀费用列表
  3883. /// </summary>
  3884. /// <param name="dto"></param>
  3885. /// <returns></returns>
  3886. [HttpPost]
  3887. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3888. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3889. {
  3890. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3891. if (groupData.Code != 0)
  3892. {
  3893. return Ok(JsonView(false, groupData.Msg));
  3894. }
  3895. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3896. }
  3897. /// <summary>
  3898. /// 商邀费用列表
  3899. /// 下载文件
  3900. /// </summary>
  3901. /// <param name="dto"></param>
  3902. /// <returns></returns>
  3903. [HttpGet("{id}")]
  3904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3905. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3906. {
  3907. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3908. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3909. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3910. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3911. var filePaths = new List<string>();
  3912. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3913. try
  3914. {
  3915. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3916. }
  3917. catch (Exception ex)
  3918. {
  3919. filePaths.Add(info.Attachment);
  3920. }
  3921. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3922. for (int i = 0; i < filePaths.Count; i++)
  3923. {
  3924. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3925. }
  3926. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3927. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3928. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3929. {
  3930. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3931. {
  3932. foreach (string filePath in filePaths)
  3933. {
  3934. if (System.IO.File.Exists(filePath))
  3935. {
  3936. // 获取文件名
  3937. string fileName = Path.GetFileName(filePath);
  3938. // 将文件添加到ZIP归档中
  3939. zipArchive.CreateEntryFromFile(filePath, fileName);
  3940. }
  3941. }
  3942. }
  3943. }
  3944. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3945. }
  3946. /// <summary>
  3947. /// 商邀费用 Info Page 基础数据源
  3948. /// </summary>
  3949. /// <param name="dto"></param>
  3950. /// <returns></returns>
  3951. [HttpPost]
  3952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3953. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3954. {
  3955. try
  3956. {
  3957. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3958. if (groupData.Code != 0)
  3959. {
  3960. return Ok(JsonView(false, groupData.Msg));
  3961. }
  3962. return Ok(JsonView(true, "操作成功", groupData.Data));
  3963. }
  3964. catch (Exception ex)
  3965. {
  3966. return Ok(JsonView(false, ex.Message));
  3967. throw;
  3968. }
  3969. }
  3970. /// <summary>
  3971. /// 根据商邀费用ID查询C表和商邀费用数据
  3972. /// </summary>
  3973. /// <param name="dto"></param>
  3974. /// <returns></returns>
  3975. [HttpPost]
  3976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3977. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3978. {
  3979. try
  3980. {
  3981. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3982. if (groupData.Code != 0)
  3983. {
  3984. return Ok(JsonView(false, groupData.Msg));
  3985. }
  3986. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3987. }
  3988. catch (Exception ex)
  3989. {
  3990. return Ok(JsonView(false, ex.Message));
  3991. throw;
  3992. }
  3993. }
  3994. /// <summary>
  3995. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3996. /// </summary>
  3997. /// <param name="dto"></param>
  3998. /// <returns></returns>
  3999. [HttpPost]
  4000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4001. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4002. {
  4003. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4004. if (groupData.Code != 0)
  4005. {
  4006. return Ok(JsonView(false, groupData.Msg));
  4007. }
  4008. #region 应用推送
  4009. try
  4010. {
  4011. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4012. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4013. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4014. //2024-10-21 新增LZ UID
  4015. var userIds = new List<int>() { 21 };
  4016. string title = $"系统通知";
  4017. string content = "";
  4018. var diId = dto.DiId;
  4019. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4020. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4021. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4022. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4023. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4024. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4025. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4026. }
  4027. catch (Exception ex)
  4028. {
  4029. }
  4030. #endregion
  4031. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4032. }
  4033. /// <summary>
  4034. /// 商邀删除
  4035. /// </summary>
  4036. /// <param name="dto"></param>
  4037. /// <returns></returns>
  4038. [HttpPost]
  4039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4040. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4041. {
  4042. try
  4043. {
  4044. _sqlSugar.BeginTran();
  4045. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4046. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4047. {
  4048. IsDel = 1,
  4049. DeleteUserId = dto.DeleteUserId,
  4050. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4051. })
  4052. .Where(it => it.Id == dto.Id)
  4053. .ExecuteCommand();
  4054. if (res1 > 0)
  4055. {
  4056. int _diId = 0;
  4057. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4058. if (_ioaInfo != null)
  4059. {
  4060. _diId = _ioaInfo.DiId;
  4061. }
  4062. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4063. .SetColumns(a => new Grp_CreditCardPayment()
  4064. {
  4065. IsDel = 1,
  4066. DeleteUserId = dto.DeleteUserId,
  4067. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4068. })
  4069. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4070. .ExecuteCommand();
  4071. if (res2 > 0)
  4072. {
  4073. _sqlSugar.CommitTran();
  4074. return Ok(JsonView(true, "删除成功!"));
  4075. }
  4076. }
  4077. _sqlSugar.RollbackTran();
  4078. return Ok(JsonView(false, "删除失败"));
  4079. }
  4080. catch (Exception ex)
  4081. {
  4082. _sqlSugar.RollbackTran();
  4083. return Ok(JsonView(false, ex.Message));
  4084. }
  4085. }
  4086. /// <summary>
  4087. /// 团组模块文件上传
  4088. /// </summary>
  4089. /// <param name="dto"></param>
  4090. /// <returns></returns>
  4091. [HttpPost]
  4092. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4093. {
  4094. var jw = JsonView(false);
  4095. long M = 1024 * 1024;
  4096. if (dto.Files == null || dto.Files.Count == 0)
  4097. {
  4098. jw.Msg = "无文件信息!";
  4099. return Ok(jw);
  4100. }
  4101. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4102. {
  4103. jw.Msg = "文件大小超过20M!";
  4104. return Ok(jw);
  4105. }
  4106. //var nameSp = dto.File.FileName.Split(".");
  4107. //if (nameSp.Length < 2)
  4108. //{
  4109. // jw.Msg = "拓展名称有误!";
  4110. // return Ok(jw);
  4111. //}
  4112. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4113. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4114. //{
  4115. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4116. // return Ok(jw);
  4117. //}
  4118. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4119. if (Ctable == null)
  4120. {
  4121. jw.Msg = "Ctable指向有误!";
  4122. return Ok(jw);
  4123. }
  4124. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4125. if (groupInfo == null)
  4126. {
  4127. jw.Msg = "团组信息不存在!";
  4128. return Ok(jw);
  4129. }
  4130. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4131. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4132. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4133. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4134. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4135. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4136. try
  4137. {
  4138. if (!Directory.Exists(fileBase))
  4139. {
  4140. Directory.CreateDirectory(fileBase);
  4141. }
  4142. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4143. foreach (var fileStream in dto.Files)
  4144. {
  4145. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4146. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4147. {
  4148. Cid = dto.Cid,
  4149. CreateTime = DateTime.Now,
  4150. CreateUserId = dto.Userid,
  4151. Ctable = dto.Ctable,
  4152. Diid = dto.Diid,
  4153. IsDel = 0,
  4154. FilePath = saveFilePath,
  4155. FileName = fileStream.FileName
  4156. };
  4157. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4158. {
  4159. fileStream.CopyTo(fs);
  4160. fs.Flush();
  4161. }
  4162. saveArr.Add(file);
  4163. }
  4164. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4165. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4166. jw = JsonView(true, "保存成功!", new
  4167. {
  4168. count = addResult,
  4169. filesName = saveArr.Select(x => x.FileName)
  4170. });
  4171. }
  4172. catch (Exception ex)
  4173. {
  4174. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4175. {
  4176. count = 0,
  4177. filesName = new string[0],
  4178. });
  4179. }
  4180. return Ok(jw);
  4181. }
  4182. /// <summary>
  4183. /// 查询各模块已保存文件
  4184. /// </summary>
  4185. /// <param name="dto"></param>
  4186. /// <returns></returns>
  4187. [HttpPost]
  4188. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4189. {
  4190. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4191. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4192. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4193. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4194. {
  4195. expression = Expressionable.Create<Grp_GroupModelFile>()
  4196. .And(x => visaIds.Contains(x.CreateUserId));
  4197. }
  4198. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4199. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4200. .Where(expression.ToExpression())
  4201. .ToList();
  4202. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4203. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4204. {
  4205. x.FileName,
  4206. x.Id,
  4207. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4208. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4209. })));
  4210. }
  4211. /// <summary>
  4212. /// 下载该团组下的所有文件
  4213. /// </summary>
  4214. /// <param name="dto"></param>
  4215. /// <returns></returns>
  4216. [HttpPost]
  4217. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4218. {
  4219. var jw = JsonView(false);
  4220. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4221. if (groupInfo == null)
  4222. {
  4223. jw.Msg = "团组信息不存在!";
  4224. return Ok(jw);
  4225. }
  4226. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4227. var isModule = Convert.ToBoolean(dto.isModule);
  4228. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4229. IOOperatorHelper io = new IOOperatorHelper();
  4230. if (isModule)
  4231. {
  4232. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4233. foreach (var moduleArr in moduleGroup)
  4234. {
  4235. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4236. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4237. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4238. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4239. foreach (var item in moduleArr)
  4240. {
  4241. if (System.IO.File.Exists(item.FilePath))
  4242. {
  4243. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4244. {
  4245. byte[] bytes = new byte[fileStream.Length];
  4246. fileStream.Read(bytes, 0, bytes.Length);
  4247. fileStream.Close();
  4248. Stream stream = new MemoryStream(bytes);
  4249. chiZips.Add(item.FileName, stream);
  4250. }
  4251. }
  4252. }
  4253. if (chiZips.Count > 0)
  4254. {
  4255. var byts = io.ConvertZipStream(chiZips);
  4256. Stream stream = new MemoryStream(byts);
  4257. Zips.Add(key.Name + "_.zip", stream);
  4258. }
  4259. }
  4260. }
  4261. else
  4262. {
  4263. foreach (var item in dbQuery)
  4264. {
  4265. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4266. {
  4267. byte[] bytes = new byte[fileStream.Length];
  4268. fileStream.Read(bytes, 0, bytes.Length);
  4269. fileStream.Close();
  4270. Stream stream = new MemoryStream(bytes);
  4271. while (Zips.Keys.Contains(item.FileName))
  4272. {
  4273. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4274. }
  4275. Zips.Add(item.FileName, stream);
  4276. }
  4277. }
  4278. }
  4279. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4280. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4281. if (Zips.Count > 0)
  4282. {
  4283. var byts = io.ConvertZipStream(Zips);
  4284. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4285. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4286. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4287. }
  4288. else
  4289. {
  4290. jw.Msg = "暂无生成文件!";
  4291. }
  4292. return Ok(jw);
  4293. }
  4294. /// <summary>
  4295. /// 下载该团组下此模块的所有文件
  4296. /// </summary>
  4297. /// <param name="dto"></param>
  4298. /// <returns></returns>
  4299. [HttpPost]
  4300. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4301. {
  4302. var jw = JsonView(false);
  4303. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4304. if (groupInfo == null)
  4305. {
  4306. jw.Msg = "团组信息不存在!";
  4307. return Ok(jw);
  4308. }
  4309. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4310. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4311. && x.IsDel == 0);
  4312. if (key == null)
  4313. {
  4314. jw.Msg = "Ctable指向错误!";
  4315. return Ok(jw);
  4316. }
  4317. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4318. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4319. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4320. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4321. IOOperatorHelper io = new IOOperatorHelper();
  4322. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4323. foreach (var item in dbQuery)
  4324. {
  4325. if (System.IO.File.Exists(item.FilePath))
  4326. {
  4327. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4328. {
  4329. byte[] bytes = new byte[fileStream.Length];
  4330. fileStream.Read(bytes, 0, bytes.Length);
  4331. fileStream.Close();
  4332. Stream stream = new MemoryStream(bytes);
  4333. while (Zips.Keys.Contains(item.FileName))
  4334. {
  4335. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4336. }
  4337. Zips.Add(item.FileName, stream);
  4338. }
  4339. }
  4340. }
  4341. if (Zips.Count > 0)
  4342. {
  4343. var byts = io.ConvertZipStream(Zips);
  4344. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4345. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4346. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4347. }
  4348. else
  4349. {
  4350. jw.Msg = "暂无生成文件!";
  4351. }
  4352. return Ok(jw);
  4353. }
  4354. /// <summary>
  4355. /// 删除该团组下的指定文件
  4356. /// </summary>
  4357. /// <param name="dto"></param>
  4358. /// <returns></returns>
  4359. [HttpPost]
  4360. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4361. {
  4362. var jw = JsonView(false);
  4363. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4364. if (sing == null)
  4365. {
  4366. jw.Msg = "暂无";
  4367. return Ok(jw);
  4368. }
  4369. if (System.IO.File.Exists(sing.FilePath))
  4370. {
  4371. try
  4372. {
  4373. System.IO.File.Delete(sing.FilePath);
  4374. }
  4375. catch (Exception ex)
  4376. {
  4377. jw.Msg = "删除失败!" + ex.Message;
  4378. return Ok(jw);
  4379. }
  4380. }
  4381. sing.IsDel = 1;
  4382. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4383. sing.DeleteUserId = dto.UserId;
  4384. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4385. jw = JsonView(true, "删除成功!");
  4386. return Ok(jw);
  4387. }
  4388. #endregion
  4389. #region 团组英文资料
  4390. /// <summary>
  4391. /// 查询团组英文所有资料
  4392. /// </summary>
  4393. /// <param name="dto"></param>
  4394. /// <returns></returns>
  4395. [HttpPost]
  4396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4397. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4398. {
  4399. try
  4400. {
  4401. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4402. if (groupData.Code != 0)
  4403. {
  4404. return Ok(JsonView(false, groupData.Msg));
  4405. }
  4406. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4407. }
  4408. catch (Exception ex)
  4409. {
  4410. return Ok(JsonView(false, "程序错误!"));
  4411. throw;
  4412. }
  4413. }
  4414. /// <summary>
  4415. /// 团组英文资料操作(Status:1.新增,2.修改)
  4416. /// </summary>
  4417. /// <param name="dto"></param>
  4418. /// <returns></returns>
  4419. [HttpPost]
  4420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4421. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4422. {
  4423. try
  4424. {
  4425. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4426. if (groupData.Code != 0)
  4427. {
  4428. return Ok(JsonView(false, groupData.Msg));
  4429. }
  4430. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4431. }
  4432. catch (Exception ex)
  4433. {
  4434. return Ok(JsonView(false, "程序错误!"));
  4435. throw;
  4436. }
  4437. }
  4438. /// <summary>
  4439. /// 团组英文资料Id查询数据
  4440. /// </summary>
  4441. /// <param name="dto"></param>
  4442. /// <returns></returns>
  4443. [HttpPost]
  4444. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4445. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4446. {
  4447. try
  4448. {
  4449. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4450. if (_DelegationEnData != null)
  4451. {
  4452. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4453. }
  4454. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4455. }
  4456. catch (Exception ex)
  4457. {
  4458. return Ok(JsonView(false, "程序错误!"));
  4459. throw;
  4460. }
  4461. }
  4462. /// <summary>
  4463. /// 团组英文资料删除
  4464. /// </summary>
  4465. /// <param name="dto"></param>
  4466. /// <returns></returns>
  4467. [HttpPost]
  4468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4469. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4470. {
  4471. try
  4472. {
  4473. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4474. if (!res)
  4475. {
  4476. return Ok(JsonView(false, "删除失败"));
  4477. }
  4478. return Ok(JsonView(true, "删除成功!"));
  4479. }
  4480. catch (Exception ex)
  4481. {
  4482. return Ok(JsonView(false, "程序错误!"));
  4483. throw;
  4484. }
  4485. }
  4486. #endregion
  4487. #region 导出邀请函
  4488. /// <summary>
  4489. /// 导出邀请函页面初始化
  4490. /// </summary>
  4491. /// <param name="dto"></param>
  4492. /// <returns></returns>
  4493. [HttpPost]
  4494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4495. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4496. {
  4497. try
  4498. {
  4499. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4500. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4501. if (dto.DiId == 0)
  4502. {
  4503. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4504. }
  4505. else
  4506. {
  4507. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4508. }
  4509. return Ok(JsonView(true, "查询成功!", new
  4510. {
  4511. deleClient = crm_Deles,
  4512. delegations = grp_Delegations
  4513. }));
  4514. }
  4515. catch (Exception ex)
  4516. {
  4517. return Ok(JsonView(false, "程序错误!"));
  4518. throw;
  4519. }
  4520. }
  4521. /// <summary>
  4522. /// 导出邀请函
  4523. /// </summary>
  4524. /// <param name="dto"></param>
  4525. /// <returns></returns>
  4526. [HttpPost]
  4527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4528. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4529. {
  4530. #region 参数验证
  4531. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4532. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4533. #endregion
  4534. try
  4535. {
  4536. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4537. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4538. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4539. From Grp_TourClientList tcl
  4540. Left Join
  4541. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4542. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4543. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4544. From Crm_DeleClient dc
  4545. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4546. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4547. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4548. Where dc.IsDel = 0) temp
  4549. On temp.DcId =tcl.ClientId
  4550. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4551. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4552. List<string> texts = new List<string>();
  4553. if (datas.Count != 0)
  4554. {
  4555. foreach (TourClientListDetailsView item in datas)
  4556. {
  4557. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4558. {
  4559. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4560. }
  4561. else
  4562. {
  4563. string name = item.LastName + item.FirstName;
  4564. texts.Add(name);
  4565. }
  4566. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4567. {
  4568. if (!transDic.ContainsKey(item.Job))
  4569. {
  4570. texts.Add(item.Job);
  4571. }
  4572. }
  4573. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4574. {
  4575. texts.Add(item.CompanyFullName);
  4576. }
  4577. }
  4578. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4579. if (transData.Count > 0)
  4580. {
  4581. foreach (TranslateResult item in transData)
  4582. {
  4583. if (!transDic.ContainsKey(item.Query))
  4584. {
  4585. transDic.Add(item.Query, item.Translation);
  4586. }
  4587. }
  4588. }
  4589. List<GuestList> list = new List<GuestList>();
  4590. foreach (TourClientListDetailsView dele in datas)
  4591. {
  4592. GuestList guestList = new GuestList();
  4593. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4594. {
  4595. guestList.Name = dele.Pinyin;
  4596. }
  4597. else
  4598. {
  4599. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4600. guestList.Name = Name;
  4601. }
  4602. if (dele.Sex == 0)
  4603. {
  4604. guestList.Sex = "Male";
  4605. }
  4606. else if (dele.Sex == 1)
  4607. {
  4608. guestList.Sex = "Female";
  4609. }
  4610. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4611. if (!string.IsNullOrEmpty(dele.Job))
  4612. {
  4613. guestList.Job = dele.Job;
  4614. }
  4615. list.Add(guestList);
  4616. }
  4617. //载入模板
  4618. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4619. DocumentBuilder builder = new DocumentBuilder(doc);
  4620. //获取word里所有表格
  4621. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4622. //获取所填表格的序数
  4623. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4624. var rowStart = tableOne.Rows[0]; //获取第1行
  4625. //循环赋值
  4626. for (int i = 0; i < list.Count; i++)
  4627. {
  4628. builder.MoveToCell(0, i + 1, 0, 0);
  4629. builder.Write(list[i].Name.ToString());
  4630. builder.MoveToCell(0, i + 1, 1, 0);
  4631. builder.Write(list[i].Sex.ToString());
  4632. builder.MoveToCell(0, i + 1, 2, 0);
  4633. builder.Write(list[i].DOB.ToString());
  4634. builder.MoveToCell(0, i + 1, 3, 0);
  4635. builder.Write(list[i].Job.ToString());
  4636. }
  4637. //删除多余行
  4638. while (tableOne.Rows.Count > list.Count + 1)
  4639. {
  4640. tableOne.Rows.RemoveAt(list.Count + 1);
  4641. }
  4642. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4643. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4644. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4645. doc.Save(filePath);
  4646. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4647. return Ok(JsonView(true, "操作成功!", Url));
  4648. }
  4649. else
  4650. {
  4651. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4652. }
  4653. }
  4654. catch (Exception ex)
  4655. {
  4656. return Ok(JsonView(false, ex.Message));
  4657. throw;
  4658. }
  4659. }
  4660. #endregion
  4661. #region 团组经理模块 出入境费用
  4662. /// <summary>
  4663. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4664. /// </summary>
  4665. /// <returns></returns>
  4666. [HttpPost]
  4667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4668. public async Task<IActionResult> SetDayAndCostAreaChange()
  4669. {
  4670. try
  4671. {
  4672. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4673. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4674. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4675. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4676. foreach (var item in unite) //处理交集数据
  4677. {
  4678. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4679. }
  4680. foreach (var item in merge) //处理差集数据
  4681. {
  4682. int nationalTravelFeeId = 0;
  4683. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4684. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4685. else
  4686. {
  4687. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4688. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4689. }
  4690. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4691. }
  4692. //只更新dayAndCost 的 nationalTravelFeeId;
  4693. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4694. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4695. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4696. }
  4697. catch (Exception ex)
  4698. {
  4699. return Ok(JsonView(false, ex.Message));
  4700. throw;
  4701. }
  4702. }
  4703. /// <summary>
  4704. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4705. /// </summary>
  4706. /// <returns></returns>
  4707. [HttpPost]
  4708. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4709. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4710. {
  4711. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4712. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4713. //SetDataInfoView
  4714. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4715. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4716. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4717. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4718. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4719. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4720. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4721. //默认币种显示
  4722. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4723. {
  4724. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4725. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4726. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4727. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4728. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4729. };
  4730. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4731. if (_currencyRate.Count > 0)
  4732. {
  4733. foreach (var item in _currencyInfos)
  4734. {
  4735. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4736. if (rateInfo != null)
  4737. {
  4738. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4739. rate1 *= 1.035M;
  4740. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4741. }
  4742. }
  4743. }
  4744. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4745. return Ok(JsonView(true, "查询成功!", new
  4746. {
  4747. GroupNameData = groupNameData.Data,
  4748. CurrencyData = _CurrencyData,
  4749. WordTypeData = _WordTypeData,
  4750. ExcelTypeData = _ExcelTypeData,
  4751. CurrencyInit = _currencyInfos,
  4752. ViewPermissionData = viewPermissionData
  4753. }));
  4754. }
  4755. /// <summary>
  4756. /// 团组模块 - 出入境费用
  4757. /// 实时汇率 tips
  4758. /// 签证费用 tips
  4759. /// 机票费用 tips
  4760. /// </summary>
  4761. /// <returns></returns>
  4762. [HttpPost]
  4763. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4764. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4765. {
  4766. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4767. //默认币种显示
  4768. var _currencyInfos = _currencyInit;
  4769. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4770. List<dynamic> reteInfos = new List<dynamic>();
  4771. if (_currencyRate.Count > 0)
  4772. {
  4773. foreach (var item in _currencyInfos)
  4774. {
  4775. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4776. if (rateInfo != null)
  4777. {
  4778. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4779. decimal rate1 = item.Rate;
  4780. rate1 *= 1.03M;
  4781. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4782. reteInfos.Add(new
  4783. {
  4784. currCode = item.CurrencyCode,
  4785. currName = item.CurrencyName,
  4786. rate = rate2,
  4787. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4788. });
  4789. }
  4790. }
  4791. }
  4792. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4793. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4794. return Ok(JsonView(true, "查询成功!", new
  4795. {
  4796. //GroupNameData = groupNameData.Data,
  4797. visaData = visaData.Data,
  4798. airData = airData.Data,
  4799. reteInfos = reteInfos
  4800. }));
  4801. }
  4802. /// <summary>
  4803. /// 团组模块 - 出入境费用 - Info
  4804. /// </summary>
  4805. /// <returns></returns>
  4806. [HttpPost]
  4807. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4808. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4809. {
  4810. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4811. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4812. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4813. }
  4814. /// <summary>
  4815. /// 团组模块 - 出入境费用 - 设置view权限
  4816. /// </summary>
  4817. /// <returns></returns>
  4818. [HttpPost]
  4819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4820. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4821. {
  4822. if (dto.CurrUserId < 1) return Ok(JsonView(false,MsgTips.UserId));
  4823. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4824. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4825. var permissions = new List<Grp_EnterExitCostPermission>();
  4826. foreach (var userId in dto.UserIds)
  4827. {
  4828. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4829. }
  4830. if (permissions.Any())
  4831. {
  4832. _sqlSugar.BeginTran();
  4833. try
  4834. {
  4835. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4836. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4837. if (result < 1)
  4838. {
  4839. _sqlSugar.RollbackTran();
  4840. return Ok(JsonView(false));
  4841. }
  4842. }
  4843. catch (Exception ex)
  4844. {
  4845. _sqlSugar.RollbackTran();
  4846. return Ok(JsonView(false, ex.Message));
  4847. }
  4848. _sqlSugar.CommitTran();
  4849. return Ok(JsonView(true));
  4850. }
  4851. return Ok(JsonView(false));
  4852. }
  4853. /// <summary>
  4854. /// 团组模块 - 出入境费用 - Add And Update
  4855. /// </summary>
  4856. /// <returns></returns>
  4857. [HttpPost]
  4858. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4859. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4860. {
  4861. try
  4862. {
  4863. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4864. if (dto.DayOtherPriceData.Any())
  4865. {
  4866. var inserList = dto.DayOtherPriceData
  4867. .Where(x => x.Id == 0)
  4868. .Select(x => new Grp_DayOtherPrice
  4869. {
  4870. Cost = x.Cost,
  4871. Id = x.Id,
  4872. CreateTime = DateTime.Now,
  4873. CreateUserId = dto.UserId,
  4874. Currency = x.Currency,
  4875. Diid = x.DiId,
  4876. Index = x.Index,
  4877. IsDel = 0,
  4878. SetDataId = x.SetDataId,
  4879. SubTotal = x.SubTotal,
  4880. Remark = x.Remark
  4881. })
  4882. .ToList();
  4883. var updateList = dto.DayOtherPriceData
  4884. .Where(x => x.Id != 0)
  4885. .Select(x => new Grp_DayOtherPrice
  4886. {
  4887. Cost = x.Cost,
  4888. Id = x.Id,
  4889. CreateTime = DateTime.Now,
  4890. CreateUserId = dto.UserId,
  4891. Currency = x.Currency,
  4892. Diid = x.DiId,
  4893. Index = x.Index,
  4894. IsDel = 0,
  4895. SetDataId = x.SetDataId,
  4896. SubTotal = x.SubTotal,
  4897. Remark = x.Remark
  4898. })
  4899. .ToList();
  4900. //添加
  4901. _sqlSugar.BeginTran();
  4902. if (inserList.Any())
  4903. {
  4904. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4905. }
  4906. if (updateList.Any())
  4907. {
  4908. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4909. }
  4910. _sqlSugar.CommitTran();
  4911. }
  4912. if (data.Code != 0)
  4913. {
  4914. return Ok(JsonView(false, data.Msg));
  4915. }
  4916. //生成默认文件pdf并且通知人员
  4917. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4918. {
  4919. DiId = dto.DiId,
  4920. ExportType = 1,
  4921. SubTypeId = 1005
  4922. }, "pdf");
  4923. //发送通知
  4924. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4925. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4926. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4927. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4928. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4929. //汇率信息记录
  4930. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4931. return Ok(JsonView(true, data.Msg, data.Data));
  4932. }
  4933. catch (Exception ex)
  4934. {
  4935. return Ok(JsonView(false, ex.Message));
  4936. }
  4937. }
  4938. /// <summary>
  4939. /// 团组模块 - 出入境费用 - Confirm 费用
  4940. /// </summary>
  4941. /// <returns></returns>
  4942. [HttpPost]
  4943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4944. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4945. {
  4946. //TODO:测试完毕需把对应的用户ID更改
  4947. //1、数据表添加字段
  4948. //2、更改字段接口()
  4949. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4950. //3、确认成功 给财务发送消息
  4951. if (_view.Code == 200)
  4952. {
  4953. if (dto.Type == 1)
  4954. {
  4955. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4956. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4957. }
  4958. }
  4959. return Ok(_view);
  4960. }
  4961. /// <summary>
  4962. /// 团组模块 - 出入境费用 - File downlaod
  4963. /// </summary>
  4964. /// <param name="dto"></param>
  4965. /// <returns></returns>
  4966. [HttpPost]
  4967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4968. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4969. {
  4970. try
  4971. {
  4972. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4973. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4974. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4975. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4976. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4977. 3 团组成员名单 1 团组成员名单", ""));
  4978. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  4979. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4980. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4981. //数据源
  4982. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4983. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4984. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4985. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4986. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4987. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4988. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  4989. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4990. .Select((x, a, b) => new
  4991. {
  4992. x.Index,
  4993. itemName = a.Name,
  4994. CurrencyStr = b.Name,
  4995. x.Cost,
  4996. x.SubTotal,
  4997. x.Remark
  4998. })
  4999. .OrderBy((x) => x.Index)
  5000. .ToList(); //其他款项费用
  5001. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5002. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5003. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5004. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5005. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5006. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5007. .Select((tcl, dc, cc) => new ClientInfo
  5008. {
  5009. LastName = dc.LastName,
  5010. FirstName = dc.FirstName,
  5011. Sex = dc.Sex,
  5012. Birthday = dc.BirthDay,
  5013. Company = cc.CompanyFullName,
  5014. Job = dc.Job
  5015. })
  5016. .ToList();
  5017. foreach (var item in DeleClientList)
  5018. {
  5019. EncryptionProcessor.DecryptProperties(item);
  5020. }
  5021. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5022. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5023. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5024. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5025. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5026. if (dto.ExportType == 1) //明细表
  5027. {
  5028. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5029. {
  5030. //获取模板
  5031. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5032. //载入模板
  5033. Document doc = new Document(tempPath);
  5034. DocumentBuilder builder = new DocumentBuilder(doc);
  5035. //利用键值对存放数据
  5036. Dictionary<string, string> dic = new Dictionary<string, string>();
  5037. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5038. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5039. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5040. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5041. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5042. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5043. //境内费用(其他费用)
  5044. if (_EnterExitCosts.ChoiceOne == 1)
  5045. {
  5046. string row1_1 = "";
  5047. if (_EnterExitCosts.Visa > 0)
  5048. {
  5049. //insidePayTotal += _EnterExitCosts.Visa;
  5050. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5051. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5052. {
  5053. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5054. }
  5055. }
  5056. string row1_2 = "";
  5057. if (_EnterExitCosts.YiMiao > 0)
  5058. {
  5059. //insidePayTotal += _EnterExitCosts.YiMiao;
  5060. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5061. }
  5062. if (_EnterExitCosts.HeSuan > 0)
  5063. {
  5064. //insidePayTotal += _EnterExitCosts.HeSuan;
  5065. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5066. }
  5067. if (_EnterExitCosts.Service > 0)
  5068. {
  5069. //insidePayTotal += _EnterExitCosts.Service;
  5070. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5071. }
  5072. string row1_3 = "";
  5073. if (_EnterExitCosts.Safe > 0)
  5074. {
  5075. //insidePayTotal += _EnterExitCosts.Safe;
  5076. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5077. }
  5078. if (_EnterExitCosts.Ticket > 0)
  5079. {
  5080. //insidePayTotal += _EnterExitCosts.Ticket;
  5081. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5082. }
  5083. string row1 = "";
  5084. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5085. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5086. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5087. row1 += $"备注:{_EnterExitCosts.Remark}";
  5088. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5089. dic.Add("Row1Str", row1);
  5090. }
  5091. string airTotalStr = string.Empty,
  5092. airPriceStr = string.Empty;
  5093. //经济舱
  5094. if (_EnterExitCosts.SumJJC == 1)
  5095. {
  5096. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5097. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5098. }
  5099. //公务舱
  5100. if (_EnterExitCosts.SumGWC == 1)
  5101. {
  5102. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5103. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5104. }
  5105. //头等舱
  5106. if (_EnterExitCosts.SumTDC == 1)
  5107. {
  5108. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5109. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5110. }
  5111. string twoItemRemark = "备注:";
  5112. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
  5113. {
  5114. twoItemRemark = _EnterExitCosts.TwoItemRemark;
  5115. }
  5116. dic.Add("AirTotalStr", airTotalStr);
  5117. dic.Add("AirPriceStr", airPriceStr);
  5118. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5119. dic.Add("TwoItemRemark", twoItemRemark);
  5120. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5121. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5122. int table1Row = 0,
  5123. table2Row = 0,
  5124. table3Row = 0,
  5125. table4Row = 0,
  5126. table5Row = 0;
  5127. //住宿费
  5128. if (_EnterExitCosts.ChoiceThree == 1)
  5129. {
  5130. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5131. table1Row = dac1.Count;
  5132. #region 填充word表格内容
  5133. for (int i = 0; i < dac1.Count; i++)
  5134. {
  5135. Grp_DayAndCost dac = dac1[i];
  5136. if (dac == null) continue;
  5137. builder.MoveToCell(0, i, 0, 0);
  5138. builder.Write("第" + dac.Days.ToString() + "晚:");
  5139. builder.MoveToCell(0, i, 1, 0);
  5140. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5141. //builder.Write(dac.Place == null ? "" : dac.Place);
  5142. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5143. builder.MoveToCell(0, i, 2, 0);
  5144. builder.Write("费用标准:");
  5145. string curr = "";
  5146. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5147. if (currData != null)
  5148. {
  5149. curr = currData.Name;
  5150. }
  5151. builder.MoveToCell(0, i, 3, 0);
  5152. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5153. builder.MoveToCell(0, i, 4, 0);
  5154. builder.Write("费用小计:");
  5155. builder.MoveToCell(0, i, 5, 0);
  5156. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5157. }
  5158. #endregion
  5159. }
  5160. else dic.Add("SubZS", "0.00");
  5161. //删除多余行
  5162. while (table1.Rows.Count > table1Row)
  5163. {
  5164. table1.Rows.RemoveAt(table1Row);
  5165. }
  5166. //伙食费
  5167. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5168. if (_EnterExitCosts.ChoiceFour == 1)
  5169. {
  5170. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5171. table2Row = dac2.Count;
  5172. #region 填充word表格内容
  5173. for (int i = 0; i < dac2.Count; i++)
  5174. {
  5175. Grp_DayAndCost dac = dac2[i];
  5176. if (dac == null) continue;
  5177. builder.MoveToCell(1, i, 0, 0);
  5178. builder.Write("第" + dac.Days.ToString() + "天:");
  5179. builder.MoveToCell(1, i, 1, 0);
  5180. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5181. builder.MoveToCell(1, i, 2, 0);
  5182. builder.Write("费用标准:");
  5183. string curr = "";
  5184. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5185. if (currData != null)
  5186. {
  5187. curr = currData.Name;
  5188. }
  5189. builder.MoveToCell(1, i, 3, 0);
  5190. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5191. builder.MoveToCell(1, i, 4, 0);
  5192. builder.Write("费用小计:");
  5193. builder.MoveToCell(1, i, 5, 0);
  5194. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5195. }
  5196. #endregion
  5197. }
  5198. else dic.Add("SubHS", "0.00");
  5199. //删除多余行
  5200. while (table2.Rows.Count > table2Row)
  5201. {
  5202. table2.Rows.RemoveAt(table2Row);
  5203. }
  5204. //公杂费
  5205. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5206. if (_EnterExitCosts.ChoiceFive == 1)
  5207. {
  5208. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5209. table3Row = dac3.Count;
  5210. #region 填充word表格内容
  5211. for (int i = 0; i < dac3.Count; i++)
  5212. {
  5213. Grp_DayAndCost dac = dac3[i];
  5214. if (dac == null) continue;
  5215. builder.MoveToCell(2, i, 0, 0);
  5216. builder.Write("第" + dac.Days.ToString() + "天:");
  5217. builder.MoveToCell(2, i, 1, 0);
  5218. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5219. builder.MoveToCell(2, i, 2, 0);
  5220. builder.Write("费用标准:");
  5221. string curr = "";
  5222. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5223. if (currData != null)
  5224. {
  5225. curr = currData.Name;
  5226. }
  5227. builder.MoveToCell(2, i, 3, 0);
  5228. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5229. builder.MoveToCell(2, i, 4, 0);
  5230. builder.Write("费用小计:");
  5231. builder.MoveToCell(2, i, 5, 0);
  5232. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5233. }
  5234. //删除多余行
  5235. while (table3.Rows.Count > table3Row)
  5236. {
  5237. table3.Rows.RemoveAt(table3Row);
  5238. }
  5239. #endregion
  5240. }
  5241. else dic.Add("SubGZF", "0.00");
  5242. //删除多余行
  5243. while (table3.Rows.Count > table3Row)
  5244. {
  5245. table3.Rows.RemoveAt(table3Row);
  5246. }
  5247. //培训费
  5248. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5249. if (_EnterExitCosts.ChoiceSix == 1)
  5250. {
  5251. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5252. dic.Add("SubPX", pxStr);
  5253. table4Row = dac4.Count;
  5254. #region 填充word表格内容
  5255. for (int i = 0; i < dac4.Count; i++)
  5256. {
  5257. Grp_DayAndCost dac = dac4[i];
  5258. if (dac == null) continue;
  5259. builder.MoveToCell(3, i, 0, 0);
  5260. builder.Write("第" + dac.Days.ToString() + "天:");
  5261. builder.MoveToCell(3, i, 1, 0);
  5262. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5263. builder.MoveToCell(3, i, 2, 0);
  5264. builder.Write("费用标准:");
  5265. string curr = "";
  5266. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5267. if (currData != null)
  5268. {
  5269. curr = currData.Name;
  5270. }
  5271. builder.MoveToCell(3, i, 3, 0);
  5272. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5273. builder.MoveToCell(3, i, 4, 0);
  5274. builder.Write("费用小计:");
  5275. builder.MoveToCell(3, i, 5, 0);
  5276. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5277. }
  5278. #endregion
  5279. }
  5280. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  5281. //删除多余行
  5282. while (table4.Rows.Count > table4Row)
  5283. {
  5284. table4.Rows.RemoveAt(table4Row);
  5285. }
  5286. //其他费用
  5287. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5288. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5289. {
  5290. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5291. dic.Add("titleQi", qtStr);
  5292. table5Row = dac5.Count;
  5293. #region 填充word表格内容
  5294. for (int i = 0; i < dac5.Count; i++)
  5295. {
  5296. var dac = dac5[i];
  5297. if (dac == null) continue;
  5298. builder.MoveToCell(4, i, 0, 0);
  5299. builder.Write("第" + dac.Index.ToString() + "项:");
  5300. builder.MoveToCell(4, i, 1, 0);
  5301. builder.Write(dac.itemName);
  5302. builder.MoveToCell(4, i, 2, 0);
  5303. builder.Write("费用标准:");
  5304. builder.MoveToCell(4, i, 3, 0);
  5305. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5306. builder.MoveToCell(4, i, 4, 0);
  5307. builder.Write("费用小计:");
  5308. builder.MoveToCell(4, i, 5, 0);
  5309. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5310. builder.MoveToCell(4, i, 6, 0);
  5311. builder.Write("备注:");
  5312. builder.MoveToCell(4, i, 7, 0);
  5313. builder.Write(dac.Remark);
  5314. }
  5315. #endregion
  5316. }
  5317. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5318. //删除多余行
  5319. while (table5.Rows.Count > table5Row)
  5320. {
  5321. table5.Rows.RemoveAt(table5Row);
  5322. }
  5323. //加上其他费用
  5324. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5325. decimal subJJC = 0.00M,
  5326. subGWC = 0.00M,
  5327. subTDC = 0.00M;
  5328. //经济舱
  5329. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5330. //公务舱
  5331. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5332. //头等舱
  5333. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5334. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5335. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5336. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5337. #region 填充word模板书签内容
  5338. foreach (var key in dic.Keys)
  5339. {
  5340. Bookmark bookmark = doc.Range.Bookmarks[key];
  5341. if (bookmark != null)
  5342. {
  5343. builder.MoveToBookmark(key);
  5344. builder.Write(dic[key]);
  5345. }
  5346. }
  5347. #endregion
  5348. //文件名
  5349. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5350. AsposeHelper.removewatermark_v2180();
  5351. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5352. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5353. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5354. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5355. }
  5356. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5357. {
  5358. //获取模板
  5359. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5360. //载入模板
  5361. Document doc = new Document(tempPath);
  5362. DocumentBuilder builder = new DocumentBuilder(doc);
  5363. Dictionary<string, string> dic = new Dictionary<string, string>();
  5364. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5365. {
  5366. List<string> list = new List<string>();
  5367. try
  5368. {
  5369. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5370. foreach (var item in spilitArr)
  5371. {
  5372. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5373. var depCode = spDotandEmpty[2].Substring(0, 3);
  5374. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5375. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5376. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5377. list.Add(depName);
  5378. list.Add(arrName);
  5379. }
  5380. list = list.Distinct().ToList();
  5381. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5382. }
  5383. catch (Exception)
  5384. {
  5385. dic.Add("ReturnCode", "行程录入不正确!");
  5386. }
  5387. }
  5388. else
  5389. {
  5390. dic.Add("ReturnCode", "未录入行程!");
  5391. }
  5392. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5393. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5394. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5395. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5396. {
  5397. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5398. dic.Add("Day", sp.Days.ToString());
  5399. }
  5400. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5401. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5402. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5403. //dic.Add("Names", Names);
  5404. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5405. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5406. decimal dac1totalPrice = 0.00M;
  5407. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5408. foreach (var dac in dac1)
  5409. {
  5410. if (dac.SubTotal == 0.00M)
  5411. {
  5412. continue;
  5413. }
  5414. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5415. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5416. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5417. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5418. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5419. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5420. builder.Write(currency);//币种
  5421. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5422. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5423. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5424. builder.Write("");//人数
  5425. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5426. builder.Write("");//天数
  5427. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5428. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5429. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5430. decimal rate = 0.00M;
  5431. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5432. builder.Write(rate.ToString("#0.0000"));//汇率
  5433. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5434. decimal rbmPrice = dac.SubTotal;
  5435. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5436. accommodationStartIndex++;
  5437. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5438. }
  5439. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5440. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5441. {
  5442. table1.Rows.RemoveAt(i - 1);
  5443. foodandotherStartIndex--;
  5444. }
  5445. if (dac2.Count == dac3.Count)//国家 币种 金额
  5446. {
  5447. for (int i = 0; i < dac2.Count; i++)
  5448. {
  5449. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5450. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5451. }
  5452. }
  5453. decimal dac2totalPrice = 0.00M;
  5454. foreach (var dac in dac2)
  5455. {
  5456. if (dac.SubTotal == 0)
  5457. {
  5458. continue;
  5459. }
  5460. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5461. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5462. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5463. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5464. builder.Write(currency);//币种
  5465. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5466. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5467. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5468. builder.Write("");//人数
  5469. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5470. builder.Write("");//天数
  5471. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5472. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5473. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5474. decimal rate = 0.00M;
  5475. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5476. builder.Write(rate.ToString("#0.0000"));//汇率
  5477. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5478. decimal rbmPrice = dac.SubTotal;
  5479. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5480. foodandotherStartIndex++;
  5481. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5482. }
  5483. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5484. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5485. {
  5486. table1.Rows.RemoveAt(i - 1);
  5487. }
  5488. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5489. string otherFeeStr = "";
  5490. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5491. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5492. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5493. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5494. foreach (var otherInfo in dac5)
  5495. {
  5496. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5497. }
  5498. #endregion
  5499. if (otherFeeStr.Length > 0)
  5500. {
  5501. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5502. otherFeeStr = $"({otherFeeStr})";
  5503. dic.Add("OtherFeeStr", otherFeeStr);
  5504. }
  5505. //总计
  5506. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5507. //国际旅费
  5508. string outsideAir = string.Empty;
  5509. string allPriceAir = string.Empty;
  5510. if (_EnterExitCosts.SumJJC == 1)
  5511. {
  5512. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5513. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5514. }
  5515. if (_EnterExitCosts.SumGWC == 1)
  5516. {
  5517. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5518. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5519. }
  5520. if (_EnterExitCosts.SumTDC == 1)
  5521. {
  5522. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5523. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5524. }
  5525. dic.Add("InTravelPrice", $"({outsideAir})");
  5526. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5527. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5528. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5529. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5530. foreach (var key in dic.Keys)
  5531. {
  5532. builder.MoveToBookmark(key);
  5533. builder.Write(dic[key]);
  5534. }
  5535. //模板文件名
  5536. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5537. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5538. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5539. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5540. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5541. }
  5542. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5543. {
  5544. //获取模板
  5545. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5546. //载入模板
  5547. WorkbookDesigner designer = new WorkbookDesigner();
  5548. designer.Workbook = new Workbook(tempPath);
  5549. Dictionary<string, string> dic = new Dictionary<string, string>();
  5550. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5551. {
  5552. List<string> list = new List<string>();
  5553. try
  5554. {
  5555. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5556. foreach (var item in spilitArr)
  5557. {
  5558. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5559. var depCode = spDotandEmpty[2].Substring(0, 3);
  5560. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5561. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5562. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5563. list.Add(depName);
  5564. list.Add(arrName);
  5565. }
  5566. list = list.Distinct().ToList();
  5567. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5568. }
  5569. catch (Exception)
  5570. {
  5571. dic.Add("ReturnCode", "行程录入不正确!");
  5572. }
  5573. }
  5574. else
  5575. {
  5576. dic.Add("ReturnCode", "未录入行程!");
  5577. }
  5578. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5579. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5580. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5581. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5582. {
  5583. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5584. dic.Add("Day", sp.Days.ToString());
  5585. }
  5586. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5587. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5588. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5589. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5590. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5591. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5592. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5593. designer.SetDataSource("Name", Names);
  5594. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5595. designer.SetDataSource("Day", dic["Day"] + "天");
  5596. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5597. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5598. int startIndex = 10;
  5599. const int startIndexcopy = 10;
  5600. if (dac2.Count == dac3.Count)//国家 币种 金额
  5601. {
  5602. for (int i = 0; i < dac2.Count; i++)
  5603. {
  5604. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5605. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5606. }
  5607. }
  5608. DataTable dtdac1 = new DataTable();
  5609. List<string> place = new List<string>();
  5610. dtdac1.Columns.AddRange(new DataColumn[] {
  5611. new DataColumn(){ ColumnName = "city"},
  5612. new DataColumn(){ ColumnName = "curr"},
  5613. new DataColumn(){ ColumnName = "criterion"},
  5614. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5615. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5616. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5617. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5618. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5619. });
  5620. DataTable dtdac2 = new DataTable();
  5621. dtdac2.Columns.AddRange(new DataColumn[] {
  5622. new DataColumn(){ ColumnName = "city"},
  5623. new DataColumn(){ ColumnName = "curr"},
  5624. new DataColumn(){ ColumnName = "criterion"},
  5625. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5626. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5627. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5628. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5629. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5630. });
  5631. dtdac1.TableName = "tb1";
  5632. dtdac2.TableName = "tb2";
  5633. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5634. foreach (var item in dac1)
  5635. {
  5636. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5637. if (place.Contains(item.Place))
  5638. {
  5639. continue;
  5640. }
  5641. DataRow row = dtdac1.NewRow();
  5642. row["city"] = item.Place;
  5643. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5644. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5645. row["curr"] = currency;
  5646. row["rate"] = rate.ToString("#0.0000");
  5647. row["criterion"] = item.Cost.ToString("#0.00");
  5648. row["number"] = 1;
  5649. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5650. //row["costRMB"] = rbmPrice;
  5651. dtdac1.Rows.Add(row);
  5652. place.Add(item.Place);
  5653. }
  5654. place = new List<string>();
  5655. foreach (var item in dac2)
  5656. {
  5657. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5658. if (place.Contains(item.Place))
  5659. {
  5660. continue;
  5661. }
  5662. DataRow row = dtdac2.NewRow();
  5663. row["city"] = item.Place;
  5664. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5665. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5666. row["curr"] = currency;
  5667. row["rate"] = rate.ToString("#0.0000");
  5668. row["criterion"] = item.Cost.ToString("#0.00");
  5669. row["number"] = 1;
  5670. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5671. //row["cost"] = item.SubTotal;
  5672. //row["costRMB"] = rbmPrice;
  5673. dtdac2.Rows.Add(row);
  5674. place.Add(item.Place);
  5675. //dac2totalPrice += rbmPrice;
  5676. }
  5677. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5678. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5679. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5680. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5681. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5682. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5683. string cell4Str1 = string.Empty;
  5684. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5685. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5686. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5687. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5688. string cellStr = $" 5.其他费用(";
  5689. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5690. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5691. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5692. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5693. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5694. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5695. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5696. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5697. foreach (var otherInfo in dac5)
  5698. {
  5699. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5700. }
  5701. #endregion
  5702. if (cellStr.Length > 8)
  5703. {
  5704. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5705. }
  5706. cellStr += ")";
  5707. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5708. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5709. decimal pxFee = dac4.Sum(it => it.Cost);
  5710. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5711. string celllastStr1 = "";
  5712. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5713. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5714. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5715. celllastStr1 += $",国际旅费 元";
  5716. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5717. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5718. designer.SetDataSource("cell4Str", cell4Str);
  5719. designer.SetDataSource("cellStr", cellStr);
  5720. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5721. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5722. designer.SetDataSource("celllastStr", celllastStr);
  5723. Workbook wb = designer.Workbook;
  5724. var sheet = wb.Worksheets[0];
  5725. //绑定datatable数据集
  5726. designer.SetDataSource(dtdac1);
  5727. designer.SetDataSource(dtdac2);
  5728. designer.Process();
  5729. var rowStart = dtdac1.Rows.Count;
  5730. while (rowStart > 0)
  5731. {
  5732. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5733. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5734. startIndex++;
  5735. rowStart--;
  5736. }
  5737. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5738. startIndex += 1; //总计行
  5739. rowStart = dtdac2.Rows.Count;
  5740. while (rowStart > 0)
  5741. {
  5742. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5743. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5744. startIndex++;
  5745. rowStart--;
  5746. }
  5747. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5748. wb.CalculateFormula(true);
  5749. //模板文件名
  5750. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5751. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5752. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5753. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5754. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5755. }
  5756. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5757. {
  5758. //获取模板
  5759. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5760. //载入模板
  5761. Document doc = new Document(tempPath);
  5762. DocumentBuilder builder = new DocumentBuilder(doc);
  5763. Dictionary<string, string> dic = new Dictionary<string, string>();
  5764. dic.Add("GroupName", _DelegationInfo.TeamName);
  5765. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5766. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5767. string missionLeaderJob = "";//负责人job
  5768. int groupNumber = 0; //团人数
  5769. if (DeleClientList.Count > 0)
  5770. {
  5771. missionLeader = DeleClientList[0]?.Name ?? "";
  5772. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5773. }
  5774. dic.Add("MissionLeader", missionLeader); //团负责人
  5775. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5776. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5777. #region MyRegion
  5778. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5779. //{
  5780. // List<string> list = new List<string>();
  5781. // try
  5782. // {
  5783. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5784. // foreach (var item in spilitArr)
  5785. // {
  5786. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5787. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5788. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5789. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5790. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5791. // list.Add(depName);
  5792. // list.Add(arrName);
  5793. // }
  5794. // list = list.Distinct().ToList();
  5795. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5796. // }
  5797. // catch (Exception)
  5798. // {
  5799. // dic.Add("ReturnCode", "行程录入不正确!");
  5800. // }
  5801. //}
  5802. //else
  5803. //{
  5804. // dic.Add("ReturnCode", "未录入行程!");
  5805. //}
  5806. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5807. dic.Add("ReturnCode", string.Join("、", countrys));
  5808. #endregion
  5809. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5810. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5811. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5812. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5813. //{
  5814. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5815. // dic.Add("Day", sp.Days.ToString());
  5816. //}
  5817. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5818. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5819. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5820. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5821. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5822. //培训人员名单
  5823. int cultivateRowIndex = 7;
  5824. foreach (var item in DeleClientList)
  5825. {
  5826. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5827. builder.Write(item.Name);
  5828. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5829. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5830. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5831. string birthDay = "";
  5832. if (item.Birthday != null)
  5833. {
  5834. DateTime dt = Convert.ToDateTime(item.Birthday);
  5835. birthDay = $"{dt.Year}.{dt.Month}";
  5836. }
  5837. builder.Write(birthDay);
  5838. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5839. builder.Write(item.Company);
  5840. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5841. builder.Write(item.Job);
  5842. cultivateRowIndex++;
  5843. }
  5844. //删除多余行
  5845. //cultivateRowIndex -= 2;
  5846. int delRows = 10 + 7 - cultivateRowIndex;
  5847. if (delRows > 0)
  5848. {
  5849. for (int i = 0; i < delRows; i++)
  5850. {
  5851. table1.Rows.RemoveAt(cultivateRowIndex);
  5852. //cultivateRowIndex++;
  5853. }
  5854. }
  5855. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5856. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5857. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5858. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5859. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5860. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5861. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5862. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5863. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5864. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5865. //其他费用
  5866. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5867. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5868. //其他费用合计
  5869. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5870. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5871. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5872. //公务舱合计
  5873. //国际旅费
  5874. string outsideJJ = "";
  5875. string allPriceJJ = "";
  5876. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5877. {
  5878. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5879. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5880. }
  5881. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5882. {
  5883. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5884. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5885. }
  5886. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5887. {
  5888. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5889. dic.Add("AirFeeTotal", airFeeTotalStr);
  5890. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5891. dic.Add("FeeTotal", feeTotalStr);
  5892. }
  5893. foreach (var key in dic.Keys)
  5894. {
  5895. builder.MoveToBookmark(key);
  5896. builder.Write(dic[key]);
  5897. }
  5898. //模板文件名
  5899. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5900. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5901. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5902. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5903. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5904. }
  5905. }
  5906. else if (dto.ExportType == 2) //表格
  5907. {
  5908. //利用键值对存放数据
  5909. Dictionary<string, string> dic = new Dictionary<string, string>();
  5910. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5911. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5912. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5913. dic.Add("Day", sp.Days.ToString());
  5914. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5915. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5916. {
  5917. //获取模板
  5918. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5919. //载入模板
  5920. Document doc = new Document(tempPath);
  5921. DocumentBuilder builder = new DocumentBuilder(doc);
  5922. dic.Add("TeamName", _DelegationInfo.TeamName);
  5923. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5924. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5925. string missionLeaderName = "",
  5926. missionLeaderJob = "";
  5927. if (DeleClientList.Count > 0)
  5928. {
  5929. missionLeaderName = DeleClientList[0].Name;
  5930. missionLeaderJob = DeleClientList[0].Job;
  5931. }
  5932. dic.Add("MissionLeaderName", missionLeaderName);
  5933. dic.Add("MissionLeaderJob", missionLeaderJob);
  5934. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5935. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5936. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5937. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5938. int rowCount = 10;//总人数行
  5939. int startRowIndex = 7; //起始行
  5940. for (int i = 0; i < DeleClientList.Count; i++)
  5941. {
  5942. builder.MoveToCell(0, startRowIndex, 0, 0);
  5943. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5944. builder.MoveToCell(0, startRowIndex, 1, 0);
  5945. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5946. builder.Write(sex);//性别
  5947. builder.MoveToCell(0, startRowIndex, 2, 0);
  5948. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5949. builder.MoveToCell(0, startRowIndex, 3, 0);
  5950. builder.Write(DeleClientList[i].Company);//工作单位
  5951. builder.MoveToCell(0, startRowIndex, 4, 0);
  5952. builder.Write(DeleClientList[i].Job);//职务及级别
  5953. builder.MoveToCell(0, startRowIndex, 5, 0);
  5954. builder.Write("");//人员属性
  5955. builder.MoveToCell(0, startRowIndex, 6, 0);
  5956. builder.Write("");//上次出国时间
  5957. startRowIndex++;
  5958. }
  5959. int nullRow = rowCount - DeleClientList.Count;//空行
  5960. for (int i = 0; i < nullRow; i++)
  5961. {
  5962. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5963. }
  5964. foreach (var key in dic.Keys)
  5965. {
  5966. builder.MoveToBookmark(key);
  5967. builder.Write(dic[key]);
  5968. }
  5969. //模板文件名
  5970. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5971. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5972. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5973. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5974. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5975. }
  5976. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5977. {
  5978. //获取模板
  5979. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5980. //载入模板
  5981. Document doc = new Document(tempPath);
  5982. DocumentBuilder builder = new DocumentBuilder(doc);
  5983. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5984. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5985. dic.Add("Names", Names);
  5986. int accommodationRows = 12, foodandotherRows = 12;
  5987. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5988. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5989. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5990. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5991. int accommodationStartIndex = 6;
  5992. decimal dac1totalPrice = 0.00M;
  5993. foreach (var dac in dac1)
  5994. {
  5995. if (dac.SubTotal == 0)
  5996. {
  5997. continue;
  5998. }
  5999. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6000. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6001. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6002. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6003. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6004. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6005. builder.Write(currency);//币种
  6006. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6007. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6008. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6009. builder.Write("");//人数
  6010. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6011. builder.Write("");//天数
  6012. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6013. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6014. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6015. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6016. builder.Write(rate.ToString("#0.0000"));//汇率
  6017. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6018. decimal rbmPrice = rate * dac.SubTotal;
  6019. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6020. accommodationStartIndex++;
  6021. dac1totalPrice += rbmPrice;
  6022. }
  6023. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6024. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6025. builder.Write("小计");
  6026. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6027. builder.Write(dac1totalPrice.ToString("#0.00"));
  6028. accommodationStartIndex++;
  6029. int nullRow = accommodationRows - dac1.Count;
  6030. //删除空行
  6031. //if (nullRow > 0)
  6032. //{
  6033. // int rowIndex = accommodationStartIndex;
  6034. // for (int i = 0; i < nullRow; i++)
  6035. // {
  6036. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6037. // row.Remove();
  6038. // rowIndex++;
  6039. // }
  6040. //}
  6041. if (dac2.Count == dac3.Count)//国家 币种 金额
  6042. {
  6043. for (int i = 0; i < dac2.Count; i++)
  6044. {
  6045. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6046. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6047. }
  6048. }
  6049. int foodandotherStartIndex = 19;//
  6050. decimal dac2totalPrice = 0.00M;
  6051. foreach (var dac in dac2)
  6052. {
  6053. if (dac.SubTotal == 0)
  6054. {
  6055. continue;
  6056. }
  6057. //foodandotherStartIndex = 12;
  6058. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6059. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6060. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6061. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6062. builder.Write(currency);//币种
  6063. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6064. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6065. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6066. builder.Write("");//人数
  6067. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6068. builder.Write("");//天数
  6069. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6070. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6071. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6072. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6073. builder.Write(rate.ToString("#0.0000"));//汇率
  6074. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6075. decimal rbmPrice = rate * dac.SubTotal;
  6076. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6077. foodandotherStartIndex++;
  6078. dac2totalPrice += rbmPrice;
  6079. }
  6080. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6081. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6082. //删除空行
  6083. //if (dac2.Count < foodandotherRows)
  6084. //{
  6085. // while (table2.Rows.Count > dac2.Count)
  6086. // {
  6087. // table2.Rows.RemoveAt(dac2.Count);
  6088. // }
  6089. //}
  6090. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6091. string otherFeeStr = "";
  6092. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6093. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6094. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6095. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6096. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6097. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6098. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6099. foreach (var otherInfo in dac5)
  6100. {
  6101. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6102. }
  6103. #endregion
  6104. if (otherFeeStr.Length > 0)
  6105. {
  6106. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6107. otherFeeStr = $"({otherFeeStr})";
  6108. dic.Add("OtherFeeStr", otherFeeStr);
  6109. }
  6110. foreach (var key in dic.Keys)
  6111. {
  6112. builder.MoveToBookmark(key);
  6113. builder.Write(dic[key]);
  6114. }
  6115. //模板文件名
  6116. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6117. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6118. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6119. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6120. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6121. }
  6122. }
  6123. else if (dto.ExportType == 3)
  6124. {
  6125. if (dto.SubTypeId == 1) //团组成员名单
  6126. {
  6127. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6128. //获取模板
  6129. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6130. //载入模板
  6131. Document doc = new Document(tempPath);
  6132. DocumentBuilder builder = new DocumentBuilder(doc);
  6133. //获取word里所有表格
  6134. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6135. //获取所填表格的序数
  6136. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6137. var rowStart = tableOne.Rows[0]; //获取第1行
  6138. //循环赋值
  6139. for (int i = 0; i < DeleClientList.Count; i++)
  6140. {
  6141. builder.MoveToCell(0, i + 1, 0, 0);
  6142. builder.Write(DeleClientList[i].Name);
  6143. builder.MoveToCell(0, i + 1, 1, 0);
  6144. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6145. builder.Write(sex);
  6146. builder.MoveToCell(0, i + 1, 2, 0);
  6147. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6148. builder.MoveToCell(0, i + 1, 3, 0);
  6149. builder.Write(DeleClientList[i].Company);
  6150. builder.MoveToCell(0, i + 1, 4, 0);
  6151. builder.Write(DeleClientList[i].Job);
  6152. }
  6153. //删除多余行
  6154. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6155. {
  6156. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6157. }
  6158. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6159. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6160. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6161. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6162. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6163. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6164. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6165. }
  6166. }
  6167. return Ok(JsonView(400, "操作失败!", ""));
  6168. }
  6169. catch (Exception ex)
  6170. {
  6171. return Ok(JsonView(400, ex.Message, ""));
  6172. }
  6173. }
  6174. /// <summary>
  6175. /// 获取三公费用标准city
  6176. /// </summary>
  6177. /// <param name="placeData"></param>
  6178. /// <param name="nationalTravelFeeId"></param>
  6179. /// <returns></returns>
  6180. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6181. {
  6182. string _city = string.Empty;
  6183. if (placeData.Count < 1) return _city;
  6184. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6185. if (data == null) return _city;
  6186. string country = data.Country;
  6187. string city = data.City;
  6188. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6189. else _city = city;
  6190. return _city;
  6191. }
  6192. /// <summary>
  6193. /// 团组模块 - 出入境费用 - 明细表导出
  6194. /// </summary>
  6195. /// <returns></returns>
  6196. [HttpPost]
  6197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6198. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6199. {
  6200. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6201. if (data.Code != 0)
  6202. {
  6203. return Ok(JsonView(false, data.Msg));
  6204. }
  6205. return Ok(JsonView(true, data.Msg, data.Data));
  6206. }
  6207. /// <summary>
  6208. /// 团组模块 - 出入境费用 - 一键清空
  6209. /// </summary>
  6210. /// <returns></returns>
  6211. [HttpPost]
  6212. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6213. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6214. {
  6215. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6216. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6217. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6218. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6219. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6220. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6221. .SetColumns(x => new Grp_DayOtherPrice
  6222. {
  6223. IsDel = 1,
  6224. DeleteUserId = dto.UserId,
  6225. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6226. })
  6227. .ExecuteCommandAsync();
  6228. if (_view.Code == 0)
  6229. {
  6230. return Ok(JsonView(true, "操作成功"));
  6231. }
  6232. return Ok(JsonView(false, "操作失败"));
  6233. }
  6234. /// <summary>
  6235. /// 团组模块 - 出入境费用 - 子项删除
  6236. /// </summary>
  6237. /// <returns></returns>
  6238. [HttpPost]
  6239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6240. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6241. {
  6242. try
  6243. {
  6244. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6245. if (data.Code != 0)
  6246. {
  6247. return Ok(JsonView(false, data.Msg));
  6248. }
  6249. return Ok(JsonView(true, "操作成功!", data.Data));
  6250. }
  6251. catch (Exception ex)
  6252. {
  6253. return Ok(JsonView(false, ex.Message));
  6254. }
  6255. }
  6256. /// <summary>
  6257. /// 删除三公其他费用
  6258. /// </summary>
  6259. /// <param name="dto"></param>
  6260. /// <returns></returns>
  6261. [HttpPost]
  6262. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6263. {
  6264. var jw = JsonView(false,"删除失败!");
  6265. var data = new Grp_DayOtherPrice()
  6266. {
  6267. Id = dto.Id,
  6268. IsDel = 1,
  6269. DeleteUserId = dto.DeleteUserId,
  6270. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6271. };
  6272. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6273. if (del > 0)
  6274. {
  6275. jw.Code = 200;
  6276. jw.Msg = "删除成功!";
  6277. }
  6278. return Ok(jw);
  6279. }
  6280. /// <summary>
  6281. /// 团组模块 - 出入境国家费用标准 List
  6282. /// </summary>
  6283. /// <returns></returns>
  6284. [HttpPost]
  6285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6286. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6287. {
  6288. try
  6289. {
  6290. Stopwatch sw = new Stopwatch();
  6291. sw.Start();
  6292. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6293. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6294. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6295. Where gntf.Isdel = 0");
  6296. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6297. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6298. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6299. //foreach (var item in nationalTravel)
  6300. //{
  6301. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6302. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6303. // if (otherData != null)
  6304. // {
  6305. // cityData.Remove(otherData);
  6306. // cityData.Add(otherData);
  6307. // }
  6308. // nationalTravelFeeData1.Add(new
  6309. // {
  6310. // Country = item.Country,
  6311. // CityData = cityData
  6312. // });
  6313. //}
  6314. sw.Stop();
  6315. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6316. }
  6317. catch (Exception ex)
  6318. {
  6319. return Ok(JsonView(false, ex.Message));
  6320. throw;
  6321. }
  6322. }
  6323. /// <summary>
  6324. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6325. /// </summary>
  6326. /// <returns></returns>
  6327. [HttpPost]
  6328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6329. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6330. {
  6331. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6332. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6333. List<string> countryData = new List<string>();
  6334. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6335. countryData = countryData.Distinct().ToList();
  6336. List<dynamic> dataSource = new List<dynamic>();
  6337. foreach (var item in countryData)
  6338. {
  6339. List<string> cityData1 = new List<string>();
  6340. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6341. var countryData2 = new
  6342. {
  6343. CountryName = item,
  6344. CityData = cityData1
  6345. };
  6346. dataSource.Add(countryData2);
  6347. }
  6348. return Ok(JsonView(true, "查询成功!", dataSource));
  6349. }
  6350. /// <summary>
  6351. /// 团组模块 - 出入境国家费用标准 Page List
  6352. /// </summary>
  6353. /// <returns></returns>
  6354. [HttpPost]
  6355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6356. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6357. {
  6358. int portId = dto.PortType;
  6359. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6360. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6361. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6362. string whereSql = string.Empty;
  6363. if (!string.IsNullOrEmpty(dto.Country))
  6364. {
  6365. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6366. }
  6367. if (!string.IsNullOrEmpty(dto.City))
  6368. {
  6369. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6370. }
  6371. string pageSql = string.Format(@"Select * From (
  6372. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6373. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6374. From Grp_NationalTravelFee gntf
  6375. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6376. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6377. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6378. RefAsync<int> total = 0;
  6379. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6380. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6381. }
  6382. /// <summary>
  6383. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6384. /// </summary>
  6385. /// <returns></returns>
  6386. [HttpPost]
  6387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6388. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6389. {
  6390. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6391. int portId = dto.PortType;
  6392. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6393. string whereSql = string.Empty;
  6394. if (!string.IsNullOrEmpty(dto.Country))
  6395. {
  6396. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6397. }
  6398. if (!string.IsNullOrEmpty(dto.City))
  6399. {
  6400. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6401. }
  6402. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6403. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6404. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6405. From Grp_NationalTravelFee gntf
  6406. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6407. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6408. Where gntf.Isdel = 0 {0} ", whereSql);
  6409. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6410. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6411. }
  6412. /// <summary>
  6413. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6414. /// </summary>
  6415. /// <returns></returns>
  6416. [HttpPost]
  6417. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6418. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6419. {
  6420. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6421. if (data.Code != 0)
  6422. {
  6423. return Ok(JsonView(false, data.Msg));
  6424. }
  6425. return Ok(JsonView(true, "操作成功!", data.Data));
  6426. }
  6427. /// <summary>
  6428. /// 团组模块 - 出入境国家费用标准 - Del
  6429. /// </summary>
  6430. /// <returns></returns>
  6431. [HttpPost]
  6432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6433. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6434. {
  6435. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6436. {
  6437. Id = dto.Id,
  6438. DeleteUserId = dto.DeleteUserId,
  6439. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6440. IsDel = 1
  6441. };
  6442. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6443. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6444. .WhereColumns(it => new { it.Id })
  6445. .ExecuteCommandAsync();
  6446. if (delStatus <= 0)
  6447. {
  6448. return Ok(JsonView(false, "删除失败!"));
  6449. }
  6450. return Ok(JsonView(true, "操作成功!"));
  6451. }
  6452. /// <summary>
  6453. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6454. /// 注:Get 请求Headers 加 Token
  6455. /// </summary>
  6456. /// <param name="groupId"></param>
  6457. /// <returns></returns>
  6458. [HttpGet("{groupId}")]
  6459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6460. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6461. {
  6462. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6463. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6464. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6465. data.ForEach(x =>
  6466. {
  6467. x.CreateUserId = _currUserInfo.UserId;
  6468. });
  6469. if (data.Any())
  6470. {
  6471. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6472. if (add > 0)
  6473. {
  6474. return Ok(JsonView(true, "操作成功!"));
  6475. }
  6476. }
  6477. return Ok(JsonView(false, "未操作!"));
  6478. }
  6479. #endregion
  6480. #region 团组经理模块 出入境费用-草稿
  6481. /// <summary>
  6482. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6483. /// </summary>
  6484. /// <returns></returns>
  6485. [HttpPost]
  6486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6487. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6488. {
  6489. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6490. .Where(x => x.IsDel == 0)
  6491. .OrderByDescending(x => x.CreateTime)
  6492. .Select(x => new { x.Id, x.DraftName })
  6493. .ToListAsync();
  6494. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6495. //SetDataInfoView
  6496. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6497. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6498. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6499. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6500. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6501. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6502. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6503. //默认币种显示
  6504. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  6505. {
  6506. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  6507. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  6508. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  6509. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  6510. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  6511. };
  6512. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6513. if (_currencyRate.Count > 0)
  6514. {
  6515. foreach (var item in _currencyInfos)
  6516. {
  6517. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6518. if (rateInfo != null)
  6519. {
  6520. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6521. rate1 *= 1.035M;
  6522. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6523. }
  6524. }
  6525. }
  6526. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6527. return Ok(JsonView(true, "查询成功!", new
  6528. {
  6529. DraftNameDatas = draftNameDatas,
  6530. CurrencyData = _CurrencyData,
  6531. WordTypeData = _WordTypeData,
  6532. ExcelTypeData = _ExcelTypeData,
  6533. CurrencyInit = _currencyInfos,
  6534. ViewPermissionData = viewPermissionData
  6535. }));
  6536. }
  6537. /// <summary>
  6538. /// 团组模块 - 出入境费用-草稿
  6539. /// 实时汇率 tips
  6540. /// 签证费用 tips
  6541. /// 机票费用 tips
  6542. /// </summary>
  6543. /// <returns></returns>
  6544. [HttpPost]
  6545. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6546. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6547. {
  6548. //var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6549. //默认币种显示
  6550. var _currencyInfos = _currencyInit;
  6551. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6552. List<dynamic> reteInfos = new List<dynamic>();
  6553. if (_currencyRate.Count > 0)
  6554. {
  6555. foreach (var item in _currencyInfos)
  6556. {
  6557. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6558. if (rateInfo != null)
  6559. {
  6560. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6561. decimal rate1 = item.Rate;
  6562. rate1 *= 1.03M;
  6563. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6564. reteInfos.Add(new
  6565. {
  6566. currCode = item.CurrencyCode,
  6567. currName = item.CurrencyName,
  6568. rate = rate2,
  6569. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6570. });
  6571. }
  6572. }
  6573. }
  6574. //var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  6575. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6576. return Ok(JsonView(true, "查询成功!", new
  6577. {
  6578. //GroupNameData = groupNameData.Data,
  6579. //visaData = visaData.Data,
  6580. //airData = airData.Data,
  6581. reteInfos = reteInfos
  6582. }));
  6583. }
  6584. /// <summary>
  6585. /// 团组模块 - 出入境费用-草稿 - Info
  6586. /// </summary>
  6587. /// <returns></returns>
  6588. [HttpPost]
  6589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6590. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6591. {
  6592. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6593. }
  6594. /// <summary>
  6595. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6596. /// </summary>
  6597. /// <returns></returns>
  6598. [HttpPost]
  6599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6600. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6601. {
  6602. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6603. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6604. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6605. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6606. foreach (var userId in dto.UserIds)
  6607. {
  6608. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6609. }
  6610. if (permissions.Any())
  6611. {
  6612. _sqlSugar.BeginTran();
  6613. try
  6614. {
  6615. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6616. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6617. if (result < 1)
  6618. {
  6619. _sqlSugar.RollbackTran();
  6620. return Ok(JsonView(false));
  6621. }
  6622. }
  6623. catch (Exception ex)
  6624. {
  6625. _sqlSugar.RollbackTran();
  6626. return Ok(JsonView(false, ex.Message));
  6627. }
  6628. _sqlSugar.CommitTran();
  6629. return Ok(JsonView(true));
  6630. }
  6631. return Ok(JsonView(false));
  6632. }
  6633. /// <summary>
  6634. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6635. /// </summary>
  6636. /// <returns></returns>
  6637. [HttpPost]
  6638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6639. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6640. {
  6641. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6642. if (data.Code != 0)
  6643. {
  6644. return Ok(JsonView(false, data.Msg));
  6645. }
  6646. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6647. //汇率信息记录
  6648. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6649. return Ok(JsonView(true, data.Msg, data.Data));
  6650. }
  6651. /// <summary>
  6652. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6653. /// </summary>
  6654. /// <param name="dto"></param>
  6655. /// <returns></returns>
  6656. [HttpPost]
  6657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6658. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6659. {
  6660. try
  6661. {
  6662. var id = dto.Id;
  6663. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6664. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6665. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6666. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6667. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6668. 3 团组成员名单 1 团组成员名单", ""));
  6669. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6670. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6671. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6672. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6673. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6674. //数据源
  6675. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6676. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6677. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6678. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6679. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6680. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6681. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6682. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6683. .Select((x, a, b) => new
  6684. {
  6685. x.Index,
  6686. itemName = a.Name,
  6687. CurrencyStr = b.Name,
  6688. x.Cost,
  6689. x.SubTotal,
  6690. x.Remark
  6691. })
  6692. .OrderBy((x) => x.Index)
  6693. .ToList(); //其他款项费用
  6694. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6695. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6696. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6697. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6698. if (dto.ExportType == 1) //明细表
  6699. {
  6700. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6701. {
  6702. //获取模板
  6703. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6704. //载入模板
  6705. Document doc = new Document(tempPath);
  6706. DocumentBuilder builder = new DocumentBuilder(doc);
  6707. //利用键值对存放数据
  6708. Dictionary<string, string> dic = new Dictionary<string, string>();
  6709. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6710. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6711. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6712. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6713. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6714. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6715. //境内费用(其他费用)
  6716. if (_EnterExitCosts.ChoiceOne == 1)
  6717. {
  6718. string row1_1 = "";
  6719. if (_EnterExitCosts.Visa > 0)
  6720. {
  6721. //insidePayTotal += _EnterExitCosts.Visa;
  6722. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6723. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6724. {
  6725. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6726. }
  6727. }
  6728. string row1_2 = "";
  6729. if (_EnterExitCosts.YiMiao > 0)
  6730. {
  6731. //insidePayTotal += _EnterExitCosts.YiMiao;
  6732. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6733. }
  6734. if (_EnterExitCosts.HeSuan > 0)
  6735. {
  6736. //insidePayTotal += _EnterExitCosts.HeSuan;
  6737. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6738. }
  6739. if (_EnterExitCosts.Service > 0)
  6740. {
  6741. //insidePayTotal += _EnterExitCosts.Service;
  6742. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6743. }
  6744. string row1_3 = "";
  6745. if (_EnterExitCosts.Safe > 0)
  6746. {
  6747. //insidePayTotal += _EnterExitCosts.Safe;
  6748. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6749. }
  6750. if (_EnterExitCosts.Ticket > 0)
  6751. {
  6752. //insidePayTotal += _EnterExitCosts.Ticket;
  6753. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6754. }
  6755. string row1 = "";
  6756. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6757. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6758. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6759. row1 += $"备注:{_EnterExitCosts.Remark}";
  6760. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6761. dic.Add("Row1Str", row1);
  6762. }
  6763. string airTotalStr = string.Empty,
  6764. airPriceStr = string.Empty;
  6765. //经济舱
  6766. if (_EnterExitCosts.SumJJC == 1)
  6767. {
  6768. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6769. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6770. }
  6771. //公务舱
  6772. if (_EnterExitCosts.SumGWC == 1)
  6773. {
  6774. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6775. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6776. }
  6777. //头等舱
  6778. if (_EnterExitCosts.SumTDC == 1)
  6779. {
  6780. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6781. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6782. }
  6783. string twoItemRemark = "备注:";
  6784. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
  6785. {
  6786. twoItemRemark = _EnterExitCosts.TwoItemRemark;
  6787. }
  6788. dic.Add("AirTotalStr", airTotalStr);
  6789. dic.Add("AirPriceStr", airPriceStr);
  6790. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6791. dic.Add("TwoItemRemark", twoItemRemark);
  6792. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6793. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6794. int table1Row = 0,
  6795. table2Row = 0,
  6796. table3Row = 0,
  6797. table4Row = 0,
  6798. table5Row = 0;
  6799. //住宿费
  6800. if (_EnterExitCosts.ChoiceThree == 1)
  6801. {
  6802. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6803. table1Row = dac1.Count;
  6804. #region 填充word表格内容
  6805. for (int i = 0; i < dac1.Count; i++)
  6806. {
  6807. var dac = dac1[i];
  6808. if (dac == null) continue;
  6809. builder.MoveToCell(0, i, 0, 0);
  6810. builder.Write("第" + dac.Days.ToString() + "晚:");
  6811. builder.MoveToCell(0, i, 1, 0);
  6812. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6813. //builder.Write(dac.Place == null ? "" : dac.Place);
  6814. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6815. builder.MoveToCell(0, i, 2, 0);
  6816. builder.Write("费用标准:");
  6817. string curr = "";
  6818. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6819. if (currData != null)
  6820. {
  6821. curr = currData.Name;
  6822. }
  6823. builder.MoveToCell(0, i, 3, 0);
  6824. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6825. builder.MoveToCell(0, i, 4, 0);
  6826. builder.Write("费用小计:");
  6827. builder.MoveToCell(0, i, 5, 0);
  6828. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6829. }
  6830. #endregion
  6831. }
  6832. else dic.Add("SubZS", "0.00");
  6833. //删除多余行
  6834. while (table1.Rows.Count > table1Row)
  6835. {
  6836. table1.Rows.RemoveAt(table1Row);
  6837. }
  6838. //伙食费
  6839. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6840. if (_EnterExitCosts.ChoiceFour == 1)
  6841. {
  6842. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6843. table2Row = dac2.Count;
  6844. #region 填充word表格内容
  6845. for (int i = 0; i < dac2.Count; i++)
  6846. {
  6847. var dac = dac2[i];
  6848. if (dac == null) continue;
  6849. builder.MoveToCell(1, i, 0, 0);
  6850. builder.Write("第" + dac.Days.ToString() + "天:");
  6851. builder.MoveToCell(1, i, 1, 0);
  6852. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6853. builder.MoveToCell(1, i, 2, 0);
  6854. builder.Write("费用标准:");
  6855. string curr = "";
  6856. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6857. if (currData != null)
  6858. {
  6859. curr = currData.Name;
  6860. }
  6861. builder.MoveToCell(1, i, 3, 0);
  6862. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6863. builder.MoveToCell(1, i, 4, 0);
  6864. builder.Write("费用小计:");
  6865. builder.MoveToCell(1, i, 5, 0);
  6866. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6867. }
  6868. #endregion
  6869. }
  6870. else dic.Add("SubHS", "0.00");
  6871. //删除多余行
  6872. while (table2.Rows.Count > table2Row)
  6873. {
  6874. table2.Rows.RemoveAt(table2Row);
  6875. }
  6876. //公杂费
  6877. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6878. if (_EnterExitCosts.ChoiceFive == 1)
  6879. {
  6880. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6881. table3Row = dac3.Count;
  6882. #region 填充word表格内容
  6883. for (int i = 0; i < dac3.Count; i++)
  6884. {
  6885. var dac = dac3[i];
  6886. if (dac == null) continue;
  6887. builder.MoveToCell(2, i, 0, 0);
  6888. builder.Write("第" + dac.Days.ToString() + "天:");
  6889. builder.MoveToCell(2, i, 1, 0);
  6890. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6891. builder.MoveToCell(2, i, 2, 0);
  6892. builder.Write("费用标准:");
  6893. string curr = "";
  6894. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6895. if (currData != null)
  6896. {
  6897. curr = currData.Name;
  6898. }
  6899. builder.MoveToCell(2, i, 3, 0);
  6900. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6901. builder.MoveToCell(2, i, 4, 0);
  6902. builder.Write("费用小计:");
  6903. builder.MoveToCell(2, i, 5, 0);
  6904. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6905. }
  6906. //删除多余行
  6907. while (table3.Rows.Count > table3Row)
  6908. {
  6909. table3.Rows.RemoveAt(table3Row);
  6910. }
  6911. #endregion
  6912. }
  6913. else dic.Add("SubGZF", "0.00");
  6914. //删除多余行
  6915. while (table3.Rows.Count > table3Row)
  6916. {
  6917. table3.Rows.RemoveAt(table3Row);
  6918. }
  6919. //培训费
  6920. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6921. if (_EnterExitCosts.ChoiceSix == 1)
  6922. {
  6923. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6924. dic.Add("SubPX", pxStr);
  6925. table4Row = dac4.Count;
  6926. #region 填充word表格内容
  6927. for (int i = 0; i < dac4.Count; i++)
  6928. {
  6929. var dac = dac4[i];
  6930. if (dac == null) continue;
  6931. builder.MoveToCell(3, i, 0, 0);
  6932. builder.Write("第" + dac.Days.ToString() + "天:");
  6933. builder.MoveToCell(3, i, 1, 0);
  6934. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6935. builder.MoveToCell(3, i, 2, 0);
  6936. builder.Write("费用标准:");
  6937. string curr = "";
  6938. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6939. if (currData != null)
  6940. {
  6941. curr = currData.Name;
  6942. }
  6943. builder.MoveToCell(3, i, 3, 0);
  6944. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6945. builder.MoveToCell(3, i, 4, 0);
  6946. builder.Write("费用小计:");
  6947. builder.MoveToCell(3, i, 5, 0);
  6948. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6949. }
  6950. #endregion
  6951. }
  6952. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  6953. //删除多余行
  6954. while (table4.Rows.Count > table4Row)
  6955. {
  6956. table4.Rows.RemoveAt(table4Row);
  6957. }
  6958. //其他费用
  6959. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6960. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6961. {
  6962. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6963. dic.Add("titleQi", qtStr);
  6964. table5Row = dac5.Count;
  6965. #region 填充word表格内容
  6966. for (int i = 0; i < dac5.Count; i++)
  6967. {
  6968. var dac = dac5[i];
  6969. if (dac == null) continue;
  6970. builder.MoveToCell(4, i, 0, 0);
  6971. builder.Write("第" + dac.Index.ToString() + "项:");
  6972. builder.MoveToCell(4, i, 1, 0);
  6973. builder.Write(dac.itemName);
  6974. builder.MoveToCell(4, i, 2, 0);
  6975. builder.Write("费用标准:");
  6976. builder.MoveToCell(4, i, 3, 0);
  6977. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6978. builder.MoveToCell(4, i, 4, 0);
  6979. builder.Write("费用小计:");
  6980. builder.MoveToCell(4, i, 5, 0);
  6981. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6982. builder.MoveToCell(4, i, 6, 0);
  6983. builder.Write("备注:");
  6984. builder.MoveToCell(4, i, 7, 0);
  6985. builder.Write(dac.Remark);
  6986. }
  6987. #endregion
  6988. }
  6989. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6990. //删除多余行
  6991. while (table5.Rows.Count > table5Row)
  6992. {
  6993. table5.Rows.RemoveAt(table5Row);
  6994. }
  6995. //加上其他费用
  6996. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6997. decimal subJJC = 0.00M,
  6998. subGWC = 0.00M,
  6999. subTDC = 0.00M;
  7000. //经济舱
  7001. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7002. //公务舱
  7003. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7004. //头等舱
  7005. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7006. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7007. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7008. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7009. #region 填充word模板书签内容
  7010. foreach (var key in dic.Keys)
  7011. {
  7012. Bookmark bookmark = doc.Range.Bookmarks[key];
  7013. if (bookmark != null)
  7014. {
  7015. builder.MoveToBookmark(key);
  7016. builder.Write(dic[key]);
  7017. }
  7018. }
  7019. #endregion
  7020. //文件名
  7021. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7022. strFileName = CommonFun.ValidFileName(strFileName);
  7023. AsposeHelper.removewatermark_v2180();
  7024. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7025. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7026. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7027. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7028. }
  7029. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7030. {
  7031. //获取模板
  7032. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7033. //载入模板
  7034. Document doc = new Document(tempPath);
  7035. DocumentBuilder builder = new DocumentBuilder(doc);
  7036. Dictionary<string, string> dic = new Dictionary<string, string>();
  7037. string returnCodeLabel = string.Empty;
  7038. if (nationalTravelFeeData.Any())
  7039. {
  7040. List<string> list = new List<string>();
  7041. foreach (var item in nationalTravelFeeData)
  7042. {
  7043. list.Add($"{item.Country}({item.City})");
  7044. }
  7045. list = list.Distinct().ToList();
  7046. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7047. }
  7048. var countryLabel = string.Empty;
  7049. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7050. if (countryData.Any())
  7051. {
  7052. countryLabel = string.Join("、", countryData);
  7053. }
  7054. dic.Add("ReturnCodeAir", returnCodeLabel);
  7055. dic.Add("VisitStartDate", "-");
  7056. dic.Add("VisitEndDate", "-");
  7057. dic.Add("Day", "-");
  7058. dic.Add("VisitCountry", countryLabel);
  7059. dic.Add("ClientUnit", "-");
  7060. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7061. //dic.Add("Names", Names);
  7062. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7063. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7064. decimal dac1totalPrice = 0.00M;
  7065. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7066. foreach (var dac in dac1)
  7067. {
  7068. if (dac.SubTotal == 0.00M)
  7069. {
  7070. continue;
  7071. }
  7072. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7073. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7074. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7075. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7076. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7077. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7078. builder.Write(currency);//币种
  7079. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7080. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7081. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7082. builder.Write("");//人数
  7083. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7084. builder.Write("");//天数
  7085. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7086. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7087. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7088. decimal rate = 0.00M;
  7089. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7090. builder.Write(rate.ToString("#0.0000"));//汇率
  7091. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7092. decimal rbmPrice = dac.SubTotal;
  7093. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7094. accommodationStartIndex++;
  7095. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7096. }
  7097. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7098. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7099. {
  7100. table1.Rows.RemoveAt(i - 1);
  7101. foodandotherStartIndex--;
  7102. }
  7103. if (dac2.Count == dac3.Count)//国家 币种 金额
  7104. {
  7105. for (int i = 0; i < dac2.Count; i++)
  7106. {
  7107. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7108. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7109. }
  7110. }
  7111. decimal dac2totalPrice = 0.00M;
  7112. foreach (var dac in dac2)
  7113. {
  7114. if (dac.SubTotal == 0)
  7115. {
  7116. continue;
  7117. }
  7118. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7119. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7120. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7121. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7122. builder.Write(currency);//币种
  7123. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7124. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7125. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7126. builder.Write("");//人数
  7127. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7128. builder.Write("");//天数
  7129. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7130. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7131. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7132. decimal rate = 0.00M;
  7133. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7134. builder.Write(rate.ToString("#0.0000"));//汇率
  7135. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7136. decimal rbmPrice = dac.SubTotal;
  7137. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7138. foodandotherStartIndex++;
  7139. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7140. }
  7141. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7142. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7143. {
  7144. table1.Rows.RemoveAt(i - 1);
  7145. }
  7146. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7147. string otherFeeStr = "";
  7148. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7149. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7150. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7151. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7152. foreach (var otherInfo in dac5)
  7153. {
  7154. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7155. }
  7156. #endregion
  7157. if (otherFeeStr.Length > 0)
  7158. {
  7159. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7160. otherFeeStr = $"({otherFeeStr})";
  7161. dic.Add("OtherFeeStr", otherFeeStr);
  7162. }
  7163. //总计
  7164. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7165. //国际旅费
  7166. string outsideAir = string.Empty;
  7167. string allPriceAir = string.Empty;
  7168. if (_EnterExitCosts.SumJJC == 1)
  7169. {
  7170. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7171. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7172. }
  7173. if (_EnterExitCosts.SumGWC == 1)
  7174. {
  7175. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7176. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7177. }
  7178. if (_EnterExitCosts.SumTDC == 1)
  7179. {
  7180. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7181. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7182. }
  7183. dic.Add("InTravelPrice", $"({outsideAir})");
  7184. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7185. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7186. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7187. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7188. foreach (var key in dic.Keys)
  7189. {
  7190. builder.MoveToBookmark(key);
  7191. builder.Write(dic[key]);
  7192. }
  7193. //模板文件名
  7194. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7195. strFileName = CommonFun.ValidFileName(strFileName);
  7196. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7197. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7198. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7199. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7200. }
  7201. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7202. {
  7203. //获取模板
  7204. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7205. //载入模板
  7206. WorkbookDesigner designer = new WorkbookDesigner();
  7207. designer.Workbook = new Workbook(tempPath);
  7208. Dictionary<string, string> dic = new Dictionary<string, string>();
  7209. string returnCodeLabel = string.Empty;
  7210. if (nationalTravelFeeData.Any())
  7211. {
  7212. List<string> list = new List<string>();
  7213. foreach (var item in nationalTravelFeeData)
  7214. {
  7215. list.Add($"{item.Country}({item.City})");
  7216. }
  7217. list = list.Distinct().ToList();
  7218. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7219. }
  7220. var countryLabel = string.Empty;
  7221. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7222. if (countryData.Any())
  7223. {
  7224. countryLabel = string.Join("、", countryData);
  7225. }
  7226. dic.Add("ReturnCodeAir", returnCodeLabel);
  7227. dic.Add("VisitStartDate", "-");
  7228. dic.Add("VisitEndDate", "-");
  7229. dic.Add("Day", "0");
  7230. dic.Add("VisitCountry", countryLabel);
  7231. dic.Add("ClientUnit", "-");
  7232. designer.SetDataSource("ClientUnit", "-");
  7233. designer.SetDataSource("VisitCountry", countryLabel);
  7234. designer.SetDataSource("Group", "-");
  7235. designer.SetDataSource("ClientUnitTitle", "-");
  7236. designer.SetDataSource("Name", "-");
  7237. designer.SetDataSource("VisitStartDate", "-" );
  7238. designer.SetDataSource("Day", "0");
  7239. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7240. designer.SetDataSource("ReturnCodeAir", "-");
  7241. int startIndex = 10;
  7242. const int startIndexcopy = 10;
  7243. if (dac2.Count == dac3.Count)//国家 币种 金额
  7244. {
  7245. for (int i = 0; i < dac2.Count; i++)
  7246. {
  7247. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7248. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7249. }
  7250. }
  7251. DataTable dtdac1 = new DataTable();
  7252. List<string> place = new List<string>();
  7253. dtdac1.Columns.AddRange(new DataColumn[] {
  7254. new DataColumn(){ ColumnName = "city"},
  7255. new DataColumn(){ ColumnName = "curr"},
  7256. new DataColumn(){ ColumnName = "criterion"},
  7257. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7258. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7259. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7260. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7261. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7262. });
  7263. DataTable dtdac2 = new DataTable();
  7264. dtdac2.Columns.AddRange(new DataColumn[] {
  7265. new DataColumn(){ ColumnName = "city"},
  7266. new DataColumn(){ ColumnName = "curr"},
  7267. new DataColumn(){ ColumnName = "criterion"},
  7268. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7269. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7270. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7271. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7272. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7273. });
  7274. dtdac1.TableName = "tb1";
  7275. dtdac2.TableName = "tb2";
  7276. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7277. foreach (var item in dac1)
  7278. {
  7279. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7280. if (place.Contains(item.Place))
  7281. {
  7282. continue;
  7283. }
  7284. DataRow row = dtdac1.NewRow();
  7285. row["city"] = item.Place;
  7286. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7287. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7288. row["curr"] = currency;
  7289. row["rate"] = rate.ToString("#0.0000");
  7290. row["criterion"] = item.Cost.ToString("#0.00");
  7291. row["number"] = 1;
  7292. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7293. //row["costRMB"] = rbmPrice;
  7294. dtdac1.Rows.Add(row);
  7295. place.Add(item.Place);
  7296. }
  7297. place = new List<string>();
  7298. foreach (var item in dac2)
  7299. {
  7300. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7301. if (place.Contains(item.Place))
  7302. {
  7303. continue;
  7304. }
  7305. DataRow row = dtdac2.NewRow();
  7306. row["city"] = item.Place;
  7307. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7308. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7309. row["curr"] = currency;
  7310. row["rate"] = rate.ToString("#0.0000");
  7311. row["criterion"] = item.Cost.ToString("#0.00");
  7312. row["number"] = 1;
  7313. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7314. //row["cost"] = item.SubTotal;
  7315. //row["costRMB"] = rbmPrice;
  7316. dtdac2.Rows.Add(row);
  7317. place.Add(item.Place);
  7318. //dac2totalPrice += rbmPrice;
  7319. }
  7320. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7321. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7322. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7323. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7324. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  7325. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  7326. string cell4Str1 = string.Empty;
  7327. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  7328. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  7329. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  7330. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7331. string cellStr = $" 5.其他费用(";
  7332. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7333. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7334. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7335. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7336. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7337. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7338. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7339. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7340. foreach (var otherInfo in dac5)
  7341. {
  7342. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7343. }
  7344. #endregion
  7345. if (cellStr.Length > 8)
  7346. {
  7347. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7348. }
  7349. cellStr += ")";
  7350. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7351. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7352. decimal pxFee = dac4.Sum(it => it.Cost);
  7353. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7354. string celllastStr1 = "";
  7355. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  7356. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  7357. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  7358. celllastStr1 += $",国际旅费 元";
  7359. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  7360. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7361. designer.SetDataSource("cell4Str", cell4Str);
  7362. designer.SetDataSource("cellStr", cellStr);
  7363. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7364. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7365. designer.SetDataSource("celllastStr", celllastStr);
  7366. Workbook wb = designer.Workbook;
  7367. var sheet = wb.Worksheets[0];
  7368. //绑定datatable数据集
  7369. designer.SetDataSource(dtdac1);
  7370. designer.SetDataSource(dtdac2);
  7371. designer.Process();
  7372. var rowStart = dtdac1.Rows.Count;
  7373. while (rowStart > 0)
  7374. {
  7375. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7376. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7377. startIndex++;
  7378. rowStart--;
  7379. }
  7380. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7381. startIndex += 1; //总计行
  7382. rowStart = dtdac2.Rows.Count;
  7383. while (rowStart > 0)
  7384. {
  7385. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7386. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7387. startIndex++;
  7388. rowStart--;
  7389. }
  7390. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7391. wb.CalculateFormula(true);
  7392. //模板文件名
  7393. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7394. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7395. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7396. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7397. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7398. }
  7399. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7400. {
  7401. //获取模板
  7402. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7403. //载入模板
  7404. Document doc = new Document(tempPath);
  7405. DocumentBuilder builder = new DocumentBuilder(doc);
  7406. Dictionary<string, string> dic = new Dictionary<string, string>();
  7407. dic.Add("GroupName", "-");
  7408. dic.Add("ClientUnit", "-");
  7409. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7410. string missionLeaderJob = "";//负责人job
  7411. int groupNumber = 0; //团人数
  7412. dic.Add("MissionLeader", "-"); //团负责人
  7413. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7414. dic.Add("GroupNumber", "0"); //团人数
  7415. dic.Add("Day", "0");
  7416. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7417. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7418. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7419. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7420. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7421. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7422. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7423. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7424. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7425. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7426. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7427. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7428. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7429. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7430. //其他费用
  7431. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7432. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7433. //其他费用合计
  7434. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7435. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7436. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7437. //公务舱合计
  7438. //国际旅费
  7439. string outsideJJ = "";
  7440. string allPriceJJ = "";
  7441. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7442. {
  7443. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7444. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7445. }
  7446. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7447. {
  7448. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7449. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7450. }
  7451. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7452. {
  7453. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7454. dic.Add("AirFeeTotal", airFeeTotalStr);
  7455. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7456. dic.Add("FeeTotal", feeTotalStr);
  7457. }
  7458. foreach (var key in dic.Keys)
  7459. {
  7460. builder.MoveToBookmark(key);
  7461. builder.Write(dic[key]);
  7462. }
  7463. //模板文件名
  7464. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7465. strFileName = CommonFun.ValidFileName(strFileName);
  7466. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7467. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7468. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7469. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7470. }
  7471. }
  7472. else if (dto.ExportType == 2) //表格
  7473. {
  7474. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7475. }
  7476. else if (dto.ExportType == 3)
  7477. {
  7478. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7479. }
  7480. return Ok(JsonView(400, "只可导出明细表!", ""));
  7481. }
  7482. catch (Exception ex)
  7483. {
  7484. return Ok(JsonView(400, ex.Message, ""));
  7485. }
  7486. }
  7487. /// <summary>
  7488. /// 获取三公费用标准city
  7489. /// </summary>
  7490. /// <param name="placeData"></param>
  7491. /// <param name="nationalTravelFeeId"></param>
  7492. /// <returns></returns>
  7493. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7494. {
  7495. string _city = string.Empty;
  7496. if (!placeData.Any()) return _city;
  7497. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7498. if (data == null) return _city;
  7499. string country = data.Country;
  7500. string city = data.City;
  7501. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7502. else _city = city;
  7503. return _city;
  7504. }
  7505. /// <summary>
  7506. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7507. /// </summary>
  7508. /// <returns></returns>
  7509. [HttpPost]
  7510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7511. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7512. {
  7513. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7514. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7515. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7516. if (_view.Code == 0)
  7517. {
  7518. return Ok(JsonView(true, "操作成功"));
  7519. }
  7520. return Ok(JsonView(false, "操作失败"));
  7521. }
  7522. /// <summary>
  7523. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7524. /// </summary>
  7525. /// <returns></returns>
  7526. [HttpPost]
  7527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7528. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7529. {
  7530. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7531. if (data.Code != 0)
  7532. {
  7533. return Ok(JsonView(false, data.Msg));
  7534. }
  7535. return Ok(JsonView(true, "操作成功!", data.Data));
  7536. }
  7537. /// <summary>
  7538. /// 三公其他费用草稿 删除
  7539. /// </summary>
  7540. /// <param name="dto"></param>
  7541. /// <returns></returns>
  7542. [HttpPost]
  7543. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7544. {
  7545. var jw = JsonView(false, "删除失败!");
  7546. var data = new Grp_DayOtherPriceDraft()
  7547. {
  7548. Id = dto.Id,
  7549. IsDel = 1,
  7550. DeleteUserId = dto.DeleteUserId,
  7551. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7552. };
  7553. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7554. if (del > 0)
  7555. {
  7556. jw.Code = 200;
  7557. jw.Msg = "删除成功!";
  7558. }
  7559. return Ok(jw);
  7560. }
  7561. /// <summary>
  7562. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7563. /// </summary>
  7564. /// <param name="dto"></param>
  7565. /// <returns></returns>
  7566. [HttpPost]
  7567. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7568. {
  7569. var jw = JsonView(false);
  7570. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7571. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new {x.Id,x.DraftName }).ToListAsync();
  7572. jw.Code = StatusCodes.Status200OK;
  7573. jw.Msg = "操作成功!";
  7574. jw.Data = new { groupNameDatas= groupNameDatas.Data, draftNames = draftDatas };
  7575. return Ok(jw);
  7576. }
  7577. /// <summary>
  7578. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7579. /// </summary>
  7580. /// <param name="dto"></param>
  7581. /// <returns></returns>
  7582. [HttpPost]
  7583. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7584. {
  7585. int userId = dto.UserId,
  7586. portId = dto.PortType,
  7587. groupId = dto.GroupId,
  7588. draftId = dto.DraftId;
  7589. _portTypeData.Add(1);
  7590. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7591. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7592. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7593. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7594. _sqlSugar.BeginTran();
  7595. try
  7596. {
  7597. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7598. if (draftDatas == null)
  7599. {
  7600. _sqlSugar.RollbackTran();
  7601. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7602. }
  7603. //验证可覆盖已有数据 两边创建人需为同一人;
  7604. int draftCreateUserId = draftDatas.CreateUserId,
  7605. formalCreateUserId = 0;
  7606. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7607. if (formalData != null)
  7608. {
  7609. formalCreateUserId = formalData.CreateUserId;
  7610. if (draftCreateUserId != formalCreateUserId)
  7611. {
  7612. _sqlSugar.RollbackTran();
  7613. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7614. }
  7615. }
  7616. var permissionUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  7617. var userIds = permissionUsers.Select(x => x.Id).ToList();
  7618. var permissions = new List<Grp_EnterExitCostPermission>();
  7619. if (userIds.Any())
  7620. {
  7621. foreach (var userId1 in userIds)
  7622. {
  7623. permissions.Add(new Grp_EnterExitCostPermission() {
  7624. GroupId = groupId,
  7625. UserId = userId1,
  7626. CreateUserId = dto.UserId
  7627. });
  7628. }
  7629. }
  7630. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7631. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7632. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7633. newExterData.DiId = groupId;
  7634. newExterData.CreateUserId = userId;
  7635. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7636. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7637. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7638. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7639. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7640. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7641. //数据如果存在执行删除
  7642. if (enterExitCostInfo != null)
  7643. {
  7644. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7645. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7646. .Where(x => x.Id == enterExitCostInfo.Id)
  7647. .ExecuteCommand();
  7648. _sqlSugar.Updateable<Grp_DayAndCost>()
  7649. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7650. .Where(x => x.DiId == groupId)
  7651. .ExecuteCommand();
  7652. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7653. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7654. .Where(x => x.Diid == groupId)
  7655. .ExecuteCommand();
  7656. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7657. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7658. .Where(x => x.GroupId == groupId)
  7659. .ExecuteCommand();
  7660. }
  7661. //执行insert
  7662. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7663. if (insertId < 1)
  7664. {
  7665. _sqlSugar.RollbackTran();
  7666. return Ok(JsonView(false, "草稿数据导入失败!"));
  7667. }
  7668. if (permissions.Any()) _sqlSugar.Insertable(permissions).ExecuteCommand();
  7669. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7670. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7671. _sqlSugar.CommitTran();
  7672. //执行操作之后
  7673. //生成默认文件pdf并且通知人员
  7674. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7675. {
  7676. DiId = groupId,
  7677. ExportType = 1,
  7678. SubTypeId = 1005
  7679. }, "pdf");
  7680. //发送通知
  7681. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7682. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7683. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7684. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7685. //汇率信息记录
  7686. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7687. return Ok(JsonView(true));
  7688. }
  7689. catch (Exception ex)
  7690. {
  7691. _sqlSugar.RollbackTran();
  7692. return Ok(JsonView(false,ex.Message));
  7693. }
  7694. }
  7695. #endregion
  7696. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7697. /// <summary>
  7698. /// 获取币种基础数据(含逻辑处理)
  7699. /// </summary>
  7700. /// <returns></returns>
  7701. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7702. {
  7703. //默认币种显示
  7704. var _currencyInfos = _currencyInit;
  7705. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7706. if (_currencyRate.Count > 0)
  7707. {
  7708. foreach (var item in _currencyInfos)
  7709. {
  7710. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7711. if (rateInfo != null)
  7712. {
  7713. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  7714. rate1 *= 1.035M;
  7715. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7716. }
  7717. }
  7718. }
  7719. return _currencyInfos;
  7720. }
  7721. /// <summary>
  7722. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7723. /// </summary>
  7724. /// <returns></returns>
  7725. [HttpPost]
  7726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7727. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7728. {
  7729. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7730. //SetDataInfoView
  7731. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7732. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7733. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7734. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7735. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7736. //默认币种显示
  7737. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7738. return Ok(JsonView(true, "查询成功!", new
  7739. {
  7740. WordTypeData = _WordTypeData,
  7741. ExcelTypeData = _ExcelTypeData,
  7742. CurrencyInit = _currencyInfos
  7743. }));
  7744. }
  7745. /// <summary>
  7746. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7747. /// </summary>
  7748. /// <returns></returns>
  7749. [HttpPost]
  7750. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7751. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7752. {
  7753. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7754. RefAsync<int> total = 0;
  7755. int diId = 0;
  7756. var status = int.TryParse(dto.GroupName, out diId);
  7757. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  7758. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  7759. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7760. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  7761. .Select(x => new
  7762. {
  7763. Id = x.Id,
  7764. GroupName = x.TeamName
  7765. })
  7766. .OrderByDescending(x => x.Id)
  7767. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7768. return Ok(JsonView(true, "查询成功!", data, total));
  7769. }
  7770. /// <summary>
  7771. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7772. /// </summary>
  7773. /// <returns></returns>
  7774. [HttpPost]
  7775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7776. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7777. {
  7778. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7779. RefAsync<int> total = 0;
  7780. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7781. .Where(x => x.IsDel == 0 && x.STid == 66)
  7782. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7783. .Select(x => new
  7784. {
  7785. id = x.Id,
  7786. name = x.Name,
  7787. remark = x.Remark,
  7788. })
  7789. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7790. return Ok(JsonView(true, "查询成功!", data, total));
  7791. }
  7792. /// <summary>
  7793. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7794. /// </summary>
  7795. /// <returns></returns>
  7796. [HttpPost]
  7797. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7798. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7799. {
  7800. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7801. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7802. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7803. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7804. var groupOtherRateData = groupRateData.TeamRates;
  7805. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7806. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7807. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7808. groupOtherRateData = groupOtherRateData
  7809. .Select(x => new TeamRateDescAddCurrencyIdView {
  7810. CurrencyId = x.CurrencyId,
  7811. CurrencyName = x.CurrencyName,
  7812. CurrencyCode = x.CurrencyCode,
  7813. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7814. }).ToList();
  7815. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7816. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData= groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7817. }
  7818. /// <summary>
  7819. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7820. /// </summary>
  7821. /// <returns></returns>
  7822. [HttpPost]
  7823. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7824. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7825. {
  7826. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7827. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7828. var tipsData = new List<int>() {1,2,3 };
  7829. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7830. if (dto.TipsType == 1)
  7831. {
  7832. //默认币种显示
  7833. var _currencyInfos = _currencyInit;
  7834. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7835. List<dynamic> reteInfos = new List<dynamic>();
  7836. if (_currencyRate.Count > 0)
  7837. {
  7838. foreach (var item in _currencyInfos)
  7839. {
  7840. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7841. if (rateInfo != null)
  7842. {
  7843. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  7844. decimal rate1 = item.Rate;
  7845. rate1 *= 1.03M;
  7846. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7847. reteInfos.Add(new
  7848. {
  7849. currCode = item.CurrencyCode,
  7850. currName = item.CurrencyName,
  7851. rate = rate2,
  7852. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  7853. });
  7854. }
  7855. }
  7856. }
  7857. return Ok(JsonView(true, "查询成功!", reteInfos));
  7858. }
  7859. else if (dto.TipsType == 2)
  7860. {
  7861. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  7862. return Ok(JsonView(true, "查询成功!", visaData.Data));
  7863. }
  7864. else if (dto.TipsType == 3)
  7865. {
  7866. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  7867. return Ok(JsonView(true, "查询成功!", airData.Data));
  7868. }
  7869. return Ok(JsonView(false));
  7870. }
  7871. /// <summary>
  7872. /// 团组模块 - 出入境国家费用标准-移动端 List
  7873. /// </summary>
  7874. /// <returns></returns>
  7875. [HttpPost]
  7876. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7877. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  7878. {
  7879. Stopwatch sw = new Stopwatch();
  7880. sw.Start();
  7881. RefAsync<int> total = 0;
  7882. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7883. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  7884. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  7885. .Where((ntf, sd, u) => ntf.IsDel == 0)
  7886. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  7887. .Select((ntf, sd, u) => new
  7888. {
  7889. Id = ntf.Id,
  7890. Area = $"{ntf.Country}-{ntf.City}",
  7891. Currency = ntf.Currency,
  7892. CurrencyCode = sd.Name,
  7893. CurrencyName = sd.Remark,
  7894. RoomCost = ntf.RoomCost,
  7895. FoodCost = ntf.FoodCost,
  7896. PublicCost = ntf.PublicCost,
  7897. LastUpdateUserId = ntf.LastUpdateUserId,
  7898. LastUpdateUserName = u.CnName,
  7899. LastUpdateTime = ntf.LastUpdateTime,
  7900. })
  7901. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7902. sw.Stop();
  7903. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  7904. }
  7905. /// <summary>
  7906. /// 团组模块 - 出入境费用-移动端 - Info
  7907. /// </summary>
  7908. /// <returns></returns>
  7909. [HttpPost]
  7910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7911. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  7912. {
  7913. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7914. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7915. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  7916. return Ok(data);
  7917. }
  7918. /// <summary>
  7919. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  7920. /// </summary>
  7921. /// <returns></returns>
  7922. [HttpPost]
  7923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7924. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  7925. {
  7926. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7927. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7928. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7929. var mobileInfo = new EnterExitCostMobileParentInfoView();
  7930. mobileInfo.DiId = dto.DiId;
  7931. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  7932. if (eecInfo == null) return Ok(mobileInfo);
  7933. //验证查看、操作权限
  7934. // var isView = await _enterExitCostRep.vi
  7935. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  7936. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  7937. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  7938. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  7939. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  7940. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  7941. {
  7942. SubId = dac.Id,
  7943. DiId = dac.DiId,
  7944. Type = dac.Type,
  7945. Days = dac.Days,
  7946. NationalTravelFeeId = dac.NationalTravelFeeId,
  7947. Arae = $"{ntf.Country}-{ntf.City}",
  7948. Cost = dac.Cost,
  7949. Currency = dac.Currency,
  7950. CurrencyName = sd.Name,
  7951. SubTotal = dac.SubTotal,
  7952. })
  7953. .ToList();
  7954. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  7955. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  7956. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  7957. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  7958. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  7959. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  7960. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  7961. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  7962. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  7963. //其他款项
  7964. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  7965. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  7966. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  7967. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  7968. .OrderBy((dop, sd1, sd2) => dop.Index)
  7969. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  7970. {
  7971. SubId = dop.Id,
  7972. DiId = dop.Diid,
  7973. Index = dop.Index,
  7974. SetDataId = dop.SetDataId,
  7975. SetDataName = sd1.Name,
  7976. Cost = dop.Cost,
  7977. Currency = dop.Currency,
  7978. CurrencyName = sd2.Remark,
  7979. SubTotal = dop.SubTotal,
  7980. Remark = dop.Remark,
  7981. })
  7982. .ToArray();
  7983. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  7984. return Ok(mobileInfo);
  7985. }
  7986. /// <summary>
  7987. /// 团组模块 - 出入境费用-移动端 - SubInfo
  7988. /// </summary>
  7989. /// <returns></returns>
  7990. [HttpPost]
  7991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7992. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  7993. {
  7994. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7995. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7996. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  7997. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  7998. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7999. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8000. var subType = dto.SubType;
  8001. if (subType == 1) //1:境内费用
  8002. {
  8003. var oneData = new ChoiceOneMobileSubInfoView()
  8004. {
  8005. Id = eecInfo.Id,
  8006. ChoiceOne = eecInfo.ChoiceOne,
  8007. ChoiceOneTotalCost = eecInfo.InsidePay,
  8008. Visa = eecInfo.Visa,
  8009. VisaRemark = eecInfo.VisaRemark,
  8010. YiMiao = eecInfo.YiMiao,
  8011. HeSuan = eecInfo.HeSuan,
  8012. Service = eecInfo.Service,
  8013. Ticket = eecInfo.Ticket,
  8014. Safe = eecInfo.Safe,
  8015. FirstItemRemark = eecInfo.FirstItemRemark
  8016. };
  8017. return Ok(JsonView(oneData));
  8018. }
  8019. else if (subType == 2) //2:国际旅费
  8020. {
  8021. var twoData = new ChoiceTwoMobileSubInfoView() {
  8022. Id = eecInfo.Id,
  8023. ChoiceTwoJJ = eecInfo.SumJJC,
  8024. OutsideJJPay = eecInfo.OutsideJJPay,
  8025. ChoiceTwoGW = eecInfo.SumGWC,
  8026. OutsideGWPay = eecInfo.OutsideGWPay,
  8027. ChoiceTwoTD = eecInfo.SumTDC,
  8028. OutsideTDPay = eecInfo.OutsideTDPay,
  8029. AirJJ = eecInfo.AirJJ,
  8030. AirGW = eecInfo.AirGW,
  8031. AirTD = eecInfo.AirTD,
  8032. CityTranffic = eecInfo.CityTranffic,
  8033. TwoItemRemark = eecInfo.TwoItemRemark
  8034. };
  8035. return Ok(JsonView(twoData));
  8036. }
  8037. else if (subType == 3) //3:住宿费
  8038. {
  8039. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8040. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8041. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8042. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8043. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8044. {
  8045. SubId = dac.Id,
  8046. DiId = dac.DiId,
  8047. Type = dac.Type,
  8048. Days = dac.Days,
  8049. NationalTravelFeeId = dac.NationalTravelFeeId,
  8050. Arae = $"{ntf.Country}-{ntf.City}",
  8051. Cost = dac.Cost,
  8052. Currency = dac.Currency,
  8053. CurrencyName = sd.Name,
  8054. SubTotal = dac.SubTotal,
  8055. })
  8056. .ToArray();
  8057. var data = new ChoiceMobileSubInfo3To6View() {
  8058. ParentId = eecInfo.Id,
  8059. Choice = eecInfo.ChoiceThree,
  8060. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8061. Details = dayAndCostDatas
  8062. };
  8063. return Ok(JsonView(data));
  8064. }
  8065. else if (subType == 4) //4:伙食费
  8066. {
  8067. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8068. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8069. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8070. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8071. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8072. {
  8073. SubId = dac.Id,
  8074. DiId = dac.DiId,
  8075. Type = dac.Type,
  8076. Days = dac.Days,
  8077. NationalTravelFeeId = dac.NationalTravelFeeId,
  8078. Arae = $"{ntf.Country}-{ntf.City}",
  8079. Cost = dac.Cost,
  8080. Currency = dac.Currency,
  8081. CurrencyName = sd.Name,
  8082. SubTotal = dac.SubTotal,
  8083. })
  8084. .ToArray();
  8085. var data = new ChoiceMobileSubInfo3To6View()
  8086. {
  8087. ParentId = eecInfo.Id,
  8088. Choice = eecInfo.ChoiceFour,
  8089. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8090. Details = dayAndCostDatas
  8091. };
  8092. return Ok(JsonView(data));
  8093. }
  8094. else if (subType == 5) //5:公杂费
  8095. {
  8096. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8097. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8098. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8099. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8100. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8101. {
  8102. SubId = dac.Id,
  8103. DiId = dac.DiId,
  8104. Type = dac.Type,
  8105. Days = dac.Days,
  8106. NationalTravelFeeId = dac.NationalTravelFeeId,
  8107. Arae = $"{ntf.Country}-{ntf.City}",
  8108. Cost = dac.Cost,
  8109. Currency = dac.Currency,
  8110. CurrencyName = sd.Name,
  8111. SubTotal = dac.SubTotal,
  8112. })
  8113. .ToArray();
  8114. var data = new ChoiceMobileSubInfo3To6View()
  8115. {
  8116. ParentId = eecInfo.Id,
  8117. Choice = eecInfo.ChoiceFive,
  8118. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8119. Details = dayAndCostDatas
  8120. };
  8121. return Ok(JsonView(data));
  8122. }
  8123. else if (subType == 6) //6:培训费
  8124. {
  8125. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8126. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8127. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8128. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8129. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8130. {
  8131. SubId = dac.Id,
  8132. DiId = dac.DiId,
  8133. Type = dac.Type,
  8134. Days = dac.Days,
  8135. NationalTravelFeeId = dac.NationalTravelFeeId,
  8136. Arae = $"{ntf.Country}-{ntf.City}",
  8137. Cost = dac.Cost,
  8138. Currency = dac.Currency,
  8139. CurrencyName = sd.Name,
  8140. SubTotal = dac.SubTotal,
  8141. })
  8142. .ToArray();
  8143. var data = new ChoiceMobileSubInfo3To6View()
  8144. {
  8145. ParentId = eecInfo.Id,
  8146. Choice = eecInfo.ChoiceSix,
  8147. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8148. Details = dayAndCostDatas
  8149. };
  8150. return Ok(JsonView(data));
  8151. }
  8152. else if (subType == 7) //7:其他
  8153. {
  8154. //其他款项
  8155. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8156. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8157. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8158. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8159. .OrderBy((dop, sd1, sd2) => dop.Index)
  8160. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8161. {
  8162. SubId = dop.Id,
  8163. DiId = dop.Diid,
  8164. Index = dop.Index,
  8165. SetDataId = dop.SetDataId,
  8166. SetDataName = sd1.Name,
  8167. Cost = dop.Cost,
  8168. Currency = dop.Currency,
  8169. CurrencyName = sd2.Name,
  8170. SubTotal = dop.SubTotal,
  8171. Remark = dop.Remark,
  8172. })
  8173. .ToArray();
  8174. var data = new ChoiceSevenMobileSubInfoView()
  8175. {
  8176. ParentId = eecInfo.Id,
  8177. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8178. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8179. Details = otherData
  8180. };
  8181. return Ok(JsonView(data));
  8182. }
  8183. return Ok(JsonView(false));
  8184. }
  8185. #region op
  8186. /// <summary>
  8187. /// 移动端更新费用消息通知
  8188. /// </summary>
  8189. /// <param name="diid"></param>
  8190. /// <param name="id"></param>
  8191. /// <param name="currUserId"></param>
  8192. private async Task EnterExitCostMobileOpNotice(int diid, int id,int currUserId)
  8193. {
  8194. try
  8195. {
  8196. ////生成默认文件pdf并且通知人员
  8197. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8198. //{
  8199. // DiId = diid,
  8200. // ExportType = 1,
  8201. // SubTypeId = 1005
  8202. //}, "pdf");
  8203. ////发送通知
  8204. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8205. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8206. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8207. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8208. ////汇率信息记录
  8209. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8210. }
  8211. catch (Exception ex)
  8212. {
  8213. //记录日志
  8214. throw;
  8215. }
  8216. }
  8217. /// <summary>
  8218. /// 验证出入境费用数据是否存在
  8219. /// 不存在添加
  8220. /// </summary>
  8221. /// <param name="diId"></param>
  8222. /// <param name="currUserId"></param>
  8223. /// <returns></returns>
  8224. /// <exception cref="CustomException"></exception>
  8225. private async Task<int> EnterExitCostVerifyIsNull(int diId,int currUserId)
  8226. {
  8227. var parentId = 0;
  8228. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8229. if (info != null) parentId = info.Id;
  8230. else
  8231. {
  8232. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8233. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8234. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8235. parentId = addId;
  8236. }
  8237. return parentId;
  8238. }
  8239. /// <summary>
  8240. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8241. /// </summary>
  8242. /// <returns></returns>
  8243. [HttpPost]
  8244. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8245. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8246. {
  8247. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8248. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8249. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8250. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8251. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8252. int id = dto.Id;
  8253. if (id <= 0) //add
  8254. {
  8255. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8256. if (add < 1) return Ok(JsonView(false));
  8257. id = add;
  8258. }
  8259. else //update
  8260. {
  8261. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8262. if (upd < 1) return Ok(JsonView(false));
  8263. }
  8264. #region 汇率变更时更改币种相关费用
  8265. var opDayCosts = new List<Grp_DayAndCost>();
  8266. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8267. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8268. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8269. .LeftJoin<Sys_SetData>((dac,sd) => dac.Currency == sd.Id)
  8270. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8271. .Select((dac, sd) => new {
  8272. dac.Id,
  8273. dac.DiId,
  8274. CurrencyCode = sd.Name,
  8275. dac.Cost
  8276. })
  8277. .ToList();
  8278. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8279. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8280. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8281. .Select((dop, sd) => new {
  8282. dop.Id,
  8283. dop.Diid,
  8284. CurrencyCode = sd.Name,
  8285. dop.Cost
  8286. })
  8287. .ToList();
  8288. if (dayCosts.Count > 0)
  8289. {
  8290. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8291. foreach (var dc in new_dayCosts)
  8292. {
  8293. var thisCurrency = dc.Key.ToUpper();
  8294. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8295. if (thisRate == 0.00M) continue;
  8296. foreach (var dcSub in dc)
  8297. {
  8298. opDayCosts.Add(new Grp_DayAndCost() {
  8299. Id = dcSub.Id,
  8300. DiId = dcSub.DiId,
  8301. Cost = dcSub.Cost,
  8302. SubTotal = dcSub.Cost * thisRate,
  8303. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8304. });
  8305. }
  8306. }
  8307. if (opDayCosts.Count > 0)
  8308. {
  8309. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8310. }
  8311. }
  8312. if (dayOtherCosts.Count > 0)
  8313. {
  8314. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8315. foreach (var dc in new_dayOtherCosts)
  8316. {
  8317. var thisCurrency = dc.Key.ToUpper();
  8318. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8319. if (thisRate == 0.00M) continue;
  8320. foreach (var dcSub in dc)
  8321. {
  8322. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8323. {
  8324. Id = dcSub.Id,
  8325. Diid = dcSub.Diid,
  8326. Cost = dcSub.Cost,
  8327. SubTotal = dcSub.Cost * thisRate,
  8328. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8329. });
  8330. }
  8331. }
  8332. if (opDayOtherCosts.Count > 0)
  8333. {
  8334. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8335. }
  8336. }
  8337. #endregion
  8338. //消息通知
  8339. await EnterExitCostMobileOpNotice(dto.DiId, id,dto.CurrUserId);
  8340. //汇率信息记录
  8341. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8342. return Ok(JsonView(new { parentId = id }));
  8343. }
  8344. /// <summary>
  8345. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8346. /// </summary>
  8347. /// <returns></returns>
  8348. [HttpPost]
  8349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8350. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8351. {
  8352. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8353. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8354. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8355. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8356. int id = dto.Id;
  8357. if (id <= 0) //add
  8358. {
  8359. checkboxInfo.CreateUserId = dto.CurrUserId;
  8360. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8361. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8362. if (add < 1) return Ok(JsonView(false));
  8363. }
  8364. else //update
  8365. {
  8366. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8367. .UpdateColumns(x => new {
  8368. x.ChoiceOne,
  8369. x.ChoiceTwo,
  8370. x.SumJJC,
  8371. x.SumGWC,
  8372. x.SumTDC,
  8373. x.ChoiceThree,
  8374. x.ChoiceFour,
  8375. x.ChoiceFive,
  8376. x.ChoiceSix,
  8377. x.OtherExpenses_Checked
  8378. })
  8379. .Where(x => x.Id == id)
  8380. .ExecuteCommandAsync();
  8381. if (upd < 1) return Ok(JsonView(false));
  8382. }
  8383. return Ok(JsonView(new { parentId = id }));
  8384. }
  8385. /// <summary>
  8386. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8387. /// </summary>
  8388. /// <returns></returns>
  8389. [HttpPost]
  8390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8391. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8392. {
  8393. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId,isSelected = dto.IsSelected;
  8394. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8395. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8396. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8397. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8398. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8399. var checkboxInfo = new Grp_EnterExitCost() {
  8400. Id = id,
  8401. DiId = diId,
  8402. CreateUserId = currUserId
  8403. };
  8404. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8405. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8406. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8407. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8408. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8409. if (id <= 0) //add
  8410. {
  8411. checkboxInfo.CreateUserId = dto.CurrUserId;
  8412. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8413. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8414. if (add < 1) return Ok(JsonView(false));
  8415. }
  8416. else //update
  8417. {
  8418. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8419. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8420. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8421. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8422. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8423. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8424. .Where(x => x.Id == id)
  8425. .ExecuteCommandAsync();
  8426. if (upd < 1) return Ok(JsonView(false));
  8427. }
  8428. return Ok(JsonView(new { parentId = id }));
  8429. }
  8430. /// <summary>
  8431. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8432. /// </summary>
  8433. /// <returns></returns>
  8434. [HttpPost]
  8435. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8436. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8437. {
  8438. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8439. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8440. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8441. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8442. info.FirstItemRemark = dto.FirstItemRemark;
  8443. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8444. int id = dto.Id;
  8445. if (id <= 0) //add
  8446. {
  8447. info.CreateUserId = dto.CurrUserId;
  8448. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8449. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8450. if (add < 1) return Ok(JsonView(false));
  8451. id = add;
  8452. }
  8453. else //update
  8454. {
  8455. var upd = await _sqlSugar.Updateable(info)
  8456. .UpdateColumns(x => new {
  8457. x.ChoiceOne,
  8458. x.InsidePay,
  8459. x.VisaRemark,
  8460. x.Visa,
  8461. x.Service,
  8462. x.Safe,
  8463. x.Ticket,
  8464. x.HeSuan,
  8465. x.YiMiao,
  8466. x.FirstItemRemark
  8467. })
  8468. .Where(x => x.Id == id)
  8469. .ExecuteCommandAsync();
  8470. if (upd < 1) return Ok(JsonView(false));
  8471. }
  8472. //消息通知
  8473. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8474. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8475. }
  8476. /// <summary>
  8477. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8478. /// </summary>
  8479. /// <returns></returns>
  8480. [HttpPost]
  8481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8482. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8483. {
  8484. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8485. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8486. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8487. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8488. info.OutsideJJPay = dto.OutsideJJPay;
  8489. info.OutsideGWPay = dto.OutsideGWPay;
  8490. info.OutsideTDPay = dto.OutsideTDPay;
  8491. info.AirJJ = dto.AirJJ;
  8492. info.AirGW = dto.AirGW;
  8493. info.AirTD = dto.AirTD;
  8494. info.CityTranffic = dto.CityTranffic;
  8495. info.TwoItemRemark = dto.TwoItemRemark;
  8496. info.SumJJC = dto.ChoiceTwoJJ;
  8497. info.SumGWC = dto.ChoiceTwoGW;
  8498. info.SumTDC = dto.ChoiceTwoTD;
  8499. int id = dto.Id;
  8500. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8501. if (id <= 0) //add
  8502. {
  8503. info.CreateUserId = dto.CurrUserId;
  8504. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8505. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8506. if (addId <= 0) return Ok(JsonView(false));
  8507. id = addId;
  8508. }
  8509. else //update
  8510. {
  8511. var upd = await _sqlSugar.Updateable(info)
  8512. .UpdateColumns(x => new {
  8513. x.SumJJC,
  8514. x.OutsideJJPay,
  8515. x.SumGWC,
  8516. x.OutsideGWPay,
  8517. x.SumTDC,
  8518. x.OutsideTDPay,
  8519. x.AirJJ,
  8520. x.AirGW,
  8521. x.AirTD,
  8522. x.CityTranffic,
  8523. x.TwoItemRemark
  8524. })
  8525. .Where(x => x.Id == id)
  8526. .ExecuteCommandAsync();
  8527. if (upd <1) return Ok(JsonView(false));
  8528. }
  8529. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8530. gwcItemTotal = info.AirGW + info.CityTranffic;
  8531. tdcItemTotal = info.AirTD + info.CityTranffic;
  8532. //消息通知
  8533. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8534. return Ok(JsonView(new
  8535. {
  8536. parentId = id,
  8537. choiceTwoJJ = dto.ChoiceTwoJJ,
  8538. jjcItemTotal = jjcItemTotal,
  8539. choiceTwoGW = dto.ChoiceTwoGW,
  8540. gwcItemTotal = gwcItemTotal,
  8541. choiceTwoTD = dto.ChoiceTwoTD,
  8542. tdcItemTotal = tdcItemTotal
  8543. }));
  8544. }
  8545. /// <summary>
  8546. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8547. /// </summary>
  8548. /// <returns></returns>
  8549. [HttpPost]
  8550. [ApiExplorerSettings(IgnoreApi = true)]
  8551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8552. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8553. {
  8554. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8555. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8556. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8557. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8558. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8559. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8560. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8561. var infos = infos1.Select(x => new Grp_DayAndCost
  8562. {
  8563. Id = x.Id,
  8564. DiId = dto.DiId,
  8565. Type = dto.FeeType,
  8566. Days = x.Days,
  8567. NationalTravelFeeId = x.NationalTravelFeeId,
  8568. Cost = x.Cost,
  8569. Currency = x.Currency,
  8570. SubTotal = x.SubTotal,
  8571. CreateUserId = dto.CurrUserId
  8572. })
  8573. .ToList();
  8574. var adds = infos.Where(x => x.Id <= 0).ToList();
  8575. var upds = infos.Where(x => x.Id > 0).ToList();
  8576. if (adds.Count > 0)
  8577. {
  8578. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8579. if (add < 1) return Ok(JsonView(false));
  8580. }
  8581. if (upds.Count > 0)
  8582. {
  8583. var upd = await _sqlSugar.Updateable(adds)
  8584. .UpdateColumns(x => new
  8585. {
  8586. x.Days,
  8587. x.NationalTravelFeeId,
  8588. x.Cost,
  8589. x.Currency,
  8590. x.SubTotal
  8591. })
  8592. .WhereColumns(x => new { x.Id })
  8593. .ExecuteCommandAsync();
  8594. if (upd < 1) return Ok(JsonView(false));
  8595. }
  8596. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8597. //消息通知
  8598. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8599. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8600. return Ok(JsonView(new { itemTotal = itemTotal }));
  8601. }
  8602. /// <summary>
  8603. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8604. /// </summary>
  8605. /// <returns></returns>
  8606. [HttpPost]
  8607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8608. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8609. {
  8610. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8611. int subId = dto.SubId, feeType = dto.FeeType;
  8612. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8613. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8614. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8615. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8616. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8617. subInfo.Id = subId;
  8618. subInfo.DiId = dto.DiId;
  8619. if (feeType == 3) subInfo.Type = 1;
  8620. else if (feeType == 4) subInfo.Type = 2;
  8621. else if (feeType == 5) subInfo.Type = 3;
  8622. else if (feeType == 6) subInfo.Type = 4;
  8623. subInfo.CreateUserId = dto.CurrUserId;
  8624. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8625. if (parentId < 1) return Ok(JsonView(false));
  8626. //子表op
  8627. if (subId < 1)
  8628. {
  8629. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8630. if (subAdd < 1) return Ok(JsonView(false));
  8631. }
  8632. else
  8633. {
  8634. var subUpd = await _sqlSugar.Updateable(subInfo)
  8635. .UpdateColumns(x => new
  8636. {
  8637. x.Days,
  8638. x.NationalTravelFeeId,
  8639. x.Cost,
  8640. x.Currency,
  8641. x.SubTotal
  8642. })
  8643. .WhereColumns(x => new { x.Id })
  8644. .ExecuteCommandAsync();
  8645. if (subUpd < 1) return Ok(JsonView(false));
  8646. }
  8647. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8648. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8649. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8650. }
  8651. /// <summary>
  8652. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8653. /// </summary>
  8654. /// <returns></returns>
  8655. [HttpPost]
  8656. [ApiExplorerSettings(IgnoreApi = true)]
  8657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8658. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8659. {
  8660. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8661. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8662. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8663. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8664. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8665. {
  8666. Id = x.Id,
  8667. Diid = dto.DiId,
  8668. SetDataId = x.SetDataId,
  8669. Index = x.Index,
  8670. Cost = x.Cost,
  8671. Currency = x.Currency,
  8672. SubTotal = x.SubTotal,
  8673. CreateUserId = dto.CurrUserId,
  8674. Remark = x.Remark
  8675. }).ToList();
  8676. var adds = infos.Where(x => x.Id <= 0).ToList();
  8677. var upds = infos.Where(x => x.Id > 0).ToList();
  8678. if (adds.Count > 0)
  8679. {
  8680. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8681. if (add < 1) return Ok(JsonView(false));
  8682. }
  8683. if (upds.Count > 0)
  8684. {
  8685. var upd = await _sqlSugar.Updateable(adds)
  8686. .UpdateColumns(x => new
  8687. {
  8688. x.Index,
  8689. x.SetDataId,
  8690. x.Cost,
  8691. x.Currency,
  8692. x.SubTotal,
  8693. x.Remark
  8694. })
  8695. .WhereColumns(x => new { x.Id })
  8696. .ExecuteCommandAsync();
  8697. if (upd < 1) return Ok(JsonView(false));
  8698. }
  8699. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8700. //消息通知
  8701. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8702. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8703. return Ok(JsonView(new { itemTotal = itemTotal }));
  8704. }
  8705. /// <summary>
  8706. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8707. /// </summary>
  8708. /// <returns></returns>
  8709. [HttpPost]
  8710. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8711. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8712. {
  8713. int subId = dto.SubId;
  8714. int diId = dto.Diid;
  8715. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8716. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8717. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8718. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8719. subInfo.Id = subId;
  8720. subInfo.Diid = dto.Diid;
  8721. subInfo.CreateUserId = dto.CurrUserId;
  8722. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8723. if (parentId < 1) return Ok(JsonView(false));
  8724. #region 子表op
  8725. if (subId < 1)//add
  8726. {
  8727. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8728. if (subAdd < 1) return Ok(JsonView(false));
  8729. }
  8730. else //upd
  8731. {
  8732. var subUpd = await _sqlSugar.Updateable(subInfo)
  8733. .UpdateColumns(x => new
  8734. {
  8735. x.Index,
  8736. x.SetDataId,
  8737. x.Cost,
  8738. x.Currency,
  8739. x.SubTotal,
  8740. x.Remark
  8741. })
  8742. .WhereColumns(x => new { x.Id })
  8743. .ExecuteCommandAsync();
  8744. if (subUpd < 1) return Ok(JsonView(false));
  8745. }
  8746. #endregion
  8747. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  8748. //消息通知
  8749. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  8750. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8751. }
  8752. /// <summary>
  8753. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  8754. /// </summary>
  8755. /// <returns></returns>
  8756. [HttpPost]
  8757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8758. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  8759. {
  8760. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8761. if (data.Code != 0)
  8762. {
  8763. return Ok(JsonView(false, data.Msg));
  8764. }
  8765. return Ok(JsonView(true, "操作成功!", data.Data));
  8766. }
  8767. /// <summary>
  8768. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  8769. /// </summary>
  8770. /// <param name="dto"></param>
  8771. /// <returns></returns>
  8772. [HttpPost]
  8773. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  8774. {
  8775. var data = new Grp_DayOtherPrice()
  8776. {
  8777. Id = dto.Id,
  8778. IsDel = 1,
  8779. DeleteUserId = dto.DeleteUserId,
  8780. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8781. };
  8782. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8783. if (del > 0) return Ok(JsonView(true,"删除成功!"));
  8784. return Ok(JsonView(false,"删除失败!"));
  8785. }
  8786. #endregion
  8787. #endregion
  8788. #region 签证费用录入
  8789. /// <summary>
  8790. /// 根据diid查询签证费用列表
  8791. /// </summary>
  8792. /// <param name="dto"></param>
  8793. /// <returns></returns>
  8794. [HttpPost]
  8795. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8796. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  8797. {
  8798. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  8799. if (groupData.Code != 0)
  8800. {
  8801. return Ok(JsonView(false, groupData.Msg));
  8802. }
  8803. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8804. }
  8805. /// <summary>
  8806. /// 根据签证费用Id查询单条数据及c表数据
  8807. /// </summary>
  8808. /// <param name="dto"></param>
  8809. /// <returns></returns>
  8810. [HttpPost]
  8811. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8812. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  8813. {
  8814. Result groupData = await _visaPriceRep.PostVisaById(dto);
  8815. if (groupData.Code != 0)
  8816. {
  8817. return Ok(JsonView(false, groupData.Msg));
  8818. }
  8819. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8820. }
  8821. /// <summary>
  8822. /// 签证费用删除
  8823. /// </summary>
  8824. /// <param name="dto"></param>
  8825. /// <returns></returns>
  8826. [HttpPost]
  8827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8828. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  8829. {
  8830. _sqlSugar.BeginTran();
  8831. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  8832. if (!res)
  8833. {
  8834. _sqlSugar.RollbackTran();
  8835. return Ok(JsonView(false, "删除失败"));
  8836. }
  8837. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  8838. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  8839. .SetColumns(a => new Grp_CreditCardPayment()
  8840. {
  8841. IsDel = 1,
  8842. DeleteUserId = dto.DeleteUserId,
  8843. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8844. })
  8845. .ExecuteCommand();
  8846. if (resSub < 1)
  8847. {
  8848. _sqlSugar.RollbackTran();
  8849. return Ok(JsonView(false, "删除失败"));
  8850. }
  8851. _sqlSugar.CommitTran();
  8852. return Ok(JsonView(true, "删除成功!"));
  8853. }
  8854. /// <summary>
  8855. /// 签证费用录入下拉框初始化
  8856. /// </summary>
  8857. /// <returns></returns>
  8858. [HttpPost]
  8859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8860. public async Task<IActionResult> VisaPriceAddSelect()
  8861. {
  8862. //支付方式
  8863. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  8864. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  8865. //币种
  8866. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  8867. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  8868. //乘客类型
  8869. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  8870. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  8871. //卡类型
  8872. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  8873. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  8874. //代办费类型
  8875. var agencyFeeTypeData = new List<dynamic>() {
  8876. new { id = 0 , Text = "未选择" },
  8877. new { id = 1 , Text = "小公务" },
  8878. new { id = 2 , Text = "大公务" },
  8879. };
  8880. //签证费用标准国家Data
  8881. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  8882. var data = new
  8883. {
  8884. Payment = _Payment,
  8885. CurrencyList = _CurrencyList,
  8886. PassengerType = _PassengerType,
  8887. BankCard = _BankCard,
  8888. AgencyFeeType = agencyFeeTypeData,
  8889. CountryFeeData = visaCountryFeeData
  8890. };
  8891. return Ok(JsonView(true, "查询成功!", data));
  8892. }
  8893. /// <summary>
  8894. /// 签证费用录入操作(Status:1.新增,2.修改)
  8895. /// </summary>
  8896. /// <param name="dto"></param>
  8897. /// <returns></returns>
  8898. [HttpPost]
  8899. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8900. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  8901. {
  8902. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  8903. if (groupData.Code != 0)
  8904. {
  8905. return Ok(JsonView(false, groupData.Msg));
  8906. }
  8907. #region 应用推送
  8908. try
  8909. {
  8910. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  8911. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  8912. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8913. //2024-10-21 新增LZ UID
  8914. var userIds = new List<int>() { 21 };
  8915. string title = $"系统通知";
  8916. string content = "";
  8917. var diId = dto.DiId;
  8918. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  8919. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  8920. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  8921. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  8922. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  8923. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  8924. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  8925. }
  8926. catch (Exception ex)
  8927. {
  8928. }
  8929. #endregion
  8930. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8931. }
  8932. #endregion
  8933. #region 签证提成录入
  8934. /// <summary>
  8935. /// 签证提成录入
  8936. /// 基础数据
  8937. /// </summary>
  8938. /// <param name="_dto"></param>
  8939. /// <returns></returns>
  8940. [HttpGet]
  8941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8942. public async Task<IActionResult> VisaCommissionInit()
  8943. {
  8944. return Ok(await _visaCommissionRep.Init());
  8945. }
  8946. /// <summary>
  8947. /// 签证提成录入
  8948. /// Item
  8949. /// </summary>
  8950. /// <param name="_dto"></param>
  8951. /// <returns></returns>
  8952. [HttpPost]
  8953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8954. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  8955. {
  8956. var validator = new VisaCommissionItemDtoValidator();
  8957. var validatorRes = await validator.ValidateAsync(_dto);
  8958. if (!validatorRes.IsValid)
  8959. {
  8960. StringBuilder sb = new StringBuilder();
  8961. foreach (var item in validatorRes.Errors)
  8962. {
  8963. sb.AppendLine(item.ErrorMessage);
  8964. }
  8965. return Ok(JsonView(false, sb.ToString()));
  8966. }
  8967. return Ok(await _visaCommissionRep.Item(_dto));
  8968. }
  8969. /// <summary>
  8970. /// 签证提成录入
  8971. /// Save
  8972. /// </summary>
  8973. /// <param name="_dto"></param>
  8974. /// <returns></returns>
  8975. [HttpPost]
  8976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8977. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  8978. {
  8979. //参数验证
  8980. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  8981. foreach (var item in _dto.Items)
  8982. {
  8983. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  8984. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  8985. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  8986. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  8987. }
  8988. return Ok(await _visaCommissionRep.Save(_dto));
  8989. }
  8990. /// <summary>
  8991. /// 签证提成录入
  8992. /// Create
  8993. /// </summary>
  8994. /// <param name="_dto"></param>
  8995. /// <returns></returns>
  8996. [HttpPost]
  8997. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8998. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  8999. {
  9000. var validator = new VisaCommissionCreateDtoValidator();
  9001. var validatorRes = await validator.ValidateAsync(_dto);
  9002. if (!validatorRes.IsValid)
  9003. {
  9004. StringBuilder sb = new StringBuilder();
  9005. foreach (var item in validatorRes.Errors)
  9006. {
  9007. sb.AppendLine(item.ErrorMessage);
  9008. }
  9009. return Ok(JsonView(false, sb.ToString()));
  9010. }
  9011. return Ok(await _visaCommissionRep.Create(_dto));
  9012. }
  9013. /// <summary>
  9014. /// 签证提成录入
  9015. /// Put(编辑)
  9016. /// </summary>
  9017. /// <param name="id"></param>
  9018. /// <param name="_dto"></param>
  9019. /// <returns></returns>
  9020. [HttpPut]
  9021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9022. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  9023. {
  9024. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  9025. var validator = new VisaCommissionCreateDtoValidator();
  9026. var validatorRes = await validator.ValidateAsync(_dto);
  9027. if (!validatorRes.IsValid)
  9028. {
  9029. StringBuilder sb = new StringBuilder();
  9030. foreach (var item in validatorRes.Errors)
  9031. {
  9032. sb.AppendLine(item.ErrorMessage);
  9033. }
  9034. return Ok(JsonView(false, sb.ToString()));
  9035. }
  9036. return Ok(await _visaCommissionRep.Edit(id, _dto));
  9037. }
  9038. /// <summary>
  9039. /// 签证提成录入
  9040. /// Del
  9041. /// </summary>
  9042. /// <param name="id"></param>
  9043. /// <param name="currUserId"></param>
  9044. /// <returns></returns>
  9045. [HttpPost]
  9046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9047. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  9048. {
  9049. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  9050. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  9051. return Ok(await _visaCommissionRep.Del(id, currUserId));
  9052. }
  9053. #endregion
  9054. #region op费用录入
  9055. /// <summary>
  9056. /// 根据diid查询op费用列表
  9057. /// </summary>
  9058. /// <param name="dto"></param>
  9059. /// <returns></returns>
  9060. [HttpPost]
  9061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9062. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  9063. {
  9064. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  9065. if (groupData.Code != 0)
  9066. {
  9067. return Ok(JsonView(false, groupData.Msg));
  9068. }
  9069. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9070. }
  9071. /// <summary>
  9072. /// 根据op费用Id查询单条数据及c表数据
  9073. /// </summary>
  9074. /// <param name="dto"></param>
  9075. /// <returns></returns>
  9076. [HttpPost]
  9077. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9078. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  9079. {
  9080. try
  9081. {
  9082. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  9083. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  9084. var data = new
  9085. {
  9086. CarTouristGuideGround = _groupData,
  9087. CreditCardPayment = _creditCardPayment
  9088. };
  9089. return Ok(JsonView(true, "查询成功!", data));
  9090. }
  9091. catch (Exception ex)
  9092. {
  9093. return Ok(JsonView(false, "程序错误!"));
  9094. }
  9095. }
  9096. /// <summary>
  9097. /// op费用删除
  9098. /// </summary>
  9099. /// <param name="dto"></param>
  9100. /// <returns></returns>
  9101. [HttpPost]
  9102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9103. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  9104. {
  9105. try
  9106. {
  9107. _sqlSugar.BeginTran();
  9108. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  9109. if (!res)
  9110. {
  9111. return Ok(JsonView(false, "删除失败"));
  9112. }
  9113. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  9114. {
  9115. IsDel = 1,
  9116. DeleteUserId = dto.DeleteUserId,
  9117. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9118. }).ExecuteCommandAsync();
  9119. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  9120. {
  9121. IsDel = 1,
  9122. DeleteUserId = dto.DeleteUserId,
  9123. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9124. }).ExecuteCommandAsync();
  9125. #region 删除超支相关数据
  9126. //删除导入的超支数据
  9127. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  9128. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  9129. {
  9130. IsDel = 1,
  9131. DeleteUserId = dto.DeleteUserId,
  9132. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9133. }).ExecuteCommand();
  9134. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  9135. {
  9136. IsDel = 1,
  9137. DeleteUserId = dto.DeleteUserId,
  9138. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9139. }).ExecuteCommand();
  9140. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  9141. {
  9142. IsDel = 1,
  9143. DeleteUserId = dto.DeleteUserId,
  9144. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9145. }).ExecuteCommand();
  9146. #endregion
  9147. _sqlSugar.CommitTran();
  9148. return Ok(JsonView(true, "删除成功!"));
  9149. }
  9150. catch (Exception ex)
  9151. {
  9152. _sqlSugar.RollbackTran();
  9153. return Ok(JsonView(false, "程序错误!" + ex.Message));
  9154. }
  9155. }
  9156. /// <summary>
  9157. /// op费用录入操作(Status:1.新增,2.修改)
  9158. /// </summary>
  9159. /// <param name="dto"></param>
  9160. /// <returns></returns>
  9161. [HttpPost]
  9162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9163. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  9164. {
  9165. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  9166. if (groupData.Code != 0)
  9167. {
  9168. return Ok(JsonView(false, groupData.Msg));
  9169. }
  9170. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9171. }
  9172. /// <summary>
  9173. /// 填写费用详细页面初始化绑定
  9174. /// </summary>
  9175. /// <param name="dto"></param>
  9176. /// <returns></returns>
  9177. [HttpPost]
  9178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9179. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  9180. {
  9181. try
  9182. {
  9183. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  9184. if (groupData.Code != 0)
  9185. {
  9186. return Ok(JsonView(false, groupData.Msg));
  9187. }
  9188. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9189. }
  9190. catch (Exception ex)
  9191. {
  9192. return Ok(JsonView(false, ex.Message));
  9193. }
  9194. }
  9195. /// <summary>
  9196. /// 根据op费用Id查询详细数据
  9197. /// </summary>
  9198. /// <param name="dto"></param>
  9199. /// <returns></returns>
  9200. [HttpPost]
  9201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9202. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  9203. {
  9204. try
  9205. {
  9206. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  9207. if (groupData.Code != 0)
  9208. {
  9209. return Ok(JsonView(false, groupData.Msg));
  9210. }
  9211. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9212. }
  9213. catch (Exception ex)
  9214. {
  9215. return Ok(JsonView(false, ex.Message));
  9216. }
  9217. }
  9218. /// <summary>
  9219. /// OP费用录入填写详情
  9220. /// </summary>
  9221. /// <param name="dto"></param>
  9222. /// <returns></returns>
  9223. [HttpPost]
  9224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9225. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  9226. {
  9227. try
  9228. {
  9229. #region 参数校验
  9230. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  9231. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  9232. if (di == null) return Ok(JsonView(false, "团组错误!"));
  9233. #endregion
  9234. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  9235. if (groupData.Code != 0)
  9236. {
  9237. return Ok(JsonView(false, groupData.Msg));
  9238. }
  9239. //自动审核
  9240. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  9241. #region 应用推送
  9242. try
  9243. {
  9244. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9245. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9246. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9247. //2024-10-21 新增LZ UID
  9248. var userIds = new List<int>() { 21 };
  9249. string title = $"系统通知";
  9250. var diId = dto.DiId;
  9251. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  9252. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  9253. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  9254. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  9255. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  9256. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  9257. }
  9258. catch (Exception ex)
  9259. {
  9260. }
  9261. #endregion
  9262. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9263. }
  9264. catch (Exception ex)
  9265. {
  9266. return Ok(JsonView(false, ex.Message));
  9267. }
  9268. }
  9269. /// <summary>
  9270. /// 获取三公详细所有城市
  9271. /// </summary>
  9272. /// <returns></returns>
  9273. [HttpGet]
  9274. public IActionResult OpCarCityResult()
  9275. {
  9276. var jw = JsonView(false);
  9277. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  9278. {
  9279. x.Id,
  9280. x.Country,
  9281. x.City,
  9282. }).ToList();
  9283. if (data.Count > 0)
  9284. {
  9285. jw = JsonView(true, "获取成功!", data);
  9286. }
  9287. else
  9288. {
  9289. jw.Msg = "城市数据为空!";
  9290. jw.Data = new string[0];
  9291. }
  9292. return Ok(jw);
  9293. }
  9294. /// <summary>
  9295. /// 导出地接费用明细
  9296. /// </summary>
  9297. /// <param name="dto"></param>
  9298. /// <returns></returns>
  9299. [HttpPost]
  9300. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  9301. {
  9302. var jw = JsonView(false);
  9303. if (dto.Diid < 1)
  9304. {
  9305. jw.Msg = "请输入正确的diid!";
  9306. return Ok(jw);
  9307. }
  9308. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  9309. if (group == null)
  9310. {
  9311. jw.Msg = "未找到团组信息!";
  9312. return Ok(jw);
  9313. }
  9314. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  9315. if (localGuideArr.Count == 0)
  9316. {
  9317. jw.Msg = "该团组暂无地接信息!";
  9318. return Ok(jw);
  9319. }
  9320. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  9321. var overspendSoure = new Dictionary<int, int>
  9322. {
  9323. { 91, 982 }, //车
  9324. { 92 , 1059} ,//导游
  9325. { 994 , 1073}, //翻译
  9326. { 988 , 1074 }, //早餐
  9327. { 93 , 1075 }, //午餐
  9328. { 989 , 1076 }, //晚餐
  9329. };
  9330. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  9331. foreach (var groupArr in localGroup)
  9332. {
  9333. var keyValue = groupArr.Key;
  9334. if (int.TryParse(keyValue, out int cityid))
  9335. {
  9336. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  9337. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  9338. }
  9339. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  9340. foreach (var item in groupArr)
  9341. {
  9342. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  9343. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  9344. new Grp_CarTouristGuideGroundReservationsContentExtend
  9345. {
  9346. Count = a.Count,
  9347. CreateTime = a.CreateTime,
  9348. CreateUserId = a.CreateUserId,
  9349. CTGGRId = a.CTGGRId,
  9350. Currency = a.Currency,
  9351. DatePrice = a.DatePrice,
  9352. DeleteTime = a.DeleteTime,
  9353. DeleteUserId = a.DeleteUserId,
  9354. DiId = a.DiId,
  9355. Id = a.Id,
  9356. IsDel = a.IsDel,
  9357. Price = a.Price,
  9358. PriceContent = a.PriceContent,
  9359. Remark = a.Remark,
  9360. SId = a.SId,
  9361. SidName = b.Name,
  9362. Units = a.Units,
  9363. }
  9364. ).ToList();
  9365. if (content.Count > 0)
  9366. {
  9367. contentArr.Add(content);
  9368. }
  9369. }
  9370. //open excel
  9371. //set excel
  9372. //save excel
  9373. try
  9374. {
  9375. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  9376. IWorkbook workbook;
  9377. if (Path.GetExtension(filePath).ToLower() == ".xls")
  9378. {
  9379. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  9380. }
  9381. else
  9382. {
  9383. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  9384. }
  9385. ISheet sheet = workbook.GetSheetAt(0);
  9386. var rowStartIndex = 2;
  9387. var clounmCount = 10;
  9388. var initStyleRow = sheet.GetRow(2);
  9389. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  9390. //var overspendArrDetail =
  9391. var existsId = new List<CarCompare>();
  9392. var lastElem = arr.Last();
  9393. var thisSid = -1;
  9394. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  9395. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  9396. {
  9397. Name = "未知币种!",
  9398. Remark = "未知币种!",
  9399. };
  9400. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  9401. Action cloneRowFn = () =>
  9402. {
  9403. rowStartIndex++;
  9404. var cloneRow = sheet.CreateRow(rowStartIndex);
  9405. // 复制样式
  9406. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  9407. {
  9408. ICell sourceCell = initStyleRow.GetCell(i);
  9409. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  9410. // 确保单元格存在样式
  9411. if (sourceCell.CellStyle != null)
  9412. {
  9413. targetCell.CellStyle = sourceCell.CellStyle;
  9414. }
  9415. }
  9416. };
  9417. var mergeRow = () =>
  9418. {
  9419. for (int i = 2; i < sheet.LastRowNum; i++)
  9420. {
  9421. var row = sheet.GetRow(i);
  9422. var cellFirst = row.GetCell(0);
  9423. var thisIndex = i + 1;
  9424. while (thisIndex < sheet.LastRowNum)
  9425. {
  9426. var nextRow = sheet.GetRow(thisIndex);
  9427. var nextCellFirst = nextRow.GetCell(0);
  9428. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  9429. {
  9430. thisIndex++;
  9431. }
  9432. else
  9433. {
  9434. break;
  9435. }
  9436. }
  9437. thisIndex--;
  9438. if (thisIndex != i)
  9439. {
  9440. //合并row
  9441. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  9442. i, // 起始行索引(0-based)
  9443. thisIndex, // 结束行索引(0-based)
  9444. 0, // 起始列索引(0-based)
  9445. 0 // 结束列索引(0-based)
  9446. );
  9447. sheet.AddMergedRegion(cellRangeAddress);
  9448. i = thisIndex;
  9449. }
  9450. }
  9451. };
  9452. var chaoshiNumber = 0;
  9453. var totalNumber = 0.00M;
  9454. string lastStr = "";
  9455. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  9456. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  9457. {
  9458. b.IsAuditGM,
  9459. x.Id,
  9460. x.Area,
  9461. b.PayPercentage,
  9462. b.PayMoney,
  9463. }).ToList();
  9464. string yesPayment = "", noPayment = "";
  9465. foreach (var item in queryCarArrByCityAndDiid)
  9466. {
  9467. if (item.IsAuditGM == 1)
  9468. {
  9469. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  9470. }
  9471. else
  9472. {
  9473. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  9474. }
  9475. }
  9476. lastStr = yesPayment + noPayment;
  9477. foreach (var item in arr)
  9478. {
  9479. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  9480. {
  9481. if (thisSid != item.SId)
  9482. {
  9483. if (thisSid == -1)
  9484. {
  9485. thisSid = item.SId;
  9486. }
  9487. else
  9488. {
  9489. //合并小计行
  9490. //创建合并区域的实例
  9491. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  9492. rowStartIndex, // 起始行索引(0-based)
  9493. rowStartIndex, // 结束行索引(0-based)
  9494. 0, // 起始列索引(0-based)
  9495. 3 // 结束列索引(0-based)
  9496. );
  9497. sheet.AddMergedRegion(cellRangeAddress);
  9498. var CellStyle = workbook.CreateCellStyle();
  9499. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9500. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  9501. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  9502. for (int i = 0; i <= clounmCount; i++)
  9503. {
  9504. if (i > 6)
  9505. {
  9506. var CellStyle1 = workbook.CreateCellStyle();
  9507. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9508. IFont Font = workbook.CreateFont(); // 创建字体
  9509. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  9510. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  9511. CellStyle1.SetFont(Font);
  9512. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  9513. }
  9514. else
  9515. {
  9516. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  9517. }
  9518. }
  9519. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  9520. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  9521. //超时合计
  9522. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  9523. //超时数
  9524. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  9525. //超时合计费用
  9526. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  9527. thisSid = item.SId;
  9528. cloneRowFn();
  9529. chaoshiNumber = 0;
  9530. totalNumber = 0;
  9531. }
  9532. }
  9533. IRow row = sheet.GetRow(rowStartIndex);
  9534. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  9535. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  9536. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  9537. if (isOpenOverspendSoure)
  9538. {
  9539. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  9540. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  9541. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  9542. }
  9543. for (int i = 0; i <= clounmCount; i++)
  9544. {
  9545. var cell = row.GetCell(i);
  9546. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  9547. if (cell == null)
  9548. {
  9549. cell = row.CreateCell(i);
  9550. }
  9551. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  9552. fontRed.CloneStyleFrom(cell.CellStyle);
  9553. IFont Font = workbook.CreateFont(); // 创建字体
  9554. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  9555. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  9556. fontRed.SetFont(Font);
  9557. byte[] rgb = new byte[3] { 255, 242, 204 };
  9558. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  9559. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  9560. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  9561. if (workbook is XSSFWorkbook)
  9562. {
  9563. BackgroundColor255_242_204.FillForegroundColor = 0;
  9564. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  9565. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  9566. }
  9567. else
  9568. {
  9569. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  9570. }
  9571. if (i == 1 || i > 6)
  9572. {
  9573. if (i > 6)
  9574. {
  9575. fontRed.FillForegroundColor = 0;
  9576. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  9577. fontRed.FillPattern = FillPattern.SolidForeground;
  9578. }
  9579. cell.CellStyle = fontRed;
  9580. }
  9581. if (i > 2 && i < 7)
  9582. {
  9583. cell.CellStyle = BackgroundColor255_242_204;
  9584. }
  9585. cell.SetCellValue(setCellValue); //写入单元格
  9586. }
  9587. if (overspendSoure.ContainsKey(thisSid))
  9588. {
  9589. var overspendId = overspendSoure[thisSid];
  9590. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  9591. }
  9592. cloneRowFn();
  9593. existsId.Add(new CarCompare
  9594. {
  9595. DataPrice = item.DatePrice.ObjToDate(),
  9596. Sid = item.SId
  9597. });
  9598. }
  9599. if (item.Equals(lastElem))
  9600. {
  9601. //合并小计行
  9602. //创建合并区域的实例
  9603. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  9604. rowStartIndex, // 起始行索引(0-based)
  9605. rowStartIndex, // 结束行索引(0-based)
  9606. 0, // 起始列索引(0-based)
  9607. 3 // 结束列索引(0-based)
  9608. );
  9609. sheet.AddMergedRegion(cellRangeAddress);
  9610. var CellStyle = workbook.CreateCellStyle();
  9611. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9612. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  9613. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  9614. for (int i = 0; i <= clounmCount; i++)
  9615. {
  9616. if (i > 6)
  9617. {
  9618. var CellStyle1 = workbook.CreateCellStyle();
  9619. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  9620. IFont Font = workbook.CreateFont(); // 创建字体
  9621. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  9622. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  9623. CellStyle1.SetFont(Font);
  9624. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  9625. }
  9626. else
  9627. {
  9628. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  9629. }
  9630. }
  9631. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  9632. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  9633. //超时合计
  9634. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  9635. //超时数
  9636. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  9637. //超时合计费用
  9638. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  9639. cloneRowFn();
  9640. // 创建合并区域的实例
  9641. cellRangeAddress = new CellRangeAddress(
  9642. rowStartIndex, // 起始行索引(0-based)
  9643. rowStartIndex, // 结束行索引(0-based)
  9644. 0, // 起始列索引(0-based)
  9645. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  9646. );
  9647. // 添加合并区域
  9648. sheet.AddMergedRegion(cellRangeAddress);
  9649. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  9650. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  9651. }
  9652. }
  9653. mergeRow();
  9654. // 保存修改后的Excel文件到新文件
  9655. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  9656. // new FileStream(newFilePath, FileMode.CreateNew)
  9657. using (var stream = new MemoryStream())
  9658. {
  9659. workbook.Write(stream, true);
  9660. stream.Flush();
  9661. stream.Seek(0, SeekOrigin.Begin);
  9662. MemoryStream memoryStream = new MemoryStream();
  9663. stream.CopyTo(memoryStream);
  9664. memoryStream.Seek(0, SeekOrigin.Begin);
  9665. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  9666. }
  9667. workbook.Close();
  9668. workbook.Dispose();
  9669. }
  9670. catch (Exception ex)
  9671. {
  9672. jw.Msg = "出现异常!" + ex.Message;
  9673. return Ok(jw);
  9674. }
  9675. }
  9676. if (Zips.Count > 0)
  9677. {
  9678. IOOperatorHelper io = new IOOperatorHelper();
  9679. var byts = io.ConvertZipStream(Zips);
  9680. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  9681. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  9682. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  9683. }
  9684. else
  9685. {
  9686. jw.Msg = "暂无生成文件!";
  9687. }
  9688. return Ok(jw);
  9689. }
  9690. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  9691. {
  9692. string outStr = string.Empty;
  9693. switch (i)
  9694. {
  9695. case 0:
  9696. outStr = arr[0].SidName;
  9697. break;
  9698. case 1:
  9699. outStr = arr[0].DataPriceStr;
  9700. break;
  9701. case 2:
  9702. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  9703. break;
  9704. case 4:
  9705. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  9706. break;
  9707. case 7:
  9708. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9709. {
  9710. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  9711. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  9712. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  9713. }
  9714. break;
  9715. case 8:
  9716. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9717. {
  9718. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  9719. }
  9720. break;
  9721. case 9:
  9722. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9723. {
  9724. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  9725. }
  9726. break;
  9727. case 10:
  9728. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  9729. {
  9730. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  9731. }
  9732. break;
  9733. }
  9734. return outStr;
  9735. }
  9736. #region OP行程单
  9737. /// <summary>
  9738. /// OP行程单初始化
  9739. /// </summary>
  9740. /// <param name="dto"></param>
  9741. /// <returns></returns>
  9742. [HttpPost]
  9743. public IActionResult InitOpTravel(InitOpTravelDto dto)
  9744. {
  9745. var jw = JsonView(false);
  9746. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  9747. var group = groupList.First();
  9748. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  9749. if (group == null)
  9750. {
  9751. jw.Msg = "暂无团组!";
  9752. return Ok(jw);
  9753. }
  9754. group = groupList.Find(x => x.Id == diid);
  9755. if (group == null)
  9756. {
  9757. jw.Msg = "请输入正确的团组ID!";
  9758. return Ok(jw);
  9759. }
  9760. string city = string.Empty;
  9761. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  9762. if (blackCode.Count > 0)
  9763. {
  9764. var black = blackCode.First();
  9765. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  9766. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  9767. if (blackSp.Length > 0)
  9768. {
  9769. try
  9770. {
  9771. var cityArrCode = new List<string>(20);
  9772. foreach (var item in blackSp)
  9773. {
  9774. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  9775. var IndexSelect = itemSp[2];
  9776. var cityArrCodeLength = cityArrCode.Count - 1;
  9777. var startCity = IndexSelect.Substring(0, 3);
  9778. if (cityArrCodeLength > 0)
  9779. {
  9780. var arrEndCity = cityArrCode[cityArrCodeLength];
  9781. if (arrEndCity != startCity)
  9782. {
  9783. cityArrCode.Add(startCity.ToUpper());
  9784. }
  9785. }
  9786. else
  9787. {
  9788. cityArrCode.Add(startCity.ToUpper());
  9789. }
  9790. var endCity = IndexSelect.Substring(3, 3);
  9791. cityArrCode.Add(endCity.ToUpper());
  9792. }
  9793. var cityThree = string.Empty;
  9794. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  9795. cityThree = cityThree.TrimEnd(',');
  9796. if (string.IsNullOrWhiteSpace(cityThree))
  9797. {
  9798. throw new
  9799. Exception("error");
  9800. }
  9801. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  9802. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  9803. foreach (var item in cityArrCode)
  9804. {
  9805. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  9806. if (find != null)
  9807. {
  9808. city += find.City + "/";
  9809. }
  9810. else
  9811. {
  9812. city += item + "三字码未收入/";
  9813. }
  9814. }
  9815. city = city.TrimEnd('/');
  9816. }
  9817. catch (Exception e)
  9818. {
  9819. city = "黑屏代码格式不正确!";
  9820. }
  9821. }
  9822. }
  9823. else
  9824. {
  9825. city = "未录入黑屏代码";
  9826. }
  9827. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  9828. {
  9829. Date = x.Date,
  9830. Days = x.Days,
  9831. Diffgroup = x.Diffgroup,
  9832. Diid = x.Diid,
  9833. Traffic_First = x.Traffic_First,
  9834. Traffic_Second = x.Traffic_Second,
  9835. Trip = x.Trip,
  9836. WeekDay = x.WeekDay,
  9837. Id = x.Id
  9838. }).ToList();
  9839. jw.Data = new
  9840. {
  9841. groupList = groupList.Select(x => new
  9842. {
  9843. x.Id,
  9844. x.TeamName,
  9845. x.TourCode
  9846. }).ToList(),
  9847. groupInfo = new
  9848. {
  9849. group.VisitDays,
  9850. group.TourCode,
  9851. group.VisitPNumber,
  9852. group.TeamName,
  9853. city
  9854. },
  9855. OpTravelList
  9856. };
  9857. jw.Code = 200;
  9858. jw.Msg = "操作成功!";
  9859. return Ok(jw);
  9860. }
  9861. /// <summary>
  9862. /// 删除团组行程单
  9863. /// </summary>
  9864. /// <returns></returns>
  9865. [HttpPost]
  9866. public IActionResult DelTravel(DelOpTravelDto dto)
  9867. {
  9868. var jw = JsonView(false);
  9869. if (dto.UserId <= 0 || dto.Diid <= 0)
  9870. {
  9871. jw.Msg = "请输入正确的参数!";
  9872. return Ok(jw);
  9873. }
  9874. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  9875. .SetColumns(x => new Grp_TravelList
  9876. {
  9877. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  9878. DeleteUserId = dto.UserId,
  9879. IsDel = 1,
  9880. }).ExecuteCommand();
  9881. jw = JsonView(true);
  9882. return Ok(jw);
  9883. }
  9884. /// <summary>
  9885. /// 行程单保存
  9886. /// </summary>
  9887. /// <returns></returns>
  9888. [HttpPost]
  9889. public IActionResult TravelSave(TravelSaveDto dto)
  9890. {
  9891. var jw = JsonView(false);
  9892. if (dto.Arr.Count > 0)
  9893. {
  9894. try
  9895. {
  9896. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  9897. .Where(x => dto.Arr.Select(x=>x.Id).Contains(x.Id))
  9898. .ToList();
  9899. _sqlSugar.BeginTran();
  9900. foreach (var item in dto.Arr)
  9901. {
  9902. if (item.Id == 0)
  9903. {
  9904. throw new Exception("请传入正确的Id");
  9905. }
  9906. //比较上一次的差异
  9907. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  9908. if (findTravel != null)
  9909. {
  9910. item.Trip = item.Trip.Replace("[++]", string.Empty);
  9911. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  9912. item.Trip = CheckStr(findTravel.Trip,item.Trip);
  9913. }
  9914. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  9915. .SetColumns(x => new Grp_TravelList
  9916. {
  9917. Trip = item.Trip
  9918. }).ExecuteCommand();
  9919. }
  9920. _sqlSugar.CommitTran();
  9921. jw = JsonView(true);
  9922. }
  9923. catch (Exception ex)
  9924. {
  9925. _sqlSugar.RollbackTran();
  9926. jw.Msg = "程序异常!" + ex.Message;
  9927. }
  9928. }
  9929. else
  9930. {
  9931. jw.Msg = "请传入正确的参数!";
  9932. }
  9933. return Ok(jw);
  9934. }
  9935. private string CheckStr(string original, string changed)
  9936. {
  9937. // 创建diff_match_patch对象
  9938. var dmp = new diff_match_patch();
  9939. // 计算差异
  9940. List<Diff> diffs = dmp.diff_main(original, changed);
  9941. // 清理和合并差异
  9942. dmp.diff_cleanupSemantic(diffs);
  9943. // 使用StringBuilder构建最终的字符串
  9944. StringBuilder finalString = new StringBuilder();
  9945. // 输出差异结果,并构建变动后的字符串
  9946. foreach (Diff diff in diffs)
  9947. {
  9948. switch (diff.operation)
  9949. {
  9950. case Operation.EQUAL:
  9951. // 相等的部分,直接添加到最终字符串
  9952. finalString.Append(diff.text);
  9953. break;
  9954. case Operation.INSERT:
  9955. // 插入的部分,添加标记并添加到最终字符串
  9956. finalString.Append("[++]" + diff.text + "[++]");
  9957. break;
  9958. case Operation.DELETE:
  9959. // 删除的部分,不添加到最终字符串
  9960. //finalString.Append("[++]" + diff.text + "[++]");
  9961. break;
  9962. }
  9963. }
  9964. // 输出变动后的字符串
  9965. return finalString.ToString();
  9966. }
  9967. private class tagContent
  9968. {
  9969. public DateTime Date { get; set; }
  9970. public string StartTag { get; set; }
  9971. public string EndTag { get; set; }
  9972. public string Content { get; set; }
  9973. public static int tagLength { get { return 3; } }
  9974. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  9975. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  9976. public bool IsFinally { get; set; }
  9977. }
  9978. private List<string> ExtractContentBetweenTags(string input, string tag)
  9979. {
  9980. List<string> results = new List<string>();
  9981. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  9982. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  9983. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  9984. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  9985. string[] strValueArr = new string[1];
  9986. foreach (Match match in matches)
  9987. {
  9988. var strValue = match.Groups[1].Value;
  9989. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  9990. }
  9991. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  9992. return results;
  9993. }
  9994. /// <summary>
  9995. /// 导出行程单
  9996. /// </summary>
  9997. /// <param name="dto"></param>
  9998. /// <returns></returns>
  9999. [HttpPost]
  10000. public IActionResult ExportTravel(ExportTravelDto dto)
  10001. {
  10002. var jw = JsonView(false);
  10003. jw.Data = "";
  10004. int diid = 0;
  10005. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  10006. if (Find == null)
  10007. {
  10008. jw.Msg = "请选择正确的团组!";
  10009. return Ok(jw);
  10010. }
  10011. else
  10012. {
  10013. diid = Find.Id;
  10014. }
  10015. //数据源
  10016. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  10017. DataTable dtBlack = null;
  10018. try
  10019. {
  10020. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  10021. }
  10022. catch (Exception)
  10023. {
  10024. jw.Msg = "机票黑屏代码有误!";
  10025. return Ok(jw);
  10026. }
  10027. string CityStr = string.Empty;
  10028. if (dtBlack.Rows.Count == 0)
  10029. {
  10030. jw.Msg = "机票黑屏代码有误!";
  10031. return Ok(jw);
  10032. }
  10033. else
  10034. {
  10035. foreach (DataRow row in dtBlack.Rows)
  10036. {
  10037. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  10038. {
  10039. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  10040. return Ok(jw);
  10041. }
  10042. }
  10043. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  10044. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  10045. }
  10046. // 指定的文字
  10047. var targetTextDic = new Dictionary<string, List<string>>();
  10048. //创建数据源Table
  10049. DataTable dtSource = new DataTable();
  10050. dtSource.Columns.Add("Days", typeof(string));
  10051. dtSource.Columns.Add("Date", typeof(string));
  10052. dtSource.Columns.Add("Week", typeof(string));
  10053. dtSource.Columns.Add("Traffic", typeof(string));
  10054. dtSource.Columns.Add("Trip", typeof(string));
  10055. //获取数据,放到datatable
  10056. foreach (var item in _travelList)
  10057. {
  10058. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  10059. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  10060. .Replace(tagContent.TagFormat.Item2, string.Empty)
  10061. .Replace("[++]", string.Empty);
  10062. DataRow dr = dtSource.NewRow();
  10063. dr["Days"] = item.Days;
  10064. dr["Date"] = item.Date;
  10065. dr["Week"] = item.WeekDay;
  10066. dr["Traffic"] = item.Traffic_First
  10067. + "\r\n"
  10068. + item.Traffic_Second;
  10069. dr["Trip"] = item.Trip;
  10070. dtSource.Rows.Add(dr);
  10071. }
  10072. Dictionary<string, string> dic = new Dictionary<string, string>();
  10073. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  10074. dic.Add("City", CityStr);
  10075. dic.Add("Days", Find.VisitDays.ToString());
  10076. dic.Add("DeleCode", Find.TourCode);
  10077. dic.Add("Pnum", Find.VisitPNumber.ToString());
  10078. //模板路径
  10079. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  10080. //载入模板
  10081. Document doc = null;
  10082. DocumentBuilder builder = null;
  10083. try
  10084. {
  10085. //载入模板
  10086. doc = new Document(tempPath);
  10087. builder = new DocumentBuilder(doc);
  10088. }
  10089. catch (Exception)
  10090. {
  10091. jw.Msg = "模板位置不存在!";
  10092. return Ok(jw);
  10093. }
  10094. foreach (var key in dic.Keys)
  10095. {
  10096. Bookmark bookmark = doc.Range.Bookmarks[key];
  10097. if (bookmark != null)
  10098. {
  10099. builder.MoveToBookmark(key);
  10100. builder.Write(dic[key]);
  10101. }
  10102. }
  10103. //获取word里所有表格
  10104. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10105. //获取所填表格的序数
  10106. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10107. try
  10108. {
  10109. //循环赋值
  10110. for (int i = 0; i < dtSource.Rows.Count; i++)
  10111. {
  10112. builder.MoveToCell(0, i + 1, 0, 0);
  10113. builder.Write(dtSource.Rows[i]["Days"].ToString());
  10114. builder.MoveToCell(0, i + 1, 1, 0);
  10115. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  10116. builder.MoveToCell(0, i + 1, 2, 0);
  10117. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  10118. var trip = dtSource.Rows[i]["Trip"].ToString();
  10119. builder.MoveToCell(0, i + 1, 3, 0);
  10120. builder.Write(trip);
  10121. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  10122. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  10123. // 获取特定索引的段落
  10124. Paragraph paragraph = (Paragraph)paragraphs[0];
  10125. Run run = paragraph.Runs[0];
  10126. Aspose.Words.Font font = run.Font;
  10127. font.Name = "黑体";
  10128. //设置双休红色
  10129. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  10130. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  10131. paragraph = (Paragraph)paragraphs[1];
  10132. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  10133. {
  10134. run = paragraph.Runs[0];
  10135. font = run.Font;
  10136. font.Color = Color.Red;
  10137. }
  10138. }
  10139. }
  10140. catch (Exception ex)
  10141. {
  10142. }
  10143. //删除多余行
  10144. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  10145. {
  10146. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  10147. }
  10148. var targetTextList = new List<string>();
  10149. // 遍历文档中的表格
  10150. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  10151. {
  10152. foreach (Aspose.Words.Tables.Row row in table.Rows)
  10153. {
  10154. var cellIndex = 0;
  10155. foreach (Cell cell in row.Cells)
  10156. {
  10157. if (cellIndex == 1 && row.Cells.Count == 4)
  10158. {
  10159. foreach (var target in targetTextDic.Keys)
  10160. {
  10161. if (cell.GetText().Contains(target))
  10162. {
  10163. targetTextList = targetTextDic[target];
  10164. break;
  10165. }
  10166. }
  10167. }
  10168. // 遍历单元格中的所有段落
  10169. foreach (Paragraph paragraph in cell.Paragraphs)
  10170. {
  10171. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  10172. List<Run> runs = new List<Run>();
  10173. foreach (Run run in paragraph.Runs)
  10174. {
  10175. runs.Add(run);
  10176. }
  10177. foreach (Run run in runs)
  10178. {
  10179. foreach (var targetText in targetTextList)
  10180. {
  10181. // 检查文字是否包含指定文字
  10182. if (run.Text.Contains(targetText))
  10183. {
  10184. // 将包含的部分设置为红色
  10185. HighlightText(run, targetText, Color.Red);
  10186. }
  10187. }
  10188. }
  10189. }
  10190. cellIndex++;
  10191. }
  10192. }
  10193. }
  10194. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  10195. if (!Directory.Exists(savePath))
  10196. {
  10197. try
  10198. {
  10199. Directory.CreateDirectory(savePath);
  10200. }
  10201. catch
  10202. {
  10203. }
  10204. }
  10205. string path = savePath + Find.TeamName + "出访日程";
  10206. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  10207. try
  10208. {
  10209. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  10210. string postfix = ".docx";
  10211. if (dto.IsPDF == 1)
  10212. {
  10213. saveFormat = Aspose.Words.SaveFormat.Pdf;
  10214. postfix = ".pdf";
  10215. }
  10216. doc.Save(path + postfix, saveFormat);
  10217. jw = JsonView(true, "导出成功", ftpPath + postfix);
  10218. }
  10219. catch (Exception)
  10220. {
  10221. jw = JsonView(false);
  10222. }
  10223. return Ok(jw);
  10224. }
  10225. /// <summary>
  10226. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  10227. /// </summary>
  10228. /// <param name="num"></param>
  10229. /// <returns></returns>
  10230. string GetNum(string num)
  10231. {
  10232. string str = "";
  10233. switch (num)
  10234. {
  10235. case "1":
  10236. str = "一";
  10237. break;
  10238. case "2":
  10239. str = "二";
  10240. break;
  10241. case "3":
  10242. str = "三";
  10243. break;
  10244. case "4":
  10245. str = "四";
  10246. break;
  10247. case "5":
  10248. str = "五";
  10249. break;
  10250. case "6":
  10251. str = "六";
  10252. break;
  10253. case "7":
  10254. str = "七";
  10255. break;
  10256. case "8":
  10257. str = "八";
  10258. break;
  10259. case "9":
  10260. str = "九";
  10261. break;
  10262. case "10":
  10263. str = "十";
  10264. break;
  10265. case "11":
  10266. str = "十一";
  10267. break;
  10268. case "12":
  10269. str = "十二";
  10270. break;
  10271. case "一":
  10272. str = "1";
  10273. break;
  10274. case "二":
  10275. str = "2";
  10276. break;
  10277. case "三":
  10278. str = "3";
  10279. break;
  10280. case "四":
  10281. str = "4";
  10282. break;
  10283. case "五":
  10284. str = "5";
  10285. break;
  10286. case "六":
  10287. str = "6";
  10288. break;
  10289. case "七":
  10290. str = "7";
  10291. break;
  10292. case "八":
  10293. str = "8";
  10294. break;
  10295. case "九":
  10296. str = "9";
  10297. break;
  10298. case "十":
  10299. str = "10";
  10300. break;
  10301. case "十一":
  10302. str = "11";
  10303. break;
  10304. case "十二":
  10305. str = "12";
  10306. break;
  10307. }
  10308. return str;
  10309. }
  10310. // 高亮包含指定文字的部分
  10311. void HighlightText(Run run, string targetText, Color color)
  10312. {
  10313. string text = run.Text;
  10314. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  10315. if (startIndex >= 0)
  10316. {
  10317. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  10318. // 前部分
  10319. if (startIndex > 0)
  10320. {
  10321. Run beforeRun = (Run)run.Clone(true);
  10322. beforeRun.Text = text.Substring(0, startIndex);
  10323. parentParagraph.InsertBefore(beforeRun, run);
  10324. }
  10325. // 匹配部分
  10326. Run matchRun = (Run)run.Clone(true);
  10327. matchRun.Text = text.Substring(startIndex, targetText.Length);
  10328. matchRun.Font.Color = color;
  10329. parentParagraph.InsertBefore(matchRun, run);
  10330. // 后部分
  10331. if (startIndex + targetText.Length < text.Length)
  10332. {
  10333. Run afterRun = (Run)run.Clone(true);
  10334. afterRun.Text = text.Substring(startIndex + targetText.Length);
  10335. parentParagraph.InsertBefore(afterRun, run);
  10336. }
  10337. // 删除原始Run
  10338. run.Remove();
  10339. }
  10340. }
  10341. #endregion
  10342. #endregion
  10343. #region 团组成本
  10344. /// <summary>
  10345. /// 团组成本数据初始化
  10346. /// </summary>
  10347. /// <param name="dto"></param>
  10348. /// <returns></returns>
  10349. [HttpPost]
  10350. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  10351. {
  10352. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  10353. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  10354. WHEN COUNT(*) >= 0 THEN 'True'
  10355. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  10356. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  10357. ").ToList(); //团组列表
  10358. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  10359. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  10360. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  10361. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  10362. if (groupinfoValue != null)
  10363. {
  10364. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  10365. var spArr = new string[1] { countryArr };
  10366. if (countryArr.Contains("|"))
  10367. {
  10368. spArr = countryArr.Split("|");
  10369. }
  10370. else if (countryArr.Contains("、"))
  10371. {
  10372. spArr = countryArr.Split("、");
  10373. }
  10374. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  10375. {
  10376. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  10377. if (dbQueryCountry != null)
  10378. {
  10379. visaCountryInfoArr.Add(dbQueryCountry);
  10380. }
  10381. }
  10382. }
  10383. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  10384. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  10385. var create = _GroupCostRepository.
  10386. CreateGroupCostByBlackCode(dto.Diid);
  10387. if (groupCost.Count == 0 && create.Code == 0)
  10388. {
  10389. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  10390. }
  10391. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  10392. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  10393. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  10394. groupCostMap = groupCostMap.Select(x =>
  10395. {
  10396. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  10397. {
  10398. x.Date = dataForamt.ToString("yyyy-MM-dd");
  10399. }
  10400. return x;
  10401. }).ToList();
  10402. //GroupCostParameter.Add(new
  10403. // Grp_GroupCostParameter());
  10404. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  10405. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  10406. return Ok(JsonView(new
  10407. {
  10408. groupList,
  10409. groupInfo,
  10410. groupChecks,
  10411. groupCost = groupCostMap,
  10412. hotelNumber,
  10413. GroupCostParameter = GroupCostParameterMap,
  10414. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  10415. {
  10416. x.VisaCountry,
  10417. x.VisaPrice,
  10418. x.Id,
  10419. }).ToList(),
  10420. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  10421. blackCodeIsTrue = create.Code == 0 ? true : false,
  10422. hotelIsTrue = hotelIsTrue,
  10423. }));
  10424. }
  10425. /// <summary>
  10426. /// 团组成本信息保存
  10427. /// </summary>
  10428. /// <param name="dto"></param>
  10429. /// <returns></returns>
  10430. [HttpPost]
  10431. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  10432. {
  10433. if (dto.Diid <= 0 || dto.Userid <= 0)
  10434. {
  10435. return Ok(JsonView(false));
  10436. }
  10437. JsonView jw = null;
  10438. bool isTrue = false;
  10439. #region 复制团组成本
  10440. //if (dto.Diid == 2581)
  10441. //{
  10442. // dto.Diid = 2599;
  10443. // dto.CheckBoxs.ForEach(x =>
  10444. // {
  10445. // x.Diid = 2599;
  10446. // });
  10447. // dto.GroupCosts.ForEach(x =>
  10448. // {
  10449. // x.Diid = 2599;
  10450. // });
  10451. // dto.CostTypeHotelNumbers.ForEach(x =>
  10452. // {
  10453. // x.Diid = 2599;
  10454. // });
  10455. // dto.GroupCostParameters.ForEach(x =>
  10456. // {
  10457. // x.DiId = 2599;
  10458. // });
  10459. //}
  10460. #endregion
  10461. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  10462. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  10463. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  10464. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  10465. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  10466. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  10467. try
  10468. {
  10469. _sqlSugar.BeginTran();
  10470. isTrue = await _GroupCostRepository.
  10471. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  10472. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  10473. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  10474. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  10475. _sqlSugar.CommitTran();
  10476. jw = JsonView(true, "保存成功!", isTrue);
  10477. }
  10478. catch (Exception)
  10479. {
  10480. _sqlSugar.RollbackTran();
  10481. jw = JsonView(false);
  10482. }
  10483. return Ok(jw);
  10484. }
  10485. /// <summary>
  10486. /// 司兼导数据
  10487. /// </summary>
  10488. /// <param name="dto"></param>
  10489. /// <returns></returns>
  10490. [HttpPost]
  10491. public IActionResult GetCarGuides(CarGuidesDto dto)
  10492. {
  10493. JsonView jw = null;
  10494. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  10495. jw = JsonView(true, "获取成功!", Data);
  10496. return Ok(jw);
  10497. }
  10498. /// <summary>
  10499. /// 导游数据
  10500. /// </summary>
  10501. /// <param name="dto"></param>
  10502. /// <returns></returns>
  10503. [HttpPost]
  10504. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  10505. {
  10506. JsonView jw = null;
  10507. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  10508. // 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
  10509. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  10510. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  10511. jw = JsonView(true, "获取成功!", Data);
  10512. return Ok(jw);
  10513. }
  10514. /// <summary>
  10515. /// 成本车数据
  10516. /// </summary>
  10517. /// <param name="dto"></param>
  10518. /// <returns></returns>
  10519. [HttpPost]
  10520. public IActionResult GetCarInfo(CarGuidesDto dto)
  10521. {
  10522. JsonView jw = null;
  10523. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  10524. jw = JsonView(true, "获取成功!", Data);
  10525. return Ok(jw);
  10526. }
  10527. /// <summary>
  10528. /// 景点数据
  10529. /// </summary>
  10530. /// <param name="dto"></param>
  10531. /// <returns></returns>
  10532. [HttpPost]
  10533. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  10534. {
  10535. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  10536. return Ok(JsonView(true, "获取成功!", Data));
  10537. }
  10538. /// <summary>
  10539. /// 成本通知
  10540. /// </summary>
  10541. /// <param name="dto"></param>
  10542. /// <returns></returns>
  10543. [HttpPost]
  10544. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  10545. {
  10546. if (dto.Diid < 0)
  10547. {
  10548. return Ok(JsonView(false));
  10549. }
  10550. JsonView jw = null;
  10551. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  10552. if (GroupCostParameter != null)
  10553. {
  10554. int IsShare = 0;
  10555. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  10556. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  10557. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  10558. string msg = string.Empty;
  10559. if (isTrue)
  10560. {
  10561. if (IsShare == 0)
  10562. {
  10563. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  10564. }
  10565. else
  10566. {
  10567. #region 企微通知对应岗位用户
  10568. try
  10569. {
  10570. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  10571. }
  10572. catch (Exception ex)
  10573. {
  10574. }
  10575. #endregion
  10576. msg = "通知成功,其他模块操作人员可见此成本信息!";
  10577. }
  10578. jw = JsonView(isTrue, msg, new { IsShare });
  10579. }
  10580. else
  10581. {
  10582. msg = "修改失败!";
  10583. jw = JsonView(isTrue, msg);
  10584. }
  10585. }
  10586. else
  10587. {
  10588. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  10589. }
  10590. return Ok(jw);
  10591. }
  10592. /// <summary>
  10593. /// 导出报价单
  10594. /// </summary>
  10595. /// <param name="dto"></param>
  10596. /// <returns></returns>
  10597. [HttpPost]
  10598. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  10599. {
  10600. if (dto.Diid == 0)
  10601. {
  10602. return Ok(JsonView(false, "请传递团组id"));
  10603. }
  10604. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  10605. if (deleInfo.Code != 0)
  10606. {
  10607. return Ok(JsonView(false, "团组信息查询失败!"));
  10608. }
  10609. var di = deleInfo.Data as DelegationInfoWebView;
  10610. if (di != null)
  10611. {
  10612. di.TeamName = di.TeamName.Replace("|", "、");
  10613. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  10614. //文件名
  10615. string strFileName = di.TeamName + "-收款账单.doc";
  10616. //获取模板
  10617. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  10618. //载入模板
  10619. Document doc = new Document(tmppath);
  10620. decimal TotalPrice = 0.00M;
  10621. string itemStr = string.Empty;
  10622. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  10623. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  10624. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  10625. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  10626. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  10627. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  10628. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  10629. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  10630. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  10631. foreach (var cost in groupCostType)
  10632. {
  10633. var List = cost.ToList();
  10634. if (cost.Key == "A")
  10635. {
  10636. foreach (var ListItem in List)
  10637. {
  10638. if (ListItem.number > 0)
  10639. {
  10640. if (ListItem.code.Contains("TBR"))
  10641. {
  10642. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10643. }
  10644. else
  10645. {
  10646. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10647. }
  10648. TotalPrice += (ListItem.number * ListItem.price);
  10649. }
  10650. }
  10651. }
  10652. else
  10653. {
  10654. itemStr = itemStr.Insert(0, "A段\r\n");
  10655. itemStr += "B段\r\n";
  10656. foreach (var ListItem in List)
  10657. {
  10658. if (ListItem.number > 0)
  10659. {
  10660. if (ListItem.code.Contains("TBR"))
  10661. {
  10662. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10663. }
  10664. else
  10665. {
  10666. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  10667. }
  10668. TotalPrice += (ListItem.number * ListItem.price);
  10669. }
  10670. }
  10671. }
  10672. }
  10673. #region 替换Word模板书签内容
  10674. Dictionary<string, string> marks = new Dictionary<string, string>();
  10675. marks.Add("To", di.ClientUnit);//付款方
  10676. marks.Add("ToTel", di.TellPhone);//付款方电话
  10677. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  10678. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  10679. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  10680. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  10681. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  10682. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  10683. marks.Add("PayItemContent", itemStr);//详细信息
  10684. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  10685. #endregion
  10686. ////注
  10687. //if (doc.Range.Bookmarks["Attention"] != null)
  10688. //{
  10689. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  10690. // mark.Text = frList[0].Attention;
  10691. //}
  10692. foreach (var item in marks.Keys)
  10693. {
  10694. if (doc.Range.Bookmarks[item] != null)
  10695. {
  10696. Bookmark mark = doc.Range.Bookmarks[item];
  10697. mark.Text = marks[item];
  10698. }
  10699. }
  10700. byte[] bytes = null;
  10701. using (MemoryStream stream = new MemoryStream())
  10702. {
  10703. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  10704. bytes = stream.ToArray();
  10705. }
  10706. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  10707. return Ok(JsonView(true, "", new
  10708. {
  10709. Data = bytes,
  10710. strFileName,
  10711. }));
  10712. }
  10713. else
  10714. {
  10715. return Ok(JsonView(false, "团组信息不存在!"));
  10716. }
  10717. }
  10718. /// <summary>
  10719. /// 导出团组成本
  10720. /// </summary>
  10721. /// <param name="dto"></param>
  10722. /// <returns></returns>
  10723. [HttpPost]
  10724. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  10725. {
  10726. var jw = JsonView(false);
  10727. if (dto.Diid == 0)
  10728. {
  10729. return Ok(JsonView(false, "请传递团组id"));
  10730. }
  10731. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  10732. if (deleInfo.Code != 0)
  10733. {
  10734. return Ok(JsonView(false, "团组信息查询失败!"));
  10735. }
  10736. var di = deleInfo.Data as DelegationInfoWebView;
  10737. if (di == null)
  10738. {
  10739. return Ok(JsonView(false, "团组信息查询失败!"));
  10740. }
  10741. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  10742. WorkbookDesigner designer = new WorkbookDesigner();
  10743. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  10744. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  10745. for (int i = 0; i < List_GC.Count; i++)
  10746. {
  10747. GroupCost_Excel gc = new GroupCost_Excel();
  10748. gc.Id = List_GC[i].Id;
  10749. gc.Diid = List_GC[i].Diid.ToString();
  10750. gc.DAY = List_GC[i].DAY;
  10751. string week = "";
  10752. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  10753. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  10754. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  10755. gc.ITIN = List_GC[i].ITIN;
  10756. gc.CarType = List_GC[i].CarType;
  10757. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  10758. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  10759. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  10760. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  10761. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  10762. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  10763. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  10764. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  10765. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  10766. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  10767. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  10768. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  10769. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  10770. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  10771. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  10772. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  10773. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  10774. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  10775. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  10776. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  10777. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  10778. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  10779. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  10780. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  10781. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  10782. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  10783. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  10784. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  10785. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  10786. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  10787. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  10788. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  10789. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  10790. List_GC1.Add(gc);
  10791. }
  10792. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  10793. dt.TableName = "TB";
  10794. //报表标题等不用dt的值
  10795. designer.SetDataSource("TeamName", dto.title.TeamName);
  10796. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  10797. designer.SetDataSource("Tax", dto.title.Tax);
  10798. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  10799. designer.SetDataSource("Currency", dto.title.Currency);
  10800. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  10801. designer.SetDataSource("Rate", dto.title.Rate);
  10802. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  10803. var Aparams = hotels.Find(x => x.Type == "Default");
  10804. if (Aparams == null)
  10805. {
  10806. return Ok(jw);
  10807. }
  10808. //酒店数量
  10809. var txtSGRNumber = Aparams.SGR.ToString();
  10810. var txtTBRNumber = Aparams.TBR.ToString();
  10811. var txtJSESNumber = Aparams.JSES.ToString();
  10812. var txtSUITENumbe = Aparams.SUITE.ToString();
  10813. if (dto.costType == "B")
  10814. {
  10815. Aparams = hotels.Find(x => x.Type == "A");
  10816. var Bparams = hotels.Find(x => x.Type == "B");
  10817. if (Aparams == null || Bparams == null)
  10818. {
  10819. return Ok(jw);
  10820. }
  10821. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  10822. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  10823. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  10824. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  10825. }
  10826. designer.SetDataSource("SGRNumber", txtSGRNumber);
  10827. designer.SetDataSource("TBRNumber", txtTBRNumber);
  10828. designer.SetDataSource("JSESNumber", txtJSESNumber);
  10829. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  10830. var ws = designer.Workbook.Worksheets[0];
  10831. int Row = List_GC.Count;
  10832. int startIndex = 11;
  10833. int HideRows = 0;
  10834. List<int> hideRowsList = new List<int>();
  10835. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  10836. #region A段left数据
  10837. var left = dto.leftInfo.Find(x => x.Type == "A");
  10838. if (left == null)
  10839. {
  10840. return Ok(jw);
  10841. }
  10842. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  10843. if (leftBindData != null)
  10844. {
  10845. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  10846. designer.SetDataSource("VisaRS", leftBindData.rs);
  10847. designer.SetDataSource("VisaXS", leftBindData.xs);
  10848. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10849. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10850. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10851. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10852. designer.SetDataSource("VisaZLR", ((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("保险"));
  10861. if (leftBindData != null)
  10862. {
  10863. designer.SetDataSource("BXDRCB", leftBindData.cb);
  10864. designer.SetDataSource("BXRS", leftBindData.rs);
  10865. designer.SetDataSource("BXXS", leftBindData.xs);
  10866. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10867. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10868. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10869. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10870. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10871. }
  10872. else
  10873. {
  10874. hideRowsList.Add(Row + startIndex + HideRows);
  10875. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10876. }
  10877. HideRows += 2;
  10878. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  10879. if (leftBindData != null)
  10880. {
  10881. designer.SetDataSource("HSDRCB", leftBindData.cb);
  10882. designer.SetDataSource("HSRS", leftBindData.rs);
  10883. designer.SetDataSource("HSXS", leftBindData.xs);
  10884. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10885. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10886. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10887. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10888. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10889. }
  10890. else
  10891. {
  10892. hideRowsList.Add(Row + startIndex + HideRows);
  10893. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10894. }
  10895. HideRows += 2;
  10896. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  10897. if (leftBindData != null)
  10898. {
  10899. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  10900. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  10901. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  10902. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10903. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10904. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10905. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10906. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10907. }
  10908. else
  10909. {
  10910. hideRowsList.Add(Row + startIndex + HideRows);
  10911. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10912. }
  10913. HideRows += 2;
  10914. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  10915. if (leftBindData != null)
  10916. {
  10917. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  10918. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  10919. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  10920. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10921. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10922. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10923. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10924. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10925. }
  10926. else
  10927. {
  10928. hideRowsList.Add(Row + startIndex + HideRows);
  10929. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10930. }
  10931. HideRows += 2;
  10932. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  10933. if (leftBindData != null)
  10934. {
  10935. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  10936. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  10937. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  10938. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10939. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10940. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10941. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10942. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10943. }
  10944. else
  10945. {
  10946. hideRowsList.Add(Row + startIndex + HideRows);
  10947. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10948. }
  10949. HideRows += 2;
  10950. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  10951. if (leftBindData != null)
  10952. {
  10953. ////TBR
  10954. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  10955. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  10956. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  10957. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10958. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10959. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10960. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10961. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10962. }
  10963. else
  10964. {
  10965. hideRowsList.Add(Row + startIndex + HideRows);
  10966. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10967. }
  10968. HideRows += 2;
  10969. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  10970. if (leftBindData != null)
  10971. {
  10972. ////SGR
  10973. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  10974. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  10975. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  10976. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10977. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10978. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10979. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10980. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  10981. }
  10982. else
  10983. {
  10984. hideRowsList.Add(Row + startIndex + HideRows);
  10985. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  10986. }
  10987. HideRows += 2;
  10988. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  10989. if (leftBindData != null)
  10990. {
  10991. ////JS/ES
  10992. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  10993. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  10994. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  10995. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  10996. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  10997. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  10998. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  10999. designer.SetDataSource("HotelJSESZLR", ((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. HideRows += 2;
  11007. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  11008. if (leftBindData != null)
  11009. {
  11010. ////SUITE
  11011. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  11012. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  11013. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  11014. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11015. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11016. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11017. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11018. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11019. }
  11020. else
  11021. {
  11022. hideRowsList.Add(Row + startIndex + HideRows);
  11023. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  11024. }
  11025. HideRows += 2;
  11026. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  11027. if (leftBindData != null)
  11028. {
  11029. designer.SetDataSource("DJDRCB", leftBindData.cb);
  11030. designer.SetDataSource("DJRS", leftBindData.rs);
  11031. designer.SetDataSource("DJXS", leftBindData.xs);
  11032. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11033. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11034. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11035. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11036. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11037. }
  11038. else
  11039. {
  11040. hideRowsList.Add(Row + startIndex + HideRows);
  11041. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  11042. }
  11043. HideRows += 2;
  11044. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  11045. if (leftBindData != null)
  11046. {
  11047. designer.SetDataSource("HCPCB", leftBindData.cb);
  11048. designer.SetDataSource("HCPRS", leftBindData.rs);
  11049. designer.SetDataSource("HCPXS", leftBindData.xs);
  11050. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11051. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11052. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11053. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11054. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11055. }
  11056. else
  11057. {
  11058. hideRowsList.Add(Row + startIndex + HideRows);
  11059. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  11060. }
  11061. HideRows += 2;
  11062. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  11063. if (leftBindData != null)
  11064. {
  11065. designer.SetDataSource("CPCB", leftBindData.cb);
  11066. designer.SetDataSource("CPRS", leftBindData.rs);
  11067. designer.SetDataSource("CPXS", leftBindData.xs);
  11068. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11069. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11070. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11071. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11072. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11073. }
  11074. else
  11075. {
  11076. hideRowsList.Add(Row + startIndex + HideRows);
  11077. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  11078. }
  11079. HideRows += 2;
  11080. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  11081. if (leftBindData != null)
  11082. {
  11083. designer.SetDataSource("GWDRCD", leftBindData.cb);
  11084. designer.SetDataSource("GWRS", leftBindData.rs);
  11085. designer.SetDataSource("GWXS", leftBindData.xs);
  11086. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11087. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11088. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11089. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11090. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11091. }
  11092. else
  11093. {
  11094. hideRowsList.Add(Row + startIndex + HideRows);
  11095. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  11096. }
  11097. HideRows += 2;
  11098. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  11099. if (leftBindData != null)
  11100. {
  11101. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  11102. designer.SetDataSource("LYJRS", leftBindData.rs);
  11103. designer.SetDataSource("LYJXS", leftBindData.xs);
  11104. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11105. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11106. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11107. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11108. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11109. }
  11110. else
  11111. {
  11112. hideRowsList.Add(Row + startIndex + HideRows);
  11113. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  11114. }
  11115. #endregion
  11116. #region A段Right信息
  11117. var right = dto.rightInfo.Find(x => x.Type == "A");
  11118. if (right == null)
  11119. {
  11120. return Ok(jw);
  11121. }
  11122. HideRows += 4;
  11123. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  11124. if (rightBindData != null)
  11125. {
  11126. //经济舱 + 双人间 TBR
  11127. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  11128. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  11129. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11130. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  11131. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11132. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11133. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11134. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11135. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11136. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11137. }
  11138. else
  11139. {
  11140. hideRowsList.Add(Row + startIndex + HideRows);
  11141. }
  11142. HideRows += 2;
  11143. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  11144. if (rightBindData != null)
  11145. {
  11146. //经济舱 + 单人间 SGR
  11147. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  11148. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  11149. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11150. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  11151. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11152. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11153. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11154. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11155. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11156. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11157. }
  11158. else
  11159. {
  11160. hideRowsList.Add(Row + startIndex + HideRows);
  11161. }
  11162. HideRows += 2;
  11163. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  11164. if (rightBindData != null)
  11165. {
  11166. //公务舱 + 单人间 SGR
  11167. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  11168. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  11169. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11170. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  11171. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11172. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11173. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11174. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11175. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11176. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11177. }
  11178. else
  11179. {
  11180. hideRowsList.Add(Row + startIndex + HideRows);
  11181. }
  11182. HideRows += 2;
  11183. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  11184. if (rightBindData != null)
  11185. {
  11186. //公务舱 + 小套房 JSES
  11187. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  11188. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  11189. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11190. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  11191. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11192. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11193. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11194. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11195. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11196. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11197. }
  11198. else
  11199. {
  11200. hideRowsList.Add(Row + startIndex + HideRows);
  11201. }
  11202. HideRows += 2;
  11203. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  11204. if (rightBindData != null)
  11205. {
  11206. //公务舱 + 小套房 JSES
  11207. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  11208. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  11209. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11210. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  11211. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11212. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11213. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11214. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11215. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11216. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11217. }
  11218. else
  11219. {
  11220. hideRowsList.Add(Row + startIndex + HideRows);
  11221. }
  11222. HideRows += 2;
  11223. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  11224. if (rightBindData != null)
  11225. {
  11226. //经济舱 + 大套房
  11227. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  11228. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  11229. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11230. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  11231. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11232. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11233. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11234. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11235. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11236. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11237. }
  11238. else
  11239. {
  11240. hideRowsList.Add(Row + startIndex + HideRows);
  11241. }
  11242. HideRows += 2;
  11243. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  11244. if (rightBindData != null)
  11245. {
  11246. //头等舱 + 小套房 JSES
  11247. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  11248. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  11249. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11250. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  11251. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11252. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11253. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11254. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11255. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11256. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11257. }
  11258. else
  11259. {
  11260. hideRowsList.Add(Row + startIndex + HideRows);
  11261. }
  11262. HideRows += 2;
  11263. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  11264. if (rightBindData != null)
  11265. {
  11266. //头等舱 + 大套房
  11267. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  11268. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  11269. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11270. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  11271. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11272. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11273. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11274. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11275. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11276. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11277. }
  11278. else
  11279. {
  11280. hideRowsList.Add(Row + startIndex + HideRows);
  11281. }
  11282. #endregion
  11283. #region B段标题清空
  11284. designer.SetDataSource("CostBDRCB", "");
  11285. designer.SetDataSource("CostBRS", "");
  11286. designer.SetDataSource("CostBXS", "");
  11287. designer.SetDataSource("CostBZCB", "");
  11288. designer.SetDataSource("CostBDRBJ", "");
  11289. designer.SetDataSource("CostBZBJ", "");
  11290. designer.SetDataSource("CostBDRLR", "");
  11291. designer.SetDataSource("CostBZLR", "");
  11292. designer.SetDataSource("CostBDRCBOM", "");
  11293. designer.SetDataSource("CostBRSOM", "");
  11294. designer.SetDataSource("CostBZCBOM", "");
  11295. designer.SetDataSource("CostBDRBJOM", "");
  11296. designer.SetDataSource("CostBZBJOM", "");
  11297. designer.SetDataSource("CostBDRLROM", "");
  11298. designer.SetDataSource("CostBZLROM", "");
  11299. #endregion
  11300. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  11301. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  11302. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  11303. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  11304. designer.SetDataSource("DJName", "地接(CNY)");
  11305. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  11306. designer.SetDataSource("CPName", "地接-船票(CNY)");
  11307. designer.SetDataSource("GWName", "公务(CNY)");
  11308. designer.SetDataSource("YQHName", "邀请函(CNY)");
  11309. designer.SetDataSource("LYJName", "零用金(CNY)");
  11310. designer.SetDataSource("HSName", "核酸检测(CNY)");
  11311. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  11312. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  11313. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  11314. designer.SetDataSource("BXName", "保险(CNY)");
  11315. designer.SetDataSource("VisaName", "签证(CNY)");
  11316. #region B段基本数据
  11317. if (dto.costType == "B")
  11318. {
  11319. left = dto.leftInfo.Find(x => x.Type == "B");
  11320. if (left == null)
  11321. {
  11322. return Ok(jw);
  11323. }
  11324. #region B段left数据
  11325. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  11326. if (leftBindData != null)
  11327. {
  11328. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  11329. designer.SetDataSource("BHSRS", leftBindData.rs);
  11330. designer.SetDataSource("BHSXS", leftBindData.xs);
  11331. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11332. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11333. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11334. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11335. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11336. }
  11337. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  11338. if (leftBindData != null)
  11339. {
  11340. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  11341. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  11342. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  11343. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11344. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11345. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11346. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11347. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11348. }
  11349. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  11350. if (leftBindData != null)
  11351. {
  11352. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  11353. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  11354. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  11355. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11356. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11357. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11358. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11359. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11360. }
  11361. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  11362. if (leftBindData != null)
  11363. {
  11364. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  11365. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  11366. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  11367. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11368. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11369. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11370. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11371. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11372. }
  11373. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  11374. if (leftBindData != null)
  11375. {
  11376. designer.SetDataSource("BHCPCB", leftBindData.cb);
  11377. designer.SetDataSource("BHCPRS", leftBindData.rs);
  11378. designer.SetDataSource("BHCPXS", leftBindData.xs);
  11379. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11380. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11381. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11382. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11383. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11384. }
  11385. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  11386. if (leftBindData != null)
  11387. {
  11388. designer.SetDataSource("BCPCB", leftBindData.cb);
  11389. designer.SetDataSource("BCPRS", leftBindData.rs);
  11390. designer.SetDataSource("BCPXS", leftBindData.xs);
  11391. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11392. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11393. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11394. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11395. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11396. }
  11397. //TBR
  11398. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  11399. if (leftBindData != null)
  11400. {
  11401. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  11402. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  11403. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  11404. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11405. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11406. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11407. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11408. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11409. }
  11410. //SGR
  11411. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  11412. if (leftBindData != null)
  11413. {
  11414. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  11415. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  11416. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  11417. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11418. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11419. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11420. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11421. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11422. }
  11423. //JS/ES
  11424. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  11425. if (leftBindData != null)
  11426. {
  11427. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  11428. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  11429. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  11430. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11431. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11432. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11433. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11434. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11435. }
  11436. //SUITE
  11437. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  11438. if (leftBindData != null)
  11439. {
  11440. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  11441. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  11442. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  11443. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11444. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11445. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11446. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11447. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11448. }
  11449. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  11450. if (leftBindData != null)
  11451. {
  11452. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  11453. designer.SetDataSource("BDJRS", leftBindData.rs);
  11454. designer.SetDataSource("BDJXS", leftBindData.xs);
  11455. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11456. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11457. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11458. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11459. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11460. }
  11461. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  11462. if (leftBindData != null)
  11463. {
  11464. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  11465. designer.SetDataSource("BGWRS", leftBindData.rs);
  11466. designer.SetDataSource("BGWXS", leftBindData.xs);
  11467. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11468. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11469. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11470. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11471. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11472. }
  11473. #region 优化方案
  11474. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  11475. //excelBind.Add("零用金", new {
  11476. //cb="",
  11477. //rs="",
  11478. //xs ="",
  11479. //zcb = "",
  11480. //});
  11481. #endregion
  11482. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  11483. if (leftBindData != null)
  11484. {
  11485. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  11486. designer.SetDataSource("BLYJRS", leftBindData.rs);
  11487. designer.SetDataSource("BLYJXS", leftBindData.xs);
  11488. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  11489. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  11490. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  11491. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  11492. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  11493. }
  11494. #endregion
  11495. #region B段Right信息
  11496. right = dto.rightInfo.Find(x => x.Type == "B");
  11497. if (right == null)
  11498. {
  11499. return Ok(jw);
  11500. }
  11501. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  11502. if (rightBindData != null)
  11503. {
  11504. //经济舱 + 双人间 TBR
  11505. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  11506. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  11507. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11508. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  11509. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11510. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11511. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11512. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11513. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11514. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11515. }
  11516. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  11517. if (rightBindData != null)
  11518. {
  11519. //经济舱 + 单人间 SGR
  11520. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  11521. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  11522. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11523. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  11524. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11525. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11526. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11527. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11528. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11529. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11530. }
  11531. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  11532. if (rightBindData != null)
  11533. {
  11534. //公务舱 + 单人间 SGR
  11535. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  11536. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  11537. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11538. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  11539. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11540. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11541. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11542. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11543. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11544. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11545. }
  11546. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  11547. if (rightBindData != null)
  11548. {
  11549. //公务舱 + 小套房 JSES
  11550. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  11551. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  11552. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11553. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  11554. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11555. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11556. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11557. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11558. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11559. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11560. }
  11561. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  11562. if (rightBindData != null)
  11563. {
  11564. //公务舱 + 小套房 JSES
  11565. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  11566. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  11567. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11568. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  11569. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11570. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11571. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11572. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11573. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11574. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11575. }
  11576. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  11577. if (rightBindData != null)
  11578. {
  11579. //经济舱 + 大套房
  11580. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  11581. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  11582. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11583. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  11584. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11585. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11586. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11587. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11588. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11589. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11590. }
  11591. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  11592. if (rightBindData != null)
  11593. {
  11594. //头等舱 + 小套房 JSES
  11595. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  11596. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  11597. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11598. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  11599. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11600. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11601. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11602. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11603. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11604. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11605. }
  11606. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  11607. if (rightBindData != null)
  11608. {
  11609. //头等舱 + 大套房
  11610. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  11611. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  11612. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  11613. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  11614. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  11615. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  11616. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  11617. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  11618. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  11619. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  11620. }
  11621. #endregion
  11622. #region 标题
  11623. designer.SetDataSource("CostBDRCB", "单人成本");
  11624. designer.SetDataSource("CostBRS", "人数");
  11625. designer.SetDataSource("CostBXS", "系数");
  11626. designer.SetDataSource("CostBZCB", "总成本");
  11627. designer.SetDataSource("CostBDRBJ", "单人报价");
  11628. designer.SetDataSource("CostBZBJ", "总报价");
  11629. designer.SetDataSource("CostBDRLR", "单人利润");
  11630. designer.SetDataSource("CostBZLR", "总利润");
  11631. designer.SetDataSource("CostBDRCBOM", "单人成本");
  11632. designer.SetDataSource("CostBRSOM", "人数");
  11633. designer.SetDataSource("CostBZCBOM", "总成本");
  11634. designer.SetDataSource("CostBDRBJOM", "单人报价");
  11635. designer.SetDataSource("CostBZBJOM", "总报价");
  11636. designer.SetDataSource("CostBDRLROM", "单人利润");
  11637. designer.SetDataSource("CostBZLROM", "总利润");
  11638. #endregion
  11639. }
  11640. #endregion
  11641. designer.SetDataSource("TzZCB2", TzZCB2);
  11642. designer.SetDataSource("TzZBJ2", TzZBJ2);
  11643. designer.SetDataSource("TzZLR2", TzZLR2);
  11644. string[] dataSourceKeys = new string[]
  11645. {
  11646. "VF",
  11647. "TGS",
  11648. "TGOF",
  11649. "TGM",
  11650. "TGA",
  11651. "TGTF",
  11652. "TGEF",
  11653. "CFM",
  11654. "CFOF",
  11655. "B",
  11656. "L",
  11657. "D",
  11658. "TBR",
  11659. "SGR",
  11660. "JSES",
  11661. "Suite",
  11662. "TV",
  11663. "1L",
  11664. "IF",
  11665. "EF",
  11666. "BRF",
  11667. "TE",
  11668. "TGT",
  11669. "DRVT",
  11670. "PC",
  11671. "TLF",
  11672. "ECT"
  11673. };
  11674. foreach (var item in dataSourceKeys)
  11675. {
  11676. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  11677. if (find != null)
  11678. {
  11679. designer.SetDataSource(item, find.text);
  11680. }
  11681. else
  11682. {
  11683. designer.SetDataSource(item, 0);
  11684. }
  11685. }
  11686. designer.SetDataSource(dt);
  11687. //根据数据源处理生成报表内容
  11688. designer.Process();
  11689. designer.Workbook.Worksheets[0].Name = "清单";
  11690. Worksheet sheet = designer.Workbook.Worksheets[0];
  11691. foreach (var Rowindex in hideRowsList)
  11692. {
  11693. ws.Cells.HideRows(Rowindex, 2);
  11694. }
  11695. byte[] bytes = null;
  11696. string strFileName = di.TeamName + "-团组-成本.xls";
  11697. using (MemoryStream stream = new MemoryStream())
  11698. {
  11699. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  11700. bytes = stream.ToArray();
  11701. }
  11702. return Ok(JsonView(true, "", new
  11703. {
  11704. Data = bytes,
  11705. strFileName,
  11706. }));
  11707. }
  11708. /// <summary>
  11709. /// 导出客户报表
  11710. /// </summary>
  11711. /// <returns></returns>
  11712. [HttpPost]
  11713. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  11714. {
  11715. var jw = JsonView(false);
  11716. if (dto.Diid == 0)
  11717. {
  11718. return Ok(JsonView(false, "请传递团组id"));
  11719. }
  11720. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  11721. if (deleInfo.Code != 0)
  11722. {
  11723. return Ok(JsonView(false, "团组信息查询失败!"));
  11724. }
  11725. var di = deleInfo.Data as DelegationInfoWebView;
  11726. if (di == null)
  11727. {
  11728. return Ok(JsonView(false, "团组信息查询失败!"));
  11729. }
  11730. //文件名
  11731. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  11732. //获取模板
  11733. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  11734. //载入模板
  11735. Document doc = new Document(tmppath);
  11736. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  11737. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  11738. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  11739. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  11740. var AParameter = ParameterList.Find(x => x.CostType == "A");
  11741. var BParameter = ParameterList.Find(x => x.CostType == "B");
  11742. if (AParameter == null)
  11743. {
  11744. return Ok(JsonView(false, "系数不存在!"));
  11745. }
  11746. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  11747. , TzAirDesc, TzZCost;
  11748. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  11749. = TzAirDesc = TzZCost = string.Empty;
  11750. TzNumber = AParameter.CostTypenumber.ToString();
  11751. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  11752. CarGuides1 = dto.CarGuides1;
  11753. Meal = dto.Meal;
  11754. SubsidizedMeals = dto.SubsidizedMeals;
  11755. NightRepair = dto.NightRepair;
  11756. AttractionsTickets = dto.AttractionsTickets;
  11757. MiscellaneousFees = dto.MiscellaneousFees;
  11758. ATip = dto.ATip;
  11759. TzHotelDesc = "";
  11760. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  11761. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  11762. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  11763. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  11764. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  11765. TzAirDesc = "";
  11766. TzZCost = dto.TzZCost;
  11767. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  11768. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  11769. var index = 1;
  11770. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  11771. foreach (var item in TzHotelDescArr)
  11772. {
  11773. if (AinfoArr != null)
  11774. {
  11775. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11776. if (Ainfo != null)
  11777. {
  11778. if (int.Parse(Ainfo.rs) <= 0)
  11779. {
  11780. continue;
  11781. }
  11782. var hotelText = string.Empty;
  11783. switch (item)
  11784. {
  11785. case "SGR":
  11786. hotelText = "单人间";
  11787. break;
  11788. case "JSES":
  11789. hotelText = "小套房";
  11790. break;
  11791. case "SUITE":
  11792. hotelText = "套房";
  11793. break;
  11794. case "TBR":
  11795. hotelText = "双人间";
  11796. break;
  11797. }
  11798. if (item != "TBR")
  11799. {
  11800. 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";
  11801. }
  11802. else
  11803. {
  11804. 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";
  11805. }
  11806. index++;
  11807. }
  11808. }
  11809. }
  11810. index = 1;
  11811. foreach (var item in TzAirDescArr)
  11812. {
  11813. if (AinfoArr != null)
  11814. {
  11815. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11816. if (Ainfo != null)
  11817. {
  11818. if (int.Parse(Ainfo.rs) <= 0)
  11819. {
  11820. continue;
  11821. }
  11822. 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";
  11823. index++;
  11824. }
  11825. }
  11826. }
  11827. if (dto.costType == "B")
  11828. {
  11829. if (BParameter == null)
  11830. {
  11831. return Ok(JsonView(false, "B段系数不存在!"));
  11832. }
  11833. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  11834. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  11835. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  11836. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  11837. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  11838. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  11839. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  11840. foreach (var item in TzHotelDescArr)
  11841. {
  11842. if (AinfoArr != null)
  11843. {
  11844. TzHotelDesc += "B段信息 \r\n";
  11845. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11846. if (Ainfo != null)
  11847. {
  11848. if (int.Parse(Ainfo.rs) <= 0)
  11849. {
  11850. continue;
  11851. }
  11852. var hotelText = string.Empty;
  11853. switch (item)
  11854. {
  11855. case "SGR":
  11856. hotelText = "单人间";
  11857. break;
  11858. case "JSES":
  11859. hotelText = "小套房";
  11860. break;
  11861. case "SUITE":
  11862. hotelText = "套房";
  11863. break;
  11864. case "TBR":
  11865. hotelText = "双人间";
  11866. break;
  11867. }
  11868. if (item != "TBR")
  11869. {
  11870. 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";
  11871. }
  11872. else
  11873. {
  11874. 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";
  11875. }
  11876. index++;
  11877. }
  11878. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  11879. }
  11880. }
  11881. index = 1;
  11882. foreach (var item in TzAirDescArr)
  11883. {
  11884. if (AinfoArr != null)
  11885. {
  11886. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  11887. if (Ainfo != null)
  11888. {
  11889. if (int.Parse(Ainfo.rs) <= 0)
  11890. {
  11891. continue;
  11892. }
  11893. 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";
  11894. index++;
  11895. }
  11896. }
  11897. }
  11898. }
  11899. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  11900. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  11901. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  11902. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  11903. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  11904. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  11905. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  11906. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  11907. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  11908. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  11909. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  11910. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  11911. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  11912. DickeyValue.Add("Visa", Visa); // 签证单人报价
  11913. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  11914. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  11915. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  11916. DickeyValue.Add("TzZCost", TzZCost);
  11917. foreach (var key in DickeyValue.Keys)
  11918. {
  11919. if (doc.Range.Bookmarks[key] != null)
  11920. {
  11921. Bookmark mark = doc.Range.Bookmarks[key];
  11922. mark.Text = DickeyValue[key];
  11923. }
  11924. }
  11925. byte[] bytes = null;
  11926. string strFileName = di.TeamName + "-客户报价.doc";
  11927. using (MemoryStream stream = new MemoryStream())
  11928. {
  11929. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  11930. bytes = stream.ToArray();
  11931. }
  11932. return Ok(JsonView(true, "", new
  11933. {
  11934. Data = bytes,
  11935. strFileName,
  11936. }));
  11937. }
  11938. /// <summary>
  11939. /// 团组成本 各模块(酒店,地接,机票)成本提示
  11940. /// </summary>
  11941. /// <param name="dto"></param>
  11942. /// <returns></returns>
  11943. [HttpPost]
  11944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11945. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  11946. {
  11947. try
  11948. {
  11949. #region 参数验证
  11950. if (dto.DiId < 0)
  11951. {
  11952. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  11953. }
  11954. List<int> cTableIds = new List<int>() {
  11955. 76 ,//酒店预订
  11956. 77 ,//行程
  11957. 79 ,//车/导游地接
  11958. 80 ,//签证
  11959. 81 ,//邀请/公务活
  11960. 82 ,//团组客户保险
  11961. 85 ,//机票预订
  11962. 98 ,//其他款项
  11963. 285 ,//收款退还
  11964. 751 ,//酒店早餐
  11965. 1015 // 超支费用
  11966. };
  11967. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  11968. {
  11969. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  11970. }
  11971. #endregion
  11972. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  11973. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  11974. if (_GroupCostParameters.Count <= 0)
  11975. {
  11976. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  11977. }
  11978. if (_GroupCostParameters[0].IsShare == 0)
  11979. {
  11980. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  11981. }
  11982. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  11983. //处理date为空问题
  11984. if (_GroupCosts.Count > 0)
  11985. {
  11986. for (int i = 0; i < _GroupCosts.Count; i++)
  11987. {
  11988. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  11989. {
  11990. if (i > 0)
  11991. {
  11992. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  11993. }
  11994. }
  11995. }
  11996. }
  11997. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  11998. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  11999. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  12000. string currCode = "";
  12001. #region currCode 验证
  12002. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  12003. if (isInt)
  12004. {
  12005. var currData = currDatas.Find(it => it.Id == intCurrency);
  12006. if (currData != null)
  12007. {
  12008. currCode = currData.Name;
  12009. }
  12010. }
  12011. else
  12012. {
  12013. currCode = _GroupCostParameters[0].Currency.Trim();
  12014. }
  12015. #endregion
  12016. //op,酒店单段模式存储
  12017. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  12018. {
  12019. CurrencyCode = currCode,
  12020. Rate = _GroupCostParameters[0].Rate,
  12021. CostType = _GroupCostParameters[0].CostType,
  12022. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  12023. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  12024. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  12025. };
  12026. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  12027. if (_GroupCostParameters.Count == 2)
  12028. {
  12029. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  12030. }
  12031. foreach (var item in _GroupCostParameters)
  12032. {
  12033. decimal _rate = 1;
  12034. decimal _rate1 = item.Rate;
  12035. decimal _scale = 1;
  12036. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  12037. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  12038. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  12039. //if (userInfo != null)
  12040. //{
  12041. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  12042. // {
  12043. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  12044. // {
  12045. // _scale = 1.00M;
  12046. // }
  12047. // }
  12048. //}
  12049. #endregion
  12050. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  12051. {
  12052. CurrencyCode = currCode,
  12053. Rate = _rate1,
  12054. CostType = item.CostType,
  12055. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  12056. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  12057. CostTypeNumber = item.CostTypenumber
  12058. };
  12059. if (_GroupCostParameters.Count > 1)
  12060. {
  12061. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  12062. }
  12063. else
  12064. {
  12065. modulePromptInfo.CostTypeNumber = item.LYJRS;
  12066. }
  12067. if (dto.CTable == 79)//
  12068. {
  12069. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  12070. modulePromptInfo.TotalCost = item.DJCB;
  12071. }
  12072. List<string> costTypes = new List<string>() { "A", "B" };
  12073. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  12074. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  12075. if (_GroupCostsDuplicates.Count() == 1)
  12076. {
  12077. _GroupCostsTypeData = _GroupCosts;
  12078. }
  12079. else
  12080. {
  12081. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  12082. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  12083. }
  12084. /*
  12085. * 76 酒店预订
  12086. * 77 行程
  12087. * 79 车/导游地接
  12088. * 80 签证
  12089. * 81 邀请/公务活动
  12090. * 82 团组客户保险
  12091. * 85 机票预订
  12092. * 98 其他款项
  12093. * 285 收款退还
  12094. * 751 酒店早餐
  12095. * 1015 超支费用
  12096. */
  12097. switch (dto.CTable)
  12098. {
  12099. case 76: // 酒店预订
  12100. _ModuleSubPromptInfo.AddRange(
  12101. _GroupCostsTypeData.Select(it => new
  12102. {
  12103. it.DAY,
  12104. it.Date,
  12105. it.ACCON,
  12106. it.ITIN,
  12107. it.SGR,
  12108. it.TBR,
  12109. it.JS_ES,
  12110. it.Suite
  12111. })
  12112. );
  12113. break;
  12114. case 79: // 车/导游地接
  12115. _ModuleSubPromptInfo.AddRange(
  12116. _GroupCostsTypeData.Select(it => new
  12117. {
  12118. Date = it.Date, //日期
  12119. CarFee = it.CarCost * _rate * _scale, //车费用
  12120. CarType = it.CarType, //车型
  12121. DriverFee = it.CFS * _rate * _scale, //司机工资
  12122. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  12123. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  12124. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  12125. GuideFee = it.TGS * _rate * _scale, //导游费用
  12126. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  12127. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  12128. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  12129. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  12130. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  12131. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  12132. Breakfast = it.B * _rate * _scale, //早餐费
  12133. Lunch = it.L * _rate * _scale, //午餐费
  12134. Dinner = it.D * _rate * _scale, //晚餐费
  12135. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  12136. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  12137. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  12138. TicketFee = it.EF * _rate * _scale, //门票费
  12139. TicketRemark = it.EFR, //门票费描述
  12140. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  12141. TravelSupplies = it.TE * _rate * _scale, //出行物资
  12142. SpentCash = it.PC * _rate * _scale, //零用金
  12143. LeadersFee = it.TLF * _rate * _scale, //领队费
  12144. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  12145. })
  12146. );
  12147. break;
  12148. case 85: // 机票
  12149. List<dynamic> datas = new List<dynamic>();
  12150. datas.Add(
  12151. new
  12152. {
  12153. AirType = "经济舱",
  12154. AirNum = item.JJCRS,
  12155. AirDRCB = item.JJCCB,
  12156. AirZCB = (item.JJCRS * item.JJCCB)
  12157. }
  12158. );
  12159. datas.Add(
  12160. new
  12161. {
  12162. AirType = "公务舱",
  12163. AirNum = item.GWCRS,
  12164. AirDRCB = item.GWCCB,
  12165. AirZCB = (item.GWCRS * item.GWCCB)
  12166. }
  12167. );
  12168. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  12169. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  12170. modulePromptInfo.Data = new
  12171. {
  12172. airFeeData = datas,
  12173. airInitData = initDatas
  12174. };
  12175. _ModulePromptInfos.Add(modulePromptInfo);
  12176. break;
  12177. default:
  12178. break;
  12179. }
  12180. }
  12181. if (dto.CTable != 85)
  12182. {
  12183. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  12184. _ModulePromptInfos.Add(_ModulePromptInfo);
  12185. }
  12186. _view.ModulePromptInfos = _ModulePromptInfos;
  12187. return Ok(JsonView(true, "操作成功!", _view));
  12188. }
  12189. catch (Exception ex)
  12190. {
  12191. return Ok(JsonView(false, ex.Message));
  12192. }
  12193. }
  12194. /// <summary>
  12195. /// 根据黑屏代码重新生成行程
  12196. /// </summary>
  12197. /// <param name="dto"></param>
  12198. /// <returns></returns>
  12199. [HttpPost]
  12200. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  12201. {
  12202. var jw = JsonView(false);
  12203. var Create = _GroupCostRepository.
  12204. CreateGroupCostByBlackCode(dto.Diid);
  12205. jw.Msg = Create.Msg;
  12206. if (Create.Code == 0)
  12207. {
  12208. jw.Code = 200;
  12209. jw.Data = new
  12210. {
  12211. groupCost = Create.Data,
  12212. blackCodeIsTrue = true
  12213. };
  12214. }
  12215. else
  12216. {
  12217. jw.Code = 400;
  12218. jw.Data = new
  12219. {
  12220. groupCost = Create.Data,
  12221. blackCodeIsTrue = false,
  12222. };
  12223. }
  12224. return Ok(jw);
  12225. }
  12226. /// <summary>
  12227. /// 成本获取OP历史车费用
  12228. /// </summary>
  12229. /// <param name="dto"></param>
  12230. /// <returns></returns>
  12231. [HttpPost]
  12232. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  12233. {
  12234. var jw = JsonView(false);
  12235. try
  12236. {
  12237. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  12238. //获取现有所有车的数据
  12239. if (!dto.Param.IsNullOrWhiteSpace())
  12240. {
  12241. string sql = $@"
  12242. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  12243. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  12244. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  12245. 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
  12246. AND gctggr.ServiceEndTime is not NULL
  12247. ORDER by gctggrc.id DESC
  12248. ";
  12249. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  12250. var numeberResult = await Task.Run(() =>
  12251. {
  12252. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  12253. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  12254. return numberArr;
  12255. });
  12256. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  12257. foreach (var item in numeberResult)
  12258. {
  12259. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  12260. {
  12261. Country = "数据异常!",
  12262. City = string.Empty,
  12263. };
  12264. item.Area = find.Country + " " + find.City;
  12265. }
  12266. dbResult.AddRange(numeberResult);
  12267. if (dto.Param.Contains("、"))
  12268. {
  12269. var sp = dto.Param.Split("、");
  12270. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  12271. .Where(x =>
  12272. {
  12273. return System.Array.Exists(sp, e =>
  12274. {
  12275. bool where = false;
  12276. if (x.Area != null)
  12277. {
  12278. where = x.Area.Contains(e);
  12279. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  12280. {
  12281. return false;
  12282. }
  12283. }
  12284. if (x.PriceName != null && !where)
  12285. {
  12286. where = x.PriceName.Contains(e);
  12287. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  12288. {
  12289. return false;
  12290. }
  12291. }
  12292. return where;
  12293. });
  12294. }).ToList();
  12295. }
  12296. else
  12297. {
  12298. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  12299. .Where(x =>
  12300. {
  12301. bool where = false;
  12302. if (x.Area != null)
  12303. {
  12304. where = x.Area.Contains(dto.Param);
  12305. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  12306. {
  12307. return false;
  12308. }
  12309. }
  12310. if (x.PriceName != null && !where)
  12311. {
  12312. where = x.PriceName.Contains(dto.Param);
  12313. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  12314. {
  12315. return false;
  12316. }
  12317. }
  12318. return where;
  12319. }
  12320. )
  12321. .ToList();
  12322. }
  12323. }
  12324. var view = dbResult.Select(x =>
  12325. {
  12326. decimal dp = 0.00M;
  12327. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  12328. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  12329. if (string.IsNullOrWhiteSpace(x.DatePrice))
  12330. {
  12331. if (startB && endB)
  12332. {
  12333. var timesp = endD.Subtract(startD);
  12334. if ((timesp.Days + 1) != 0)
  12335. {
  12336. dp = x.Price / (timesp.Days + 1);
  12337. }
  12338. }
  12339. }
  12340. else
  12341. {
  12342. dp = x.Price;
  12343. }
  12344. return new
  12345. {
  12346. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  12347. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  12348. x.Area,
  12349. x.id,
  12350. price = x.Price.ToString("F2"),
  12351. x.PriceName,
  12352. x.PriceContent,
  12353. x.TeamName,
  12354. x.DatePrice,
  12355. dayPrice = dp.ToString("F2"),
  12356. };
  12357. }).OrderByDescending(x => x.id).ToList();
  12358. jw = JsonView(true, "获取成功!", view);
  12359. }
  12360. catch (Exception e)
  12361. {
  12362. jw = JsonView(false, e.Message);
  12363. }
  12364. return Ok(jw);
  12365. }
  12366. #endregion
  12367. #region 酒店预订 新 雷怡 2023-12-28 17:45
  12368. /// <summary>
  12369. /// 酒店预订
  12370. /// 酒店费用列表 根据团组Id查询
  12371. /// </summary>
  12372. /// <param name="_dto"></param>
  12373. /// <returns></returns>
  12374. [HttpPost]
  12375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12376. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _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 (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12390. #endregion
  12391. #endregion
  12392. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  12393. }
  12394. /// <summary>
  12395. /// 酒店预订
  12396. /// 基础数据
  12397. /// </summary>
  12398. /// <param name="_dto"></param>
  12399. /// <returns></returns>
  12400. [HttpPost]
  12401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12402. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  12403. {
  12404. #region 参数验证
  12405. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12406. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12407. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12408. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12409. #region 页面操作权限验证
  12410. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12411. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12412. #endregion
  12413. #region 团组操作权限验证 76 酒店预定模块
  12414. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12415. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12416. #endregion
  12417. #endregion
  12418. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  12419. }
  12420. /// <summary>
  12421. /// 酒店预订
  12422. /// 创建 入住卷号码
  12423. /// </summary>
  12424. /// <param name="_dto"></param>
  12425. /// <returns></returns>
  12426. [HttpPost]
  12427. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12428. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  12429. {
  12430. #region 参数验证
  12431. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12432. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12433. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12434. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12435. #region 页面操作权限验证
  12436. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12437. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12438. #endregion
  12439. #region 团组操作权限验证 76 酒店预定模块
  12440. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12441. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12442. #endregion
  12443. #endregion
  12444. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  12445. if (data.Code != 0)
  12446. {
  12447. return Ok(JsonView(false, data.Msg));
  12448. }
  12449. return Ok(JsonView(true, data.Msg, data.Data));
  12450. }
  12451. /// <summary>
  12452. /// 酒店预订
  12453. /// 详情
  12454. /// </summary>
  12455. /// <param name="_dto"></param>
  12456. /// <returns></returns>
  12457. [HttpPost]
  12458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12459. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  12460. {
  12461. #region 参数验证
  12462. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  12463. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12464. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  12465. #region 团组操作权限验证 76 酒店预定模块
  12466. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12467. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12468. #endregion
  12469. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12470. #region 页面操作权限验证
  12471. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12472. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  12473. #endregion
  12474. #endregion
  12475. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  12476. }
  12477. /// <summary>
  12478. /// 酒店预订
  12479. /// Add Or Edit
  12480. /// </summary>
  12481. /// <param name="_dto"></param>
  12482. /// <returns></returns>
  12483. [HttpPost]
  12484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12485. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  12486. {
  12487. #region 参数验证
  12488. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12489. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12490. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12491. #region 团组操作权限验证 76 酒店预定模块
  12492. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12493. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12494. #endregion
  12495. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12496. #region 页面操作权限验证
  12497. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12498. if (_dto.Id == 0) // Add
  12499. {
  12500. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  12501. }
  12502. else if (_dto.Id > 1) // Edit
  12503. {
  12504. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  12505. }
  12506. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  12507. #endregion
  12508. #endregion
  12509. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  12510. if (_view.Code != 200)
  12511. {
  12512. return Ok(_view);
  12513. }
  12514. #region 成本无酒店价格数据进入超支
  12515. _sqlSugar.BeginTran();
  12516. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  12517. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  12518. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  12519. for (int i = 0; i < groupCost.Count; i++)
  12520. {
  12521. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  12522. {
  12523. groupCost[i].Date = groupCost[i - 1].Date;
  12524. }
  12525. }
  12526. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  12527. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  12528. List<Fin_GroupExtraCostDto_OP>();
  12529. if (start_Bool && end_Bool)
  12530. {
  12531. while (start_Time < end_Time)
  12532. {
  12533. foreach (var item in groupCost_Grp)
  12534. {
  12535. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  12536. {
  12537. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  12538. {
  12539. extraCostList.Add(new
  12540. Fin_GroupExtraCostDto_OP
  12541. {
  12542. Area = _dto.AreaId,
  12543. coefficient = 1.5M,
  12544. createUser = _dto.UserId,
  12545. currency = _dto.CardPriceCurrency,
  12546. diId = _dto.DiId,
  12547. ManagerConfirm = 0,
  12548. SupervisorConfirm = 0,
  12549. SYsupervisorConfirm = 0,
  12550. editType = 1,
  12551. PortType = 1,
  12552. price = _dto.CardPrice,
  12553. PriceCount = 1,
  12554. priceType = 1027,
  12555. priceDetailType = 1044,
  12556. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  12557. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  12558. });
  12559. }
  12560. }
  12561. }
  12562. start_Time = start_Time.AddDays(1);
  12563. }
  12564. }
  12565. if (extraCostList.Any())
  12566. {
  12567. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  12568. }
  12569. _sqlSugar.CommitTran();
  12570. #endregion
  12571. #region 应用推送
  12572. try
  12573. {
  12574. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  12575. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  12576. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  12577. var diId = _dto.DiId;
  12578. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12579. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12580. #region 操作记录
  12581. var opInfo = new Crm_TableOperationRecord() {
  12582. TableName = "Grp_HotelReservations",
  12583. PortType = _dto.PortType,
  12584. DataId = hotelId,
  12585. CreateUserId = _dto.UserId
  12586. };
  12587. var opStatus = OperationEnum.NoOperation;
  12588. if (_dto.Id<1) //添加操作
  12589. {
  12590. opInfo.OperationItem = OperationEnum.Add;
  12591. }
  12592. else if (_dto.Id > 0)
  12593. {
  12594. opInfo.OperationItem = OperationEnum.Edit;
  12595. }
  12596. string opRemark = string.Empty;
  12597. if (ccpInfo != null)
  12598. {
  12599. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  12600. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  12601. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  12602. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  12603. }
  12604. opInfo.Remark = opRemark;
  12605. await _tableorRep.AddAsync(opInfo);
  12606. #endregion
  12607. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  12608. //2024-10-21 新增LZ UID
  12609. var userIds = new List<int>() { 21 };
  12610. string title = $"费用审核";
  12611. string content = "";
  12612. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12613. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12614. try
  12615. {
  12616. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  12617. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  12618. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  12619. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  12620. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  12621. }
  12622. catch (Exception ex )
  12623. {
  12624. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  12625. }
  12626. }
  12627. catch (Exception ex)
  12628. {
  12629. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  12630. }
  12631. try
  12632. {
  12633. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  12634. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  12635. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  12636. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12637. //自动审核
  12638. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  12639. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  12640. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  12641. //2024-10-21 新增LZ UID
  12642. var userIds = new List<int>() { 21 };
  12643. string title = $"系统通知";
  12644. var diId = _dto.DiId;
  12645. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12646. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12647. string content = "";
  12648. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12649. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12650. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12651. }
  12652. catch (Exception ex)
  12653. {
  12654. }
  12655. #endregion
  12656. return Ok(_view);
  12657. }
  12658. /// <summary>
  12659. /// 酒店自动审核测试
  12660. /// Add Or Edit
  12661. /// </summary>
  12662. /// <param name="_dto"></param>
  12663. /// <returns></returns>
  12664. [HttpPost]
  12665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12666. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  12667. {
  12668. #region 应用推送
  12669. try
  12670. {
  12671. //自动审核
  12672. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  12673. }
  12674. catch (Exception ex)
  12675. {
  12676. return Ok(JsonView(false, "操作失败"));
  12677. }
  12678. #endregion
  12679. return Ok(JsonView(false, "操作成功"));
  12680. }
  12681. /// <summary>
  12682. /// 酒店预订
  12683. /// Del
  12684. /// </summary>
  12685. /// <param name="_dto"></param>
  12686. /// <returns></returns>
  12687. [HttpPost]
  12688. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12689. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  12690. {
  12691. #region 参数验证
  12692. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12693. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12694. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12695. #region 团组操作权限验证 76 酒店预定模块
  12696. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12697. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12698. #endregion
  12699. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12700. #region 页面操作权限验证
  12701. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12702. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  12703. #endregion
  12704. #endregion
  12705. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  12706. #region 操作记录
  12707. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  12708. {
  12709. TableName = "Grp_HotelReservations",
  12710. PortType = _dto.PortType,
  12711. OperationItem = OperationEnum.Del,
  12712. DataId = _dto.Id,
  12713. CreateUserId = _dto.UserId
  12714. });
  12715. #endregion
  12716. return Ok(data);
  12717. }
  12718. /// <summary>
  12719. /// 酒店预订
  12720. /// 生成VOUCHER
  12721. /// 2024.05.06 之前版本
  12722. /// </summary>
  12723. /// <param name="_dto"></param>
  12724. /// <returns></returns>
  12725. [HttpPost]
  12726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12727. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  12728. {
  12729. try
  12730. {
  12731. #region 参数验证
  12732. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  12733. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12734. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  12735. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  12736. #region 团组操作权限验证 76 酒店预定模块
  12737. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12738. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  12739. #endregion
  12740. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12741. #region 页面操作权限验证
  12742. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12743. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12744. #endregion
  12745. #endregion
  12746. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  12747. //判断数据是否完整
  12748. if (hr != null)
  12749. {
  12750. if (!string.IsNullOrEmpty(hr.DetermineNo))
  12751. {
  12752. string strFileName = "HotelStatement/";
  12753. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  12754. if (dele != null)
  12755. strFileName += dele.TourCode;
  12756. //载入模板
  12757. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  12758. Document doc = new Document(sss);
  12759. DocumentBuilder builder = new DocumentBuilder(doc);
  12760. #region 替换Word模板书签内容
  12761. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  12762. //入住卷预定号码
  12763. if (doc.Range.Bookmarks["VNO"] != null)
  12764. {
  12765. Bookmark mark = doc.Range.Bookmarks["VNO"];
  12766. mark.Text = hr.CheckNumber;
  12767. }
  12768. //酒店时间
  12769. if (doc.Range.Bookmarks["Date"] != null)
  12770. {
  12771. Bookmark mark = doc.Range.Bookmarks["Date"];
  12772. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  12773. }
  12774. //团号
  12775. if (doc.Range.Bookmarks["TNo"] != null)
  12776. {
  12777. Bookmark mark = doc.Range.Bookmarks["TNo"];
  12778. mark.Text = dele.TourCode;
  12779. }
  12780. //预定号码
  12781. if (doc.Range.Bookmarks["BookingId"] != null)
  12782. {
  12783. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  12784. mark.Text = hr.ReservationsNo;
  12785. }
  12786. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  12787. {
  12788. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  12789. mark.Text = hr.DetermineNo;
  12790. }
  12791. //酒店城市
  12792. if (doc.Range.Bookmarks["City"] != null)
  12793. {
  12794. Bookmark mark = doc.Range.Bookmarks["City"];
  12795. mark.Text = hr.City;
  12796. }
  12797. //酒店名称
  12798. if (doc.Range.Bookmarks["HName"] != null)
  12799. {
  12800. Bookmark mark = doc.Range.Bookmarks["HName"];
  12801. mark.Text = hr.HotelName;
  12802. }
  12803. //酒店地址
  12804. if (doc.Range.Bookmarks["Address"] != null)
  12805. {
  12806. Bookmark mark = doc.Range.Bookmarks["Address"];
  12807. mark.Text = hr.HotelAddress;
  12808. }
  12809. //酒店电话
  12810. if (doc.Range.Bookmarks["Tel"] != null)
  12811. {
  12812. Bookmark mark = doc.Range.Bookmarks["Tel"];
  12813. mark.Text = hr.HotelTel;
  12814. }
  12815. //酒店传真
  12816. if (doc.Range.Bookmarks["Fax"] != null)
  12817. {
  12818. Bookmark mark = doc.Range.Bookmarks["Fax"];
  12819. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  12820. {
  12821. mark.Text = hr.HotelFax;
  12822. }
  12823. }
  12824. //入住时间
  12825. if (doc.Range.Bookmarks["CIn"] != null)
  12826. {
  12827. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  12828. Bookmark mark = doc.Range.Bookmarks["CIn"];
  12829. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  12830. }
  12831. //退房时间
  12832. if (doc.Range.Bookmarks["COut"] != null)
  12833. {
  12834. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  12835. Bookmark mark = doc.Range.Bookmarks["COut"];
  12836. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  12837. }
  12838. //客户名称
  12839. if (doc.Range.Bookmarks["GName"] != null)
  12840. {
  12841. string guestName = "";
  12842. string[] clients = new string[] { };
  12843. if (hr.GuestName.Contains(","))
  12844. {
  12845. clients = hr.GuestName.Split(",");
  12846. }
  12847. else
  12848. {
  12849. clients = new string[] { hr.GuestName };
  12850. }
  12851. List<int> clientIds_int = new List<int>();
  12852. if (clients.Length > 0)
  12853. {
  12854. foreach (var item in clients)
  12855. {
  12856. if (item.IsNumeric())
  12857. {
  12858. clientIds_int.Add(int.Parse(item));
  12859. }
  12860. }
  12861. }
  12862. if (clientIds_int.Count > 0)
  12863. {
  12864. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  12865. foreach (var client in _clientDatas)
  12866. {
  12867. //男
  12868. if (client.Sex == 0) guestName += $"Mr.";
  12869. //女
  12870. else if (client.Sex == 1) guestName += $"Ms.";
  12871. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  12872. {
  12873. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  12874. }
  12875. //guestName += $"{client.Pinyin},";
  12876. }
  12877. if (guestName.Length > 0)
  12878. {
  12879. guestName = guestName.Substring(0, guestName.Length - 1);
  12880. }
  12881. }
  12882. else
  12883. {
  12884. guestName = hr.GuestName;
  12885. }
  12886. Bookmark mark = doc.Range.Bookmarks["GName"];
  12887. mark.Text = guestName;
  12888. }
  12889. //房间介绍
  12890. if (doc.Range.Bookmarks["ROOM"] != null)
  12891. {
  12892. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  12893. mark.Text = hr.RoomExplanation;
  12894. }
  12895. //报价描述
  12896. if (doc.Range.Bookmarks["NOTE"] != null)
  12897. {
  12898. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  12899. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  12900. if (ss != null)
  12901. mark.Text = ss.Name;
  12902. }
  12903. //入住时间
  12904. if (doc.Range.Bookmarks["CheckIn"] != null)
  12905. {
  12906. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  12907. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  12908. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  12909. }
  12910. //退房时间
  12911. if (doc.Range.Bookmarks["CheckOut"] != null)
  12912. {
  12913. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  12914. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  12915. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  12916. }
  12917. //日期
  12918. if (doc.Range.Bookmarks["DT"] != null)
  12919. {
  12920. Bookmark mark = doc.Range.Bookmarks["DT"];
  12921. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  12922. }
  12923. //名称
  12924. if (doc.Range.Bookmarks["VName"] != null)
  12925. {
  12926. Bookmark mark = doc.Range.Bookmarks["VName"];
  12927. mark.Text = hr.HotelName;
  12928. }
  12929. //号码
  12930. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  12931. {
  12932. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  12933. mark.Text = hr.CheckNumber;
  12934. }
  12935. #endregion
  12936. strFileName += "VOUCHER.doc";
  12937. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  12938. doc.Save(fileDir);
  12939. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  12940. return Ok(JsonView(true, "操作成功!", Url));
  12941. }
  12942. else
  12943. {
  12944. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  12945. }
  12946. }
  12947. else
  12948. {
  12949. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  12950. }
  12951. }
  12952. catch (Exception ex)
  12953. {
  12954. return Ok(JsonView(false, ex.Message));
  12955. }
  12956. }
  12957. /// <summary>
  12958. /// 酒店预订
  12959. /// 生成VOUCHER
  12960. /// 2024.05.06 之后版本
  12961. /// </summary>
  12962. /// <param name="_dto"></param>
  12963. /// <returns></returns>
  12964. [HttpPost]
  12965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12966. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  12967. {
  12968. #region 参数验证
  12969. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  12970. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12971. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  12972. #region 团组操作权限验证 76 酒店预定模块
  12973. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12974. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  12975. #endregion
  12976. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12977. #region 页面操作权限验证
  12978. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12979. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12980. #endregion
  12981. #endregion
  12982. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  12983. //判断数据是否完整
  12984. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  12985. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12986. string strFileName = "HotelStatement/";
  12987. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12988. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  12989. #region 数据处理
  12990. List<int> guestIds = new List<int>();
  12991. int index = 0;
  12992. foreach (var item in hrDtas)
  12993. {
  12994. if (item.GuestName.Contains(","))
  12995. {
  12996. string[] guestIdArr = item.GuestName.Split(',');
  12997. foreach (var guestIdStr in guestIdArr)
  12998. {
  12999. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  13000. if (guestBool)
  13001. {
  13002. guestIds.Add(guestId);
  13003. }
  13004. }
  13005. }
  13006. else guestNames += item.GuestName;
  13007. var voucherInfo = new HotelVoucherInfoView()
  13008. {
  13009. HotelName = item.HotelName,
  13010. CheckInDate = item.CheckInDate,
  13011. CheckOutDate = item.CheckOutDate,
  13012. ConfirmationNumber = item.DetermineNo.Trim(),
  13013. RoomType = item.RoomExplanation
  13014. };
  13015. vouchers.Add(voucherInfo);
  13016. }
  13017. if (guestIds.Count > 0)
  13018. {
  13019. guestIds = guestIds.Distinct().ToList();
  13020. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  13021. if (guestDatas.Count > 0)
  13022. {
  13023. guestNames = "";
  13024. foreach (var guest in guestDatas)
  13025. {
  13026. string guestName = "";
  13027. if (guest.Sex == 0) guestName += @"MR.";
  13028. else if (guest.Sex == 1) guestName += @"MS.";
  13029. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  13030. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  13031. guestNames += @$"{guestName.Trim()}、";
  13032. }
  13033. if (guestNames.Length > 0)
  13034. {
  13035. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  13036. }
  13037. }
  13038. }
  13039. #endregion
  13040. //载入模板
  13041. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  13042. Document doc = new Document(sss);
  13043. DocumentBuilder builder = new DocumentBuilder(doc);
  13044. if (doc.Range.Bookmarks["GuestName"] != null)
  13045. {
  13046. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  13047. mark.Text = guestNames;
  13048. }
  13049. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13050. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  13051. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  13052. for (int i = 1; i <= vouchers.Count; i++)
  13053. {
  13054. HotelVoucherInfoView hviv = vouchers[i - 1];
  13055. builder.MoveToCell(0, i, 0, 0);
  13056. builder.Write(hviv.HotelName);
  13057. builder.MoveToCell(0, i, 1, 0);
  13058. builder.Write(hviv.CheckInDate);
  13059. builder.MoveToCell(0, i, 2, 0);
  13060. builder.Write(hviv.CheckOutDate);
  13061. builder.MoveToCell(0, i, 3, 0);
  13062. builder.Write(hviv.RoomType);
  13063. builder.MoveToCell(0, i, 4, 0);
  13064. builder.Write(hviv.ConfirmationNumber);
  13065. }
  13066. //删除多余行
  13067. int currRowIndex = vouchers.Count + 1;
  13068. int delRows = 21 - currRowIndex;
  13069. if (delRows > 0)
  13070. {
  13071. for (int i = 0; i < delRows; i++)
  13072. {
  13073. table.Rows.RemoveAt(currRowIndex);
  13074. //cultivateRowIndex++;
  13075. }
  13076. }
  13077. strFileName += "VOUCHER.docx";
  13078. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  13079. doc.Save(fileDir);
  13080. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  13081. return Ok(JsonView(true, "操作成功!", Url));
  13082. }
  13083. /// <summary>
  13084. /// 酒店预订
  13085. /// 生成VOUCHER 批量生成
  13086. /// New
  13087. /// </summary>
  13088. /// <param name="_dto"></param>
  13089. /// <returns></returns>
  13090. [HttpPost]
  13091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13092. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  13093. {
  13094. #region 参数验证
  13095. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  13096. if (_dto.PageId < 1) _dto.PageId = 28;
  13097. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  13098. #region 团组操作权限验证 76 酒店预定模块
  13099. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13100. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  13101. #endregion
  13102. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13103. #region 页面操作权限验证
  13104. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13105. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  13106. #endregion
  13107. #endregion
  13108. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  13109. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  13110. .OrderBy(x => x.CheckInDate)
  13111. .ToListAsync();
  13112. //判断数据是否完整
  13113. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  13114. string strFileName = "HotelStatement/";
  13115. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  13116. if (dele != null)
  13117. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  13118. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  13119. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  13120. .Where(it => it.IsDel == 0)
  13121. .ToListAsync();
  13122. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  13123. for (int i = 0; i < hrDtas.Count; i++)
  13124. {
  13125. string guestNames = string.Empty;
  13126. List<int> guestIds = new List<int>();
  13127. var item = hrDtas[i];
  13128. //处理客户姓名
  13129. if (item.GuestName.Contains(","))
  13130. {
  13131. string[] guestIdArr = item.GuestName.Split(',');
  13132. foreach (var guestIdStr in guestIdArr)
  13133. if (int.TryParse(guestIdStr, out int guestId))
  13134. guestIds.Add(guestId);
  13135. }
  13136. else
  13137. {
  13138. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  13139. if (guestIdBool)
  13140. {
  13141. guestIds.Add(guestId);
  13142. }
  13143. //NaN
  13144. if (item.GuestName.Contains("NaN"))
  13145. {
  13146. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  13147. }
  13148. }
  13149. if (guestIds.Count > 0)
  13150. {
  13151. guestIds = guestIds.Distinct().ToList();
  13152. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  13153. if (guestDatas1.Count > 0)
  13154. {
  13155. guestNames = "";
  13156. foreach (var guest in guestDatas1)
  13157. {
  13158. string guestName = "";
  13159. if (guest.Sex == 0) guestName += @"MR.";
  13160. else if (guest.Sex == 1) guestName += @"MS.";
  13161. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  13162. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  13163. guestNames += @$"{guestName.Trim()}、";
  13164. }
  13165. if (guestNames.Length > 0)
  13166. {
  13167. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  13168. }
  13169. }
  13170. }
  13171. //if (!string.IsNullOrEmpty(guestNames))
  13172. //{
  13173. hrDtas[i].GuestName = guestNames;
  13174. //}
  13175. }
  13176. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  13177. Document doc = new Document();
  13178. DocumentBuilder builder = new DocumentBuilder(doc);
  13179. try
  13180. {
  13181. builder.MoveToDocumentStart();
  13182. foreach (var item in hrDtas)
  13183. {
  13184. //标题
  13185. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  13186. builder.ParagraphFormat.LineSpacing = 1;
  13187. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13188. builder.ParagraphFormat.Style.Font.Size = 9;
  13189. builder.ParagraphFormat.Style.Font.Bold = true;
  13190. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  13191. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  13192. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  13193. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  13194. builder.ParagraphFormat.LineSpacing = 1;
  13195. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13196. builder.ParagraphFormat.Style.Font.Size = 9;
  13197. builder.ParagraphFormat.Style.Font.Bold = true;
  13198. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  13199. builder.StartTable();
  13200. // 设置边框颜色
  13201. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  13202. //设置边框样式
  13203. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  13204. //表格
  13205. #region 第一行
  13206. builder.InsertCell();
  13207. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13208. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13209. //builder.CellFormat.AllowAutoFit = false;
  13210. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13211. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13212. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13213. builder.CellFormat.WrapText = true; //自动换行
  13214. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13215. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  13216. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13217. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13218. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13219. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13220. builder.Write("TOUR NO:");
  13221. builder.InsertCell();
  13222. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13223. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13224. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13225. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13226. builder.ParagraphFormat.Style.Font.Bold = false;
  13227. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13228. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13229. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13230. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13231. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13232. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13233. builder.Write($"{dele?.TourCode ?? "-"}");
  13234. builder.InsertCell();
  13235. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13236. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13237. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13238. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13239. builder.ParagraphFormat.Style.Font.Bold = false;
  13240. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13241. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13242. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13243. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13244. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13245. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13246. builder.Write($"CITY:");
  13247. builder.InsertCell();
  13248. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13249. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13250. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13251. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13252. builder.ParagraphFormat.Style.Font.Bold = false;
  13253. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13254. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13255. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13256. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13257. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13258. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13259. builder.Write($"{item.City}");
  13260. builder.EndRow();
  13261. #endregion
  13262. #region 第二行
  13263. builder.InsertCell();
  13264. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13265. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13266. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13267. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13268. builder.ParagraphFormat.Style.Font.Bold = false;
  13269. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13270. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13271. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13272. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13273. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13274. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13275. builder.Write("CONFIRMATION NO:");
  13276. builder.InsertCell();
  13277. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13278. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13279. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13280. builder.ParagraphFormat.Style.Font.Bold = false;
  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.CellFormat.VerticalMerge = CellMerge.None;
  13288. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13289. builder.Write($"{item.DetermineNo}");
  13290. builder.InsertCell();
  13291. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13292. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13293. builder.InsertCell();
  13294. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13295. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13296. builder.EndRow();
  13297. #endregion
  13298. #region 第三行
  13299. builder.InsertCell();
  13300. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13301. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13302. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13303. builder.ParagraphFormat.Style.Font.Bold = false;
  13304. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13305. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13306. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13307. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13308. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13309. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13310. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13311. builder.Write($"HOTEL NAME:");
  13312. builder.InsertCell();
  13313. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13314. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13315. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13316. builder.ParagraphFormat.Style.Font.Bold = false;
  13317. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13318. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13319. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13320. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13321. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13322. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13323. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13324. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13325. builder.Write($"{item.HotelName}");
  13326. builder.InsertCell();
  13327. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13328. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13329. builder.InsertCell();
  13330. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13331. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13332. builder.EndRow();
  13333. #endregion
  13334. #region 第四行
  13335. builder.InsertCell();
  13336. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13337. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13338. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13339. builder.ParagraphFormat.Style.Font.Bold = false;
  13340. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13341. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13342. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13343. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13344. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13345. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13346. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13347. builder.Write($"HOTEL ADDRESS:");
  13348. builder.InsertCell();
  13349. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13350. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13351. builder.ParagraphFormat.Style.Font.Size = 8;
  13352. builder.ParagraphFormat.Style.Font.Bold = false;
  13353. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13354. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13355. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13356. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13357. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13358. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13359. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13360. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13361. builder.Write($"{item.HotelAddress}");
  13362. builder.InsertCell();
  13363. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13364. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13365. builder.InsertCell();
  13366. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13367. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13368. builder.EndRow();
  13369. #endregion
  13370. #region 第五行
  13371. builder.InsertCell();
  13372. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13373. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13374. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13375. builder.ParagraphFormat.Style.Font.Bold = false;
  13376. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13377. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13378. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13379. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13380. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13381. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13382. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13383. builder.Write("TEL:");
  13384. builder.InsertCell();
  13385. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13386. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13387. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13388. builder.ParagraphFormat.Style.Font.Bold = false;
  13389. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13390. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13391. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13392. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13393. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13394. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13395. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13396. builder.Write($"{item.HotelTel}");
  13397. builder.InsertCell();
  13398. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13399. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13400. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13401. builder.ParagraphFormat.Style.Font.Bold = false;
  13402. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13403. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13404. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13405. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13406. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13407. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13408. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13409. builder.Write($"FAX:");
  13410. builder.InsertCell();
  13411. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13412. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13413. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13414. builder.ParagraphFormat.Style.Font.Bold = false;
  13415. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13416. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13417. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13418. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13419. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13420. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13421. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13422. builder.Write($"{item.HotelFax}");
  13423. builder.EndRow();
  13424. #endregion
  13425. #region 第六行
  13426. builder.InsertCell();
  13427. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13428. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13429. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13430. builder.ParagraphFormat.Style.Font.Bold = false;
  13431. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13432. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13433. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13434. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13435. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13436. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13437. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13438. builder.Write("CHECK IN:");
  13439. builder.InsertCell();
  13440. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13441. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13442. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13443. builder.ParagraphFormat.Style.Font.Bold = false;
  13444. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13445. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13446. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13447. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13448. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13449. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13450. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13451. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  13452. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  13453. builder.Write($"{checkInStr}");
  13454. builder.InsertCell();
  13455. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13456. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13457. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13458. builder.ParagraphFormat.Style.Font.Bold = false;
  13459. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13460. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13461. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13462. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13463. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13464. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13465. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13466. builder.Write($"CHECK OUT:");
  13467. builder.InsertCell();
  13468. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13469. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13470. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13471. builder.ParagraphFormat.Style.Font.Bold = false;
  13472. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13473. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13474. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13475. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13476. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13477. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13478. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13479. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  13480. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  13481. builder.Write($"{checkOutStr}");
  13482. builder.EndRow();
  13483. #endregion
  13484. #region 第七行
  13485. builder.InsertCell();
  13486. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13487. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13488. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13489. builder.ParagraphFormat.Style.Font.Bold = false;
  13490. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13491. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13492. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13493. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13494. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13495. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13496. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13497. builder.Write($"GUEST NAME:");
  13498. builder.InsertCell();
  13499. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13500. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13501. builder.ParagraphFormat.Style.Font.Size = 8;
  13502. builder.ParagraphFormat.Style.Font.Bold = false;
  13503. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13504. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13505. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13506. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13507. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13508. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13509. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13510. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13511. builder.Write($"{item.GuestName}");
  13512. builder.InsertCell();
  13513. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13514. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13515. builder.InsertCell();
  13516. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13517. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13518. builder.EndRow();
  13519. #endregion
  13520. #region 第八行
  13521. builder.InsertCell();
  13522. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13523. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13524. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13525. builder.ParagraphFormat.Style.Font.Bold = false;
  13526. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13527. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13528. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13529. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13530. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13531. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13532. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13533. builder.Write($"ROOM TYPE:");
  13534. builder.InsertCell();
  13535. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13536. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13537. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13538. builder.ParagraphFormat.Style.Font.Bold = false;
  13539. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13540. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13541. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13542. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13543. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13544. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13545. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13546. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13547. builder.Write($"{item.RoomExplanation}");
  13548. builder.InsertCell();
  13549. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13550. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13551. builder.InsertCell();
  13552. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13553. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13554. builder.EndRow();
  13555. #endregion
  13556. #region 第九行
  13557. builder.InsertCell();
  13558. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13559. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13560. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13561. builder.ParagraphFormat.Style.Font.Bold = false;
  13562. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13563. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13564. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  13565. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  13566. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  13567. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  13568. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  13569. builder.Write($"NOTE:");
  13570. builder.InsertCell();
  13571. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13572. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  13573. builder.ParagraphFormat.Style.Font.Size = 7.5;
  13574. builder.ParagraphFormat.Style.Font.Bold = false;
  13575. builder.CellFormat.HorizontalMerge = CellMerge.None;
  13576. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  13577. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  13578. builder.CellFormat.HorizontalMerge = CellMerge.First;
  13579. 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.");
  13580. builder.InsertCell();
  13581. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  13582. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13583. builder.InsertCell();
  13584. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  13585. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  13586. builder.EndRow();
  13587. #endregion
  13588. builder.EndTable();
  13589. //换行
  13590. builder.Writeln("");
  13591. builder.Writeln("");
  13592. }
  13593. #region 获取文档中的所有表格 设置文字自适应
  13594. // 获取文档中的所有表格。
  13595. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13596. {
  13597. // 遍历表格中的所有行。
  13598. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13599. {
  13600. foreach (Cell cell in row.Cells)
  13601. {
  13602. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  13603. cellFormat.Width = 0;
  13604. }
  13605. }
  13606. }
  13607. #endregion
  13608. #region 设置页眉
  13609. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  13610. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  13611. if (System.IO.File.Exists(voucherHeaderPath))
  13612. {
  13613. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  13614. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  13615. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  13616. Shape shape = builder.InsertImage(imageBytes);
  13617. // 调整图片位置
  13618. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  13619. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  13620. shape.Top = 50; // 将图片距离页眉上边缘的距离
  13621. shape.Left = 0; // 将图片距离页面左边缘的距离
  13622. shape.Width = 81; // 设置图片宽度
  13623. shape.Height = 36; // 设置图片高度
  13624. }
  13625. //靠右
  13626. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  13627. //// 设置页脚上下边距
  13628. //builder.PageSetup.HeaderDistance = 42;
  13629. // 添加页眉线
  13630. Aspose.Words.Border borderHeader = null;
  13631. try
  13632. {
  13633. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  13634. }
  13635. catch (Exception e)
  13636. {
  13637. // TODO Auto-generated catch block
  13638. //e.printStackTrace();
  13639. }
  13640. borderHeader.Shadow = true;
  13641. borderHeader.DistanceFromText = 2;
  13642. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  13643. #endregion
  13644. }
  13645. catch (Exception ex)
  13646. {
  13647. }
  13648. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  13649. doc.Save(fileDir);
  13650. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  13651. return Ok(JsonView(true, "操作成功!", Url));
  13652. }
  13653. /// <summary>
  13654. /// 酒店预订
  13655. /// 生成 预定成本 Excel
  13656. /// </summary>
  13657. /// <param name="_dto"></param>
  13658. /// <returns></returns>
  13659. [HttpPost]
  13660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13661. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  13662. {
  13663. #region 参数验证
  13664. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  13665. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  13666. if (!vadalitorRes.IsValid)
  13667. {
  13668. var errors = new StringBuilder();
  13669. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  13670. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  13671. }
  13672. #region 团组操作权限验证 76 酒店预定模块
  13673. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13674. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13675. #endregion
  13676. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13677. #region 页面操作权限验证
  13678. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13679. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  13680. #endregion
  13681. #endregion
  13682. decimal _rate = 1.00M;
  13683. string _currency = string.Empty;
  13684. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  13685. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  13686. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  13687. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  13688. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  13689. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  13690. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  13691. if (_GroupCostParameter == null)
  13692. {
  13693. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  13694. bool isIntType = int.TryParse(_currency, out int currId);
  13695. if (isIntType)
  13696. {
  13697. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  13698. }
  13699. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  13700. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  13701. if (currInfo == null)
  13702. {
  13703. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  13704. }
  13705. else _rate = currInfo.Rate;
  13706. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  13707. {
  13708. _rate = _GroupCostParameter.Rate;
  13709. }
  13710. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  13711. string strFileName = "HotelStatement/";
  13712. string guestNames = ""; //格式Mr.xxx Ms.xxx
  13713. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  13714. var rateDatas = new List<dynamic>();
  13715. #region 数据处理
  13716. foreach (var item in hrDtas)
  13717. {
  13718. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  13719. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  13720. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  13721. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  13722. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  13723. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  13724. {
  13725. continue;
  13726. }
  13727. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  13728. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  13729. string singleRoomFeeStr = string.Empty,
  13730. doubleRoomFeeStr = string.Empty,
  13731. suiteRoomFeeStr = string.Empty,
  13732. otherRoomFeeStr = string.Empty,
  13733. payMoneyStr = string.Empty,
  13734. cardPriceStr = string.Empty;
  13735. if (roomCurr.Equals("CNY"))
  13736. {
  13737. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  13738. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  13739. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  13740. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  13741. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  13742. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  13743. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  13744. }
  13745. else
  13746. {
  13747. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  13748. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  13749. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  13750. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  13751. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  13752. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  13753. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13754. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13755. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13756. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  13757. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  13758. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  13759. if (ccpPaymentCurrency.Equals("CNY"))
  13760. {
  13761. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  13762. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  13763. }
  13764. else
  13765. {
  13766. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  13767. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  13768. }
  13769. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  13770. if (hotelcardPriceCurrency.Equals("CNY"))
  13771. {
  13772. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  13773. }
  13774. else
  13775. {
  13776. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  13777. }
  13778. }
  13779. string breakfastPriceStr = string.Empty,
  13780. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  13781. governmentRentStr = string.Empty,
  13782. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  13783. cityTaxStr = string.Empty,
  13784. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  13785. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  13786. if (!string.IsNullOrEmpty(breakfastCurrency1))
  13787. {
  13788. if (breakfastCurrency1.Equals("CNY"))
  13789. {
  13790. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  13791. }
  13792. else
  13793. {
  13794. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  13795. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  13796. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  13797. }
  13798. }
  13799. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  13800. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  13801. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  13802. {
  13803. if (governmentRentCurrency.Equals("CNY"))
  13804. {
  13805. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  13806. }
  13807. else
  13808. {
  13809. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  13810. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  13811. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  13812. }
  13813. }
  13814. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  13815. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  13816. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  13817. {
  13818. if (cityTaxStrCurrency1.Equals("CNY"))
  13819. {
  13820. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  13821. }
  13822. else
  13823. {
  13824. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  13825. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  13826. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  13827. }
  13828. }
  13829. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  13830. int payDId = roomInfo?.PayDId ?? 0;
  13831. pcfds.Add(new HotelReservations_PCFD_View()
  13832. {
  13833. City = item.City,
  13834. HotelName = item.HotelName,
  13835. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  13836. // SingleRoomCount = item.SingleRoomCount,
  13837. SingleRoomPrice = singleRoomFeeStr,
  13838. // DoubleRoomCount = item.DoubleRoomCount,
  13839. DoubleRoomPrice = doubleRoomFeeStr,
  13840. //SuiteRoomCount = item.SuiteRoomCount,
  13841. SuiteRoomPrice = suiteRoomFeeStr,
  13842. OtherRoomPrice = otherRoomFeeStr,
  13843. //OtherRoomCount = item.OtherRoomCount,
  13844. BreakfastPrice = breakfastPriceStr,
  13845. GovernmentRent = governmentRentStr,
  13846. CityTax = cityTaxStr,
  13847. RoomExplanation = item.RoomExplanation,
  13848. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  13849. PayTime = roomInfo?.ConsumptionDate,
  13850. BankNo = roomInfo?.BankNo,
  13851. PayMoney = payMoneyStr,
  13852. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  13853. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  13854. CardPrice = cardPriceStr,
  13855. Remark = ccpInfo.Remark
  13856. });
  13857. }
  13858. #endregion
  13859. //载入模板
  13860. WorkbookDesigner designer = new WorkbookDesigner();
  13861. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  13862. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  13863. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  13864. designer.SetDataSource("TourNo", groupInfo.TourCode);
  13865. var rateDatas1 = rateDatas.Distinct();
  13866. var rateStr = string.Empty;
  13867. foreach (var item in rateDatas1)
  13868. {
  13869. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  13870. }
  13871. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  13872. designer.SetDataSource("Opertor", userInfo.CnName);
  13873. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  13874. dt.TableName = "ViewMyHotelReservations";
  13875. designer.SetDataSource(dt);
  13876. designer.Process();
  13877. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  13878. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  13879. designer.Workbook.Save(serverPath);
  13880. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  13881. #region 删除指定行
  13882. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  13883. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  13884. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  13885. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  13886. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  13887. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  13888. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  13889. cssIndex = dt.Columns["CityTax"].Ordinal,
  13890. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  13891. remarkIndex = dt.Columns["Remark"].Ordinal;
  13892. //删除指定列
  13893. foreach (DataRow item in dt.Rows)
  13894. {
  13895. string singleStr = item["SingleRoomPrice"].ToString();
  13896. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  13897. if (containsDigitButNotZero1) singleDel = false;
  13898. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  13899. string doubleStr = item["DoubleRoomPrice"].ToString();
  13900. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  13901. if (containsDigitButNotZero2) doubleDel = false;
  13902. string suiteStr = item["SuiteRoomPrice"].ToString();
  13903. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  13904. if (containsDigitButNotZero3) suiteDel = false;
  13905. string otherStr = item["OtherRoomPrice"].ToString();
  13906. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  13907. if (containsDigitButNotZero4) otherDel = false;
  13908. string zcStr = item["BreakfastPrice"].ToString();
  13909. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  13910. if (containsDigitButNotZero5) zcDel = false;
  13911. string dsStr = item["GovernmentRent"].ToString();
  13912. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  13913. if (containsDigitButNotZero6) dsDel = false;
  13914. string cssStr = item["CityTax"].ToString();
  13915. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  13916. if (containsDigitButNotZero7) cssDel = false;
  13917. string cpStr = item["ConsumptionPatterns"].ToString();
  13918. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  13919. string remarkStr = item["Remark"].ToString();
  13920. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  13921. }
  13922. DeleteColumn(serverPath, remarkIndex, remarkDel);
  13923. DeleteColumn(serverPath, cpIndex, cpDel);
  13924. DeleteColumn(serverPath, dsIndex, dsDel);
  13925. DeleteColumn(serverPath, cssIndex, cssDel);
  13926. DeleteColumn(serverPath, zcIndex, zcDel);
  13927. DeleteColumn(serverPath, otherIndex, otherDel);
  13928. DeleteColumn(serverPath, suiteIndex, suiteDel);
  13929. DeleteColumn(serverPath, doubleIndex, doubleDel);
  13930. DeleteColumn(serverPath, singleIndex, singleDel);
  13931. #endregion
  13932. //只保留第一个表格
  13933. DeleteSheet(serverPath);
  13934. return Ok(JsonView(true, "操作成功", url = rst));
  13935. }
  13936. else
  13937. {
  13938. _currency = _GroupCostParameter.Currency;
  13939. bool isIntType = int.TryParse(_currency, out int currId);
  13940. if (isIntType)
  13941. {
  13942. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  13943. }
  13944. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  13945. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  13946. if (currInfo == null)
  13947. {
  13948. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  13949. }
  13950. if (!_currency.ToUpper().Equals("CNY"))
  13951. {
  13952. _rate = _GroupCostParameter.Rate;
  13953. }
  13954. _rate = currInfo.Rate;
  13955. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  13956. string strFileName = "HotelStatement/";
  13957. string guestNames = ""; //格式Mr.xxx Ms.xxx
  13958. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  13959. #region 数据处理
  13960. foreach (var item in hrDtas)
  13961. {
  13962. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  13963. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  13964. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  13965. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  13966. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  13967. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  13968. string singleRoomFeeStr = string.Empty,
  13969. doubleRoomFeeStr = string.Empty,
  13970. suiteRoomFeeStr = string.Empty,
  13971. otherRoomFeeStr = string.Empty,
  13972. payMoneyStr = string.Empty,
  13973. cardPriceStr = string.Empty;
  13974. if (roomCurr.Equals(_currency))
  13975. {
  13976. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  13977. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  13978. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  13979. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  13980. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  13981. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  13982. }
  13983. else
  13984. {
  13985. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  13986. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  13987. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  13988. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  13989. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  13990. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  13991. }
  13992. string breakfastPriceStr = string.Empty,
  13993. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  13994. governmentRentStr = string.Empty,
  13995. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  13996. cityTaxStrStr = string.Empty,
  13997. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  13998. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  13999. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  14000. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  14001. int payDId = roomInfo?.PayDId ?? 0;
  14002. pcfds.Add(new HotelReservations_PCFD_View()
  14003. {
  14004. City = item.City,
  14005. HotelName = item.HotelName,
  14006. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  14007. // SingleRoomCount = item.SingleRoomCount,
  14008. SingleRoomPrice = singleRoomFeeStr,
  14009. // DoubleRoomCount = item.DoubleRoomCount,
  14010. DoubleRoomPrice = doubleRoomFeeStr,
  14011. //SuiteRoomCount = item.SuiteRoomCount,
  14012. SuiteRoomPrice = suiteRoomFeeStr,
  14013. OtherRoomPrice = otherRoomFeeStr,
  14014. //OtherRoomCount = item.OtherRoomCount,
  14015. BreakfastPrice = breakfastPriceStr,
  14016. GovernmentRent = governmentRentStr,
  14017. CityTax = cityTaxStrStr,
  14018. RoomExplanation = item.RoomExplanation,
  14019. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  14020. PayTime = roomInfo?.ConsumptionDate,
  14021. BankNo = roomInfo?.BankNo,
  14022. PayMoney = payMoneyStr,
  14023. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  14024. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  14025. CardPrice = cardPriceStr,
  14026. Remark = ccpInfo.Remark
  14027. });
  14028. }
  14029. #endregion
  14030. //载入模板
  14031. WorkbookDesigner designer = new WorkbookDesigner();
  14032. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  14033. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  14034. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  14035. designer.SetDataSource("TourNo", groupInfo.TourCode);
  14036. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  14037. designer.SetDataSource("Opertor", userInfo.CnName);
  14038. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  14039. dt.TableName = "ViewMyHotelReservations";
  14040. designer.SetDataSource(dt);
  14041. designer.Process();
  14042. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  14043. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  14044. designer.Workbook.Save(serverPath);
  14045. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  14046. #region 删除指定行
  14047. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  14048. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  14049. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  14050. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  14051. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  14052. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  14053. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  14054. cssIndex = dt.Columns["CityTax"].Ordinal,
  14055. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  14056. remarkIndex = dt.Columns["Remark"].Ordinal;
  14057. //删除指定列
  14058. foreach (DataRow item in dt.Rows)
  14059. {
  14060. string singleStr = item["SingleRoomPrice"].ToString();
  14061. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  14062. if (containsDigitButNotZero1) singleDel = false;
  14063. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  14064. string doubleStr = item["DoubleRoomPrice"].ToString();
  14065. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  14066. if (containsDigitButNotZero2) doubleDel = false;
  14067. string suiteStr = item["SuiteRoomPrice"].ToString();
  14068. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  14069. if (containsDigitButNotZero3) suiteDel = false;
  14070. string otherStr = item["OtherRoomPrice"].ToString();
  14071. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  14072. if (containsDigitButNotZero4) otherDel = false;
  14073. string zcStr = item["BreakfastPrice"].ToString();
  14074. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  14075. if (containsDigitButNotZero5) zcDel = false;
  14076. string dsStr = item["GovernmentRent"].ToString();
  14077. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  14078. if (containsDigitButNotZero6) dsDel = false;
  14079. string cssStr = item["CityTax"].ToString();
  14080. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  14081. if (containsDigitButNotZero7) cssDel = false;
  14082. string cpStr = item["ConsumptionPatterns"].ToString();
  14083. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  14084. string remarkStr = item["Remark"].ToString();
  14085. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  14086. }
  14087. DeleteColumn(serverPath, remarkIndex, remarkDel);
  14088. DeleteColumn(serverPath, cpIndex, cpDel);
  14089. DeleteColumn(serverPath, dsIndex, dsDel);
  14090. DeleteColumn(serverPath, cssIndex, cssDel);
  14091. DeleteColumn(serverPath, zcIndex, zcDel);
  14092. DeleteColumn(serverPath, otherIndex, otherDel);
  14093. DeleteColumn(serverPath, suiteIndex, suiteDel);
  14094. DeleteColumn(serverPath, doubleIndex, doubleDel);
  14095. DeleteColumn(serverPath, singleIndex, singleDel);
  14096. #endregion
  14097. //只保留第一个表格
  14098. DeleteSheet(serverPath);
  14099. return Ok(JsonView(true, "操作成功", url = rst));
  14100. }
  14101. return Ok(JsonView(false));
  14102. }
  14103. /// <summary>
  14104. /// 删除指定列
  14105. /// </summary>
  14106. /// <param name="file"></param>
  14107. /// <param name="columnIndex"></param>
  14108. /// <param name="isDel"></param>
  14109. private void DeleteColumn(string file, int columnIndex, bool isDel)
  14110. {
  14111. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  14112. //wb.Save(file);
  14113. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  14114. if (sheet1 != null)
  14115. {
  14116. if (isDel)
  14117. {
  14118. Cells cells = sheet1.Cells;
  14119. cells.DeleteColumn(columnIndex);
  14120. }
  14121. }
  14122. wb.Save(file);
  14123. }
  14124. /// <summary>
  14125. /// 删除sheet
  14126. /// </summary>
  14127. /// <param name="file"></param>
  14128. /// <param name="sheetName"></param>
  14129. private void DeleteSheet(string file, string sheetName = "")
  14130. {
  14131. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  14132. //wb.Save(file);
  14133. List<string> sheets = new List<string>();
  14134. foreach (var item in wb.Worksheets)
  14135. {
  14136. sheets.Add(item.Name);
  14137. }
  14138. if (sheets.Count > 0)
  14139. {
  14140. sheets.RemoveAt(0);//不删除第一个sheet
  14141. foreach (var item in sheets)
  14142. {
  14143. wb.Worksheets.RemoveAt(item);
  14144. }
  14145. }
  14146. wb.Save(file);
  14147. }
  14148. /// <summary>
  14149. /// 酒店预订
  14150. /// 确认单
  14151. /// </summary>
  14152. /// <param name="_dto"></param>
  14153. /// <returns></returns>
  14154. [HttpPost]
  14155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14156. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  14157. {
  14158. try
  14159. {
  14160. #region 参数验证
  14161. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14162. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14163. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14164. #region 团组操作权限验证 76 酒店预定模块
  14165. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14166. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14167. #endregion
  14168. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14169. #region 页面操作权限验证
  14170. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14171. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14172. #endregion
  14173. #endregion
  14174. //团组信息
  14175. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  14176. //酒店数据
  14177. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  14178. if (listhoteldata.Count < 0)
  14179. {
  14180. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  14181. }
  14182. //利datatable存储
  14183. DataTable dt = new DataTable();
  14184. dt.Columns.Add("CheckInDate", typeof(string));
  14185. dt.Columns.Add("City", typeof(string));
  14186. dt.Columns.Add("Hotel", typeof(string));
  14187. dt.Columns.Add("Room", typeof(string));
  14188. for (int i = 0; i < listhoteldata.Count; i++)
  14189. {
  14190. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  14191. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  14192. while (dayStart < dayEnd)
  14193. {
  14194. string temp = "";
  14195. DataRow row = dt.NewRow();
  14196. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  14197. row["City"] = listhoteldata[i].City;
  14198. row["Hotel"] = listhoteldata[i].HotelName;
  14199. if (listhoteldata[i].SingleRoomCount > 0)
  14200. {
  14201. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  14202. }
  14203. if (listhoteldata[i].DoubleRoomCount > 0)
  14204. {
  14205. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  14206. }
  14207. if (listhoteldata[i].SuiteRoomCount > 0)
  14208. {
  14209. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  14210. }
  14211. if (listhoteldata[i].OtherRoomCount > 0)
  14212. {
  14213. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  14214. }
  14215. row["Room"] = temp;
  14216. dt.Rows.Add(row);
  14217. dayStart = dayStart.AddDays(1);
  14218. }
  14219. }
  14220. Dictionary<string, string> dic = new Dictionary<string, string>();
  14221. dic.Add("Dele", di.TeamName);
  14222. dic.Add("City", di.VisitCountry);
  14223. //模板路径
  14224. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  14225. //载入模板
  14226. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  14227. DocumentBuilder builder = new DocumentBuilder(doc);
  14228. foreach (var key in dic.Keys)
  14229. {
  14230. builder.MoveToBookmark(key);
  14231. builder.Write(dic[key]);
  14232. }
  14233. //获取word里所有表格
  14234. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14235. //获取所填表格的序数
  14236. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14237. var rowStart = tableOne.Rows[0]; //获取第1行
  14238. //循环赋值
  14239. for (int i = 0; i < dt.Rows.Count; i++)
  14240. {
  14241. builder.MoveToCell(0, i + 1, 0, 0);
  14242. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  14243. builder.MoveToCell(0, i + 1, 1, 0);
  14244. builder.Write(dt.Rows[i]["City"].ToString());
  14245. builder.MoveToCell(0, i + 1, 2, 0);
  14246. builder.Write(dt.Rows[i]["Hotel"].ToString());
  14247. builder.MoveToCell(0, i + 1, 3, 0);
  14248. builder.Write(dt.Rows[i]["Room"].ToString());
  14249. }
  14250. //删除多余行
  14251. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  14252. {
  14253. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  14254. }
  14255. string strFileName = di.TeamName + "酒店确认单.doc";
  14256. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  14257. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  14258. return Ok(JsonView(true, "成功", url));
  14259. }
  14260. catch (Exception ex)
  14261. {
  14262. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  14263. }
  14264. }
  14265. #endregion
  14266. #region 团组状态
  14267. /// <summary>
  14268. /// 团组状态列表 Page
  14269. /// </summary>
  14270. /// <param name="dto">团组列表请求dto</param>
  14271. /// <returns></returns>
  14272. [HttpPost]
  14273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14274. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  14275. {
  14276. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  14277. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  14278. {
  14279. string sqlWhere = string.Empty;
  14280. if (dto.IsSure == 0) //未完成
  14281. {
  14282. sqlWhere += string.Format(@" And IsSure = 0");
  14283. }
  14284. else if (dto.IsSure == 1) //已完成
  14285. {
  14286. sqlWhere += string.Format(@" And IsSure = 1");
  14287. }
  14288. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  14289. {
  14290. string tj = dto.SearchCriteria;
  14291. 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}%')",
  14292. tj, tj, tj, tj, tj);
  14293. }
  14294. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  14295. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  14296. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  14297. From (
  14298. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  14299. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  14300. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  14301. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  14302. From Grp_DelegationInfo gdi
  14303. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  14304. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  14305. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  14306. Where gdi.IsDel = 0 {0}
  14307. ) temp ", sqlWhere);
  14308. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  14309. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  14310. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  14311. }
  14312. else
  14313. {
  14314. return Ok(JsonView(false, "查询失败"));
  14315. }
  14316. }
  14317. /// <summary>
  14318. /// 团组状态
  14319. /// 设置操作完成
  14320. /// </summary>
  14321. /// <param name="dto">团组列表请求dto</param>
  14322. /// <returns></returns>
  14323. [HttpPost]
  14324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14325. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  14326. {
  14327. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  14328. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  14329. {
  14330. Id = dto.Id,
  14331. IsSure = 1
  14332. };
  14333. var result = await _sqlSugar.Updateable(_DelegationInfo)
  14334. .UpdateColumns(it => new { it.IsSure })
  14335. .WhereColumns(it => new { it.Id })
  14336. .ExecuteCommandAsync();
  14337. if (result > 0)
  14338. {
  14339. return Ok(JsonView(true, "操作完成!"));
  14340. }
  14341. return Ok(JsonView(false, "操作失败!"));
  14342. }
  14343. #endregion
  14344. #region 保险费用录入
  14345. /// <summary>
  14346. /// 根据团组Id查询保险费用列表
  14347. /// </summary>
  14348. /// <param name="dto"></param>
  14349. /// <returns></returns>
  14350. [HttpPost]
  14351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14352. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  14353. {
  14354. Result groupData = await _customersRep.CustomersByDiId(dto);
  14355. if (groupData.Code != 0)
  14356. {
  14357. return Ok(JsonView(false, groupData.Msg));
  14358. }
  14359. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14360. }
  14361. /// <summary>
  14362. /// 根据保险费用Id查询保险费用详细
  14363. /// </summary>
  14364. /// <param name="dto"></param>
  14365. /// <returns></returns>
  14366. [HttpPost]
  14367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14368. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  14369. {
  14370. try
  14371. {
  14372. Result groupData = await _customersRep.CustomersById(dto);
  14373. if (groupData.Code != 0)
  14374. {
  14375. return Ok(JsonView(false, groupData.Msg));
  14376. }
  14377. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14378. }
  14379. catch (Exception ex)
  14380. {
  14381. return Ok(JsonView(false, ex.Message));
  14382. }
  14383. }
  14384. /// <summary>
  14385. /// 保险费用录入页面初始化绑定
  14386. /// </summary>
  14387. /// <param name="dto"></param>
  14388. /// <returns></returns>
  14389. [HttpPost]
  14390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14391. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  14392. {
  14393. try
  14394. {
  14395. Result groupData = await _customersRep.CustomersInitialize(dto);
  14396. if (groupData.Code != 0)
  14397. {
  14398. return Ok(JsonView(false, groupData.Msg));
  14399. }
  14400. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14401. }
  14402. catch (Exception ex)
  14403. {
  14404. return Ok(JsonView(false, ex.Message));
  14405. }
  14406. }
  14407. /// <summary>
  14408. /// 保险费用操作(Status:1.新增,2.修改)
  14409. /// </summary>
  14410. /// <param name="dto"></param>
  14411. /// <returns></returns>
  14412. [HttpPost]
  14413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14414. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  14415. {
  14416. Result groupData = await _customersRep.OpCustomers(dto);
  14417. if (groupData.Code != 0)
  14418. {
  14419. return Ok(JsonView(false, groupData.Msg));
  14420. }
  14421. #region 应用推送
  14422. try
  14423. {
  14424. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  14425. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  14426. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  14427. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14428. //自动审核
  14429. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  14430. //2024-10-21 新增LZ UID
  14431. var userIds = new List<int>() { 21 };
  14432. string title = $"系统通知";
  14433. var diId = dto.DiId;
  14434. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14435. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14436. string content = "";
  14437. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14438. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  14439. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14440. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  14441. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  14442. }
  14443. catch (Exception ex)
  14444. {
  14445. }
  14446. #endregion
  14447. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14448. }
  14449. /// <summary>
  14450. /// 保险文件上传
  14451. /// </summary>
  14452. /// <param name="file"></param>
  14453. /// <returns></returns>
  14454. [HttpPost]
  14455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14456. public async Task<IActionResult> UploadCus(IFormFile file)
  14457. {
  14458. try
  14459. {
  14460. if (file != null)
  14461. {
  14462. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  14463. //文件名称
  14464. string projectFileName = file.FileName;
  14465. //上传的文件的路径
  14466. string filePath = "";
  14467. if (!Directory.Exists(fileDir))
  14468. {
  14469. Directory.CreateDirectory(fileDir);
  14470. }
  14471. //上传的文件的路径
  14472. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  14473. using (FileStream fs = System.IO.File.Create(filePath))
  14474. {
  14475. file.CopyTo(fs);
  14476. fs.Flush();
  14477. }
  14478. return Ok(JsonView(true, "上传成功!", projectFileName));
  14479. }
  14480. else
  14481. {
  14482. return Ok(JsonView(false, "上传失败!"));
  14483. }
  14484. }
  14485. catch (Exception ex)
  14486. {
  14487. return Ok(JsonView(false, "程序错误!"));
  14488. throw;
  14489. }
  14490. }
  14491. /// <summary>
  14492. /// 保险删除指定文件
  14493. /// </summary>
  14494. /// <param name="dto"></param>
  14495. /// <returns></returns>
  14496. [HttpPost]
  14497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14498. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  14499. {
  14500. try
  14501. {
  14502. string filePath = "";
  14503. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  14504. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  14505. //int id = 0;
  14506. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  14507. // 删除该文件
  14508. try
  14509. {
  14510. System.IO.File.Delete(filePath);
  14511. 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()
  14512. {
  14513. Attachment = "",
  14514. }).ExecuteCommandAsync();
  14515. if (result != 0)
  14516. {
  14517. return Ok(JsonView(true, "成功!"));
  14518. }
  14519. else
  14520. {
  14521. return Ok(JsonView(false, "失败!"));
  14522. }
  14523. }
  14524. catch (Exception)
  14525. {
  14526. 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()
  14527. {
  14528. Attachment = "",
  14529. }).ExecuteCommandAsync();
  14530. if (result != 0)
  14531. {
  14532. return Ok(JsonView(true, "成功!"));
  14533. }
  14534. else
  14535. {
  14536. return Ok(JsonView(false, "失败!"));
  14537. }
  14538. }
  14539. }
  14540. catch (Exception ex)
  14541. {
  14542. return Ok(JsonView(false, "程序错误!"));
  14543. throw;
  14544. }
  14545. }
  14546. /// <summary>
  14547. /// 保险费用操作(删除)
  14548. /// </summary>
  14549. /// <param name="dto"></param>
  14550. /// <returns></returns>
  14551. [HttpPost]
  14552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14553. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  14554. {
  14555. try
  14556. {
  14557. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  14558. if (!res)
  14559. {
  14560. return Ok(JsonView(false, "删除失败"));
  14561. }
  14562. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  14563. {
  14564. IsDel = 1,
  14565. DeleteUserId = dto.DeleteUserId,
  14566. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14567. }).ExecuteCommandAsync();
  14568. return Ok(JsonView(true, "删除成功!"));
  14569. }
  14570. catch (Exception ex)
  14571. {
  14572. return Ok(JsonView(false, "程序错误!"));
  14573. throw;
  14574. }
  14575. }
  14576. #endregion
  14577. #region 接团客户名单 PageId 104
  14578. /// <summary>
  14579. /// 接团客户名单
  14580. /// 迁移数据(慎用!)
  14581. /// </summary>
  14582. /// <param name="dto"></param>
  14583. /// <returns></returns>
  14584. [HttpPost]
  14585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14586. public async Task<IActionResult> PostTourClientListChange()
  14587. {
  14588. try
  14589. {
  14590. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  14591. //var groupClinetData1
  14592. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  14593. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  14594. int updateCount = 0;
  14595. if (oldOAClientList.Count > 0)
  14596. {
  14597. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  14598. _sqlSugar.BeginTran();
  14599. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  14600. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  14601. foreach (var item in oldOAClientList)
  14602. {
  14603. int comId = 0;
  14604. string format = "yyyy-MM-dd HH:mm:ss";
  14605. string data11 = "1990-01-01 00:00";
  14606. var data1 = IsValidDate(item.OPdate, format);
  14607. if (data1) data11 = item.OPdate;
  14608. //客户公司验证
  14609. if (!string.IsNullOrEmpty(item.Company))
  14610. {
  14611. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  14612. if (clientComInfo == null) // add
  14613. {
  14614. var addInfo = new Crm_CustomerCompany()
  14615. {
  14616. CompanyAbbreviation = "",
  14617. CompanyFullName = item.Company,
  14618. Address = "",
  14619. PostCodes = "",
  14620. LastedOpUserId = item.OPer,
  14621. LastedOpDt = Convert.ToDateTime(data11),
  14622. CreateUserId = item.OPer,
  14623. CreateTime = Convert.ToDateTime(data11),
  14624. IsDel = 0
  14625. };
  14626. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  14627. if (comId1 > 0) comId = comId1;
  14628. }
  14629. else comId = clientComInfo.Id;
  14630. }
  14631. //客户人员验证
  14632. int clientId = 0;
  14633. string name = item.LastName + item.Name;
  14634. if (!string.IsNullOrEmpty(name))
  14635. {
  14636. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  14637. if (clientInfo == null)
  14638. {
  14639. DateTime? dateTime = null;
  14640. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  14641. if (isDt) dateTime = birthDayDt;
  14642. var addInfo1 = new Crm_DeleClient()
  14643. {
  14644. CrmCompanyId = comId,
  14645. DiId = -1,
  14646. LastName = item.LastName,
  14647. FirstName = item.Name,
  14648. OldName = "",
  14649. Pinyin = item.Pinyin,
  14650. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  14651. Marriage = 0,
  14652. Phone = item.Phone,
  14653. Job = item.Job,
  14654. BirthDay = dateTime
  14655. };
  14656. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  14657. if (clientId1 > 0) clientId = clientId1;
  14658. }
  14659. else clientId = clientInfo.Id;
  14660. }
  14661. if (clientId < 1)
  14662. {
  14663. continue;
  14664. }
  14665. int airType = 0;
  14666. if (item.AirType == "超经舱") airType = 459;
  14667. else if (item.AirType == "公务舱") airType = 458;
  14668. else if (item.AirType == "经济舱") airType = 460;
  14669. else if (item.AirType == "其他") airType = 565;
  14670. else if (item.AirType == "头等舱") airType = 457;
  14671. var _TourClientListEntity = new Grp_TourClientList()
  14672. {
  14673. DiId = item.Diid,
  14674. ClientId = clientId,
  14675. CreateUserId = item.OPer,
  14676. CreateTime = Convert.ToDateTime(data11),
  14677. Remark = item.Remark,
  14678. IsDel = item.Isdel,
  14679. ShippingSpaceTypeId = airType,
  14680. ShippingSpaceSpecialNeeds = item.AirRemark,
  14681. HotelSpecialNeeds = item.RoomType
  14682. };
  14683. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  14684. if (_TourClientList > 0)
  14685. {
  14686. updateCount++;
  14687. }
  14688. }
  14689. _sqlSugar.CommitTran();
  14690. }
  14691. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  14692. }
  14693. catch (Exception ex)
  14694. {
  14695. _sqlSugar.RollbackTran();
  14696. return Ok(JsonView(false, ex.Message));
  14697. }
  14698. return Ok(JsonView(true));
  14699. }
  14700. private bool IsValidDate(string dateString, string format)
  14701. {
  14702. DateTime dateValue;
  14703. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  14704. return valid;
  14705. }
  14706. /// <summary>
  14707. /// 接团客户名单
  14708. /// 根据团组Id查询List
  14709. /// </summary>
  14710. /// <param name="dto"></param>
  14711. /// <returns></returns>
  14712. [HttpPost]
  14713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14714. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  14715. {
  14716. #region 参数验证
  14717. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  14718. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  14719. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  14720. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14721. #region 页面操作权限验证
  14722. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14723. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14724. #endregion
  14725. #endregion
  14726. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  14727. if (viewData.Code != 0)
  14728. {
  14729. return Ok(JsonView(false, viewData.Msg));
  14730. }
  14731. return Ok(JsonView(viewData.Data));
  14732. }
  14733. /// <summary>
  14734. /// 接团客户名单
  14735. /// 基础数据 Init
  14736. /// </summary>
  14737. /// <param name="_dto"></param>
  14738. /// <returns></returns>
  14739. [HttpPost]
  14740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14741. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  14742. {
  14743. #region 参数验证
  14744. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14745. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14746. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14747. #region 页面操作权限验证
  14748. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14749. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14750. #endregion
  14751. #endregion
  14752. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  14753. }
  14754. /// <summary>
  14755. /// 接团客户名单
  14756. /// 根据 Id查询 Details
  14757. /// </summary>
  14758. /// <param name="_dto"></param>
  14759. /// <returns></returns>
  14760. [HttpPost]
  14761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14762. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  14763. {
  14764. #region 参数验证
  14765. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14766. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14767. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  14768. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14769. #region 页面操作权限验证
  14770. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14771. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  14772. #endregion
  14773. #endregion
  14774. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  14775. if (viewData.Code != 0)
  14776. {
  14777. return Ok(JsonView(false, viewData.Msg));
  14778. }
  14779. return Ok(JsonView(viewData.Data));
  14780. }
  14781. /// <summary>
  14782. /// 接团客户名单
  14783. /// Add Or Edit
  14784. /// </summary>
  14785. /// <param name="_dto"></param>
  14786. /// <returns></returns>
  14787. [HttpPost]
  14788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14789. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  14790. {
  14791. #region 参数验证
  14792. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14793. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14794. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  14795. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14796. #region 页面操作权限验证
  14797. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14798. if (_dto.Id == 0) //添加
  14799. {
  14800. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14801. }
  14802. else if (_dto.Id >= 0) //修改
  14803. {
  14804. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  14805. }
  14806. #endregion
  14807. #endregion
  14808. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  14809. if (viewData.Code != 0)
  14810. {
  14811. return Ok(JsonView(false, viewData.Msg));
  14812. }
  14813. return Ok(JsonView(true));
  14814. }
  14815. /// <summary>
  14816. /// 接团客户名单
  14817. /// json字符串 AddMultiple(添加多个)
  14818. /// </summary>
  14819. /// <param name="_dto"></param>
  14820. /// <returns></returns>
  14821. [HttpPost]
  14822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14823. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  14824. {
  14825. #region 参数验证
  14826. string jsonLabel = _dto.JsonLabel;
  14827. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14828. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14829. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14830. #region 页面操作权限验证
  14831. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14832. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14833. #endregion
  14834. #endregion
  14835. var request = new TourClientListAddMultipleDto();
  14836. request.DiId = _dto.DiId;
  14837. request.UserId = _dto.UserId;
  14838. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  14839. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  14840. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  14841. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  14842. var infos = new List<TourClientListInfo>();
  14843. foreach (var data in datas)
  14844. {
  14845. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  14846. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  14847. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  14848. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  14849. {
  14850. continue;
  14851. }
  14852. infos.Add(new TourClientListInfo() {
  14853. IsAccompany = 1,
  14854. LastName = lastName,
  14855. FirstName = firstName,
  14856. Pinyin = lastNameEn + @"/" + firstNameEn,
  14857. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女")? 1:2,
  14858. CompanyFullName = data.CompanyFullName,
  14859. Job = data.Job
  14860. });
  14861. }
  14862. if (infos.Any())
  14863. {
  14864. var viewData = await _tourClientListRep._AddMultiple(request);
  14865. if (viewData.Code != 0)
  14866. {
  14867. return Ok(JsonView(false, viewData.Msg));
  14868. }
  14869. return Ok(JsonView(true));
  14870. }
  14871. return Ok(JsonView(false));
  14872. }
  14873. /// <summary>
  14874. /// 接团客户名单
  14875. /// AddMultiple(添加多个)
  14876. /// </summary>
  14877. /// <param name="_dto"></param>
  14878. /// <returns></returns>
  14879. [HttpPost]
  14880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14881. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  14882. {
  14883. #region 参数验证
  14884. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14885. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14886. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14887. #region 页面操作权限验证
  14888. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14889. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  14890. #endregion
  14891. #endregion
  14892. var viewData = await _tourClientListRep._AddMultiple(_dto);
  14893. if (viewData.Code != 0)
  14894. {
  14895. return Ok(JsonView(false, viewData.Msg));
  14896. }
  14897. return Ok(JsonView(true));
  14898. }
  14899. /// <summary>
  14900. /// 接团客户名单
  14901. /// Del
  14902. /// </summary>
  14903. /// <param name="_dto"></param>
  14904. /// <returns></returns>
  14905. [HttpPost]
  14906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14907. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  14908. {
  14909. #region 参数验证
  14910. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14911. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14912. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14913. #region 页面操作权限验证
  14914. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14915. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14916. #endregion
  14917. #endregion
  14918. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  14919. if (viewData.Code != 0)
  14920. {
  14921. return Ok(JsonView(false, viewData.Msg));
  14922. }
  14923. return Ok(JsonView(true));
  14924. }
  14925. /// <summary>
  14926. /// 接团客户名单
  14927. /// 文件下载 客户名单
  14928. /// </summary>
  14929. /// <param name="_dto"></param>
  14930. /// <returns></returns>
  14931. [HttpPost]
  14932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14933. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  14934. {
  14935. #region 参数验证
  14936. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  14937. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  14938. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  14939. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14940. #region 页面操作权限验证
  14941. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14942. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14943. #endregion
  14944. #endregion
  14945. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  14946. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  14947. From Grp_TourClientList tcl
  14948. Left Join
  14949. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  14950. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  14951. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  14952. From Crm_DeleClient dc
  14953. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  14954. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  14955. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  14956. Where dc.IsDel = 0) temp
  14957. On temp.DcId =tcl.ClientId
  14958. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  14959. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  14960. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  14961. //载入模板
  14962. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  14963. if (_dto.Language == 1)
  14964. {
  14965. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  14966. }
  14967. //载入模板
  14968. var doc = new Document(tempPath);
  14969. DocumentBuilder builder = new DocumentBuilder(doc);
  14970. //获取word里所有表格
  14971. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14972. //获取所填表格的序数
  14973. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14974. var rowStart = tableOne.Rows[0]; //获取第1行
  14975. if (_dto.Language == 0)
  14976. {
  14977. //循环赋值
  14978. for (int i = 0; i < DcList.Count; i++)
  14979. {
  14980. EncryptionProcessor.DecryptProperties(DcList[i]);
  14981. builder.MoveToCell(0, i + 1, 0, 0);
  14982. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  14983. builder.MoveToCell(0, i + 1, 1, 0);
  14984. int sex = DcList[i].Sex;
  14985. string sexStr = string.Empty;
  14986. if (sex == 0) sexStr = "男";
  14987. else if (sex == 1) sexStr = "女";
  14988. else sexStr = "未设置";
  14989. builder.Write(sexStr);
  14990. builder.MoveToCell(0, i + 1, 2, 0);
  14991. string birthDay = DcList[i].BirthDay;
  14992. string birthDayStr = string.Empty;
  14993. if (!string.IsNullOrEmpty(birthDay))
  14994. {
  14995. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  14996. }
  14997. builder.Write(birthDayStr);
  14998. builder.MoveToCell(0, i + 1, 3, 0);
  14999. string company = "";
  15000. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  15001. {
  15002. company = DcList[i].CompanyFullName.ToString();
  15003. }
  15004. builder.Write(company);
  15005. builder.MoveToCell(0, i + 1, 4, 0);
  15006. builder.Write(DcList[i].Job);
  15007. }
  15008. }
  15009. else if (_dto.Language == 1)
  15010. {
  15011. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  15012. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  15013. List<string> transArrayStr = new List<string>();
  15014. string transStrRes1 = "";
  15015. for (int i = 0; i < DcList.Count; i++)
  15016. {
  15017. var dc = DcList[i];
  15018. EncryptionProcessor.DecryptProperties(dc);
  15019. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  15020. if (dc.Job.Equals("暂无")) dc.Job = "-";
  15021. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  15022. if (DcList.Count - 1 == i) transStrRes1 += str1;
  15023. else transStrRes1 += $"{str1}|";
  15024. }
  15025. //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";
  15026. string transStrRes = "";
  15027. if (transStrRes1.Length > 0)
  15028. {
  15029. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  15030. }
  15031. //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
  15032. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  15033. //List<string> transArray = new List<string> { };
  15034. List<TranslateInfo> transArray = new List<TranslateInfo>();
  15035. if (transStrRes.Contains("|"))
  15036. {
  15037. string[] transArray1 = transStrRes.Split('|');
  15038. if (transArray1.Length > 0)
  15039. {
  15040. foreach (var item in transArray1)
  15041. {
  15042. if (item.Contains("&"))
  15043. {
  15044. string[] transArray2 = item.Split('&');
  15045. int index = 0;
  15046. string companyName = "", job = "";
  15047. if (transArray2.Length > 0)
  15048. {
  15049. bool success = int.TryParse(transArray2[0].Trim(), out index);
  15050. if (1 < transArray2.Length) companyName = transArray2[1];
  15051. if (2 < transArray2.Length) job = transArray2[2];
  15052. }
  15053. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  15054. }
  15055. }
  15056. }
  15057. }
  15058. //循环赋值
  15059. for (int i = 0; i < DcList.Count; i++)
  15060. {
  15061. string PYName = "";
  15062. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  15063. {
  15064. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  15065. string PY_First = DcList[i].Pinyin.Split('/')[1];
  15066. PYName = PY_First + " " + PY_Last;
  15067. }
  15068. else
  15069. {
  15070. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  15071. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  15072. PYName = PY_First + " " + PY_Last;
  15073. }
  15074. builder.MoveToCell(0, i + 1, 0, 0);
  15075. builder.Write(PYName);
  15076. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  15077. builder.MoveToCell(0, i + 1, 1, 0);
  15078. builder.Write(sex);
  15079. DateTime birthDt;
  15080. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  15081. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  15082. builder.MoveToCell(0, i + 1, 2, 0);
  15083. builder.Write(birthday);
  15084. string company = string.Empty, job = string.Empty;
  15085. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  15086. if (dcTransInfo != null)
  15087. {
  15088. company = dcTransInfo.CompanyName;
  15089. job = dcTransInfo.Job;
  15090. }
  15091. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  15092. {
  15093. //查询对照表
  15094. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  15095. if (tempCec != null)
  15096. {
  15097. company = tempCec.enName;
  15098. }
  15099. //翻译
  15100. else
  15101. {
  15102. }
  15103. }
  15104. builder.MoveToCell(0, i + 1, 3, 0);
  15105. builder.Write(company);
  15106. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  15107. {
  15108. //查询对照表
  15109. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  15110. if (tempPec != null)
  15111. {
  15112. job = tempPec.enName;
  15113. }
  15114. //翻译
  15115. else
  15116. {
  15117. }
  15118. }
  15119. builder.MoveToCell(0, i + 1, 4, 0);
  15120. builder.Write(job);
  15121. }
  15122. }
  15123. //删除多余行
  15124. while (tableOne.Rows.Count > DcList.Count + 1)
  15125. {
  15126. tableOne.Rows.RemoveAt(DcList.Count + 1);
  15127. }
  15128. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  15129. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  15130. doc.Save(fileDir);
  15131. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  15132. return Ok(JsonView(true, "操作成功!", Url));
  15133. }
  15134. private class TranslateInfo
  15135. {
  15136. public int Index { get; set; }
  15137. public string CompanyName { get; set; }
  15138. public string Job { get; set; }
  15139. }
  15140. #endregion
  15141. #region 团组倒推表
  15142. /// <summary>
  15143. /// 倒推表基础数据
  15144. /// Init
  15145. /// </summary>
  15146. /// <param name="dto"></param>
  15147. /// <returns></returns>
  15148. [HttpPost]
  15149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15150. public async Task<IActionResult> PostInvertedListInit()
  15151. {
  15152. var viewData = await _invertedListRep._Init();
  15153. if (viewData.Code != 0)
  15154. {
  15155. return Ok(JsonView(false, viewData.Msg));
  15156. }
  15157. return Ok(JsonView(viewData.Data));
  15158. }
  15159. /// <summary>
  15160. /// 倒推表
  15161. /// Info
  15162. /// </summary>
  15163. /// <param name="dto"></param>
  15164. /// <returns></returns>
  15165. [HttpPost]
  15166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15167. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  15168. {
  15169. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  15170. if (viewData.Code != 0)
  15171. {
  15172. return Ok(JsonView(false, viewData.Msg));
  15173. }
  15174. return Ok(JsonView(viewData.Data));
  15175. }
  15176. /// <summary>
  15177. /// 倒推表
  15178. /// Create
  15179. /// </summary>
  15180. /// <param name="dto"></param>
  15181. /// <returns></returns>
  15182. [HttpPost]
  15183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15184. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  15185. {
  15186. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  15187. if (viewData.Code != 0)
  15188. {
  15189. return Ok(JsonView(false, viewData.Msg));
  15190. }
  15191. return Ok(JsonView(viewData.Data));
  15192. }
  15193. /// <summary>
  15194. /// 倒推表
  15195. /// Update
  15196. /// </summary>
  15197. /// <param name="dto"></param>
  15198. /// <returns></returns>
  15199. [HttpPost]
  15200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15201. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  15202. {
  15203. var viewData = await _invertedListRep._Update(dto);
  15204. if (viewData.Code != 0)
  15205. {
  15206. return Ok(JsonView(false, viewData.Msg));
  15207. }
  15208. return Ok(JsonView(viewData.Data));
  15209. }
  15210. /// <summary>
  15211. /// 倒推表
  15212. /// File Download
  15213. /// </summary>
  15214. /// <param name="dto"></param>
  15215. /// <returns></returns>
  15216. [HttpPost]
  15217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15218. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  15219. {
  15220. var info2 = await _invertedListRep._Info(1, dto.DiId);
  15221. if (info2.Code != 0)
  15222. {
  15223. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  15224. }
  15225. var info1 = info2.Data as InvertedListInfoView;
  15226. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  15227. string teamName = "";
  15228. if (info != null) teamName = info.TeamName;
  15229. //载入模板
  15230. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  15231. DocumentBuilder builder = new DocumentBuilder(doc);
  15232. //利用键值对存放数据
  15233. Dictionary<string, string> dic = new Dictionary<string, string>();
  15234. dic.Add("TeamName", teamName);
  15235. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  15236. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  15237. dic.Add("BPRemark", info1.ApprovalDataRemark);
  15238. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  15239. dic.Add("SQRemark", info1.ApprovalRemark);
  15240. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  15241. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  15242. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  15243. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  15244. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  15245. dic.Add("QZRemark", info1.VisaInformationRemark);
  15246. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  15247. dic.Add("SQQZRemark", info1.SendVisaRemark);
  15248. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  15249. dic.Add("CQRemark", info1.IssueVisaRemark);
  15250. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  15251. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  15252. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  15253. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  15254. #region 填充word模板书签内容
  15255. foreach (var key in dic.Keys)
  15256. {
  15257. builder.MoveToBookmark(key);
  15258. builder.Write(dic[key]);
  15259. }
  15260. #endregion
  15261. var fileDir = AppSettingsHelper.Get("WordBasePath");
  15262. string fileName = $"{teamName}团出行准备流程表.doc";
  15263. string filePath = fileDir + $@"InvertedList/{fileName}";
  15264. doc.Save(filePath);
  15265. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  15266. return Ok(JsonView(true, "操作成功!", Url));
  15267. }
  15268. #endregion
  15269. #region 三公签证费用(签证费、代办费)
  15270. /// <summary>
  15271. /// 三公签证费用(签证费、代办费)
  15272. /// List
  15273. /// </summary>
  15274. /// <returns></returns>
  15275. [HttpPost]
  15276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15277. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  15278. {
  15279. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  15280. if (_view.Code != 0)
  15281. {
  15282. return Ok(JsonView(false, _view.Msg));
  15283. }
  15284. return Ok(JsonView(true, "操作成功!", _view.Data));
  15285. }
  15286. /// <summary>
  15287. /// 三公签证费用(签证费、代办费)
  15288. /// Add Or Update
  15289. /// </summary>
  15290. /// <returns></returns>
  15291. [HttpPost]
  15292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15293. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  15294. {
  15295. var _view = await _visaFeeInfoRep._Update(_dto);
  15296. if (_view.Code != 0)
  15297. {
  15298. return Ok(JsonView(false, _view.Msg));
  15299. }
  15300. return Ok(JsonView(true, _view.Msg));
  15301. }
  15302. #endregion
  15303. #region 酒店询价
  15304. /// <summary>
  15305. /// 酒店询价
  15306. /// Init
  15307. /// </summary>
  15308. /// <param name="dto"></param>
  15309. /// <returns></returns>
  15310. [HttpPost]
  15311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15312. public async Task<IActionResult> PostHotelInquiryInit()
  15313. {
  15314. var res = await _hotelInquiryRep._Init();
  15315. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15316. return Ok(JsonView(true, res.Msg, res.Data));
  15317. }
  15318. /// <summary>
  15319. /// 酒店询价
  15320. /// page Item
  15321. /// </summary>
  15322. /// <param name="_dto"></param>
  15323. /// <returns></returns>
  15324. [HttpPost]
  15325. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15326. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  15327. {
  15328. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  15329. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15330. var view = res.Data as PageDataViewBase;
  15331. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  15332. }
  15333. /// <summary>
  15334. /// 酒店询价
  15335. /// info
  15336. /// </summary>
  15337. /// <param name="_dto"></param>
  15338. /// <returns></returns>
  15339. [HttpPost]
  15340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15341. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  15342. {
  15343. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  15344. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15345. return Ok(JsonView(true, res.Msg, res.Data));
  15346. }
  15347. /// <summary>
  15348. /// 酒店询价
  15349. /// Add Or Edit
  15350. /// </summary>
  15351. /// <param name="_dto"></param>
  15352. /// <returns></returns>
  15353. [HttpPost]
  15354. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15355. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  15356. {
  15357. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  15358. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15359. return Ok(JsonView(true, res.Msg, res.Data));
  15360. }
  15361. /// <summary>
  15362. /// 酒店询价
  15363. /// Del
  15364. /// </summary>
  15365. /// <param name="_dto"></param>
  15366. /// <returns></returns>
  15367. [HttpPost]
  15368. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15369. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  15370. {
  15371. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  15372. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  15373. return Ok(JsonView(true, res.Msg, res.Data));
  15374. }
  15375. #endregion
  15376. #region 下载匹配op行程单
  15377. /// <summary>
  15378. /// 匹配op行程单
  15379. /// Init
  15380. /// </summary>
  15381. /// <param name="dto">团组列表请求dto</param>
  15382. /// <returns></returns>
  15383. [HttpPost]
  15384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15385. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  15386. {
  15387. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  15388. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  15389. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  15390. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  15391. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  15392. .Where(it => it.IsDel == 0)
  15393. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  15394. .OrderByDescending(it => it.CreateUserId)
  15395. .ToList();
  15396. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  15397. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  15398. var diids = groupInfos.Select(it => it.Id).ToList();
  15399. List<string> countrys = new List<string>();
  15400. foreach (var item in country)
  15401. {
  15402. var data = _groupRepository.FormartTeamName(item);
  15403. var dataArray = _groupRepository.GroupSplitCountry(data);
  15404. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  15405. }
  15406. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  15407. List<string> areaArray = new List<string>(); //GetGroupCityLine
  15408. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  15409. foreach (var item in areaItem)
  15410. {
  15411. string areaStr = item.Value;
  15412. if (!string.IsNullOrEmpty(areaStr))
  15413. {
  15414. string[] str1 = areaStr.Split("-");
  15415. if (str1.Length > 0)
  15416. {
  15417. areaArray.AddRange(str1);
  15418. }
  15419. }
  15420. }
  15421. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  15422. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  15423. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  15424. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  15425. .ToList();
  15426. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  15427. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  15428. .Where(it => countriesIds.Contains(it.Id))
  15429. .Select(it => new { it.Id, Name = it.Name_CN })
  15430. .ToList();
  15431. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  15432. .Select(it => it.TeamName).ToList();
  15433. stopwatch.Stop();
  15434. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  15435. }
  15436. ///// <summary>
  15437. ///// 匹配op行程单
  15438. ///// Init 查询区域数据
  15439. ///// </summary>
  15440. ///// <param name="dto">团组列表请求dto</param>
  15441. ///// <returns></returns>
  15442. //[HttpPost]
  15443. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15444. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  15445. //{
  15446. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  15447. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  15448. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  15449. // if (string.IsNullOrEmpty(countriesDataStr))
  15450. // {
  15451. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  15452. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  15453. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  15454. // }
  15455. // else
  15456. // {
  15457. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  15458. // }
  15459. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  15460. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  15461. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  15462. // List<dynamic> childList = new List<dynamic>();
  15463. // int parentId = dto.CountriesId;
  15464. // if (provinceData.Count > 1)
  15465. // {
  15466. // foreach (var item1 in provinceData)
  15467. // {
  15468. // List<dynamic> childList1 = new List<dynamic>();
  15469. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  15470. // foreach (var item2 in citiesData1)
  15471. // {
  15472. // List<dynamic> childList2 = new List<dynamic>();
  15473. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  15474. // foreach (var item3 in countiesData1)
  15475. // {
  15476. // childList2.Add(new
  15477. // {
  15478. // id = item3.Id,
  15479. // parentId = item2.Id,
  15480. // level = "district",
  15481. // name = item3.Name_CN,
  15482. // });
  15483. // }
  15484. // childList1.Add(new
  15485. // {
  15486. // id = item2.Id,
  15487. // parentId = item1.Id,
  15488. // level = "city",
  15489. // name = item2.Name_CN,
  15490. // childList = childList2
  15491. // });
  15492. // }
  15493. // childList.Add(new
  15494. // {
  15495. // id = item1.Id,
  15496. // parentId = parentId,
  15497. // level = "province",
  15498. // name = item1.Name_CN,
  15499. // childList = childList1
  15500. // });
  15501. // }
  15502. // //城市
  15503. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  15504. // foreach (var item2 in citiesData2)
  15505. // {
  15506. // List<dynamic> childList22 = new List<dynamic>();
  15507. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  15508. // foreach (var item3 in countiesData1)
  15509. // {
  15510. // childList22.Add(new
  15511. // {
  15512. // id = item3.Id,
  15513. // parentId = item2.Id,
  15514. // level = "district",
  15515. // name = item3.Name_CN,
  15516. // });
  15517. // }
  15518. // childList.Add(new
  15519. // {
  15520. // id = item2.Id,
  15521. // parentId = parentId,
  15522. // level = "city",
  15523. // name = item2.Name_CN,
  15524. // childList = childList22
  15525. // });
  15526. // }
  15527. // }
  15528. // else
  15529. // {
  15530. // foreach (var item2 in citiesData)
  15531. // {
  15532. // string cname = item2.Name_CN;
  15533. // List<dynamic> childList1 = new List<dynamic>();
  15534. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  15535. // foreach (var item3 in countiesData1)
  15536. // {
  15537. // childList1.Add(new
  15538. // {
  15539. // Id = item3.Id,
  15540. // parentId = item2.Id,
  15541. // level = "district",
  15542. // name = item3.Name_CN
  15543. // });
  15544. // }
  15545. // childList.Add(new
  15546. // {
  15547. // id = item2.Id,
  15548. // parentId = parentId,
  15549. // level = "city",
  15550. // name = item2.Name_CN,
  15551. // childList = childList1
  15552. // });
  15553. // }
  15554. // }
  15555. // stopwatch.Stop();
  15556. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  15557. //}
  15558. /// <summary>
  15559. /// 匹配op行程单
  15560. /// 接团信息列表 Page
  15561. /// </summary>
  15562. /// <param name="dto">团组列表请求dto</param>
  15563. /// <returns></returns>
  15564. [HttpPost]
  15565. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15566. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  15567. {
  15568. var swatch = new Stopwatch();
  15569. swatch.Start();
  15570. #region 参数验证
  15571. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15572. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  15573. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15574. #region 页面操作权限验证
  15575. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  15576. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  15577. #endregion
  15578. #endregion
  15579. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  15580. {
  15581. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  15582. string sqlWhere = "";
  15583. if (!string.IsNullOrEmpty(dto.Country))
  15584. {
  15585. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  15586. }
  15587. if (!string.IsNullOrEmpty(dto.Area))
  15588. {
  15589. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  15590. }
  15591. if (!string.IsNullOrEmpty(dto.TeamName))
  15592. {
  15593. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  15594. }
  15595. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  15596. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  15597. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  15598. swatch.Stop();
  15599. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  15600. }
  15601. else
  15602. {
  15603. return Ok(JsonView(false, "查询失败"));
  15604. }
  15605. }
  15606. /// <summary>
  15607. /// 匹配op行程单
  15608. /// 行程单下载
  15609. /// </summary>
  15610. /// <param name="dto">团组列表请求dto</param>
  15611. /// <returns></returns>
  15612. [HttpPost]
  15613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15614. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  15615. {
  15616. #region 参数验证
  15617. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  15618. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  15619. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15620. #region 页面操作权限验证
  15621. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  15622. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  15623. #endregion
  15624. #endregion
  15625. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  15626. {
  15627. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  15628. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  15629. }
  15630. else
  15631. {
  15632. return Ok(JsonView(false, "下载失败!"));
  15633. }
  15634. }
  15635. #endregion
  15636. #region 国家信息 数据 注释
  15637. //[HttpPost]
  15638. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  15639. //{
  15640. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  15641. // foreach (var item in dto)
  15642. // {
  15643. // infos.Add(new Grp_GroupsTaskAssignment()
  15644. // {
  15645. // DIId = item,
  15646. // CTId = 82,
  15647. // UId = 248,
  15648. // IsEnable = 1,
  15649. // CreateUserId = 233,
  15650. // CreateTime = DateTime.Now,
  15651. // IsDel = 0
  15652. // });
  15653. // infos.Add(new Grp_GroupsTaskAssignment()
  15654. // {
  15655. // DIId = item,
  15656. // CTId = 82,
  15657. // UId = 286,
  15658. // IsEnable = 1,
  15659. // CreateUserId = 233,
  15660. // CreateTime = DateTime.Now,
  15661. // IsDel = 0
  15662. // });
  15663. // }
  15664. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  15665. // return Ok("操作成功");
  15666. //}
  15667. //public class paramJsonDto
  15668. //{
  15669. // public List<CountriesInfo> str { get; set; }
  15670. //}
  15671. //[HttpPost]
  15672. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  15673. //{
  15674. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  15675. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  15676. // List<Sys_Cities> cities = new List<Sys_Cities>();
  15677. // List<Sys_Cities> districts = new List<Sys_Cities>();
  15678. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  15679. // _sqlSugar.BeginTran();
  15680. // int countitiesIndex = 0;
  15681. // foreach (var item in dto.str)
  15682. // {
  15683. // dynamic data = item.c;
  15684. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  15685. // if (data != null)
  15686. // {
  15687. // countitiesIndex++;
  15688. // foreach (var item1 in data)
  15689. // {
  15690. // string cnname = item1.cn;
  15691. // string enname = item1.en;
  15692. // Sys_Cities provinceInfo = new Sys_Cities()
  15693. // {
  15694. // CountriesId = countriesId,
  15695. // Name_CN = cnname,
  15696. // Name_EN = enname,
  15697. // ParentId = 0,
  15698. // IsCapital = 1,
  15699. // CreateUserId = 208,
  15700. // CreateTime = DateTime.Now,
  15701. // IsDel = 0
  15702. // };
  15703. // if (item1.lv == "province") //省份
  15704. // {
  15705. // provinceInfo.Level = 1;
  15706. // int provinceId = 0;
  15707. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  15708. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  15709. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  15710. // var data1 = item1.c;
  15711. // foreach (var item2 in data1)
  15712. // {
  15713. // if (item2.lv == "city")
  15714. // {
  15715. // string citycnname = item2.cn;
  15716. // string cityenname = item2.en;
  15717. // Sys_Cities cityInfo = new Sys_Cities()
  15718. // {
  15719. // CountriesId = countriesId,
  15720. // ParentId = provinceId,
  15721. // Level = 2,
  15722. // Name_CN = citycnname,
  15723. // Name_EN = cityenname,
  15724. // IsCapital = 1,
  15725. // CreateUserId = 208,
  15726. // CreateTime = DateTime.Now,
  15727. // IsDel = 0
  15728. // };
  15729. // if (item2.c != null)
  15730. // {
  15731. // int cityId = 0;
  15732. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  15733. // if (citiesInfo != null) cityId = citiesInfo.Id;
  15734. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  15735. // foreach (var item3 in item2.c)
  15736. // {
  15737. // if (item3.lv == "district")
  15738. // {
  15739. // var districtInfo = new Sys_Cities()
  15740. // {
  15741. // CountriesId = countriesId,
  15742. // Name_CN = item3.cn,
  15743. // Name_EN = item3.en,
  15744. // Level = 3,
  15745. // ParentId = cityId,
  15746. // IsCapital = 1,
  15747. // CreateUserId = 208,
  15748. // CreateTime = DateTime.Now,
  15749. // IsDel = 0
  15750. // };
  15751. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  15752. // //{
  15753. // districts.Add(districtInfo);
  15754. // //}
  15755. // }
  15756. // }
  15757. // }
  15758. // else
  15759. // {
  15760. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  15761. // //{
  15762. // cities.Add(cityInfo);
  15763. // //}
  15764. // }
  15765. // }
  15766. // }
  15767. // }
  15768. // else if (item1.lv == "city")//城市
  15769. // {
  15770. // provinceInfo.Level = 2;
  15771. // if (item1.c != null)
  15772. // {
  15773. // int cityId = 0;
  15774. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  15775. // if (citiesInfo != null) cityId = citiesInfo.Id;
  15776. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  15777. // foreach (var item3 in item1.c)
  15778. // {
  15779. // if (item3.lv == "district")
  15780. // {
  15781. // var districtInfo = new Sys_Cities()
  15782. // {
  15783. // CountriesId = countriesId,
  15784. // Name_CN = item3.cn,
  15785. // Name_EN = item3.en,
  15786. // Level = 3,
  15787. // ParentId = cityId,
  15788. // IsCapital = 1,
  15789. // CreateUserId = 208,
  15790. // CreateTime = DateTime.Now,
  15791. // IsDel = 0
  15792. // };
  15793. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  15794. // //{
  15795. // districts.Add(districtInfo);
  15796. // //}
  15797. // }
  15798. // }
  15799. // }
  15800. // else
  15801. // {
  15802. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  15803. // //{
  15804. // cities.Add(provinceInfo);
  15805. // //}
  15806. // }
  15807. // }
  15808. // }
  15809. // }
  15810. // }
  15811. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  15812. // cities = cities.Distinct().ToList();
  15813. // districts = districts.Distinct().ToList();
  15814. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  15815. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  15816. // cities.AddRange(districts);
  15817. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  15818. // //_sqlSugar.RollbackTran();
  15819. // _sqlSugar.CommitTran();
  15820. // return Ok(JsonView(false, "操作成功!"));
  15821. //}
  15822. //[HttpPost]
  15823. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  15824. //{
  15825. // List<CountitiesInfo> infos = dto.MyProperty;
  15826. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  15827. // _sqlSugar.BeginTran();
  15828. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  15829. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  15830. // foreach (var item in infos)
  15831. // {
  15832. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  15833. // if (countryInfo != null)
  15834. // {
  15835. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  15836. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  15837. // if (cityInfo1 != null)
  15838. // {
  15839. // cityInfo1.IsCapital = 0;
  15840. // cityInfos.Add(cityInfo1);
  15841. // }
  15842. // }
  15843. // }
  15844. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  15845. // .UpdateColumns(it => it.IsCapital)
  15846. // .WhereColumns(it => it.Id)
  15847. // .ExecuteCommand();
  15848. // //_sqlSugar.RollbackTran();
  15849. // _sqlSugar.CommitTran();
  15850. // return Ok(JsonView(false, "操作成功!"));
  15851. //}
  15852. //public class CounrtiesDto
  15853. //{
  15854. // public List<CountitiesInfo> MyProperty { get; set; }
  15855. //}
  15856. //public class CountitiesInfo
  15857. //{
  15858. // /// <summary>
  15859. // /// 圣约翰
  15860. // /// </summary>
  15861. // public string capital_name_chinese { get; set; }
  15862. // /// <summary>
  15863. // ///
  15864. // /// </summary>
  15865. // public string capital_name { get; set; }
  15866. // /// <summary>
  15867. // ///
  15868. // /// </summary>
  15869. // public string country_type { get; set; }
  15870. // /// <summary>
  15871. // /// 安提瓜和巴布达
  15872. // /// </summary>
  15873. // public string country_name_chinese { get; set; }
  15874. // /// <summary>
  15875. // /// 安提瓜和巴布达
  15876. // /// </summary>
  15877. // public string country_name_chinese_short { get; set; }
  15878. // /// <summary>
  15879. // /// 安提瓜和巴布达
  15880. // /// </summary>
  15881. // public string country_name_chinese_UN { get; set; }
  15882. // /// <summary>
  15883. // ///
  15884. // /// </summary>
  15885. // public string country_name_english_abbreviation { get; set; }
  15886. // /// <summary>
  15887. // ///
  15888. // /// </summary>
  15889. // public string country_name_english_formal { get; set; }
  15890. // /// <summary>
  15891. // ///
  15892. // /// </summary>
  15893. // public string country_name_english_UN { get; set; }
  15894. // /// <summary>
  15895. // ///
  15896. // /// </summary>
  15897. // public string continent_name { get; set; }
  15898. // /// <summary>
  15899. // ///
  15900. // /// </summary>
  15901. // public string subregion_name { get; set; }
  15902. // /// <summary>
  15903. // ///
  15904. // /// </summary>
  15905. // public string country_code2 { get; set; }
  15906. // /// <summary>
  15907. // ///
  15908. // /// </summary>
  15909. // public string country_code3 { get; set; }
  15910. // /// <summary>
  15911. // ///
  15912. // /// </summary>
  15913. // public string phone_code { get; set; }
  15914. //}
  15915. //public class CountriesInfo : BasicInfo
  15916. //{
  15917. // public List<CitiesInfo> c { get; set; }
  15918. //}
  15919. //public class CitiesInfo : BasicInfo
  15920. //{
  15921. // public List<AreaInfo> c { get; set; }
  15922. //}
  15923. //public class AreaInfo : BasicInfo
  15924. //{
  15925. // public List<AreaInfo> c { get; set; }
  15926. //}
  15927. //public class BasicInfo
  15928. //{
  15929. // public string code { get; set; }
  15930. // public string cn { get; set; }
  15931. // public string lv { get; set; }
  15932. // public string en { get; set; }
  15933. //}
  15934. #endregion
  15935. #region 查看邀请方
  15936. /// <summary>
  15937. /// 查看邀请方
  15938. /// 邀请方信息 Init
  15939. /// </summary>
  15940. /// <param name="dto"></param>
  15941. /// <returns></returns>
  15942. [HttpPost]
  15943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15944. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  15945. {
  15946. string sqlWhere = string.Empty;
  15947. if (!string.IsNullOrEmpty(dto.Search))
  15948. {
  15949. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  15950. }
  15951. string sql = string.Format($@"Select
  15952. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  15953. Id,
  15954. UnitName
  15955. From Res_InvitationOfficialActivityData
  15956. Where IsDel = 0
  15957. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  15958. RefAsync<int> total = 0;
  15959. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15960. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  15961. }
  15962. /// <summary>
  15963. /// 查看邀请方
  15964. /// 国家信息 Init
  15965. /// </summary>
  15966. /// <param name="dto"></param>
  15967. /// <returns></returns>
  15968. [HttpPost]
  15969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15970. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  15971. {
  15972. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  15973. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  15974. var diids = groupInfos.Select(it => it.Id).ToList();
  15975. List<string> countrys = new List<string>();
  15976. foreach (var item in country)
  15977. {
  15978. var data = _groupRepository.FormartTeamName(item);
  15979. var dataArray = _groupRepository.GroupSplitCountry(data);
  15980. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  15981. }
  15982. countrys = countrys.Distinct().ToList();
  15983. for (int i = 0; i < countrys.Count; i++)
  15984. {
  15985. string item = countrys[i];
  15986. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  15987. {
  15988. countrys.Remove(item);
  15989. i--;
  15990. }
  15991. }
  15992. RefAsync<int> total = 0;
  15993. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  15994. .Where(it => countrys.Contains(it.Name_CN))
  15995. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  15996. .Select(it => new { id = it.Id, name = it.Name_CN })
  15997. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  15998. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  15999. }
  16000. /// <summary>
  16001. /// 查看邀请方
  16002. /// 城市信息 Init
  16003. /// </summary>
  16004. /// <param name="dto"></param>
  16005. /// <returns></returns>
  16006. [HttpPost]
  16007. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16008. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  16009. {
  16010. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  16011. RefAsync<int> total = 0;
  16012. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  16013. .Where(it => it.CountriesId == dto.CountiesId)
  16014. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  16015. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  16016. .Select(it => new { id = it.Id, name = it.Name_CN })
  16017. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  16018. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  16019. }
  16020. /// <summary>
  16021. /// 查看邀请方
  16022. /// 团组名称 Init
  16023. /// </summary>
  16024. /// <param name="dto"></param>
  16025. /// <returns></returns>
  16026. [HttpPost]
  16027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16028. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  16029. {
  16030. var watch = new Stopwatch();
  16031. watch.Start();
  16032. RefAsync<int> total = 0;
  16033. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  16034. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  16035. .Where((oa, di) => oa.IsDel == 0)
  16036. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  16037. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  16038. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  16039. .Distinct()
  16040. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  16041. watch.Stop();
  16042. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  16043. }
  16044. /// <summary>
  16045. /// 查看邀请方
  16046. /// 团组 & 邀请方信息
  16047. /// </summary>
  16048. /// <param name="dto"></param>
  16049. /// <returns></returns>
  16050. [HttpPost]
  16051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16052. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  16053. {
  16054. var watch = new Stopwatch();
  16055. watch.Start();
  16056. RefAsync<int> total = 0;
  16057. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  16058. .AS("Grp_DelegationInfo")
  16059. .Includes(x => x.InvitingInfos)
  16060. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  16061. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  16062. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  16063. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  16064. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  16065. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  16066. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  16067. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  16068. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  16069. infos.ForEach(x =>
  16070. {
  16071. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  16072. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  16073. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  16074. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  16075. });
  16076. watch.Stop();
  16077. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  16078. }
  16079. #endregion
  16080. #region 报批行程
  16081. /// <summary>
  16082. /// 报批行程初始化
  16083. /// </summary>
  16084. /// <param name="dto"></param>
  16085. /// <returns></returns>
  16086. [HttpPost]
  16087. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  16088. {
  16089. const int chiNumber = 5;
  16090. var jw = JsonView(false);
  16091. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  16092. var group = groupList.First();
  16093. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  16094. group = groupList.First(x => x.Id == diid);
  16095. if (group == null)
  16096. {
  16097. jw.Msg = "暂无团组!";
  16098. return Ok(jw);
  16099. }
  16100. var data = new
  16101. {
  16102. groupList = groupList.Select(x => new
  16103. {
  16104. x.TeamName,
  16105. x.Id
  16106. }),
  16107. content = new ArrayList(),
  16108. groupInfo = new
  16109. {
  16110. group.VisitDays,
  16111. group.TourCode,
  16112. group.VisitPNumber,
  16113. group.TeamName,
  16114. group.Id,
  16115. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  16116. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  16117. },
  16118. };
  16119. var resultArr = new ArrayList();
  16120. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  16121. if (content.Count == 0)
  16122. {
  16123. var stay = "-";
  16124. var cityPath = "-";
  16125. //添加城市路径以及住宿地
  16126. //黑屏代码数据
  16127. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  16128. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  16129. {
  16130. jw = JsonView(true, "黑屏代码有误!", data);
  16131. return Ok(jw);
  16132. }
  16133. foreach (DataRow row in dtBlack.Rows)
  16134. {
  16135. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  16136. {
  16137. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  16138. return Ok(jw);
  16139. }
  16140. }
  16141. //黑屏代码获取时间区间
  16142. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  16143. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  16144. _sqlSugar.BeginTran();
  16145. for (int i = 0; i < timeArr.Count; i++)
  16146. {
  16147. stay = "-";
  16148. cityPath = "-";
  16149. DateTime NewData = DateTime.Parse(timeArr[i]);
  16150. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  16151. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  16152. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  16153. if (tbSelect.Length > 0)
  16154. {
  16155. List<string> threeCodeStr = new List<string>();
  16156. foreach (var item in tbSelect)
  16157. {
  16158. var threeCode = item["Three"].ToString() ?? "";
  16159. if (threeCode.Length == 6)
  16160. {
  16161. var start = threeCode.Substring(0, 3);
  16162. var end = threeCode.Substring(3, 3);
  16163. if (threeCodeStr.Count == 0)
  16164. {
  16165. threeCodeStr.Add(start);
  16166. threeCodeStr.Add(end);
  16167. }
  16168. else
  16169. {
  16170. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  16171. {
  16172. threeCodeStr.Add(end);
  16173. }
  16174. else
  16175. {
  16176. threeCodeStr.Add(start);
  16177. threeCodeStr.Add(end);
  16178. }
  16179. }
  16180. }
  16181. }
  16182. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  16183. var last = threeCodeStr.Last();
  16184. foreach (var item in threeCodeStr)
  16185. {
  16186. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  16187. if (item.Equals(last))
  16188. {
  16189. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  16190. }
  16191. }
  16192. cityPath = cityPath.Trim('-');
  16193. }
  16194. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  16195. appro.Diid = diid ?? -1;
  16196. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  16197. appro.Id = thisId;
  16198. appro.CreateUserId = dto.UserId;
  16199. appro.CreateTime = DateTime.Now;
  16200. content.Add(appro);
  16201. }
  16202. _sqlSugar.CommitTran();
  16203. }
  16204. foreach (var x in content)
  16205. {
  16206. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  16207. if (chiList.Count < chiNumber)
  16208. {
  16209. for (int i = chiList.Count; i < chiNumber; i++)
  16210. {
  16211. chiList.Add(new Grp_ApprovalTravelDetails());
  16212. }
  16213. }
  16214. resultArr.Add(new
  16215. {
  16216. x.Id,
  16217. x.Date,
  16218. x.Diid,
  16219. chiList = chiList.Select(x1 => new
  16220. {
  16221. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  16222. x1.Details,
  16223. x1.ParentId,
  16224. x1.Id
  16225. })
  16226. });
  16227. }
  16228. data = data with
  16229. {
  16230. content = resultArr,
  16231. };
  16232. jw = JsonView(true, "获取成功!", data);
  16233. return Ok(jw);
  16234. }
  16235. /// <summary>
  16236. /// 报批行程删除
  16237. /// </summary>
  16238. /// <param name="dto"></param>
  16239. /// <returns></returns>
  16240. [HttpPost]
  16241. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  16242. {
  16243. var jw = JsonView(false);
  16244. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  16245. if (group == null)
  16246. {
  16247. jw.Msg = "团组参数有误!";
  16248. return Ok(jw);
  16249. }
  16250. try
  16251. {
  16252. _sqlSugar.BeginTran();
  16253. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  16254. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  16255. {
  16256. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  16257. DeleteUserId = dto.uesrId,
  16258. IsDel = 1
  16259. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  16260. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  16261. {
  16262. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  16263. DeleteUserId = dto.uesrId,
  16264. IsDel = 1
  16265. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  16266. _sqlSugar.CommitTran();
  16267. jw = JsonView(true, "删除成功");
  16268. }
  16269. catch (Exception ex)
  16270. {
  16271. jw = JsonView(false, ex.Message);
  16272. }
  16273. return Ok(jw);
  16274. }
  16275. /// <summary>
  16276. /// 报批行程保存
  16277. /// </summary>
  16278. /// <param name="dto"></param>
  16279. /// <returns></returns>
  16280. [HttpPost]
  16281. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  16282. {
  16283. var jw = JsonView(false);
  16284. var Find = dto.Arr.Find(x => x.id == 0);
  16285. if (Find != null)
  16286. {
  16287. jw.Msg = "生成的ID为0!";
  16288. return Ok(jw);
  16289. }
  16290. foreach (var item in dto.Arr)
  16291. {
  16292. foreach (var chi in item.chiList)
  16293. {
  16294. if (chi.parentId == 0)
  16295. {
  16296. chi.parentId = item.id;
  16297. }
  16298. }
  16299. }
  16300. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  16301. _sqlSugar.BeginTran();
  16302. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  16303. {
  16304. var parentIds = dto.Arr.Select(x => x.id).ToList();
  16305. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  16306. {
  16307. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  16308. DeleteUserId = dto.UserId,
  16309. IsDel = 1
  16310. }).ExecuteCommand();
  16311. }
  16312. try
  16313. {
  16314. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  16315. {
  16316. CreateTime = DateTime.Now,
  16317. CreateUserId = dto.UserId,
  16318. Details = x.details,
  16319. ParentId = x.parentId,
  16320. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  16321. Remark = "",
  16322. IsDel = 0
  16323. }).ToList()).ExecuteCommand();
  16324. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  16325. {
  16326. Id = x.id,
  16327. Details = x.details,
  16328. ParentId = x.parentId,
  16329. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  16330. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  16331. {
  16332. Details = x.Details,
  16333. ParentId = x.ParentId,
  16334. Time = x.Time
  16335. }).ExecuteCommand();
  16336. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  16337. {
  16338. Id = x.id,
  16339. Date = x.date,
  16340. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  16341. {
  16342. Date = x.Date
  16343. }).ExecuteCommand();
  16344. _sqlSugar.CommitTran();
  16345. jw = JsonView(true, "保存成功!");
  16346. }
  16347. catch (Exception ex)
  16348. {
  16349. _sqlSugar.RollbackTran();
  16350. jw = JsonView(false, "保存失败!" + ex.Message);
  16351. }
  16352. return Ok(jw);
  16353. }
  16354. /// <summary>
  16355. /// 报批行程生成
  16356. /// </summary>
  16357. /// <param name="dto"></param>
  16358. /// <returns></returns>
  16359. [HttpPost]
  16360. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  16361. {
  16362. var jw = JsonView(false);
  16363. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  16364. if (group == null)
  16365. {
  16366. jw.Msg = "暂无该团组!";
  16367. return Ok(jw);
  16368. }
  16369. //黑屏代码数据
  16370. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  16371. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  16372. {
  16373. jw.Msg = "黑屏代码有误!";
  16374. return Ok(jw);
  16375. }
  16376. foreach (DataRow row in dtBlack.Rows)
  16377. {
  16378. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  16379. {
  16380. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  16381. return Ok(jw);
  16382. }
  16383. }
  16384. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  16385. var resultArr = new ArrayList();
  16386. if (officialActivitiesArr.Count == 0)
  16387. {
  16388. jw.Msg = "暂无公务出访信息!";
  16389. return Ok(jw);
  16390. }
  16391. try
  16392. {
  16393. _sqlSugar.BeginTran();
  16394. DeleteApprovalJourney(new
  16395. Domain.Dtos.Groups.DeleteApprovalJourney
  16396. {
  16397. Diid = dto.Diid,
  16398. uesrId = dto.Userid
  16399. });
  16400. var stay = "-";
  16401. var cityPath = "-";
  16402. //添加城市路径以及住宿地
  16403. //黑屏代码获取时间区间
  16404. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  16405. var empty = "【未收入该三字码!请机票同事录入】";
  16406. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  16407. for (int i = 0; i < timeArr.Count; i++)
  16408. {
  16409. stay = "-";
  16410. cityPath = "-";
  16411. var chiarr = new List<Grp_ApprovalTravelDetails>();
  16412. DateTime NewData = DateTime.Parse(timeArr[i]);
  16413. 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();
  16414. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  16415. if (tbSelect.Length > 0)
  16416. {
  16417. List<string> threeCodeStr = new List<string>();
  16418. bool isTrade = false;
  16419. string trip = string.Empty;
  16420. var rowLast = tbSelect.Last();
  16421. var rowFirst = tbSelect.First();
  16422. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  16423. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  16424. var takeOffTime = DateTime.Parse(timeArr[i]);
  16425. var fallToTime = DateTime.Parse(timeArr[i]);
  16426. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  16427. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  16428. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  16429. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  16430. foreach (var item in tbSelect)
  16431. {
  16432. var start = string.Empty;
  16433. var end = string.Empty;
  16434. var threeCode = item["Three"].ToString() ?? "";
  16435. if (threeCode.Length == 6)
  16436. {
  16437. start = threeCode.Substring(0, 3);
  16438. end = threeCode.Substring(3, 3);
  16439. if (threeCodeStr.Count == 0)
  16440. {
  16441. threeCodeStr.Add(start);
  16442. threeCodeStr.Add(end);
  16443. }
  16444. else
  16445. {
  16446. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  16447. {
  16448. threeCodeStr.Add(end);
  16449. }
  16450. else
  16451. {
  16452. threeCodeStr.Add(start);
  16453. threeCodeStr.Add(end);
  16454. }
  16455. }
  16456. }
  16457. //处理机票信息
  16458. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  16459. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  16460. if (start_Object == null)
  16461. {
  16462. start_Object = new Res_ThreeCode()
  16463. {
  16464. AirPort = empty,
  16465. AirPort_En = empty,
  16466. City = empty,
  16467. Country = empty,
  16468. Four = empty,
  16469. Three = empty,
  16470. };
  16471. }
  16472. if (end_Object == null)
  16473. {
  16474. end_Object = new Res_ThreeCode()
  16475. {
  16476. AirPort = empty,
  16477. AirPort_En = empty,
  16478. City = empty,
  16479. Country = empty,
  16480. Four = empty,
  16481. Three = empty,
  16482. };
  16483. }
  16484. //机型判断
  16485. string airModel = item["AirModel"].ToString();
  16486. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  16487. string flightTime = item["FlightTime"].ToString();
  16488. if (flightTime!.Contains(":"))
  16489. {
  16490. flightTime = flightTime.Replace(":", "小时");
  16491. flightTime += "分钟";
  16492. }
  16493. if (flightTime.Contains("H"))
  16494. {
  16495. flightTime = flightTime.Replace("H", "小时");
  16496. }
  16497. if (flightTime.Contains("M"))
  16498. {
  16499. flightTime = flightTime.Replace("M", "分钟");
  16500. }
  16501. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  16502. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  16503. {
  16504. flightTime = flightDataTime.Hour > 0
  16505. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  16506. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  16507. ? flightDataTime.Minute.ToString() + "分钟" : "";
  16508. }
  16509. //航班号
  16510. string flightcode = item["Fliagtcode"].ToString();
  16511. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  16512. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  16513. if (aircompany == null)
  16514. {
  16515. aircompany = new Res_AirCompany
  16516. {
  16517. CnName = hsEmpty,
  16518. EnName = hsEmpty,
  16519. ShortCode = hsEmpty,
  16520. };
  16521. }
  16522. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  16523. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  16524. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  16525. if (isTrade)
  16526. {
  16527. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  16528. }
  16529. else
  16530. {
  16531. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  16532. }
  16533. }
  16534. chiarr.Add(new Grp_ApprovalTravelDetails
  16535. {
  16536. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  16537. CreateTime = DateTime.Now,
  16538. CreateUserId = dto.Userid,
  16539. ParentId = 0,
  16540. Details = trip
  16541. });
  16542. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  16543. var last = threeCodeStr.Last();
  16544. foreach (var item in threeCodeStr)
  16545. {
  16546. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  16547. if (item.Equals(last))
  16548. {
  16549. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  16550. }
  16551. }
  16552. cityPath = cityPath.Trim('-');
  16553. }
  16554. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  16555. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  16556. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  16557. appro.Diid = dto.Diid;
  16558. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  16559. appro.Id = thisId;
  16560. appro.CreateUserId = dto.Userid;
  16561. appro.CreateTime = DateTime.Now;
  16562. foreach (var item in gwinfo)
  16563. {
  16564. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  16565. chi.Details = "拜访" + item.Client;
  16566. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  16567. {
  16568. chi.Details += "," + item.ReqSample;
  16569. }
  16570. chi.ParentId = thisId;
  16571. chi.Time = item.Time;
  16572. chiarr.Add(chi);
  16573. }
  16574. if (chiarr.Count < 5)
  16575. {
  16576. for (int j = chiarr.Count; j < 5; j++)
  16577. {
  16578. chiarr.Add(new
  16579. Grp_ApprovalTravelDetails());
  16580. }
  16581. }
  16582. resultArr.Add(new
  16583. {
  16584. appro.Id,
  16585. appro.Date,
  16586. appro.Diid,
  16587. chiList = chiarr.Select(x1 => new
  16588. {
  16589. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  16590. x1.Details,
  16591. x1.ParentId,
  16592. x1.Id
  16593. })
  16594. });
  16595. }
  16596. _sqlSugar.CommitTran();
  16597. jw = JsonView(true, "生成成功!", resultArr);
  16598. }
  16599. catch (Exception ex)
  16600. {
  16601. jw.Code = 400;
  16602. jw.Msg = "生成失败!" + ex.Message;
  16603. }
  16604. return Ok(jw);
  16605. }
  16606. /// <summary>
  16607. /// 报批行程word导出
  16608. /// </summary>
  16609. /// <param name="dto"></param>
  16610. /// <returns></returns>
  16611. [HttpPost]
  16612. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  16613. {
  16614. var jw = JsonView(false);
  16615. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  16616. if (group == null)
  16617. {
  16618. jw.Msg = "暂无该团组!";
  16619. return Ok(jw);
  16620. }
  16621. //模板路径
  16622. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  16623. //载入模板
  16624. Document doc = new Document(tempPath);
  16625. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16626. //获取所填表格的序数
  16627. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16628. Aspose.Words.Tables.Row titleRowClone = null;
  16629. Aspose.Words.Tables.Row CenterRowClone = null;
  16630. int index = 0;
  16631. int indexChi = 0;
  16632. int SetIndex = 0;
  16633. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  16634. //获取数据,放到datatable
  16635. foreach (var item in ApprovalTravelArr)
  16636. {
  16637. if (index > 0)
  16638. {
  16639. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  16640. tableOne.AppendChild(titleRowClone);
  16641. }
  16642. var textTime = item.Date;
  16643. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  16644. SetCells(tableOne, doc, SetIndex, 0, textTime);
  16645. SetIndex++;
  16646. if (ChiRep.Count > 0)
  16647. {
  16648. foreach (var itemChi in ChiRep)
  16649. {
  16650. var txtTime = itemChi.Time;
  16651. var txtDetail = itemChi.Details;
  16652. if (indexChi > 0)
  16653. {
  16654. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  16655. tableOne.AppendChild(CenterRowClone);
  16656. }
  16657. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  16658. {
  16659. SetCells(tableOne, doc, SetIndex, 0, "");
  16660. SetCells(tableOne, doc, SetIndex, 1, "");
  16661. indexChi++;
  16662. SetIndex++;
  16663. break;
  16664. }
  16665. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  16666. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  16667. indexChi++;
  16668. SetIndex++;
  16669. }
  16670. }
  16671. else
  16672. {
  16673. if (indexChi > 0)
  16674. {
  16675. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  16676. tableOne.AppendChild(CenterRowClone);
  16677. }
  16678. SetCells(tableOne, doc, SetIndex, 0, "");
  16679. SetCells(tableOne, doc, SetIndex, 1, "");
  16680. indexChi++;
  16681. SetIndex++;
  16682. }
  16683. index++;
  16684. }
  16685. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  16686. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  16687. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  16688. jw.Code = 200;
  16689. jw.Msg = "";
  16690. return Ok(jw);
  16691. }
  16692. private string intToString(int numberVal)
  16693. {
  16694. string numberval = numberVal.ToString();
  16695. Dictionary<char, string> Number = new Dictionary<char, string>();
  16696. Number.Add('1', "一");
  16697. Number.Add('2', "二");
  16698. Number.Add('3', "三");
  16699. Number.Add('4', "四");
  16700. Number.Add('5', "五");
  16701. Number.Add('6', "六");
  16702. Number.Add('7', "七");
  16703. Number.Add('8', "八");
  16704. Number.Add('9', "九");
  16705. string stringNumberVal = string.Empty;
  16706. for (int i = 0; i < numberval.Length; i++)
  16707. {
  16708. if (i == 0)
  16709. {
  16710. stringNumberVal += Number[numberval[i]];
  16711. }
  16712. else if (i >= 1)
  16713. {
  16714. if (numberval[i] == '0')
  16715. {
  16716. stringNumberVal = "十";
  16717. }
  16718. else
  16719. {
  16720. stringNumberVal += "十" + Number[numberval[i]];
  16721. }
  16722. }
  16723. }
  16724. return stringNumberVal;
  16725. }
  16726. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  16727. {
  16728. //获取table中的某个单元格,从0开始
  16729. Cell lshCell = table.Rows[rows].Cells[cells];
  16730. //将单元格中段落移除
  16731. foreach (Node item in lshCell.Paragraphs)
  16732. {
  16733. lshCell.Paragraphs.Remove(item);
  16734. }
  16735. if (val.Contains("\r\n"))
  16736. {
  16737. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  16738. foreach (var item in spArr)
  16739. {
  16740. //新建一个段落
  16741. Paragraph p = new Paragraph(doc);
  16742. var r = new Run(doc, item);
  16743. //把设置的值赋给之前新建的段落
  16744. p.AppendChild(r);
  16745. //将此段落加到单元格内
  16746. lshCell.AppendChild(p);
  16747. }
  16748. }
  16749. else
  16750. {
  16751. //新建一个段落
  16752. Paragraph p = new Paragraph(doc);
  16753. var r = new Run(doc, val);
  16754. //把设置的值赋给之前新建的段落
  16755. p.AppendChild(r);
  16756. //将此段落加到单元格内
  16757. lshCell.AppendChild(p);
  16758. }
  16759. }
  16760. [HttpPost]
  16761. public async Task<IActionResult> ServerHttp(string paramStr)
  16762. {
  16763. paramStr = paramStr.TrimEnd('\'');
  16764. paramStr = paramStr.TrimStart('\'');
  16765. JsonView jw = JsonView(false);
  16766. JObject param = JObject.Parse(paramStr);
  16767. if (!param.ContainsKey("url"))
  16768. {
  16769. jw.Msg = "url null";
  16770. return Ok(jw);
  16771. }
  16772. string url = param["url"]!.ToString();
  16773. var methon = "get";
  16774. Dictionary<string, string> headValues = null;
  16775. string bodyStr = string.Empty;
  16776. if (param.ContainsKey("methon"))
  16777. {
  16778. methon = param["methon"]!.ToString().ToLower();
  16779. }
  16780. if (param.ContainsKey("header"))
  16781. {
  16782. var header = param["header"]!.ToString();
  16783. JObject headerJobject = JObject.Parse(header);
  16784. headValues = new Dictionary<string, string>();
  16785. foreach (JProperty item in headerJobject.Properties())
  16786. {
  16787. var value = item.Value.ToString();
  16788. var head = item.Path;
  16789. headValues.Add(head, value);
  16790. }
  16791. }
  16792. HttpClient client = new HttpClient();
  16793. string responseString = string.Empty;
  16794. StringContent content = null;
  16795. if (headValues != null)
  16796. {
  16797. foreach (var item in headValues.Keys)
  16798. {
  16799. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  16800. {
  16801. if (param.ContainsKey("body"))
  16802. {
  16803. bodyStr = param["body"]!.ToString();
  16804. }
  16805. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  16806. }
  16807. else
  16808. {
  16809. client.DefaultRequestHeaders.Add(item, headValues[item]);
  16810. }
  16811. }
  16812. }
  16813. try
  16814. {
  16815. if (methon == "get")
  16816. {
  16817. responseString = await client.GetStringAsync(url);
  16818. }
  16819. else if (methon == "post")
  16820. {
  16821. var request = new HttpRequestMessage(HttpMethod.Post, url)
  16822. {
  16823. Content = content
  16824. };
  16825. var response = await client.SendAsync(request);
  16826. try
  16827. {
  16828. Stream responseStream = await response.Content.ReadAsStreamAsync();
  16829. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  16830. {
  16831. using (StreamReader reader = new StreamReader(gzipStream))
  16832. {
  16833. responseString = await reader.ReadToEndAsync();
  16834. }
  16835. }
  16836. }
  16837. catch (Exception)
  16838. {
  16839. responseString = await response.Content.ReadAsStringAsync();
  16840. }
  16841. }
  16842. else
  16843. {
  16844. responseString = "methon error";
  16845. }
  16846. jw = JsonView(true, "success", responseString);
  16847. }
  16848. catch (Exception ex)
  16849. {
  16850. jw.Msg = "error " + ex.Message;
  16851. jw.Data = ex.StackTrace;
  16852. }
  16853. finally
  16854. {
  16855. client.Dispose();
  16856. }
  16857. return Ok(jw);
  16858. }
  16859. #endregion
  16860. #region 团组接待意见调查
  16861. /// <summary>
  16862. /// 团组接待意见调查 - 信息管理
  16863. /// 基础数据(团组)
  16864. /// </summary>
  16865. /// <param name="dto"></param>
  16866. /// <returns></returns>
  16867. [HttpGet]
  16868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16869. public async Task<IActionResult> OpinionaireInit()
  16870. {
  16871. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  16872. .Select(x => new
  16873. {
  16874. x.Id,
  16875. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  16876. })
  16877. .OrderByDescending(x => x.Id)
  16878. .ToListAsync();
  16879. return Ok(JsonView(groupData, groupData.Count));
  16880. }
  16881. /// <summary>
  16882. /// 团组接待意见调查 - 信息管理
  16883. /// 列表
  16884. /// </summary>
  16885. /// <param name="groupId"></param>
  16886. /// <returns></returns>
  16887. [HttpGet("{groupId}")]
  16888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16889. public async Task<IActionResult> OpinionaireManageList(int groupId)
  16890. {
  16891. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  16892. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  16893. .Select(x => new
  16894. {
  16895. x.Id,
  16896. x.TourGuideName,
  16897. x.CityName,
  16898. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  16899. x.CreateTime
  16900. })
  16901. .OrderBy(x => x.Id)
  16902. .ToListAsync();
  16903. return Ok(JsonView(data));
  16904. }
  16905. /// <summary>
  16906. /// 团组接待意见调查 - 信息管理
  16907. /// 保存
  16908. /// </summary>
  16909. /// <param name="dto"></param>
  16910. /// <returns></returns>
  16911. [HttpPost]
  16912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16913. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  16914. {
  16915. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  16916. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  16917. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  16918. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  16919. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  16920. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  16921. _opinionaireRep.BeginTran();
  16922. if (addData != null && addData.Count > 0)
  16923. {
  16924. foreach (var item in addData)
  16925. {
  16926. item.CreateUserId = currUserInfo.UserId;
  16927. item.DiId = dto.DiId;
  16928. }
  16929. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  16930. }
  16931. if (updData != null && updData.Count > 0)
  16932. {
  16933. var upd = await _opinionaireRep._sqlSugar
  16934. .Updateable(updData)
  16935. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  16936. .WhereColumns(x => new { x.Id })
  16937. .ExecuteCommandAsync();
  16938. }
  16939. _opinionaireRep.CommitTran();
  16940. return Ok(JsonView("操作成功!"));
  16941. }
  16942. /// <summary>
  16943. /// 团组接待意见调查 - 信息管理
  16944. /// 删除
  16945. /// </summary>
  16946. /// <param name="id"></param>
  16947. /// <returns></returns>
  16948. [HttpDelete("{id}")]
  16949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16950. public async Task<IActionResult> OpinionaireManageDel(int id)
  16951. {
  16952. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  16953. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  16954. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  16955. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  16956. if (!del) return Ok(JsonView("操作失败!"));
  16957. return Ok(JsonView("操作成功!"));
  16958. }
  16959. /// <summary>
  16960. /// 团组接待意见调查 - 用户
  16961. /// 列表
  16962. /// </summary>
  16963. /// <param name="id"></param>
  16964. /// <returns></returns>
  16965. [HttpGet("{diId}")]
  16966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16967. public async Task<IActionResult> OpinionaireUserList(int diId)
  16968. {
  16969. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  16970. var sql = string.Format(@"
  16971. SELECT
  16972. o.Id,
  16973. o.DiId,
  16974. di.TeamName AS 'GroupName',
  16975. di.VisitPNumber AS 'PeopleNumber',
  16976. di.ClientName AS 'LeadGroup',
  16977. di.VisitCountry AS 'Travel',
  16978. di.VisitDays AS 'Days',
  16979. o.CityName,
  16980. o.TourGuideName,
  16981. o.Catering,
  16982. o.CateringReason,
  16983. o.Stay,
  16984. o.StayReason,
  16985. o.[Route],
  16986. o.RouteReason,
  16987. o.OfficialActivity,
  16988. o.OfficialActivityReason,
  16989. o.TourGuide,
  16990. o.TourGuideReason,
  16991. o.[Translate],
  16992. o.TranslateReason,
  16993. o.Trip,
  16994. o.TripReason,
  16995. o.ESFileName,
  16996. o.SignatureDate,
  16997. o.Remark
  16998. FROM
  16999. Grp_Opinionaire o
  17000. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  17001. WHERE
  17002. o.IsDel = 0
  17003. AND o.DiId = {0}
  17004. ORDER BY
  17005. o.Id ASC", diId);
  17006. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  17007. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  17008. return Ok(JsonView(data));
  17009. }
  17010. /// <summary>
  17011. /// 团组接待意见调查 - 用户
  17012. /// 保存
  17013. /// </summary>
  17014. /// <param name="id"></param>
  17015. /// <returns></returns>
  17016. [HttpPost]
  17017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17018. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  17019. {
  17020. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  17021. foreach (var item in dto)
  17022. {
  17023. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  17024. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  17025. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  17026. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  17027. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  17028. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  17029. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  17030. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  17031. }
  17032. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  17033. if (!Directory.Exists(filePathBase))
  17034. {
  17035. Directory.CreateDirectory(filePathBase);
  17036. }
  17037. #region 上传文件
  17038. var filePaths = new List<string>();
  17039. foreach (var item in dto)
  17040. {
  17041. var file = item.File;
  17042. // 将文件保存到指定位置
  17043. var filePath = Path.Combine(filePathBase, file.FileName);
  17044. using (var stream = new FileStream(filePath, FileMode.Create))
  17045. {
  17046. await file.CopyToAsync(stream);
  17047. }
  17048. //验证文件是否上传成功
  17049. if (!System.IO.File.Exists(filePath))
  17050. {
  17051. foreach (var filePathStr in filePaths)
  17052. {
  17053. System.IO.File.Delete(filePathStr);
  17054. }
  17055. return Ok(JsonView(false, "文件上传失败!"));
  17056. }
  17057. item.ESFileName = file.FileName;
  17058. }
  17059. #endregion
  17060. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  17061. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  17062. .UpdateColumns(x => new
  17063. {
  17064. x.Catering,
  17065. x.CateringReason,
  17066. x.Stay,
  17067. x.StayReason,
  17068. x.Route,
  17069. x.RouteReason,
  17070. x.OfficialActivity,
  17071. x.OfficialActivityReason,
  17072. x.TourGuide,
  17073. x.TourGuideReason,
  17074. x.Translate,
  17075. x.TranslateReason,
  17076. x.Trip,
  17077. x.TripReason,
  17078. x.ESFileName,
  17079. x.SignatureDate,
  17080. x.Remark
  17081. })
  17082. .WhereColumns(x => new { x.Id })
  17083. .ExecuteCommandAsync();
  17084. if (upd < 1)
  17085. {
  17086. foreach (var filePathStr in filePaths)
  17087. {
  17088. System.IO.File.Delete(filePathStr);
  17089. }
  17090. return Ok(JsonView(false));
  17091. }
  17092. return Ok(JsonView(true));
  17093. }
  17094. #endregion
  17095. #region 团组餐厅相关信息
  17096. /// <summary>
  17097. /// 团组相关餐厅信息
  17098. /// 基础数据(团组)
  17099. /// </summary>
  17100. /// <returns></returns>
  17101. [HttpGet]
  17102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17103. public async Task<IActionResult> RestaurantInit()
  17104. {
  17105. return Ok(await _restaurantRep.InitAsync());
  17106. }
  17107. /// <summary>
  17108. /// 团组相关餐厅信息
  17109. /// Item
  17110. /// </summary>
  17111. /// <param name="dto"></param>
  17112. /// <returns></returns>
  17113. [HttpPost]
  17114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17115. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  17116. {
  17117. int portType = dto.PortType,
  17118. groupId = dto.GroupId;
  17119. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false,MsgTips.Port));
  17120. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  17121. return Ok(await _restaurantRep.ItemAsync(portType,groupId));
  17122. }
  17123. /// <summary>
  17124. /// 团组相关餐厅信息
  17125. /// List
  17126. /// </summary>
  17127. /// <param name="dto"></param>
  17128. /// <returns></returns>
  17129. [HttpPost]
  17130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17131. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  17132. {
  17133. int portType = dto.PortType,
  17134. groupId = dto.GroupId;
  17135. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  17136. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  17137. var sql = string.Format(@" SELECT
  17138. ri.Id,
  17139. ri.GroupId,
  17140. ri.Date,
  17141. ri.StartTime,
  17142. ri.EndTime,
  17143. CASE WHEN ri.Type = 1 THEN '早餐'
  17144. WHEN ri.Type = 2 THEN '午餐'
  17145. WHEN ri.Type = 3 THEN '晚餐'
  17146. ELSE '其他'
  17147. END AS 'Type',
  17148. ri.Name,
  17149. ri.Address,
  17150. ri.Tel,
  17151. ri.Remark,
  17152. ri.CreateTime,
  17153. u.CnName AS CreateUserName
  17154. FROM
  17155. Grp_RestaurantInfo ri
  17156. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  17157. WHERE
  17158. ri.IsDel = 0
  17159. AND ri.GroupId = {0}
  17160. ORDER BY
  17161. ri.Date ASC
  17162. ", groupId);
  17163. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  17164. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  17165. return Ok(JsonView(infos));
  17166. }
  17167. /// <summary>
  17168. /// 团组相关餐厅信息
  17169. /// Info
  17170. /// </summary>
  17171. /// <param name="dto"></param>
  17172. /// <returns></returns>
  17173. [HttpPost]
  17174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17175. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  17176. {
  17177. int portType = dto.PortType,
  17178. id = dto.Id;
  17179. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  17180. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  17181. return Ok(await _restaurantRep.InfoAsync(portType, id));
  17182. }
  17183. /// <summary>
  17184. /// 团组相关餐厅信息
  17185. /// Op
  17186. /// </summary>
  17187. /// <param name="dto"></param>
  17188. /// <returns></returns>
  17189. [HttpPost]
  17190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17191. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  17192. {
  17193. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  17194. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  17195. if ( string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  17196. return Ok(await _restaurantRep.OpAsync(dto));
  17197. }
  17198. /// <summary>
  17199. /// 团组相关餐厅信息
  17200. /// Del
  17201. /// </summary>
  17202. /// <param name="dto"></param>
  17203. /// <returns></returns>
  17204. [HttpPost]
  17205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17206. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  17207. {
  17208. int userId = dto.DeleteUserId;
  17209. var id = dto.Id;
  17210. if (userId < 1) return Ok( JsonView(false, MsgTips.UserId));
  17211. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  17212. return Ok(await _restaurantRep.DelAsync(dto));
  17213. }
  17214. #endregion
  17215. // /// <summary>
  17216. // ///
  17217. // /// </summary>
  17218. // /// <param name="_dto"></param>
  17219. // /// <returns></returns>
  17220. // [HttpPost]
  17221. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17222. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  17223. // {
  17224. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  17225. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  17226. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  17227. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  17228. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  17229. // dic_psg.Add("客人", 974);
  17230. // dic_psg.Add("司机", 975);
  17231. // dic_psg.Add("导游", 976);
  17232. // dic_psg.Add("公司内部人员", 977);
  17233. // dic_psg.Add("司机/导游/公司内部人员", 978);
  17234. // foreach (var item in list_visa)
  17235. // {
  17236. // Grp_VisaInfo temp = new Grp_VisaInfo();
  17237. // temp.Id = item.Id;
  17238. // temp.DIId = item.DIId;
  17239. // temp.VisaClient = item.VisaClient;
  17240. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  17241. // temp.VisaCurrency = item.VisaCurrency;
  17242. // temp.IsThird = item.IsThird;
  17243. // if (dic_psg.ContainsKey(item.PassengerType))
  17244. // {
  17245. // temp.PassengerType = dic_psg[item.PassengerType];
  17246. // }
  17247. // else {
  17248. // temp.PassengerType = -1;
  17249. // }
  17250. // temp.VisaNumber = item.VisaNumber;
  17251. // temp.VisaFreeNumber = item.VisaFreeNumber;
  17252. // temp.CreateUserId = item.Operators;
  17253. // DateTime dt_ct;
  17254. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  17255. // if (b_ct)
  17256. // {
  17257. // temp.CreateTime = dt_ct;
  17258. // }
  17259. // else
  17260. // {
  17261. // temp.CreateTime = DateTime.Now;
  17262. // }
  17263. // temp.DeleteTime = "";
  17264. // temp.DeleteUserId = 0;
  17265. // temp.Remark = item.Remark;
  17266. // if (string.IsNullOrEmpty(temp.Remark)) {
  17267. // temp.Remark = "";
  17268. // }
  17269. // temp.IsDel = item.IsDel;
  17270. // temp.VisaDescription = item.VisaAttachment;
  17271. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  17272. //([Id]
  17273. // ,[DIId]
  17274. // ,[VisaClient]
  17275. // ,[VisaPrice]
  17276. // ,[VisaCurrency]
  17277. // ,[IsThird]
  17278. // ,[PassengerType]
  17279. // ,[VisaNumber]
  17280. // ,[VisaFreeNumber]
  17281. // ,[CreateUserId]
  17282. // ,[CreateTime]
  17283. // ,[DeleteTime]
  17284. // ,[DeleteUserId]
  17285. // ,[Remark]
  17286. // ,[IsDel]
  17287. // ,[visaDescription])
  17288. // VALUES
  17289. // ({0},{1},'{2}',{3},{4}
  17290. //,{5},{6},{7},{8},{9}
  17291. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  17292. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  17293. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  17294. //);
  17295. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  17296. // }
  17297. // return Ok(JsonView(true, "操作成功!"));
  17298. // }
  17299. /// <summary>
  17300. /// 123132123
  17301. /// </summary>
  17302. /// <param name="_dto"></param>
  17303. /// <returns></returns>
  17304. [HttpPost]
  17305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17306. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  17307. {
  17308. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  17309. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  17310. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  17311. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  17312. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  17313. dicDetail.Add(789, 1034);
  17314. dicDetail.Add(790, 1035);
  17315. dicDetail.Add(791, 1036);
  17316. dicDetail.Add(792, 1037);
  17317. dicDetail.Add(793, 1038);
  17318. dicDetail.Add(794, 1039);
  17319. dicDetail.Add(795, 1040);
  17320. dicDetail.Add(796, 1041);
  17321. dicDetail.Add(797, 1042);
  17322. dicDetail.Add(798, 1043);
  17323. dicDetail.Add(801, 1044);
  17324. dicDetail.Add(802, 1045);
  17325. dicDetail.Add(803, 1046);
  17326. Dictionary<int, int> dic = new Dictionary<int, int>();
  17327. dic.Add(806, 1027);
  17328. dic.Add(807, 1028);
  17329. dic.Add(808, 1029);
  17330. dic.Add(809, 1030);
  17331. dic.Add(810, 1031);
  17332. dic.Add(811, 1032);
  17333. dic.Add(812, 1033);
  17334. foreach (var item in list_visa)
  17335. {
  17336. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  17337. temp.Coefficient = item.coefficient;
  17338. DateTime dtCrt;
  17339. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  17340. if (b1)
  17341. {
  17342. temp.CreateTime = dtCrt;
  17343. }
  17344. else
  17345. {
  17346. temp.CreateTime = DateTime.Now;
  17347. }
  17348. temp.CreateUserId = item.Operators;
  17349. temp.DeleteTime = "";
  17350. temp.DeleteUserId = 0;
  17351. temp.DiId = int.Parse(item.DIID);
  17352. temp.FilePath = item.FilePath;
  17353. temp.IsDel = item.IsDel;
  17354. temp.Price = item.Price;
  17355. temp.PriceCount = 1;
  17356. temp.PriceCurrency = item.Currency;
  17357. int detailId = 0;
  17358. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  17359. {
  17360. detailId = dicDetail[item.PriceTypeDetail];
  17361. }
  17362. temp.PriceDetailType = detailId;
  17363. temp.PriceDt = DateTime.Now;
  17364. temp.PriceName = item.PriceName;
  17365. temp.PriceSum = item.Price;
  17366. int tid = 0;
  17367. if (dic.ContainsKey(item.PriceType))
  17368. {
  17369. tid = dic[item.PriceType];
  17370. }
  17371. temp.PriceType = tid;
  17372. temp.Remark = item.Remark;
  17373. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  17374. }
  17375. return Ok(JsonView(true, "操作成功!"));
  17376. }
  17377. [HttpPost]
  17378. public IActionResult TimeTest()
  17379. {
  17380. var jw = JsonView(false, "error");
  17381. _sqlSugar.BeginTran();
  17382. try
  17383. {
  17384. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  17385. .Select(x => new Crm_NewClientData
  17386. {
  17387. Id = x.Id,
  17388. Client = x.Client,
  17389. Contact = x.Contact,
  17390. Location = x.Location,
  17391. })
  17392. .ToList();
  17393. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x=>x.Id).ToList();
  17394. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  17395. Stopwatch stopwatch = new Stopwatch();
  17396. // 开始计时
  17397. stopwatch.Start();
  17398. foreach (var item in clientList)
  17399. {
  17400. EncryptionProcessor.DecryptProperties(item);
  17401. }
  17402. stopwatch.Stop();
  17403. jw.Code = 200;
  17404. jw.Data = stopwatch.ElapsedMilliseconds;
  17405. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  17406. }
  17407. catch (Exception ex)
  17408. {
  17409. jw.Code = 400;
  17410. jw.Msg = ex.Message;
  17411. }
  17412. return Ok(jw);
  17413. }
  17414. }
  17415. }