GroupsController.cs 1.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743
  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.Extensions.Logging;
  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.KiMiApi;
  20. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  21. using OASystem.Domain.AesEncryption;
  22. using OASystem.Domain.Attributes;
  23. using OASystem.Domain.Dtos.CRM;
  24. using OASystem.Domain.Dtos.FileDto;
  25. using OASystem.Domain.Dtos.Financial;
  26. using OASystem.Domain.Dtos.Groups;
  27. using OASystem.Domain.Entities.Customer;
  28. using OASystem.Domain.Entities.Financial;
  29. using OASystem.Domain.Entities.Groups;
  30. using OASystem.Domain.ViewModels.Financial;
  31. using OASystem.Domain.ViewModels.Groups;
  32. using OASystem.Domain.ViewModels.OCR;
  33. using OASystem.Infrastructure.Repositories.CRM;
  34. using OASystem.Infrastructure.Repositories.Financial;
  35. using OASystem.Infrastructure.Repositories.Groups;
  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 System.Web;
  44. using static OASystem.API.OAMethodLib.JWTHelper;
  45. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  46. using Bookmark = Aspose.Words.Bookmark;
  47. using Cell = Aspose.Words.Tables.Cell;
  48. using Table = Aspose.Words.Tables.Table;
  49. namespace OASystem.API.Controllers
  50. {
  51. /// <summary>
  52. /// 团组相关
  53. /// </summary>
  54. //[Authorize]
  55. [Route("api/[controller]/[action]")]
  56. public class GroupsController : ControllerBase
  57. {
  58. private readonly ILogger<GroupsController> _logger;
  59. private readonly GrpScheduleRepository _grpScheduleRep;
  60. private readonly IMapper _mapper;
  61. private readonly DelegationInfoRepository _groupRepository;
  62. private readonly TaskAssignmentRepository _taskAssignmentRep;
  63. private readonly AirTicketResRepository _airTicketResRep;
  64. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  65. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  66. private readonly DelegationEnDataRepository _delegationEnDataRep;
  67. private readonly DelegationVisaRepository _delegationVisaRep;
  68. private readonly VisaPriceRepository _visaPriceRep;
  69. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  70. private readonly HotelPriceRepository _hotelPriceRep;
  71. private readonly CustomersRepository _customersRep;
  72. private readonly MessageRepository _message;
  73. private readonly SqlSugarClient _sqlSugar;
  74. private readonly TourClientListRepository _tourClientListRep;
  75. private readonly TeamRateRepository _teamRateRep;
  76. #region 成本相关
  77. private readonly CheckBoxsRepository _checkBoxs;
  78. private readonly GroupCostRepository _GroupCostRepository;
  79. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  80. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  81. #endregion
  82. private readonly SetDataRepository _setDataRep;
  83. private string url;
  84. private string path;
  85. private readonly EnterExitCostRepository _enterExitCostRep;
  86. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  87. private readonly UsersRepository _usersRep;
  88. private readonly IJuHeApiService _juHeApi;
  89. private readonly InvertedListRepository _invertedListRep;
  90. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  91. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  92. private readonly ThreeCodeRepository _threeCodeRepository;
  93. private readonly HotelInquiryRepository _hotelInquiryRep;
  94. private readonly FeeAuditRepository _feeAuditRep;
  95. private readonly VisaCommissionRepository _visaCommissionRep;
  96. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  97. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  98. private readonly List<CurrencyInfo> _currencyInit;
  99. private readonly List<int> _portTypeData;
  100. private readonly TableOperationRecordRepository _tableorRep;
  101. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  102. private readonly RestaurantRepository _restaurantRep;
  103. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  104. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  105. /// <summary>
  106. /// 构造函数
  107. /// </summary>
  108. /// <param name="logger"></param>
  109. /// <param name="mapper"></param>
  110. /// <param name="hubContext"></param>
  111. /// <param name="sqlSugar"></param>
  112. /// <param name="grpScheduleRep"></param>
  113. /// <param name="groupRepository"></param>
  114. /// <param name="taskAssignmentRep"></param>
  115. /// <param name="airTicketResRep"></param>
  116. /// <param name="decreasePaymentsRep"></param>
  117. /// <param name="InvitationOfficialActivitiesRep"></param>
  118. /// <param name="delegationEnDataRep"></param>
  119. /// <param name="enterExitCostRep"></param>
  120. /// <param name="delegationVisaRep"></param>
  121. /// <param name="message"></param>
  122. /// <param name="visaPriceRep"></param>
  123. /// <param name="carTouristGuideGroundRep"></param>
  124. /// <param name="checkBoxs"></param>
  125. /// <param name="GroupCostRepository"></param>
  126. /// <param name="CostTypeHotelNumberRepository"></param>
  127. /// <param name="GroupCostParameterRepository"></param>
  128. /// <param name="hotelPriceRep"></param>
  129. /// <param name="customersRep"></param>
  130. /// <param name="setDataRep"></param>
  131. /// <param name="tourClientListRep"></param>
  132. /// <param name="teamRateRep"></param>
  133. /// <param name="usersRep"></param>
  134. /// <param name="juHeApi"></param>
  135. /// <param name="invertedListRep"></param>
  136. /// <param name="visaFeeInfoRep"></param>
  137. /// <param name="ticketBlackCodeRep"></param>
  138. /// <param name="hotelInquiryRep"></param>
  139. /// <param name="threeCodeRepository"></param>
  140. /// <param name="feeAuditRep"></param>
  141. /// <param name="visaCommissionRep"></param>
  142. /// <param name="ffrRep"></param>
  143. /// <param name="opinionaireRep"></param>
  144. /// <param name="tableorRep"></param>
  145. /// <param name="enterExitCostDraftRep"></param>
  146. /// <param name="restaurantRep"></param>
  147. /// <param name="enterExitCostQuoteRep"></param>
  148. /// <param name="grpOrderPreInfoRep"></param>
  149. public GroupsController(
  150. ILogger<GroupsController> logger,
  151. IMapper mapper,
  152. IHubContext<ChatHub, IChatClient> hubContext,
  153. SqlSugarClient sqlSugar,
  154. GrpScheduleRepository grpScheduleRep,
  155. DelegationInfoRepository groupRepository,
  156. TaskAssignmentRepository taskAssignmentRep,
  157. AirTicketResRepository airTicketResRep,
  158. DecreasePaymentsRepository decreasePaymentsRep,
  159. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  160. DelegationEnDataRepository delegationEnDataRep,
  161. EnterExitCostRepository enterExitCostRep,
  162. DelegationVisaRepository delegationVisaRep,
  163. MessageRepository message,
  164. VisaPriceRepository visaPriceRep,
  165. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  166. CheckBoxsRepository checkBoxs,
  167. GroupCostRepository GroupCostRepository,
  168. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  169. GroupCostParameterRepository GroupCostParameterRepository,
  170. HotelPriceRepository hotelPriceRep,
  171. CustomersRepository customersRep,
  172. SetDataRepository setDataRep,
  173. TourClientListRepository tourClientListRep,
  174. TeamRateRepository teamRateRep,
  175. UsersRepository usersRep,
  176. IJuHeApiService juHeApi,
  177. InvertedListRepository invertedListRep,
  178. VisaFeeInfoRepository visaFeeInfoRep,
  179. TicketBlackCodeRepository ticketBlackCodeRep,
  180. HotelInquiryRepository hotelInquiryRep,
  181. ThreeCodeRepository threeCodeRepository,
  182. FeeAuditRepository feeAuditRep,
  183. VisaCommissionRepository visaCommissionRep,
  184. ForeignReceivablesRepository ffrRep,
  185. OpinionaireRepository opinionaireRep,
  186. TableOperationRecordRepository tableorRep,
  187. EnterExitCostDraftRepository enterExitCostDraftRep,
  188. RestaurantRepository restaurantRep,
  189. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  190. GroupOrderPreInfoRepository grpOrderPreInfoRep
  191. )
  192. {
  193. _logger = logger;
  194. _mapper = mapper;
  195. _grpScheduleRep = grpScheduleRep;
  196. _groupRepository = groupRepository;
  197. _taskAssignmentRep = taskAssignmentRep;
  198. _airTicketResRep = airTicketResRep;
  199. _sqlSugar = sqlSugar;
  200. url = AppSettingsHelper.Get("ExcelBaseUrl");
  201. path = AppSettingsHelper.Get("ExcelBasePath");
  202. if (!System.IO.Directory.Exists(path))
  203. {
  204. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  205. }
  206. _decreasePaymentsRep = decreasePaymentsRep;
  207. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  208. _delegationEnDataRep = delegationEnDataRep;
  209. _enterExitCostRep = enterExitCostRep;
  210. _delegationVisaRep = delegationVisaRep;
  211. _message = message;
  212. _visaPriceRep = visaPriceRep;
  213. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  214. _checkBoxs = checkBoxs;
  215. _GroupCostRepository = GroupCostRepository;
  216. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  217. _GroupCostParameterRepository = GroupCostParameterRepository;
  218. _hotelPriceRep = hotelPriceRep;
  219. _customersRep = customersRep;
  220. _setDataRep = setDataRep;
  221. _tourClientListRep = tourClientListRep;
  222. _teamRateRep = teamRateRep;
  223. _hubContext = hubContext;
  224. _usersRep = usersRep;
  225. _juHeApi = juHeApi;
  226. _invertedListRep = invertedListRep;
  227. _visaFeeInfoRep = visaFeeInfoRep;
  228. _ticketBlackCodeRep = ticketBlackCodeRep;
  229. _hotelInquiryRep = hotelInquiryRep;
  230. _threeCodeRepository = threeCodeRepository;
  231. _feeAuditRep = feeAuditRep;
  232. _visaCommissionRep = visaCommissionRep;
  233. _ffrRep = ffrRep;
  234. _opinionaireRep = opinionaireRep;
  235. _currencyInit = new List<CurrencyInfo>()
  236. {
  237. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  238. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  239. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  240. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  241. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  242. };
  243. _portTypeData = new List<int>() { 2, 3 };
  244. _tableorRep = tableorRep;
  245. _enterExitCostDraftRep = enterExitCostDraftRep;
  246. _restaurantRep = restaurantRep;
  247. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  248. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  249. }
  250. #region 流程管控
  251. /// <summary>
  252. /// 获取团组流程管控信息
  253. /// </summary>
  254. /// <param name="_jsonDto">查询参数</param>
  255. /// <returns></returns>
  256. [HttpPost]
  257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  258. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  259. {
  260. if (string.IsNullOrEmpty(_jsonDto.Paras))
  261. {
  262. return Ok(JsonView(false, "参数为空"));
  263. }
  264. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  265. if (_ScheduleDto != null)
  266. {
  267. if (_ScheduleDto.SearchType == 2)//获取列表
  268. {
  269. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  270. return Ok(JsonView(_grpScheduleViewList));
  271. }
  272. else//获取对象
  273. {
  274. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  275. if (_grpScheduleView != null)
  276. {
  277. return Ok(JsonView(_grpScheduleView));
  278. }
  279. }
  280. }
  281. else
  282. {
  283. return Ok(JsonView(false, "参数反序列化失败"));
  284. }
  285. return Ok(JsonView(false, "暂无数据!"));
  286. }
  287. /// <summary>
  288. /// 修改团组流程管控详细表数据
  289. /// </summary>
  290. /// <param name="dto"></param>
  291. /// <returns></returns>
  292. [HttpPost]
  293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  294. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  295. {
  296. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  297. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  298. .SetColumns(it => it.Duty == _detail.Duty)
  299. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  300. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  301. .SetColumns(it => it.JobContent == _detail.JobContent)
  302. .SetColumns(it => it.Remark == _detail.Remark)
  303. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  304. .Where(s => s.Id == dto.Id)
  305. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  306. .ExecuteCommandAsync();
  307. if (result > 0)
  308. {
  309. return Ok(JsonView(true, "保存成功!"));
  310. }
  311. return Ok(JsonView(false, "保存失败!"));
  312. }
  313. /// <summary>
  314. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  315. /// </summary>
  316. /// <param name="dto"></param>
  317. /// <returns></returns>
  318. [HttpPost]
  319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  320. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  321. {
  322. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  323. _detail.IsDel = 1;
  324. _detail.DeleteUserId = dto.Duty;
  325. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  326. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  327. .SetColumns(it => it.IsDel == _detail.IsDel)
  328. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  329. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  330. .Where(it => it.Id == dto.Id)
  331. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  332. //.WhereColumns(s => s.Id == dto.Id)
  333. .ExecuteCommandAsync();
  334. if (result > 0)
  335. {
  336. return Ok(JsonView(true, "删除成功!"));
  337. }
  338. return Ok(JsonView(false, "删除失败!"));
  339. }
  340. /// <summary>
  341. /// 增加团组流程管控详细表数据
  342. /// </summary>
  343. /// <param name="dto"></param>
  344. /// <returns></returns>
  345. [HttpPost]
  346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  347. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  348. {
  349. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  350. if (DateTime.Now < _detail.ExpectBeginDt)
  351. {
  352. _detail.StepStatus = 0;
  353. }
  354. else
  355. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  356. _detail.StepStatus = 1;
  357. }
  358. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  359. if (result > 0)
  360. {
  361. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  362. return Ok(JsonView(true, "添加成功!", _result));
  363. }
  364. return Ok(JsonView(false, "添加失败!"));
  365. }
  366. #endregion
  367. #region 团组前期信息
  368. /// <summary>
  369. /// 团组前期信息 List
  370. /// </summary>
  371. /// <returns></returns>
  372. [HttpPost]
  373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  374. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  375. {
  376. var search = dto.Search;
  377. int[] nameTempIds = new int[] { 1, 12, 28 },
  378. countryTempIds = new int[] { 2, 13, 29 },
  379. daysTempIds = new int[] { 4, 15, 31 },
  380. ppNumTempIds = new int[] { 6 };
  381. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  382. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  383. .Where((opi, u) => opi.IsDel == 0)
  384. .OrderByDescending((opi, u) => opi.CreateTime)
  385. .Select((opi, u) => new GroupOrderPreInfoListView()
  386. {
  387. Id = opi.Id,
  388. Name = opi.Name,
  389. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  390. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  391. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  392. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  393. Operator = u.CnName,
  394. OperationTime = opi.CreateTime
  395. })
  396. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  397. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  398. .ToListAsync();
  399. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  400. int total = list.Count;
  401. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  402. var listPageData1 = listPageData
  403. .Skip((dto.PageIndex - 1) * dto.PageSize)
  404. .Take(dto.PageSize)
  405. .ToList();
  406. var infoIds = listPageData1.Select(x => x.Id).ToList();
  407. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  408. .Where(x => x.IsDel == 0 && x.STid == 109)
  409. .ToArrayAsync();
  410. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  411. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  412. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  413. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  414. .ToListAsync();
  415. foreach (var item in listPageData1)
  416. {
  417. var typeDatas1 = typeDatas.Select(x => new
  418. {
  419. Id = x.Id,
  420. Name = x.Name,
  421. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  422. }).ToArray();
  423. item.VersionDetails = typeDatas1;
  424. }
  425. return Ok(JsonView(listPageData1, listPageData1.Count));
  426. }
  427. /// <summary>
  428. /// 团组前期信息 Init
  429. /// </summary>
  430. /// <returns></returns>
  431. [HttpGet("{userId}")]
  432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  433. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  434. {
  435. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  436. }
  437. /// <summary>
  438. /// 国家数据源
  439. /// </summary>
  440. /// <param name="pageIndex">当前页码</param>
  441. /// <param name="pageSize">每页条数</param>
  442. /// <param name="search">查询条件</param>
  443. /// <returns></returns>
  444. [HttpGet]
  445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  446. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  447. {
  448. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  449. if (pageIndex == 0 && pageSize == 0)
  450. {
  451. //所有数据
  452. return Ok(JsonView(countrys, countrys.Count));
  453. }
  454. //分页
  455. int skip = (pageIndex - 1) * pageSize;
  456. int take = pageSize;
  457. if (!string.IsNullOrEmpty(search))
  458. {
  459. IEnumerable<char> charSequence = search.Select(c => c);
  460. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  461. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  462. return Ok(JsonView(pageData, pageResult1.Count));
  463. }
  464. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  465. return Ok(JsonView(pageResult2, countrys.Count));
  466. }
  467. /// <summary>
  468. /// 城市数据源
  469. /// </summary>
  470. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  471. /// <param name="pageIndex">当前页码</param>
  472. /// <param name="pageSize">每页条数</param>
  473. /// <param name="search">查询条件</param>
  474. /// <returns></returns>
  475. [HttpGet("{countryLabel}")]
  476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  477. public async Task<IActionResult> CityByCountry(
  478. string countryLabel,
  479. [FromQuery] int pageIndex,
  480. [FromQuery] int pageSize,
  481. [FromQuery] string search)
  482. {
  483. countryLabel = HttpUtility.UrlDecode(countryLabel);
  484. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  485. var citys = Array.Empty<string?>();
  486. if (countryList.Any())
  487. {
  488. var cityDatas = await _sqlSugar
  489. .Queryable<Grp_NationalTravelFee>()
  490. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  491. .ToArrayAsync();
  492. foreach (var item in cityDatas)
  493. {
  494. if (item.City.Contains("城市"))
  495. {
  496. item.City = item.Country + "-所有城市";
  497. }
  498. }
  499. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  500. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  501. }
  502. if (pageIndex == 0 && pageSize == 0)
  503. {
  504. //所有数据
  505. return Ok(JsonView(citys, citys?.Length ?? 0));
  506. }
  507. //分页
  508. int skip = (pageIndex - 1) * pageSize;
  509. int take = pageSize;
  510. if (!string.IsNullOrEmpty(search))
  511. {
  512. IEnumerable<char> charSequence = search.Select(c => c);
  513. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  514. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  515. return Ok(JsonView(pageData, pageResult1.Count()));
  516. }
  517. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  518. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  519. }
  520. /// <summary>
  521. /// 团组前期信息 Info
  522. /// </summary>
  523. /// <param name="dto">Id</param>
  524. /// <param name="portType">Id</param>
  525. /// <returns></returns>
  526. [HttpGet("{Id}/{TempId}")]
  527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  528. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto, int portType = 1)
  529. {
  530. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  531. }
  532. /// <summary>
  533. /// 团组前期信息 移动端 Info
  534. /// </summary>
  535. /// <param name="dto">Id</param>
  536. /// <returns></returns>
  537. [HttpGet("{Id}/{TempId}")]
  538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  539. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  540. {
  541. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  542. }
  543. /// <summary>
  544. /// 团组前期信息 Save
  545. /// </summary>
  546. /// <param name="dto">Id</param>
  547. /// <returns></returns>
  548. [HttpPost]
  549. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  550. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  551. {
  552. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  553. }
  554. /// <summary>
  555. /// 团组前期信息 Del
  556. /// </summary>
  557. /// <param name="dto">Id</param>
  558. /// <returns></returns>
  559. [HttpPost]
  560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  561. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  562. {
  563. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  564. }
  565. /// <summary>
  566. /// 团组前期信息 文件下载
  567. /// </summary>
  568. /// <param name="dto">Id</param>
  569. /// <returns></returns>
  570. [HttpGet("{Id}/{TempId}")]
  571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  572. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  573. {
  574. int id = dto.Id, tempId = dto.TempId;
  575. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  576. var data = view.Data as GrpOrderPreInfoView;
  577. #region Excel
  578. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  579. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  580. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  581. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  582. var fileNamePrefix = string.Empty;
  583. if (tempId == 1405)
  584. {
  585. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  586. fileNamePrefix = $"{data.Name}_无商邀版";
  587. }
  588. else if (tempId == 1406)
  589. {
  590. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  591. fileNamePrefix = $"{data.Name}_有商邀版";
  592. }
  593. else
  594. {
  595. //tempId == 1404 默认下载
  596. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  597. fileNamePrefix = $"{data.Name}_单接送机";
  598. }
  599. foreach (var item in data.Items)
  600. {
  601. var obj = item.NewValue;
  602. if (obj == null) item.OriginVal = "";
  603. else if (obj.Equals("有") || obj.Equals("无"))
  604. {
  605. item.OriginVal = obj.ToString();
  606. }
  607. else if (obj is object[] objArray)
  608. {
  609. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  610. item.OriginVal = string.Join("、", stringArray);
  611. }
  612. else if (obj is string[] stringArray)
  613. {
  614. item.OriginVal = string.Join("、", stringArray);
  615. }
  616. else if (obj.Equals("-"))
  617. {
  618. item.OriginVal = "";
  619. }
  620. }
  621. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  622. fileName = CommonFun.ValidFileName(fileName);
  623. //载入模板
  624. WorkbookDesigner designer = new WorkbookDesigner();
  625. designer.Workbook = new Workbook(tempPath);
  626. if (tempId == 1406)
  627. {
  628. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  629. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  630. for (int i = 1; i <= view2.Length; i++)
  631. {
  632. view2[i - 1].Index = i;
  633. }
  634. designer.SetDataSource("View1", view1);
  635. designer.SetDataSource("View2", view2);
  636. }
  637. else
  638. {
  639. designer.SetDataSource("View", data.Items);
  640. }
  641. designer.Process();
  642. if (!Directory.Exists(savePath))
  643. {
  644. Directory.CreateDirectory(savePath);
  645. }
  646. string serverPath = $"{savePath}{fileName}";
  647. designer.Workbook.Save(serverPath);
  648. string rst = $"{servicePath}{ftpPath}{fileName}";
  649. #endregion
  650. return Ok(JsonView(new { url = rst }));
  651. }
  652. #endregion
  653. #region 团组基本信息
  654. /// <summary>
  655. /// 接团信息列表
  656. /// </summary>
  657. /// <param name="dto">团组列表请求dto</param>
  658. /// <returns></returns>
  659. [HttpPost]
  660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  661. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  662. {
  663. var groupData = await _groupRepository.GetGroupList(dto);
  664. if (groupData.Code != 0)
  665. {
  666. return Ok(JsonView(false, groupData.Msg));
  667. }
  668. return Ok(JsonView(groupData.Data));
  669. }
  670. /// <summary>
  671. /// 分页查询团组列表
  672. /// </summary>
  673. /// <param name="dto"></param>
  674. /// <returns></returns>
  675. [HttpPost]
  676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  677. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  678. {
  679. var watch = new Stopwatch();
  680. watch.Start();
  681. RefAsync<int> total = 0;
  682. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  683. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  684. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  685. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  686. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  687. .Distinct()
  688. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  689. watch.Stop();
  690. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  691. }
  692. /// <summary>
  693. /// 接团信息列表 Page Init
  694. /// </summary>
  695. /// <returns></returns>
  696. [HttpPost]
  697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  698. public async Task<IActionResult> PostGroupPageListInit()
  699. {
  700. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  701. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  702. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  703. var _view = new
  704. {
  705. depData = depDatas,
  706. rankData = rankDatas
  707. };
  708. return Ok(JsonView(true, "查询成功!", _view));
  709. }
  710. /// <summary>
  711. /// 接团信息列表 Page
  712. /// </summary>
  713. /// <param name="dto">团组列表请求dto</param>
  714. /// <returns></returns>
  715. [HttpPost]
  716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  717. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  718. {
  719. #region 参数验证
  720. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  721. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  722. PageFunAuthViewBase
  723. pageFunAuthView = new PageFunAuthViewBase();
  724. #region 页面操作权限验证
  725. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  726. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  727. #endregion
  728. #endregion
  729. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  730. {
  731. string sqlWhere = string.Empty;
  732. if (dto.IsSure == 0) //未完成
  733. {
  734. sqlWhere += string.Format(@" And IsSure = 0");
  735. }
  736. else if (dto.IsSure == 1) //已完成
  737. {
  738. sqlWhere += string.Format(@" And IsSure = 1");
  739. }
  740. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  741. {
  742. string tj = dto.SearchCriteria;
  743. 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}%')",
  744. tj, tj, tj, tj, tj);
  745. }
  746. if (int.TryParse(dto.Rank, out int rankId))
  747. {
  748. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  749. }
  750. string sqlWhere1 = string.Empty;
  751. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  752. {
  753. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  754. }
  755. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  756. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  757. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  758. JietuanOperator,IsSure,CreateTime,IsBid
  759. From (
  760. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  761. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  762. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  763. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  764. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  765. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  766. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  767. From Grp_DelegationInfo gdi
  768. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  769. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  770. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  771. Where gdi.IsDel = 0 {0}
  772. ) temp {1}", sqlWhere, sqlWhere1);
  773. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  774. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  775. var _view = new
  776. {
  777. PageFuncAuth = pageFunAuthView,
  778. Data = _DelegationList
  779. };
  780. return Ok(JsonView(true, "查询成功!", _view, total));
  781. }
  782. else
  783. {
  784. return Ok(JsonView(false, "查询失败"));
  785. }
  786. }
  787. /// <summary>
  788. /// 团组列表
  789. /// </summary>
  790. /// <returns></returns>
  791. [HttpPost]
  792. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  793. {
  794. #region 参数验证
  795. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  796. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  797. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  798. #region 页面操作权限验证
  799. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  800. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  801. #endregion
  802. #endregion
  803. if (dto.PortType != 1 && dto.PortType != 2)
  804. {
  805. return Ok(JsonView(false, "查询失败!"));
  806. }
  807. string orderbyStr = "order by gdi.CreateTime Desc";
  808. string sqlWhere = string.Empty;
  809. if (dto.IsSure == 0) //未完成
  810. {
  811. sqlWhere += string.Format(@" And IsSure = 0");
  812. }
  813. else if (dto.IsSure == 1) //已完成
  814. {
  815. sqlWhere += string.Format(@" And IsSure = 1");
  816. }
  817. //团组类型
  818. if (dto.TeamDid > 0)
  819. {
  820. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  821. }
  822. //团组名称
  823. if (!string.IsNullOrEmpty(dto.TeamName))
  824. {
  825. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  826. }
  827. //客户名称
  828. if (!string.IsNullOrEmpty(dto.ClientName))
  829. {
  830. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  831. }
  832. //客户单位
  833. if (!string.IsNullOrEmpty(dto.ClientUnit))
  834. {
  835. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  836. }
  837. //出访时间
  838. if (!string.IsNullOrEmpty(dto.visitDataTime))
  839. {
  840. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  841. orderbyStr = "order by gdi.VisitDate";
  842. }
  843. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  844. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  845. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  846. JietuanOperator,IsSure,CreateTime
  847. From (
  848. Select row_number() over({0}) as Row_Number,
  849. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  850. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  851. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  852. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  853. From Grp_DelegationInfo gdi
  854. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  855. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  856. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  857. Where gdi.IsDel = 0 {1}
  858. ) temp ", orderbyStr, sqlWhere);
  859. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  860. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  861. #region 处理所属部门
  862. /*
  863. * 1.sq 和 gyy 等显示 市场部
  864. * 2.王鸽和主管及张总还有管理员号统一国交部
  865. * 2-1. 4 管理员 ,21 张海麟
  866. */
  867. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  868. List<int> userIds1 = new List<int>() { 4, 21 };
  869. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  870. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  871. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  872. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  873. .ToList();
  874. foreach (var item in _DelegationList)
  875. {
  876. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  877. }
  878. #endregion
  879. var _view = new
  880. {
  881. PageFuncAuth = pageFunAuthView,
  882. Data = _DelegationList
  883. };
  884. return Ok(JsonView(true, "查询成功!", _view, total));
  885. }
  886. /// <summary>
  887. /// 接团信息详情
  888. /// </summary>
  889. /// <param name="dto">团组info请求dto</param>
  890. /// <returns></returns>
  891. [HttpPost]
  892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  893. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  894. {
  895. var groupData = await _groupRepository.GetGroupInfo(dto);
  896. if (groupData.Code != 0)
  897. {
  898. return Ok(JsonView(false, groupData.Msg));
  899. }
  900. return Ok(JsonView(groupData.Data));
  901. }
  902. /// <summary>
  903. /// 接团信息 编辑添加
  904. /// 基础信息数据源
  905. /// </summary>
  906. /// <param name="dto"></param>
  907. /// <returns></returns>
  908. [HttpPost]
  909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  910. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  911. {
  912. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  913. if (groupData.Code != 0)
  914. {
  915. return Ok(JsonView(false, groupData.Msg));
  916. }
  917. return Ok(JsonView(groupData.Data));
  918. }
  919. /// <summary>
  920. /// 成本修改团组信息
  921. /// </summary>
  922. /// <param name="dto"></param>
  923. /// <returns></returns>
  924. [HttpPost]
  925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  926. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  927. {
  928. var jw = JsonView(false, "操作失败");
  929. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  930. if (di == null)
  931. {
  932. jw.Msg = "参数有误!";
  933. return Ok(jw);
  934. }
  935. #region 添加出访起止时间
  936. var startTime = new DateTime();
  937. var endTime = new DateTime();
  938. if (DateTime.TryParse(dto.VisitDate, out startTime))
  939. {
  940. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  941. }
  942. else
  943. {
  944. jw.Msg = "参数有误!";
  945. return Ok(jw);
  946. }
  947. #endregion
  948. di.VisitDate = startTime;
  949. di.VisitPNumber = dto.VisitPNumber;
  950. di.VisitDays = dto.VisitDays;
  951. di.VisitStartDate = startTime;
  952. di.VisitEndDate = endTime;
  953. var count = _sqlSugar.Updateable(di)
  954. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  955. .ExecuteCommand();
  956. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  957. }
  958. /// <summary>
  959. /// 接团信息 编辑添加
  960. /// 省份-城市 基础信息数据源
  961. /// </summary>
  962. /// <param name="dto"></param>
  963. /// <returns></returns>
  964. [HttpPost]
  965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  966. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  967. {
  968. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  969. string search = dto.Search;
  970. var data = await _groupRepository.CityBasicSource();
  971. int total = data.Length;
  972. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  973. .Skip((pageIndex - 1) * pageSize)
  974. .Take(pageSize)
  975. .ToArray();
  976. return Ok(JsonView(data, total));
  977. }
  978. /// <summary>
  979. /// 接团信息 操作(增改)
  980. /// </summary>
  981. /// <param name="dto"></param>
  982. /// <returns></returns>
  983. [HttpPost]
  984. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  985. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  986. {
  987. // 创建 Stopwatch 实例
  988. Stopwatch stopwatch = Stopwatch.StartNew();
  989. decimal ffrPrice = 0.00M;
  990. DateTime? visitDt = null;
  991. if (dto.Status == 2)
  992. {
  993. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  994. if (groupInfo != null)
  995. {
  996. ffrPrice = groupInfo.PaymentMoney;
  997. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  998. }
  999. }
  1000. var groupData = await _groupRepository.GroupOperation(dto);
  1001. if (groupData.Code != 0)
  1002. {
  1003. return Ok(JsonView(false, groupData.Msg));
  1004. }
  1005. int diId = 0;
  1006. try
  1007. {
  1008. //添加时 默认加入团组汇率
  1009. if (dto.Status == 1) //添加
  1010. {
  1011. diId = groupData.Data;
  1012. //添加默认币种
  1013. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1014. //默认分配权限
  1015. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1016. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1017. var _managerIds = new List<int>() { 22, 32, 21 };
  1018. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1019. if (userIds.Count > 0)
  1020. {
  1021. userIds.Add(208);
  1022. //创建团组管控
  1023. GroupStepForDelegation.CreateWorkStep(diId);
  1024. //发送消息
  1025. string groupName = dto.TeamName;
  1026. string createGroupUser = string.Empty;
  1027. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1028. if (userInfo != null) createGroupUser = userInfo.CnName;
  1029. string title = $"系统通知";
  1030. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1031. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1032. }
  1033. //默认创建倒推表
  1034. await _invertedListRep._Create(dto.UserId, diId);
  1035. }
  1036. else if (dto.Status == 2)
  1037. {
  1038. diId = dto.Id;
  1039. }
  1040. #region 签证人员团组时间通知
  1041. #region 计算出访起止时间
  1042. var startTime = new DateTime();
  1043. var endTime = new DateTime();
  1044. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1045. {
  1046. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1047. }
  1048. #endregion
  1049. #endregion
  1050. #region 团组操作默认添加/修改收款账单
  1051. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1052. {
  1053. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1054. .Where(x => x.IsDel == 0 &&
  1055. x.Diid == diId &&
  1056. x.Remark.Equals("预付款")
  1057. )
  1058. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1059. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1060. .FirstAsync();
  1061. ffrInfo = new Fin_ForeignReceivables()
  1062. {
  1063. Diid = diId,
  1064. PriceName = dto.ClientUnit,
  1065. Price = dto.PaymentMoney,
  1066. Count = 1,
  1067. Unit = $"元",
  1068. ItemSumPrice = dto.PaymentMoney,
  1069. Rate = 1.0000M,
  1070. Currency = 836,
  1071. AddingWay = 0,
  1072. CreateUserId = dto.UserId,
  1073. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1074. Remark = $"预付款"
  1075. };
  1076. if (ffrInfo == null) //Add
  1077. {
  1078. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1079. }
  1080. else //修改
  1081. {
  1082. await _sqlSugar.Updateable(ffrInfo)
  1083. .UpdateColumns(x => new
  1084. {
  1085. x.PriceName,
  1086. x.Price,
  1087. x.ItemSumPrice,
  1088. x.CreateTime,
  1089. x.CreateUserId
  1090. })
  1091. .WhereColumns(x => x.Id)
  1092. .ExecuteCommandAsync();
  1093. }
  1094. }
  1095. #endregion
  1096. if (diId > 0)
  1097. {
  1098. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1099. }
  1100. // 停止计时
  1101. stopwatch.Stop();
  1102. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1103. }
  1104. catch (Exception ex)
  1105. {
  1106. // 停止计时
  1107. stopwatch.Stop();
  1108. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1109. Logs(ex.Message);
  1110. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1111. }
  1112. // 停止计时
  1113. stopwatch.Stop();
  1114. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1115. }
  1116. /// <summary>
  1117. /// 接团流程操作(增改)
  1118. /// 安卓端使用 建团时添加客户名单
  1119. /// </summary>
  1120. /// <param name="dto"></param>
  1121. /// <returns></returns>
  1122. [HttpPost]
  1123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1124. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1125. {
  1126. #region 参数验证
  1127. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1128. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1129. #region 页面操作权限验证
  1130. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1131. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1132. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1133. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1134. #endregion
  1135. #endregion
  1136. try
  1137. {
  1138. //_sqlSugar.BeginTran();
  1139. decimal ffrPrice = 0.00M;
  1140. DateTime? visitDt = null;
  1141. if (dto.Status == 2)
  1142. {
  1143. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1144. if (groupInfo != null)
  1145. {
  1146. ffrPrice = groupInfo.PaymentMoney;
  1147. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1148. }
  1149. }
  1150. var _dto = new GroupOperationDto();
  1151. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1152. var groupData = await _groupRepository.GroupOperation(_dto);
  1153. if (groupData.Code != 0)
  1154. {
  1155. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1156. }
  1157. int diId = 0;
  1158. //添加时 默认加入团组汇率
  1159. if (dto.Status == 1) //添加
  1160. {
  1161. diId = groupData.Data;
  1162. //添加默认币种
  1163. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1164. //默认分配权限
  1165. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1166. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1167. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1168. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1169. if (userIds.Count > 0)
  1170. {
  1171. userIds.Add(208);
  1172. //创建团组管控
  1173. GroupStepForDelegation.CreateWorkStep(diId);
  1174. //发送消息
  1175. string groupName = dto.TeamName;
  1176. string createGroupUser = string.Empty;
  1177. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1178. if (userInfo != null) createGroupUser = userInfo.CnName;
  1179. string title = $"系统通知";
  1180. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1181. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1182. }
  1183. #region 应用推送
  1184. try
  1185. {
  1186. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1187. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1188. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1189. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1190. {
  1191. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1192. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1193. }
  1194. }
  1195. catch (Exception ex)
  1196. {
  1197. }
  1198. #endregion
  1199. //默认创建倒推表
  1200. await _invertedListRep._Create(dto.UserId, diId);
  1201. }
  1202. if (dto.Status == 2)
  1203. {
  1204. diId = dto.Id;
  1205. if (diId == 0)
  1206. {
  1207. //_sqlSugar.RollbackTran();
  1208. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1209. }
  1210. }
  1211. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1212. if (viewData.Code != 0)
  1213. {
  1214. //_sqlSugar.RollbackTran();
  1215. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1216. }
  1217. #region 团组操作默认添加/修改收款账单
  1218. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1219. {
  1220. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1221. .Where(x => x.IsDel == 0 &&
  1222. x.Diid == diId &&
  1223. x.Remark.Equals("预付款")
  1224. )
  1225. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1226. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1227. .FirstAsync();
  1228. ffrInfo = new Fin_ForeignReceivables()
  1229. {
  1230. Diid = diId,
  1231. PriceName = dto.ClientUnit,
  1232. Price = dto.PaymentMoney,
  1233. Count = 1,
  1234. Unit = $"元",
  1235. ItemSumPrice = dto.PaymentMoney,
  1236. Rate = 1.0000M,
  1237. Currency = 836,
  1238. AddingWay = 0,
  1239. CreateUserId = dto.UserId,
  1240. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1241. Remark = $"预付款"
  1242. };
  1243. if (ffrInfo == null) //Add
  1244. {
  1245. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1246. }
  1247. else //修改
  1248. {
  1249. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1250. .UpdateColumns(x => new
  1251. {
  1252. x.PriceName,
  1253. x.Price,
  1254. x.ItemSumPrice,
  1255. x.CreateTime,
  1256. x.CreateUserId
  1257. })
  1258. .WhereColumns(x => x.Id)
  1259. .ExecuteCommandAsync();
  1260. }
  1261. }
  1262. #endregion
  1263. #region 签证人员团组时间通知
  1264. #region 计算出访起止时间
  1265. var startTime = new DateTime();
  1266. var endTime = new DateTime();
  1267. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1268. {
  1269. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1270. }
  1271. #endregion
  1272. if (diId > 0)
  1273. {
  1274. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1275. }
  1276. #endregion
  1277. //_sqlSugar.CommitTran();
  1278. return Ok(JsonView(true, "添加成功"));
  1279. }
  1280. catch (Exception ex)
  1281. {
  1282. _sqlSugar.RollbackTran();
  1283. return Ok(JsonView(false, ex.Message));
  1284. }
  1285. }
  1286. /// <summary>
  1287. /// 接团流程操作(增改)
  1288. /// 安卓端使用 建团时添加客户名单
  1289. /// </summary>
  1290. /// <param name="dto"></param>
  1291. /// <returns></returns>
  1292. [HttpPost]
  1293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1294. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1295. {
  1296. #region 参数验证
  1297. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1298. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1299. #region 页面操作权限验证
  1300. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1301. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1302. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1303. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1304. #endregion
  1305. #endregion
  1306. _sqlSugar.BeginTran();
  1307. decimal ffrPrice = 0.00M;
  1308. DateTime? visitDt = null;
  1309. if (dto.Status == 2)
  1310. {
  1311. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1312. if (groupInfo != null)
  1313. {
  1314. ffrPrice = groupInfo.PaymentMoney;
  1315. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1316. }
  1317. }
  1318. var _dto = new GroupOperationDto();
  1319. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1320. var groupData = await _groupRepository.GroupOperation(_dto);
  1321. if (groupData.Code != 0)
  1322. {
  1323. _sqlSugar.RollbackTran();
  1324. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1325. }
  1326. try
  1327. {
  1328. int diId = 0;
  1329. //添加时 默认加入团组汇率
  1330. if (dto.Status == 1) //添加
  1331. {
  1332. diId = groupData.Data;
  1333. //添加默认币种
  1334. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1335. //默认分配权限
  1336. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1337. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1338. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1339. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1340. if (userIds.Count > 0)
  1341. {
  1342. userIds.Add(208);
  1343. //创建团组管控
  1344. GroupStepForDelegation.CreateWorkStep(diId);
  1345. //发送消息
  1346. string groupName = dto.TeamName;
  1347. string createGroupUser = string.Empty;
  1348. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1349. if (userInfo != null) createGroupUser = userInfo.CnName;
  1350. string title = $"系统通知";
  1351. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1352. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1353. }
  1354. #region 应用推送
  1355. try
  1356. {
  1357. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1358. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1359. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1360. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1361. {
  1362. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1363. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1364. }
  1365. }
  1366. catch (Exception ex)
  1367. {
  1368. _sqlSugar.CommitTran();
  1369. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1370. }
  1371. #endregion
  1372. //默认创建倒推表
  1373. await _invertedListRep._Create(dto.UserId, diId);
  1374. }
  1375. else if (dto.Status == 2)
  1376. {
  1377. diId = dto.Id;
  1378. if (diId == 0)
  1379. {
  1380. _sqlSugar.RollbackTran();
  1381. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1382. }
  1383. }
  1384. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1385. if (viewData.Code != 0)
  1386. {
  1387. _sqlSugar.RollbackTran();
  1388. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1389. }
  1390. #region 团组操作默认添加/修改收款账单
  1391. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1392. {
  1393. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1394. .Where(x => x.IsDel == 0 &&
  1395. x.Diid == diId &&
  1396. x.Remark.Equals("预付款")
  1397. )
  1398. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1399. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1400. .FirstAsync();
  1401. ffrInfo = new Fin_ForeignReceivables()
  1402. {
  1403. Diid = diId,
  1404. PriceName = dto.ClientUnit,
  1405. Price = dto.PaymentMoney,
  1406. Count = 1,
  1407. Unit = $"元",
  1408. ItemSumPrice = dto.PaymentMoney,
  1409. Rate = 1.0000M,
  1410. Currency = 836,
  1411. AddingWay = 0,
  1412. CreateUserId = dto.UserId,
  1413. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1414. Remark = $"预付款"
  1415. };
  1416. if (ffrInfo == null) //Add
  1417. {
  1418. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1419. }
  1420. else //修改
  1421. {
  1422. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1423. .UpdateColumns(x => new
  1424. {
  1425. x.PriceName,
  1426. x.Price,
  1427. x.ItemSumPrice,
  1428. x.CreateTime,
  1429. x.CreateUserId
  1430. })
  1431. .WhereColumns(x => x.Id)
  1432. .ExecuteCommandAsync();
  1433. }
  1434. }
  1435. #endregion
  1436. #region 签证人员团组时间通知
  1437. #region 计算出访起止时间
  1438. var startTime = new DateTime();
  1439. var endTime = new DateTime();
  1440. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1441. {
  1442. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1443. }
  1444. #endregion
  1445. if (diId > 0)
  1446. {
  1447. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1448. }
  1449. #endregion
  1450. _sqlSugar.CommitTran();
  1451. return Ok(JsonView(true));
  1452. }
  1453. catch (Exception ex)
  1454. {
  1455. _sqlSugar.RollbackTran();
  1456. return Ok(JsonView(false, ex.Message));
  1457. }
  1458. }
  1459. /// <summary>
  1460. /// 接团信息 操作(删除)
  1461. /// </summary>
  1462. /// <param name="dto"></param>
  1463. /// <returns></returns>
  1464. [HttpPost]
  1465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1466. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1467. {
  1468. var diId = dto.Id;
  1469. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1470. #region 删除 验证
  1471. /*
  1472. * 1、收款账单数据:0 条
  1473. * 2、收款退还数据:0 条
  1474. * 3、机票费用数据:0 条
  1475. * 4、签证费用数据:0 条
  1476. * 5、保险费用数据:0 条
  1477. * 6、酒店费用数据:0 条
  1478. * 7、公务出访数据:1 条
  1479. * 8、邀请公务活动费用数据:1 条
  1480. * 9、OP费用数据:5 条
  1481. * 10、其他费用数据:0 条
  1482. * 11、团组日付报销费用数据:0 条
  1483. *
  1484. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1485. */
  1486. //收款账单
  1487. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1488. //收款退还
  1489. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1490. //机票费用
  1491. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1492. //签证费用
  1493. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1494. //保险费用
  1495. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1496. //酒店费用
  1497. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1498. //公务出访
  1499. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1500. //邀请公务活动费用
  1501. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1502. //OP费用
  1503. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1504. //其他费用
  1505. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1506. //团组日付报销费用
  1507. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1508. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1509. if (feeCount > 0)
  1510. {
  1511. var delMsgTips = new StringBuilder();
  1512. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1513. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1514. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1515. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1516. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1517. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1518. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1519. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1520. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1521. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1522. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1523. delMsgTips.AppendLine($"");
  1524. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1525. return Ok(JsonView(false, delMsgTips.ToString()));
  1526. }
  1527. #endregion
  1528. var groupData = await _groupRepository.GroupDel(dto);
  1529. if (groupData.Code != 0)
  1530. {
  1531. return Ok(JsonView(false, groupData.Msg));
  1532. }
  1533. return Ok(JsonView(true));
  1534. }
  1535. /// <summary>
  1536. /// 获取团组销售报价号
  1537. /// 团组添加时 使用
  1538. /// </summary>
  1539. /// <returns></returns>
  1540. [HttpPost]
  1541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1542. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1543. {
  1544. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1545. if (groupData.Code != 0)
  1546. {
  1547. return Ok(JsonView(false, groupData.Msg));
  1548. }
  1549. object salesQuoteNo = new
  1550. {
  1551. SalesQuoteNo = groupData.Data
  1552. };
  1553. return Ok(JsonView(salesQuoteNo));
  1554. }
  1555. /// <summary>
  1556. /// 设置确认出团
  1557. /// </summary>
  1558. /// <param name="dto"></param>
  1559. /// <returns></returns>
  1560. [HttpPost]
  1561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1562. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1563. {
  1564. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1565. if (groupData.Code != 0)
  1566. {
  1567. return Ok(JsonView(false, groupData.Msg));
  1568. }
  1569. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1570. #region OA消息推送
  1571. try
  1572. {
  1573. string groupName = groupInfo.TeamName;
  1574. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1575. string title = $"系统通知";
  1576. string content = $"团组[{groupName}]已确认出团!";
  1577. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1578. }
  1579. catch (Exception ex)
  1580. {
  1581. }
  1582. #endregion
  1583. #region 应用推送
  1584. try
  1585. {
  1586. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1587. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1588. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1589. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1590. {
  1591. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1592. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1593. }
  1594. }
  1595. catch (Exception ex)
  1596. {
  1597. }
  1598. #endregion
  1599. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1600. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1601. }
  1602. /// <summary>
  1603. /// 获取团组名称data And 签证国别Data
  1604. /// </summary>
  1605. /// <param name="dto"></param>
  1606. /// <returns></returns>
  1607. [HttpPost]
  1608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1609. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1610. {
  1611. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1612. if (groupData.Code != 0)
  1613. {
  1614. return Ok(JsonView(false, groupData.Msg));
  1615. }
  1616. return Ok(JsonView(groupData.Data));
  1617. }
  1618. /// <summary>
  1619. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1620. /// </summary>
  1621. /// <returns></returns>
  1622. [HttpPost]
  1623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1624. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1625. {
  1626. try
  1627. {
  1628. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1629. if (groupData.Code != 0)
  1630. {
  1631. return Ok(JsonView(false, groupData.Msg));
  1632. }
  1633. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1634. }
  1635. catch (Exception ex)
  1636. {
  1637. return Ok(JsonView(false, "程序错误!"));
  1638. throw;
  1639. }
  1640. }
  1641. /// <summary>
  1642. /// 团组清单 Excel
  1643. /// </summary>
  1644. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1645. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1646. /// <returns></returns>
  1647. [HttpGet]
  1648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1649. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1650. {
  1651. DateTime _beginDt, _endDt;
  1652. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1653. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1654. if (!beginBool && !endBool)
  1655. {
  1656. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1657. }
  1658. string sql = string.Format(@"
  1659. SELECT
  1660. ROW_NUMBER,
  1661. Id,
  1662. SalesQuoteNo,
  1663. TourCode,
  1664. TeamTypeId,
  1665. TeamType,
  1666. TeamLevId,
  1667. TeamLev,
  1668. TeamName,
  1669. ClientName,
  1670. ClientUnit,
  1671. VisitDate,
  1672. VisitDays,
  1673. VisitPNumber,
  1674. JietuanOperatorId,
  1675. JietuanOperator,
  1676. IsSure,
  1677. CreateUserName,
  1678. IsBid
  1679. FROM
  1680. (
  1681. SELECT
  1682. ROW_NUMBER() OVER(
  1683. ORDER BY
  1684. gdi.VisitDate Desc
  1685. ) AS ROW_NUMBER,
  1686. gdi.Id,
  1687. SalesQuoteNo,
  1688. TourCode,
  1689. ssd.Id TeamTypeId,
  1690. ssd.Name TeamType,
  1691. ssd1.Id TeamLevId,
  1692. ssd1.Name TeamLev,
  1693. TeamName,
  1694. ClientName,
  1695. ClientUnit,
  1696. VisitDate,
  1697. VisitDays,
  1698. VisitPNumber,
  1699. JietuanOperator JietuanOperatorId,
  1700. su.CnName JietuanOperator,
  1701. IsSure,
  1702. gdi.CreateTime,
  1703. su1.CnName As CreateUserName,
  1704. gdi.IsBid
  1705. FROM
  1706. Grp_DelegationInfo gdi
  1707. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1708. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1709. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1710. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1711. WHERE
  1712. gdi.IsDel = 0
  1713. AND gdi.IsBid = 0
  1714. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1715. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1716. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1717. #region 处理所属部门
  1718. /*
  1719. * 1.sq 和 gyy 等显示 市场部
  1720. * 2.王鸽和主管及张总还有管理员号统一国交部
  1721. * 2-1. 4 管理员 ,21 张海麟
  1722. */
  1723. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1724. List<int> userIds1 = new List<int>() { 4, 21 };
  1725. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1726. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1727. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1728. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1729. .ToListAsync();
  1730. var droupIds = groupList.Select(it => it.Id).ToList();
  1731. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1732. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1733. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1734. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1735. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1736. {
  1737. DiId = tcl.DiId,
  1738. LastName = dc.LastName,
  1739. FirstName = dc.FirstName,
  1740. Sex = dc.Sex,
  1741. Birthday = dc.BirthDay,
  1742. Company = cc.CompanyFullName,
  1743. Job = dc.Job,
  1744. CreateTime = tcl.CreateTime,
  1745. })
  1746. .ToList();
  1747. foreach (var item in groupList)
  1748. {
  1749. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1750. string groupFirstName = "";
  1751. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1752. if (currDatas.Any())
  1753. {
  1754. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1755. }
  1756. item.GroupFirst = groupFirstName;
  1757. }
  1758. #endregion
  1759. #region Excel
  1760. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1761. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1762. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1763. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1764. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1765. //载入模板
  1766. WorkbookDesigner designer = new WorkbookDesigner();
  1767. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1768. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1769. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1770. dt.TableName = "GroupList";
  1771. designer.SetDataSource(dt);
  1772. designer.Process();
  1773. if (!Directory.Exists(savePath))
  1774. {
  1775. Directory.CreateDirectory(savePath);
  1776. }
  1777. string serverPath = $"{savePath}{fileName}";
  1778. designer.Workbook.Save(serverPath);
  1779. string rst = $"{servicePath}{ftpPath}{fileName}";
  1780. #endregion
  1781. return Ok(JsonView(true, "操作成功!", rst));
  1782. }
  1783. /// <summary>
  1784. /// 团组合同下载(1.付款80% 2.付全款)
  1785. /// </summary>
  1786. /// <param name="dto"></param>
  1787. /// <returns></returns>
  1788. /// <exception cref="Exception"></exception>
  1789. [HttpPost]
  1790. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1791. {
  1792. var jw = JsonView(false);
  1793. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1794. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1795. if (di == null)
  1796. {
  1797. jw.Msg = "团组Id有误!";
  1798. return Ok(jw);
  1799. }
  1800. #region 权限校验
  1801. var allDownFile = new List<int>() { 21 };
  1802. try
  1803. {
  1804. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1805. .First(x => x.Id == 1418 && x.IsDel == 0);
  1806. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1807. }
  1808. catch (Exception)
  1809. { }
  1810. var guojiaoDownFile = new List<int>() { 330 };
  1811. var shichangDownFile = new List<int>() { 95 };
  1812. if (allDownFile.Contains(dto.UserId))
  1813. {
  1814. }
  1815. else if (guojiaoDownFile.Contains(dto.UserId))
  1816. {
  1817. var guojiaobuDi = new List<int>() { 4, 21 };
  1818. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1819. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1820. .Where((d, u) => u.Id == di.JietuanOperator)
  1821. .Select((d, u) => d.DepName)
  1822. .First();
  1823. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1824. {
  1825. jw.Msg = "暂无下载权限!";
  1826. return Ok(jw);
  1827. }
  1828. }
  1829. else if (shichangDownFile.Contains(dto.UserId))
  1830. {
  1831. var dic = new Dictionary<int, int[]>()
  1832. {
  1833. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1834. };
  1835. try
  1836. {
  1837. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1838. if (sqSetting != null)
  1839. {
  1840. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1841. foreach (var item in result.Keys)
  1842. {
  1843. if (dic.Keys.Contains(item))
  1844. {
  1845. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1846. Array.Copy(dic[item], dilatation, dic[item].Length);
  1847. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1848. dic[item] = dilatation;
  1849. }
  1850. else
  1851. {
  1852. dic.Add(item, result[item]);
  1853. }
  1854. }
  1855. }
  1856. if (!dic[95].Contains(di.CreateUserId))
  1857. {
  1858. jw.Msg = "暂无下载权限!";
  1859. return Ok(jw);
  1860. }
  1861. }
  1862. catch (Exception)
  1863. { }
  1864. }
  1865. else if (dto.UserId == di.CreateUserId)
  1866. {
  1867. }
  1868. else
  1869. {
  1870. jw.Msg = "暂无下载权限!";
  1871. return Ok(jw);
  1872. }
  1873. #endregion
  1874. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1875. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1876. .ToListAsync();
  1877. if (!blackCodeList.Any())
  1878. {
  1879. jw.Msg = "该团无机票行程代码!";
  1880. return Ok(jw);
  1881. }
  1882. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1883. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1884. if (groupEnterExitCost == null)
  1885. {
  1886. jw.Msg = "暂无三公费用信息!";
  1887. return Ok(jw);
  1888. }
  1889. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1890. rateList ??= new List<CurrencyInfo>();
  1891. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1892. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1893. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1894. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1895. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1896. .Select((x, a, b) => new
  1897. {
  1898. x.Index,
  1899. itemName = a.Name,
  1900. CurrencyStr = b.Name,
  1901. x.Cost,
  1902. x.SubTotal,
  1903. x.Remark
  1904. })
  1905. .OrderBy((x) => x.Index)
  1906. .ToList();
  1907. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1908. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1909. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1910. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1911. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1912. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1913. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1914. decimal subJJC = 0.00M,
  1915. subGWC = 0.00M,
  1916. subTDC = 0.00M;
  1917. //经济舱
  1918. if (groupEnterExitCost.SumJJC == 1)
  1919. {
  1920. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1921. }
  1922. //公务舱
  1923. if (groupEnterExitCost.SumGWC == 1)
  1924. {
  1925. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1926. }
  1927. //头等舱
  1928. if (groupEnterExitCost.SumTDC == 1)
  1929. {
  1930. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1931. }
  1932. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1933. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1934. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1935. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  1936. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  1937. .Select((x, s, dc, cc) => new groupClints
  1938. {
  1939. Id = x.Id,
  1940. Name = s.Name,
  1941. IsAccompany = x.IsAccompany,
  1942. CompanyFullName = cc.CompanyFullName
  1943. })
  1944. .ToListAsync();
  1945. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  1946. //获取舱位人数
  1947. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  1948. .GroupBy(x => x.Name)
  1949. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1950. .ToList();
  1951. string cityPath = string.Empty;
  1952. string startCity = string.Empty;
  1953. string endCity = string.Empty;
  1954. foreach (var item in blackCodeList)
  1955. {
  1956. string city = GeneralMethod.GetGroupCityLine(item, "-");
  1957. cityPath += city + "\r\n";
  1958. if (item.Equals(blackCodeList.First()))
  1959. {
  1960. var sp = city.Split('-');
  1961. startCity = sp[0];
  1962. endCity = sp[sp.Length - 1];
  1963. }
  1964. }
  1965. Dictionary<string, string> bookMarkDic = new Dictionary<string, string>();
  1966. bookMarkDic.Add("ClientUnit", di.ClientUnit);
  1967. bookMarkDic.Add("VisitCountry", di.VisitCountry);
  1968. bookMarkDic.Add("VisitDate", di.VisitDate.ToString("yyyy年MM月dd日"));
  1969. bookMarkDic.Add("VisitPNumber", di.VisitPNumber.ToString());
  1970. bookMarkDic.Add("CityPath", cityPath);
  1971. bookMarkDic.Add("StartCity", startCity);
  1972. bookMarkDic.Add("EndCity", endCity);
  1973. bookMarkDic.Add("StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚");
  1974. Document doc = null;
  1975. var percentage = 0.8M;
  1976. var fileNameadd = "预付";
  1977. if (dto.FileType == 1)
  1978. {
  1979. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  1980. }
  1981. else if (dto.FileType == 2)
  1982. {
  1983. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  1984. percentage = 1;
  1985. fileNameadd = "全款";
  1986. }
  1987. else
  1988. {
  1989. throw new Exception("FileType有误!");
  1990. }
  1991. DocumentBuilder builder = new DocumentBuilder(doc);
  1992. decimal totalPrice = 0.00M;
  1993. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  1994. if (firstTable != null)
  1995. {
  1996. // 遍历表格的行和单元格
  1997. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  1998. {
  1999. for (int i = 0; i < row.Cells.Count; i++)
  2000. {
  2001. var cell = row.Cells[i];
  2002. // 读取单元格内容
  2003. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2004. if (cellTextFirst.Contains("舱位"))
  2005. {
  2006. break;
  2007. }
  2008. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2009. {
  2010. if (i == 2)
  2011. {
  2012. if (cellTextFirst == "经济舱")
  2013. {
  2014. // 设置单元格内容
  2015. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2016. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2017. }
  2018. else
  2019. {
  2020. // 设置单元格内容
  2021. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2022. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2023. }
  2024. }
  2025. if (i == 3)
  2026. {
  2027. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2028. if (count != null)
  2029. {
  2030. // 设置单元格内容
  2031. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2032. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2033. }
  2034. }
  2035. if (i == 4)
  2036. {
  2037. var rowPrice = 0.00M;
  2038. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2039. count ??= 0;
  2040. if (cellTextFirst == "经济舱")
  2041. {
  2042. rowPrice = subJJC * (int)count;
  2043. }
  2044. else
  2045. {
  2046. rowPrice = subGWC * (int)count;
  2047. }
  2048. totalPrice += rowPrice;
  2049. // 设置单元格内容
  2050. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2051. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2052. }
  2053. }
  2054. }
  2055. }
  2056. }
  2057. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2058. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2059. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2060. //--合同表格部分
  2061. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2062. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2063. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2064. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2065. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2066. bookMarkDic.Add("CityPath1", cityPath);
  2067. bookMarkDic.Add("CityPath2", cityPath);
  2068. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2069. if (contractTable != null)
  2070. {
  2071. //数据源
  2072. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2073. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2074. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2075. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2076. .Select((it, y, s) => new
  2077. {
  2078. it.Cost,
  2079. it.SubTotal,
  2080. it.Type,
  2081. y.Id,
  2082. y.City,
  2083. s.Name,
  2084. CurrencyCodeCn = s.Remark
  2085. })
  2086. .ToList()
  2087. .Select(x => new
  2088. {
  2089. CurrencyCode = x.Name,
  2090. CityId = x.Id,
  2091. x.City,
  2092. VisitPNumber = di.VisitPNumber,
  2093. x.Type,
  2094. x.Cost,
  2095. x.SubTotal,
  2096. Rate = rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2097. x.CurrencyCodeCn,
  2098. });
  2099. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2100. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2101. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2102. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2103. List<tableSetting> tableSettings = new List<tableSetting>()
  2104. {
  2105. new tableSetting{ Index = 1 , Property = "City"},
  2106. new tableSetting{ Index = 2 , Property = "CurrencyCodeCn"},
  2107. new tableSetting{ Index = 3 , Property = "Cost"},
  2108. new tableSetting{ Index = 4 , Property = "VisitPNumber"},
  2109. //new tableSetting{ Index = 5 , Property = ""},
  2110. //new tableSetting{ Index = 6 , Property = ""},
  2111. new tableSetting{ Index = 7 , Property = "Rate"},
  2112. //new tableSetting{ Index = 8 , Property = ""},
  2113. };
  2114. //1.住宿费
  2115. int cloneRow = 8;
  2116. int startDayPrice = 8; //写入index
  2117. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2118. foreach (var dac in dac1)
  2119. {
  2120. var first = dac.First();
  2121. var dayCount = dac.Count();
  2122. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2123. for (int i = 1; i < row.Cells.Count; i++)
  2124. {
  2125. var cell = row.Cells[i];
  2126. var findProperty = tableSettings.Find(x => x.Index == i);
  2127. if (findProperty != null)
  2128. {
  2129. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2130. // 设置单元格内容
  2131. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2132. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2133. }
  2134. else
  2135. {
  2136. switch (i)
  2137. {
  2138. case 5:
  2139. cell.FirstParagraph.Runs.Clear();
  2140. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2141. break;
  2142. case 6:
  2143. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2144. cell.FirstParagraph.Runs.Clear();
  2145. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2146. break;
  2147. case 8:
  2148. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2149. cell.FirstParagraph.Runs.Clear();
  2150. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2151. ZSPriceSum += xiaojiRMB;
  2152. break;
  2153. default:
  2154. break;
  2155. }
  2156. }
  2157. }
  2158. startDayPrice++;
  2159. if (!dac1.Last().Equals(dac))
  2160. {
  2161. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2162. // 将克隆的行追加到原行后面
  2163. contractTable.Rows.Insert(startDayPrice, newRow);
  2164. }
  2165. else
  2166. {
  2167. cloneRow += dac1.Count() + 1;
  2168. startDayPrice = cloneRow;
  2169. }
  2170. }
  2171. //2.伙食费
  2172. foreach (var dac in dac2)
  2173. {
  2174. var first = dac.First();
  2175. var dayCount = dac.Count();
  2176. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2177. for (int i = 1; i < row.Cells.Count; i++)
  2178. {
  2179. var cell = row.Cells[i];
  2180. var findProperty = tableSettings.Find(x => x.Index == i);
  2181. if (findProperty != null)
  2182. {
  2183. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2184. // 设置单元格内容
  2185. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2186. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2187. }
  2188. else
  2189. {
  2190. switch (i)
  2191. {
  2192. case 5:
  2193. cell.FirstParagraph.Runs.Clear();
  2194. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2195. break;
  2196. case 6:
  2197. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2198. cell.FirstParagraph.Runs.Clear();
  2199. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2200. break;
  2201. case 8:
  2202. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2203. cell.FirstParagraph.Runs.Clear();
  2204. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2205. HSPriceSum += xiaojiRMB;
  2206. break;
  2207. default:
  2208. break;
  2209. }
  2210. }
  2211. }
  2212. startDayPrice++;
  2213. if (!dac2.Last().Equals(dac))
  2214. {
  2215. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2216. // 将克隆的行追加到原行后面
  2217. contractTable.Rows.Insert(startDayPrice, newRow);
  2218. }
  2219. else
  2220. {
  2221. cloneRow += dac2.Count() + 1;
  2222. startDayPrice = cloneRow;
  2223. }
  2224. }
  2225. //3.公杂费
  2226. foreach (var dac in dac3)
  2227. {
  2228. var first = dac.First();
  2229. var dayCount = dac.Count();
  2230. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2231. for (int i = 1; i < row.Cells.Count; i++)
  2232. {
  2233. var cell = row.Cells[i];
  2234. var findProperty = tableSettings.Find(x => x.Index == i);
  2235. if (findProperty != null)
  2236. {
  2237. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2238. // 设置单元格内容
  2239. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2240. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2241. }
  2242. else
  2243. {
  2244. switch (i)
  2245. {
  2246. case 5:
  2247. cell.FirstParagraph.Runs.Clear();
  2248. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2249. break;
  2250. case 6:
  2251. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2252. cell.FirstParagraph.Runs.Clear();
  2253. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2254. break;
  2255. case 8:
  2256. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2257. cell.FirstParagraph.Runs.Clear();
  2258. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2259. GZPriceSum += xiaojiRMB;
  2260. break;
  2261. default:
  2262. break;
  2263. }
  2264. }
  2265. }
  2266. startDayPrice++;
  2267. if (!dac3.Last().Equals(dac))
  2268. {
  2269. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2270. // 将克隆的行追加到原行后面
  2271. contractTable.Rows.Insert(startDayPrice, newRow);
  2272. }
  2273. else
  2274. {
  2275. cloneRow += dac3.Count() + 1;
  2276. startDayPrice = cloneRow;
  2277. }
  2278. }
  2279. //合并单元格
  2280. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2281. {
  2282. var currentRow = contractTable.Rows[i];
  2283. var nextRow = contractTable.Rows[i + 1];
  2284. // 获取当前行和下一行的第一个单元格
  2285. Cell currentCell = currentRow.Cells[0];
  2286. Cell nextCell = nextRow.Cells[0];
  2287. // 检查单元格内容是否一致(去除尾部的换行符)
  2288. string currentText = currentCell.GetText().Trim();
  2289. string nextText = nextCell.GetText().Trim();
  2290. if (currentText == nextText)
  2291. {
  2292. // 如果当前单元格已经被合并,找到合并的起始单元格
  2293. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2294. {
  2295. // 找到合并的起始单元格
  2296. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2297. // 将下一行的单元格设置为合并的后续单元格
  2298. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2299. }
  2300. else
  2301. {
  2302. // 如果当前单元格是合并的起始单元格
  2303. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2304. // 将下一行的单元格设置为合并的后续单元格
  2305. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2306. }
  2307. }
  2308. else
  2309. {
  2310. // 如果内容不一致,重置当前单元格的合并属性
  2311. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2312. {
  2313. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2314. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2315. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2316. }
  2317. else
  2318. {
  2319. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2320. }
  2321. }
  2322. }
  2323. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2324. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2325. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2326. }
  2327. foreach (var bookmarkName in bookMarkDic.Keys)
  2328. {
  2329. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2330. if (bookmark != null)
  2331. {
  2332. if (bookmarkName == "ClientUnit")
  2333. {
  2334. // 移动到书签位置
  2335. builder.MoveTo(bookmark.BookmarkStart);
  2336. // 设置字体样式为下划线
  2337. builder.Font.Underline = Aspose.Words.Underline.Single;
  2338. // 插入书签值
  2339. builder.Write(bookMarkDic[bookmarkName]);
  2340. // 清除字体格式,避免影响后续文本
  2341. builder.Font.ClearFormatting();
  2342. }
  2343. else
  2344. {
  2345. builder.MoveToBookmark(bookmarkName);
  2346. builder.Write(bookMarkDic[bookmarkName]);
  2347. }
  2348. }
  2349. }
  2350. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2351. doc.Save(savePaht);
  2352. jw.Msg = "生成成功!";
  2353. jw.Code = 200;
  2354. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2355. return Ok(jw);
  2356. }
  2357. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2358. {
  2359. int index = rowIndex;
  2360. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2361. {
  2362. index--;
  2363. }
  2364. return index;
  2365. }
  2366. #endregion
  2367. #region 团组&签证
  2368. /// <summary>
  2369. /// 根据团组Id获取签证客户信息List
  2370. /// </summary>
  2371. /// <param name="dto">请求dto</param>
  2372. /// <returns></returns>
  2373. [HttpPost]
  2374. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2375. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2376. {
  2377. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2378. if (groupData.Code != 0)
  2379. {
  2380. return Ok(JsonView(false, groupData.Msg));
  2381. }
  2382. return Ok(JsonView(groupData.Data));
  2383. }
  2384. /// <summary>
  2385. /// IOS获取团组签证拍照上传进度01(团组列表)
  2386. /// </summary>
  2387. /// <param name="dto">请求dto</param>
  2388. /// <returns></returns>
  2389. [HttpPost]
  2390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2391. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2392. {
  2393. if (dto == null)
  2394. {
  2395. return Ok(JsonView(false, "参数为空"));
  2396. }
  2397. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2398. return Ok(JsonView(visaList));
  2399. }
  2400. /// <summary>
  2401. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2402. /// </summary>
  2403. /// <returns></returns>
  2404. [HttpPost]
  2405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2406. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2407. {
  2408. if (dto == null)
  2409. {
  2410. return Ok(JsonView(false, "请求错误:"));
  2411. }
  2412. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2413. return Ok(JsonView(list));
  2414. }
  2415. /// <summary>
  2416. /// IOS获取团组签证拍照上传进度03(相册)
  2417. /// </summary>
  2418. /// <returns></returns>
  2419. [HttpPost]
  2420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2421. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2422. {
  2423. if (dto == null)
  2424. {
  2425. return Ok(JsonView(false, "请求错误:"));
  2426. }
  2427. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2428. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2429. list.ForEach(s => s.url = url);
  2430. return Ok(JsonView(list));
  2431. }
  2432. /// <summary>
  2433. /// IOS获取团组签证拍照上传进度04(图片上传)
  2434. /// </summary>
  2435. /// <param name="dto"></param>
  2436. /// <returns></returns>
  2437. [HttpPost]
  2438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2439. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2440. {
  2441. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2442. //if (!string.IsNullOrEmpty(result))
  2443. //{
  2444. //}
  2445. //else {
  2446. // return Ok(JsonView(false, "上传失败"));
  2447. //}
  2448. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2449. int sucNum = 0;
  2450. try
  2451. {
  2452. foreach (var item in dto.base64DataList)
  2453. {
  2454. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2455. string result = DecodeBase64ToImage(item, imageName);
  2456. if (!string.IsNullOrEmpty(result))
  2457. {
  2458. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  2459. pic.CreateUserId = dto.CreateUserId;
  2460. pic.PicName = imageName;
  2461. pic.PicPath = result;
  2462. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  2463. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2464. if (insertResult > 0)
  2465. {
  2466. sucNum++;
  2467. }
  2468. }
  2469. }
  2470. }
  2471. catch (Exception ex)
  2472. {
  2473. return Ok(JsonView(false, ex.Message));
  2474. }
  2475. string msg = string.Format(@"成功上传{0}张", sucNum);
  2476. return Ok(JsonView(true, msg));
  2477. }
  2478. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2479. {
  2480. string filename = "";//声明一个string类型的相对路径
  2481. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2482. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2483. try//会有异常抛出,try,catch一下
  2484. {
  2485. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2486. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2487. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2488. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2489. //文件名称
  2490. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2491. //上传的文件的路径
  2492. string filePath = "";
  2493. if (!Directory.Exists(fileDir))
  2494. {
  2495. Directory.CreateDirectory(fileDir);
  2496. }
  2497. //上传的文件的路径
  2498. filePath = fileDir + filename;
  2499. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2500. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2501. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2502. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2503. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2504. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2505. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2506. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2507. bitmap.Dispose();
  2508. }
  2509. catch (Exception e)
  2510. {
  2511. string massage = e.Message;
  2512. Logs("IOS图片上传Error:" + massage);
  2513. //filename = e.Message;
  2514. }
  2515. return filename;//返回相对路径
  2516. }
  2517. /// <summary>
  2518. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2519. /// </summary>
  2520. /// <param name="dto"></param>
  2521. /// <returns></returns>
  2522. [HttpPost]
  2523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2524. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2525. {
  2526. if (dto == null)
  2527. {
  2528. return Ok(JsonView(false, "请求错误:"));
  2529. }
  2530. string msg = "参数错误";
  2531. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2532. {
  2533. try
  2534. {
  2535. //_delegationVisaRep.BeginTran();
  2536. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2537. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2538. .Where(s => s.Id == dto.visaProgressCustomerId)
  2539. .ExecuteCommandAsync();
  2540. if (updCount > 0 && dto.publishCode == 1)
  2541. {
  2542. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2543. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2544. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2545. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2546. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2547. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2548. if (groupData == null)
  2549. {
  2550. _delegationVisaRep.RollbackTran();
  2551. }
  2552. string title = string.Format(@"[签证进度更新]");
  2553. string content = string.Format(@"测试文本");
  2554. bool rst = await _message.AddMsg(new MessageDto()
  2555. {
  2556. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2557. IssuerId = dto.publisher,
  2558. Title = title,
  2559. Content = content,
  2560. ReleaseTime = DateTime.Now,
  2561. UIdList = new List<int> {
  2562. 234
  2563. }
  2564. });
  2565. if (rst)
  2566. {
  2567. return Ok(JsonView(true, "发送通知成功"));
  2568. }
  2569. }
  2570. //_delegationVisaRep.CommitTran();
  2571. }
  2572. catch (Exception)
  2573. {
  2574. //_delegationVisaRep.RollbackTran();
  2575. }
  2576. }
  2577. return Ok(JsonView(true, msg));
  2578. }
  2579. #endregion
  2580. #region 团组任务分配
  2581. /// <summary>
  2582. /// 团组任务分配初始化
  2583. /// </summary>
  2584. /// <returns></returns>
  2585. [HttpPost]
  2586. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2587. public async Task<IActionResult> GetTaskAssignmen()
  2588. {
  2589. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2590. if (groupData.Code != 0)
  2591. {
  2592. return Ok(JsonView(false, groupData.Msg));
  2593. }
  2594. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2595. }
  2596. /// <summary>
  2597. /// 团组任务分配查询
  2598. /// </summary>
  2599. /// <param name="dto"></param>
  2600. /// <returns></returns>
  2601. [HttpPost]
  2602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2603. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2604. {
  2605. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2606. if (groupData.Code != 0)
  2607. {
  2608. return Ok(JsonView(false, groupData.Msg));
  2609. }
  2610. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2611. }
  2612. /// <summary>
  2613. /// 团组任务分配操作
  2614. /// </summary>
  2615. /// <param name="dto"></param>
  2616. /// <returns></returns>
  2617. [HttpPost]
  2618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2619. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2620. {
  2621. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2622. if (groupData.Code != 0)
  2623. {
  2624. return Ok(JsonView(false, groupData.Msg));
  2625. }
  2626. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2627. }
  2628. /// <summary>
  2629. /// 团组任务分配
  2630. /// 批量分配
  2631. /// 查询团组
  2632. /// </summary>
  2633. /// <param name="dto"></param>
  2634. /// <returns></returns>
  2635. [HttpPost]
  2636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2637. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2638. {
  2639. //参数验证
  2640. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2641. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2642. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2643. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2644. }
  2645. /// <summary>
  2646. /// 团组任务分配
  2647. /// 批量分配
  2648. /// </summary>
  2649. /// <param name="dto"></param>
  2650. /// <returns></returns>
  2651. [HttpPost]
  2652. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2653. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2654. {
  2655. //参数验证
  2656. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2657. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2658. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2659. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2660. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2661. }
  2662. #endregion
  2663. #region 团组费用审核
  2664. /// <summary>
  2665. /// 费用审核
  2666. /// 团组列表 Page
  2667. /// </summary>
  2668. /// <param name="_dto">团组列表请求dto</param>
  2669. /// <returns></returns>
  2670. [HttpPost]
  2671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2672. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2673. {
  2674. #region 参数验证
  2675. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2676. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2677. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2678. #region 页面操作权限验证
  2679. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2680. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2681. #endregion
  2682. #endregion
  2683. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2684. {
  2685. string sqlWhere = string.Empty;
  2686. if (_dto.IsSure == 0) //未完成
  2687. {
  2688. sqlWhere += string.Format(@" And IsSure = 0");
  2689. }
  2690. else if (_dto.IsSure == 1) //已完成
  2691. {
  2692. sqlWhere += string.Format(@" And IsSure = 1");
  2693. }
  2694. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2695. {
  2696. string tj = _dto.SearchCriteria;
  2697. 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}%')",
  2698. tj, tj, tj, tj, tj);
  2699. }
  2700. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2701. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2702. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2703. From (
  2704. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2705. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2706. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2707. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2708. From Grp_DelegationInfo gdi
  2709. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2710. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2711. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2712. Where gdi.IsDel = 0 {0}
  2713. ) temp ", sqlWhere);
  2714. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2715. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2716. var _view = new
  2717. {
  2718. PageFuncAuth = pageFunAuthView,
  2719. Data = _DelegationList
  2720. };
  2721. return Ok(JsonView(true, "查询成功!", _view, total));
  2722. }
  2723. else
  2724. {
  2725. return Ok(JsonView(false, "查询失败"));
  2726. }
  2727. }
  2728. /// <summary>
  2729. /// 获取团组费用审核
  2730. /// </summary>
  2731. /// <param name="_dto"></param>
  2732. /// <returns></returns>
  2733. [HttpPost]
  2734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2735. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2736. {
  2737. try
  2738. {
  2739. #region 参数验证
  2740. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2741. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2742. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2743. #region 页面操作权限验证
  2744. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2745. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2746. #endregion
  2747. #endregion
  2748. var _view = new Grp_CreditCardPaymentView();
  2749. var clientNameList = getSimplClientList(_dto.DiId);
  2750. #region 费用清单
  2751. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2752. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2753. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2754. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2755. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2756. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2757. /*
  2758. * 76://酒店预订
  2759. */
  2760. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2761. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2762. /*
  2763. * 79://车/导游地接
  2764. */
  2765. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2766. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2767. /*
  2768. * 80: //签证
  2769. */
  2770. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2771. /*
  2772. *81: //邀请/公务活动
  2773. */
  2774. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2775. /*
  2776. * 82: //团组客户保险
  2777. */
  2778. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2779. /*
  2780. * Lable = 85 机票预订
  2781. */
  2782. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2783. /*
  2784. * 85 机票预定
  2785. */
  2786. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2787. /*
  2788. * 98 其他款项
  2789. */
  2790. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2791. /*
  2792. * 285:收款退还
  2793. */
  2794. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2795. /*
  2796. * 1015: //超支费用
  2797. */
  2798. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2799. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2800. /*
  2801. * 币种信息
  2802. */
  2803. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2804. /*
  2805. * 车/导游地接 费用类型
  2806. */
  2807. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2808. /*
  2809. * 车/导游地接 费用类型
  2810. */
  2811. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2812. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2813. /*
  2814. * 用户信息
  2815. */
  2816. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2817. /*
  2818. * 费用模块
  2819. */
  2820. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2821. string priceModule = string.Empty;
  2822. if (sdPriceName != null)
  2823. {
  2824. priceModule = sdPriceName.Name;
  2825. }
  2826. /*
  2827. * 成本信息
  2828. */
  2829. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2830. decimal _groupRate = 0.0000M;
  2831. string _groupCurrencyCode = "-";
  2832. if (groupCost != null)
  2833. {
  2834. _groupRate = groupCost.Rate;
  2835. if (int.TryParse(groupCost.Currency, out int _currency))
  2836. {
  2837. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2838. }
  2839. else _groupCurrencyCode = groupCost.Currency;
  2840. }
  2841. string costContentSql = $"Select * From Grp_GroupCost";
  2842. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2843. //处理日期为空的天数
  2844. for (int i = 0; i < groupCostDetails.Count; i++)
  2845. if (i != 0)
  2846. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2847. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2848. /*
  2849. * 处理详情数据
  2850. */
  2851. foreach (var entity in entityList)
  2852. {
  2853. var _detail = new Grp_CreditCardPaymentDetailView();
  2854. _detail.Id = entity.Id;
  2855. _detail.PriceName = priceModule;
  2856. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2857. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2858. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2859. //处理金额
  2860. if (entity.CTable == 1015)
  2861. {
  2862. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2863. if (czInfo != null)
  2864. {
  2865. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2866. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2867. }
  2868. }
  2869. /*
  2870. * 应付款金额
  2871. */
  2872. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2873. string PaymentCurrency_WaitPay = "Unknown";
  2874. string hotelCurrncyCode = "Unknown";
  2875. string hotelCurrncyName = "Unknown";
  2876. if (sdPaymentCurrency_WaitPay != null)
  2877. {
  2878. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2879. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2880. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2881. if (hotelCurrncyCode.Equals("CNY"))
  2882. {
  2883. entity.DayRate = 1.0000M;
  2884. }
  2885. }
  2886. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2887. /*
  2888. * 此次付款金额
  2889. */
  2890. decimal CurrPayStr = 0.00M,
  2891. OriginalCurrPay = 0.00M;
  2892. if (entity.PayPercentage == 0)
  2893. {
  2894. if (entity.PayThenMoney != 0)
  2895. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2896. }
  2897. else
  2898. {
  2899. if (entity.PayMoney != 0)
  2900. {
  2901. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2902. }
  2903. }
  2904. //if (_dto.Label == 79)
  2905. //{
  2906. // string original = string.Empty;
  2907. // if (hotelCurrncyCode.Equals("CNY"))
  2908. // {
  2909. // OriginalCurrPay = CurrPayStr;
  2910. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2911. // }
  2912. // else
  2913. // {
  2914. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2915. // //760 EUR(7600.00 CNY)
  2916. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2917. // }
  2918. //}
  2919. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2920. string original = string.Empty;
  2921. if (hotelCurrncyCode.Equals("CNY"))
  2922. {
  2923. OriginalCurrPay = CurrPayStr;
  2924. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2925. }
  2926. else
  2927. {
  2928. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2929. //760 EUR(7600.00 CNY)
  2930. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2931. }
  2932. /*
  2933. * 剩余尾款
  2934. */
  2935. decimal BalanceStr = 0;
  2936. if (CurrPayStr != 0)
  2937. {
  2938. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2939. BalanceStr = 0;
  2940. else
  2941. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2942. }
  2943. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2944. /*
  2945. * Bus名称
  2946. */
  2947. _detail.BusName = "待增加";
  2948. /*
  2949. *费用所属
  2950. */
  2951. switch (entity.CTable)
  2952. {
  2953. case 76://酒店预订
  2954. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2955. if (hotelReservations != null)
  2956. {
  2957. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2958. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2959. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2960. string roomFeeStr = "", roomFeestr1 = "";
  2961. //是否比较房型价格
  2962. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2963. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2964. roomFeeStr += $"<br/>";
  2965. var roomTotal = 0.00M;
  2966. if (hotelReservations.SingleRoomPrice > 0)
  2967. {
  2968. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  2969. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  2970. //__isSingle = true;
  2971. roomTotal += fee;
  2972. }
  2973. if (hotelReservations.DoubleRoomPrice > 0)
  2974. {
  2975. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  2976. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  2977. // __isDouble = true;
  2978. roomTotal += fee;
  2979. }
  2980. if (hotelReservations.SuiteRoomPrice > 0)
  2981. {
  2982. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  2983. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  2984. //__isSuite = true;
  2985. roomTotal += fee;
  2986. }
  2987. if (hotelReservations.OtherRoomPrice > 0)
  2988. {
  2989. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  2990. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  2991. //__isOther = true;
  2992. roomTotal += fee;
  2993. }
  2994. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  2995. else roomFeeStr += " 0.00 * 0";
  2996. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2997. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2998. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2999. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3000. /*
  3001. * 费用类型
  3002. * 1:房费
  3003. * 2:早餐
  3004. * 3:地税
  3005. * 4:城市税
  3006. * </summary>
  3007. */
  3008. //地税
  3009. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3010. if (governmentRentData != null)
  3011. {
  3012. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3013. governmentRentFee = governmentRentData.Price;
  3014. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3015. if (governmentRentCurrData != null)
  3016. {
  3017. governmentRentCode = governmentRentCurrData.Name;
  3018. governmentRentName = $"({governmentRentCurrData.Remark})";
  3019. }
  3020. }
  3021. //城市税
  3022. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3023. if (cityTaxData != null)
  3024. {
  3025. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3026. cityTaxFee = cityTaxData.Price;
  3027. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3028. if (cityTaxCurrData != null)
  3029. {
  3030. cityTaxCode = cityTaxCurrData.Name;
  3031. cityTaxName = $"({cityTaxCurrData.Remark})";
  3032. }
  3033. }
  3034. //酒店早餐
  3035. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3036. if (breakfastData != null)
  3037. {
  3038. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3039. breakfastFee = breakfastData.Price;
  3040. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3041. if (breakfastCurrData != null)
  3042. {
  3043. breakfastCode = breakfastCurrData.Name;
  3044. breakfastName = $"({breakfastCurrData.Remark})";
  3045. }
  3046. }
  3047. //房间费用
  3048. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3049. if (roomData != null)
  3050. {
  3051. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3052. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3053. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3054. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3055. roomFee = roomData.Price;
  3056. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3057. if (roomCurrData != null)
  3058. {
  3059. roomCode = roomCurrData.Name;
  3060. roomName = $"({roomCurrData.Remark})";
  3061. }
  3062. }
  3063. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3064. string hotelCostStr = "";
  3065. decimal hotelCsotTotal = 0.00M;
  3066. if (groupCost != null)
  3067. {
  3068. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3069. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3070. }
  3071. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3072. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3073. string hotelCost_day = "";
  3074. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3075. foreach (var item in hotelCostDetails1)
  3076. {
  3077. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3078. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3079. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3080. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3081. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3082. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3083. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3084. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3085. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3086. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3087. hotelCost_day += @$"<br/>";
  3088. }
  3089. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3090. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3091. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3092. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3093. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3094. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3095. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3096. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3097. $"房间说明: {hotelReservations.Remark} <br/>" +
  3098. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3099. $"{hotelBreakfastStr}" +
  3100. $"{hotelGovernmentRentStr}" +
  3101. $"{hotelCityTaxStr}";
  3102. _detail.PriceNameContent = hotelReservations.HotelName;
  3103. }
  3104. break;
  3105. case 79://车/导游地接
  3106. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3107. if (touristGuideGroundReservations != null)
  3108. {
  3109. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3110. {
  3111. _detail.BusName = touristGuideGroundReservations.BusName;
  3112. }
  3113. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3114. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3115. //if (isInt)
  3116. //{
  3117. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3118. // if (cityInfo != null)
  3119. // {
  3120. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3121. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3122. // if (carFeeItem != null)
  3123. // {
  3124. // nameContent += $@"({carFeeItem.Name})";
  3125. // }
  3126. // _detail.PriceNameContent = nameContent;
  3127. // }
  3128. //}
  3129. //else
  3130. //{
  3131. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3132. //}
  3133. var touristGuideGroundReservationsContents =
  3134. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3135. var opContent_sb = new StringBuilder();
  3136. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3137. opContent_sb.AppendLine(contetTitle);
  3138. foreach (var item in touristGuideGroundReservationsContents)
  3139. {
  3140. string typeName = "Unknown";
  3141. string carCurrencyCode = "Unknown";
  3142. string carCurrencyName = "Unknown";
  3143. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3144. if (carTypeData != null) typeName = carTypeData.Name;
  3145. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3146. if (currencyData != null)
  3147. {
  3148. carCurrencyCode = currencyData.Name;
  3149. carCurrencyName = currencyData.Remark;
  3150. }
  3151. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3152. bool IsCurrencyAgreement = false;
  3153. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3154. string opCostStr = string.Empty;
  3155. decimal opCostTypePrice = 0.00M;
  3156. #region 处理成本各项费用
  3157. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3158. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3159. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3160. costOPFeeCNY = 0.00M, //团组成本 op费用
  3161. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3162. if (opCost.Count > 0)
  3163. {
  3164. switch (item.SId)
  3165. {
  3166. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3167. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3168. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3169. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3170. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3171. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3172. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3173. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3174. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3175. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3176. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3177. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3178. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3179. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3180. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3181. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3182. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3183. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3184. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3185. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3186. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3187. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3188. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3189. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3190. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3191. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3192. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3193. }
  3194. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3195. costOPFeeCNY = opCostTypePrice * _groupRate;
  3196. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3197. }
  3198. #endregion
  3199. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3200. aduitOPFeeCNY = item.Price * entity.DayRate;
  3201. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3202. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3203. $"{opTypeStr} {opCostStr}<br/>" +
  3204. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3205. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3206. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3207. {
  3208. if (IsCurrencyAgreement)
  3209. {
  3210. if (item.Price > opCostTypePrice)
  3211. {
  3212. opContent_sb.Append("<span style='color:red;'>");
  3213. opContent_sb.Append(opContent);
  3214. opContent_sb.Append("</span>");
  3215. opContent_sb.AppendLine();
  3216. }
  3217. else
  3218. {
  3219. opContent_sb.Append(opContent);
  3220. opContent_sb.AppendLine();
  3221. }
  3222. }
  3223. else
  3224. {
  3225. //验证是否超成本 按付款比例计算
  3226. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3227. {
  3228. opContent_sb.Append("<span style='color:red;'>");
  3229. opContent_sb.Append(opContent);
  3230. opContent_sb.Append("</span>");
  3231. opContent_sb.AppendLine();
  3232. }
  3233. else
  3234. {
  3235. opContent_sb.Append(opContent);
  3236. opContent_sb.AppendLine();
  3237. }
  3238. }
  3239. }
  3240. else
  3241. {
  3242. opContent_sb.Append(opContent);
  3243. opContent_sb.AppendLine();
  3244. }
  3245. }
  3246. _detail.PriceMsgContent = opContent_sb.ToString();
  3247. }
  3248. break;
  3249. case 80: //签证
  3250. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3251. if (visaInfo != null)
  3252. {
  3253. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  3254. _detail.PriceNameContent = visaInfo.VisaDescription;
  3255. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3256. }
  3257. break;
  3258. case 81: //邀请/公务活动
  3259. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3260. if (_ioa != null)
  3261. {
  3262. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3263. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3264. sendCurrName = "Unknown", //快递费用币种 Name
  3265. sendCurrCode = "Unknown", //快递费用币种 Code
  3266. eventsCurrName = "Unknown", //公务活动费币种 Name
  3267. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3268. translateCurrName = "Unknown", //公务翻译费 Name
  3269. translateCurrCode = "Unknown"; //公务翻译费 Code
  3270. #region 处理费用币种
  3271. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3272. if (inviteCurrData != null)
  3273. {
  3274. inviteCurrName = inviteCurrData.Remark;
  3275. inviteCurrCode = inviteCurrData.Name;
  3276. }
  3277. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3278. if (sendCurrData != null)
  3279. {
  3280. sendCurrName = sendCurrData.Remark;
  3281. sendCurrCode = sendCurrData.Name;
  3282. }
  3283. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3284. if (eventsCurrData != null)
  3285. {
  3286. eventsCurrName = eventsCurrData.Remark;
  3287. eventsCurrCode = eventsCurrData.Name;
  3288. }
  3289. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3290. if (translateCurrData != null)
  3291. {
  3292. translateCurrName = translateCurrData.Remark;
  3293. translateCurrCode = translateCurrData.Name;
  3294. }
  3295. #endregion
  3296. _detail.PriceNameContent = _ioa.InviterArea;
  3297. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  3298. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  3299. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  3300. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  3301. $@"备注:" + _ioa.Remark + "<br/>";
  3302. }
  3303. break;
  3304. case 82: //团组客户保险
  3305. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3306. if (customers != null)
  3307. {
  3308. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  3309. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3310. }
  3311. break;
  3312. case 85: //机票预订
  3313. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3314. if (jpRes != null)
  3315. {
  3316. string FlightsDescription = jpRes.FlightsDescription;
  3317. string PriceDescription = jpRes.PriceDescription;
  3318. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3319. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3320. }
  3321. break;
  3322. case 98://其他款项
  3323. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3324. if (gdpRes != null)
  3325. {
  3326. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3327. _detail.PriceNameContent = gdpRes.PriceName;
  3328. }
  3329. break;
  3330. case 285://收款退还
  3331. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3332. if (refundAndOtherMoney != null)
  3333. {
  3334. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3335. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3336. }
  3337. break;
  3338. case 751://酒店早餐
  3339. break;
  3340. case 1015://超支费用
  3341. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3342. if (groupExtraCost != null)
  3343. {
  3344. _detail.PriceNameContent = groupExtraCost.PriceName;
  3345. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3346. }
  3347. break;
  3348. default:
  3349. break;
  3350. }
  3351. /*
  3352. * 申请人
  3353. */
  3354. string operatorName = " - ";
  3355. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3356. if (_opUser != null)
  3357. {
  3358. operatorName = _opUser.CnName;
  3359. }
  3360. _detail.OperatorName = operatorName;
  3361. /*
  3362. * 审核人
  3363. */
  3364. string auditOperatorName = "Unknown";
  3365. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3366. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3367. else
  3368. {
  3369. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3370. if (_adUser != null)
  3371. {
  3372. auditOperatorName = _adUser.CnName;
  3373. }
  3374. }
  3375. _detail.AuditOperatorName = auditOperatorName;
  3376. /*
  3377. * 超预算比例
  3378. */
  3379. string overBudgetStr = "";
  3380. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3381. else if (entity.ExceedBudget == 0)
  3382. {
  3383. if (entity.CTable == 76 || entity.CTable == 79)
  3384. {
  3385. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3386. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3387. }
  3388. else
  3389. {
  3390. overBudgetStr = "未超预算";
  3391. }
  3392. }
  3393. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3394. _detail.OverBudget = overBudgetStr;
  3395. decimal auditFee = 0.00M; //已审核金额 人名币
  3396. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3397. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3398. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3399. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3400. {
  3401. auditedFeeOriginal = entity.PayMoney;
  3402. auditFee = CurrPayStr;
  3403. }
  3404. else if (entity.IsAuditGM == 0)
  3405. {
  3406. unAuditFeeCNY = CurrPayStr;
  3407. unAuditFeeOriginal = OriginalCurrPay;
  3408. OriginalCurrPay = 0.00M;
  3409. }
  3410. /*
  3411. * 费用总计
  3412. */
  3413. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3414. {
  3415. CurrencyId = entity.PaymentCurrency,
  3416. CurrencyName = PaymentCurrency_WaitPay,
  3417. AmountPayable = entity.PayMoney,
  3418. ThisPayment = OriginalCurrPay,
  3419. BalancePayment = BalanceStr,
  3420. AuditedFunds = auditFee,
  3421. AuditedFundsOriginal = auditedFeeOriginal,
  3422. UnAuditFundsCNY = unAuditFeeCNY,
  3423. UnAuditFundsOriginal = unAuditFeeOriginal
  3424. });
  3425. _detail.IsAuditGM = entity.IsAuditGM;
  3426. detailList.Add(_detail);
  3427. }
  3428. #endregion
  3429. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3430. /*
  3431. * 下方描述处理
  3432. */
  3433. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3434. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3435. if (ccpCurrencyPrice != null)
  3436. {
  3437. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3438. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3439. }
  3440. else
  3441. {
  3442. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3443. }
  3444. string amountPayableStr = string.Format(@"应付款总金额: ");
  3445. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3446. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3447. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3448. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3449. foreach (var item in nonDuplicat)
  3450. {
  3451. var currencyName = item.CurrencyName;
  3452. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3453. if (strs.Count > 0)
  3454. {
  3455. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3456. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3457. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3458. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3459. //单独处理此次付款金额
  3460. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3461. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3462. //单独处理已审核费用
  3463. //if (item.CurrencyId == 836) //人民币
  3464. //{
  3465. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3466. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3467. //}
  3468. //else
  3469. //{
  3470. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3471. //}
  3472. if (currencyName.Equals("CNY"))
  3473. {
  3474. //已审核费用
  3475. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3476. //未审核费用
  3477. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3478. }
  3479. else
  3480. {
  3481. //已审核费用
  3482. 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"));
  3483. //未审核费用
  3484. 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"));
  3485. }
  3486. }
  3487. }
  3488. _view.TotalStr1 = amountPayableStr[..^1];
  3489. _view.TotalStr2 = thisPaymentStr[..^1];
  3490. _view.TotalStr3 = balancePaymentStr[..^1];
  3491. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3492. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3493. var _view1 = new
  3494. {
  3495. PageFuncAuth = pageFunAuthView,
  3496. Data = _view
  3497. };
  3498. return Ok(JsonView(_view1));
  3499. }
  3500. catch (Exception ex)
  3501. {
  3502. return Ok(JsonView(false, ex.Message));
  3503. }
  3504. }
  3505. /// <summary>
  3506. /// 费用审核
  3507. /// 修改团组费用审核状态
  3508. /// </summary>
  3509. /// <param name="_dto">参数Json字符串</param>
  3510. /// <returns></returns>
  3511. [HttpPost]
  3512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3513. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3514. {
  3515. #region 参数验证
  3516. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3517. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3518. #endregion
  3519. #region 页面操作权限验证
  3520. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  3521. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3522. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3523. #endregion
  3524. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3525. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3526. DateTime dtNow = DateTime.Now;
  3527. _groupRepository.BeginTran();
  3528. int rst = 0;
  3529. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3530. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3531. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3532. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3533. List<dynamic> msgDatas = new List<dynamic>();
  3534. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  3535. foreach (var item in idList)
  3536. {
  3537. int CreditId = int.Parse(item);
  3538. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3539. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3540. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3541. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3542. .Where(s => s.Id == CreditId)
  3543. .ExecuteCommandAsync();
  3544. if (result < 1)
  3545. {
  3546. rst = -1;
  3547. _groupRepository.RollbackTran();
  3548. return Ok(JsonView(false, "操作失败并回滚!"));
  3549. }
  3550. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3551. if (creditData != null)
  3552. {
  3553. #region 应用通知配置
  3554. try
  3555. {
  3556. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3557. }
  3558. catch (Exception ex)
  3559. {
  3560. }
  3561. #endregion
  3562. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3563. string groupNameStr = string.Empty;
  3564. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3565. if (groupData != null) groupNameStr = groupData.TeamName;
  3566. string creditTypeStr = string.Empty;
  3567. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3568. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3569. string creditCurrency = string.Empty;
  3570. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3571. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3572. if (creditCurrency.Equals("CNY"))
  3573. {
  3574. creditData.DayRate = 1.0000M;
  3575. }
  3576. if (creditData.PayPercentage == 0.00M)
  3577. {
  3578. creditData.PayPercentage = 100M;
  3579. }
  3580. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3581. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3582. string msgContent = "";
  3583. if (creditCurrency.Equals("CNY"))
  3584. {
  3585. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  3586. }
  3587. else
  3588. {
  3589. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  3590. }
  3591. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3592. }
  3593. }
  3594. if (rst == 0)
  3595. {
  3596. _groupRepository.CommitTran();
  3597. foreach (var item in msgDatas)
  3598. {
  3599. //发送消息
  3600. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3601. }
  3602. #region 应用推送
  3603. try
  3604. {
  3605. foreach (var ccpId in dic_ccp_user.Keys)
  3606. {
  3607. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3608. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3609. }
  3610. }
  3611. catch (Exception)
  3612. {
  3613. }
  3614. #endregion
  3615. return Ok(JsonView(true, "操作成功!"));
  3616. }
  3617. return Ok(JsonView(false, "操作失败!"));
  3618. }
  3619. #endregion
  3620. #region 机票费用录入
  3621. /// <summary>
  3622. /// 机票录入当前登录人可操作团组
  3623. /// </summary>
  3624. /// <param name="dto"></param>
  3625. /// <returns></returns>
  3626. [HttpPost]
  3627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3628. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3629. {
  3630. try
  3631. {
  3632. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3633. if (groupData.Code != 0)
  3634. {
  3635. return Ok(JsonView(false, groupData.Msg));
  3636. }
  3637. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3638. }
  3639. catch (Exception ex)
  3640. {
  3641. return Ok(JsonView(false, "程序错误!"));
  3642. throw;
  3643. }
  3644. }
  3645. /// <summary>
  3646. /// 机票费用录入列表
  3647. /// </summary>
  3648. /// <param name="dto"></param>
  3649. /// <returns></returns>
  3650. [HttpPost]
  3651. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3652. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3653. {
  3654. try
  3655. {
  3656. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3657. if (groupData.Code != 0)
  3658. {
  3659. return Ok(JsonView(false, groupData.Msg));
  3660. }
  3661. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3662. }
  3663. catch (Exception ex)
  3664. {
  3665. return Ok(JsonView(false, ex.Message));
  3666. throw;
  3667. }
  3668. }
  3669. /// <summary>
  3670. /// 根据id查询费用录入信息
  3671. /// </summary>
  3672. /// <param name="dto"></param>
  3673. /// <returns></returns>
  3674. [HttpPost]
  3675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3676. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3677. {
  3678. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3679. if (groupData.Code != 0)
  3680. {
  3681. return Ok(JsonView(false, groupData.Msg));
  3682. }
  3683. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3684. }
  3685. /// <summary>
  3686. /// 机票费用录入操作(Status:1.新增,2.修改)
  3687. /// </summary>
  3688. /// <param name="dto"></param>
  3689. /// <returns></returns>
  3690. [HttpPost]
  3691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3692. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3693. {
  3694. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3695. if (groupData.Code != 0)
  3696. {
  3697. return Ok(JsonView(false, groupData.Msg));
  3698. }
  3699. #region 应用推送
  3700. try
  3701. {
  3702. var diId = dto.AirTicketResOpData.DiId;
  3703. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3704. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3705. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3706. //自动审核
  3707. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  3708. (bool status,string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  3709. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  3710. $"GroupId:{diId};airId:{dataId};",
  3711. status,
  3712. auditMsg);
  3713. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3714. //2024-10-21 新增LZ UID
  3715. var userIds = new List<int>() { 21 };
  3716. string title = $"系统通知";
  3717. string content = "";
  3718. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3719. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3720. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3721. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3722. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3723. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  3724. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3725. }
  3726. catch (Exception ex)
  3727. {
  3728. }
  3729. #endregion
  3730. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3731. }
  3732. /// <summary>
  3733. /// 机票费用自动审核 AI识别方式
  3734. /// </summary>
  3735. /// <returns></returns>
  3736. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  3737. {
  3738. var ecoTypeIds = new List<int>() {
  3739. 459, //超经舱
  3740. 460, //经济舱
  3741. 1430, //公务舱(实际经济舱)
  3742. 1432, //头等舱(实际经济舱)
  3743. };
  3744. var bizTypeIds = new List<int>() {
  3745. 457, //头等舱
  3746. 458, //公务舱
  3747. 1431, //头等舱(实际公务舱)
  3748. };
  3749. var auditFeeTypeIds = new List<int>() {};
  3750. auditFeeTypeIds.AddRange(ecoTypeIds);
  3751. auditFeeTypeIds.AddRange(bizTypeIds);
  3752. int currModule = 85;
  3753. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  3754. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  3755. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  3756. .Select((x, y) => new
  3757. {
  3758. x.Id,
  3759. CcpId = y.Id,
  3760. x.FlightsDate,
  3761. x.PrePrice,
  3762. x.CType,
  3763. x.ClientNum,
  3764. x.DIId
  3765. })
  3766. .FirstAsync();
  3767. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  3768. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  3769. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  3770. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  3771. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  3772. var groupCostContents = await _sqlSugar
  3773. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  3774. .Where(x => x.IsDel == 0 && x.Diid == diId)
  3775. .ToListAsync();
  3776. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  3777. //处理 成本详细信息日期为空 填装费用信息
  3778. var airFeeLabel = new StringBuilder();
  3779. airFeeLabel.AppendLine("费用成本:");
  3780. for (int i = 0; i < groupCostContents.Count; i++)
  3781. {
  3782. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  3783. {
  3784. int index = i - 1;
  3785. if (index >= 0)
  3786. {
  3787. groupCostContents[i].Date = groupCostContents[index].Date;
  3788. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3789. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3790. }
  3791. }
  3792. else
  3793. {
  3794. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3795. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3796. }
  3797. var item = groupCostContents[i];
  3798. airFeeLabel.AppendLine($"{item.Date}");
  3799. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  3800. }
  3801. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  3802. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  3803. //访问Kimi AI 返回价格结果
  3804. var msgs = new List<SeedMessages>()
  3805. {
  3806. new ()
  3807. {
  3808. Role = KimiRole.user,
  3809. Content = airFeeLabel.ToString()
  3810. }
  3811. };
  3812. KiMiApiClient client = new KiMiApiClient();
  3813. var kimiApiResult = await client.SeedMessage(msgs);
  3814. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  3815. string clients = kimiApiResult_JObject["content"].ToString();
  3816. decimal ecoPri_kimiAI = 0.00M,
  3817. bizPri_kimiAI = 0.00M;
  3818. //单个价格: 经济舱价格
  3819. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  3820. //价格文本包含/:/前经济舱价格 /后公务舱价格
  3821. if (clients.Contains('/'))
  3822. {
  3823. var priArray = clients.Split('/');
  3824. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  3825. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  3826. }
  3827. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  3828. var isAutoAudit = false;
  3829. //价格验证处理
  3830. //经济舱
  3831. if (ecoTypeIds.Contains(airInfo.CType))
  3832. {
  3833. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  3834. }
  3835. //公务舱
  3836. else if (bizTypeIds.Contains(airInfo.CType))
  3837. {
  3838. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  3839. }
  3840. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  3841. //是否执行自动审核
  3842. if (isAutoAudit)
  3843. {
  3844. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3845. .SetColumns(x => x.IsAuditGM == 3)
  3846. .SetColumns(x => x.AuditGMOperate == 4)
  3847. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  3848. .Where(x => x.Id == airInfo.CcpId)
  3849. .ExecuteCommandAsync();
  3850. if (auditStatus > 0 ) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  3851. }
  3852. return (false, "当前费用超过成本费用,不可自动审核!");
  3853. }
  3854. /// <summary>
  3855. /// 机票费用录入
  3856. /// 自动审核测试 - AI 识别
  3857. /// </summary>
  3858. /// <param name="groupId"></param>
  3859. /// <param name="Id"></param>
  3860. /// <returns></returns>
  3861. [HttpPost]
  3862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3863. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  3864. {
  3865. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  3866. return Ok(JsonView(status, msg));
  3867. }
  3868. /// <summary>
  3869. /// 根据舱位类型查询接团客户名单信息
  3870. /// </summary>
  3871. /// <param name="dto"></param>
  3872. /// <returns></returns>
  3873. [HttpPost]
  3874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3875. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  3876. {
  3877. try
  3878. {
  3879. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  3880. if (crm_Groups.Count != 0)
  3881. {
  3882. List<dynamic> Customer = new List<dynamic>();
  3883. foreach (var item in crm_Groups)
  3884. {
  3885. var data = new
  3886. {
  3887. Id = item.Id,
  3888. Pinyin = item.Pinyin,
  3889. Name = item.LastName + item.FirstName
  3890. };
  3891. Customer.Add(data);
  3892. }
  3893. return Ok(JsonView(true, "查询成功!", Customer));
  3894. }
  3895. return Ok(JsonView(true, "暂无数据", crm_Groups));
  3896. }
  3897. catch (Exception ex)
  3898. {
  3899. return Ok(JsonView(false, "程序错误!"));
  3900. throw;
  3901. }
  3902. }
  3903. /// <summary>
  3904. /// 根据团号获取客户信息
  3905. /// </summary>
  3906. /// <param name="dto"></param>
  3907. /// <returns></returns>
  3908. [HttpPost]
  3909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3910. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  3911. {
  3912. var jw = JsonView(false);
  3913. if (dto.DIID < 1)
  3914. {
  3915. jw.Msg += "请输入正确的diid";
  3916. return Ok(jw);
  3917. }
  3918. var arr = getSimplClientList(dto.DIID);
  3919. jw = JsonView(true, "获取成功!", arr);
  3920. return Ok(jw);
  3921. }
  3922. private List<SimplClientInfo> getSimplClientList(int diId)
  3923. {
  3924. 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);
  3925. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  3926. foreach (var item in arr)
  3927. {
  3928. EncryptionProcessor.DecryptProperties(item);
  3929. }
  3930. return arr;
  3931. }
  3932. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  3933. {
  3934. string result = origin;
  3935. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3936. {
  3937. string[] temparr = origin.Split(',');
  3938. string fistrStr = temparr[0];
  3939. int count = temparr.Count();
  3940. int tempId;
  3941. bool success = int.TryParse(fistrStr, out tempId);
  3942. if (success)
  3943. {
  3944. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3945. if (tempInfo != null)
  3946. {
  3947. if (count > 1)
  3948. {
  3949. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  3950. }
  3951. else
  3952. {
  3953. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  3954. }
  3955. }
  3956. }
  3957. }
  3958. return result;
  3959. }
  3960. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  3961. {
  3962. string result = origin;
  3963. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3964. {
  3965. string[] temparr = origin.Split(',');
  3966. result = "";
  3967. foreach (var item in temparr)
  3968. {
  3969. int tempId;
  3970. bool success = int.TryParse(item, out tempId);
  3971. if (success)
  3972. {
  3973. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3974. if (tempInfo != null)
  3975. {
  3976. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  3977. }
  3978. }
  3979. }
  3980. }
  3981. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  3982. return result;
  3983. }
  3984. /// <summary>
  3985. /// 机票费用录入,删除
  3986. /// </summary>
  3987. /// <param name="dto"></param>
  3988. /// <returns></returns>
  3989. [HttpPost]
  3990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3991. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  3992. {
  3993. try
  3994. {
  3995. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  3996. if (res)
  3997. {
  3998. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  3999. {
  4000. IsDel = 1,
  4001. DeleteUserId = dto.DeleteUserId,
  4002. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4003. }).ExecuteCommandAsync();
  4004. return Ok(JsonView(true, "删除成功!"));
  4005. }
  4006. return Ok(JsonView(false, "删除失败!"));
  4007. }
  4008. catch (Exception ex)
  4009. {
  4010. return Ok(JsonView(false, "程序错误!"));
  4011. throw;
  4012. }
  4013. }
  4014. /// <summary>
  4015. /// 导出机票录入报表
  4016. /// </summary>
  4017. /// <param name="dto"></param>
  4018. /// <returns></returns>
  4019. [HttpPost]
  4020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4021. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  4022. {
  4023. try
  4024. {
  4025. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  4026. if (groupData.Code != 0)
  4027. {
  4028. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4029. }
  4030. else
  4031. {
  4032. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  4033. if (AirTicketReservations.Count != 0)
  4034. {
  4035. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  4036. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  4037. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  4038. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  4039. WorkbookDesigner designer = new WorkbookDesigner();
  4040. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  4041. decimal countCost = 0;
  4042. foreach (var item in AirTicketReservations)
  4043. {
  4044. #region 处理客人姓名
  4045. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  4046. item.ClientName = clientNames;
  4047. #endregion
  4048. if (item.BankType == "其他")
  4049. {
  4050. item.BankNo = "--";
  4051. }
  4052. else
  4053. {
  4054. if (!string.IsNullOrEmpty(item.BankType))
  4055. {
  4056. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  4057. }
  4058. }
  4059. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  4060. item.Price = System.Decimal.Round(item.Price, 2);
  4061. countCost += Convert.ToDecimal(item.Price);
  4062. }
  4063. designer.SetDataSource("Export", AirTicketReservations);
  4064. designer.SetDataSource("ExportDiCode", diCode);
  4065. designer.SetDataSource("ExportDiName", diName);
  4066. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  4067. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  4068. designer.Process();
  4069. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  4070. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  4071. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  4072. return Ok(JsonView(true, "成功", url = rst));
  4073. }
  4074. else
  4075. {
  4076. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  4077. }
  4078. }
  4079. }
  4080. catch (Exception ex)
  4081. {
  4082. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  4083. throw;
  4084. }
  4085. }
  4086. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4087. /// <summary>
  4088. /// 行程单导出
  4089. /// </summary>
  4090. /// <param name="dto"></param>
  4091. /// <returns></returns>
  4092. [HttpPost]
  4093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4094. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  4095. {
  4096. try
  4097. {
  4098. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  4099. if (groupData.Code != 0)
  4100. {
  4101. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4102. }
  4103. else
  4104. {
  4105. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  4106. if (dto.Language == "CN")
  4107. {
  4108. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  4109. DocumentBuilder builder = new DocumentBuilder(doc);
  4110. int tableIndex = 0;//表格索引
  4111. //得到文档中的第一个表格
  4112. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4113. foreach (var item in _AirTicketReservations)
  4114. {
  4115. #region 处理固定数据
  4116. string[] FlightsCode = item.FlightsCode.Split('/');
  4117. if (FlightsCode.Length != 0)
  4118. {
  4119. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4120. if (_AirCompany != null)
  4121. {
  4122. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4123. }
  4124. else
  4125. {
  4126. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4127. }
  4128. }
  4129. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4130. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4131. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4132. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4133. string name = "";
  4134. foreach (string clientName in nameArray)
  4135. {
  4136. if (!name.Contains(clientName))
  4137. {
  4138. name += clientName + ",";
  4139. }
  4140. }
  4141. if (!string.IsNullOrWhiteSpace(name))
  4142. {
  4143. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4144. }
  4145. else
  4146. {
  4147. table.Range.Bookmarks["ClientName"].Text = "--";
  4148. }
  4149. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4150. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4151. table.Range.Bookmarks["JointTicket"].Text = "--";
  4152. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4153. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4154. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4155. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4156. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4157. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4158. #endregion
  4159. #region 循环数据处理
  4160. List<AirInfo> airs = new List<AirInfo>();
  4161. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4162. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4163. for (int i = 0; i < FlightsCode.Length; i++)
  4164. {
  4165. AirInfo air = new AirInfo();
  4166. string[] tempstr = DayArray[i]
  4167. .Replace("\r\n", string.Empty)
  4168. .Replace("\\r\\n", string.Empty)
  4169. .TrimStart().TrimEnd()
  4170. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4171. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4172. string starCity = "";
  4173. if (star_Three != null)
  4174. {
  4175. starCity = star_Three.AirPort;
  4176. }
  4177. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4178. string EndCity = "";
  4179. if (End_Three != null)
  4180. {
  4181. EndCity = End_Three.AirPort;
  4182. }
  4183. air.Destination = starCity + "/" + EndCity;
  4184. air.Flight = FlightsCode[i];
  4185. air.SeatingClass = item.CTypeName;
  4186. string dateTime = tempstr[2];
  4187. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4188. air.FlightDate = DateTemp;
  4189. air.DepartureTime = tempstr[5];
  4190. air.LandingTime = tempstr[6];
  4191. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4192. air.TicketStatus = "--";
  4193. air.Luggage = "--";
  4194. air.DepartureTerminal = "--";
  4195. air.LandingTerminal = "--";
  4196. airs.Add(air);
  4197. }
  4198. int row = 13;
  4199. for (int i = 0; i < airs.Count; i++)
  4200. {
  4201. if (airs.Count > 2)
  4202. {
  4203. for (int j = 0; j < airs.Count - 2; j++)
  4204. {
  4205. var CopyRow = table.Rows[12].Clone(true);
  4206. table.Rows.Add(CopyRow);
  4207. }
  4208. }
  4209. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4210. int index = 0;
  4211. foreach (PropertyInfo property in properties)
  4212. {
  4213. string value = property.GetValue(airs[i]).ToString();
  4214. Cell ishcel0 = table.Rows[row].Cells[index];
  4215. Paragraph p = new Paragraph(doc);
  4216. string s = value;
  4217. p.AppendChild(new Run(doc, s));
  4218. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4219. ishcel0.AppendChild(p);
  4220. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4221. index++;
  4222. }
  4223. row++;
  4224. }
  4225. #endregion
  4226. Paragraph lastParagraph = new Paragraph(doc);
  4227. //第一个表格末尾加段落
  4228. table.ParentNode.InsertAfter(lastParagraph, table);
  4229. //复制第一个表格
  4230. Table cloneTable = (Table)table.Clone(true);
  4231. //在文档末尾段落后面加入复制的表格
  4232. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4233. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4234. {
  4235. int rownewsIndex = 13;
  4236. for (int i = 0; i < 2; i++)
  4237. {
  4238. var CopyRow = table.Rows[12].Clone(true);
  4239. table.Rows.RemoveAt(13);
  4240. table.Rows.Add(CopyRow);
  4241. rownewsIndex++;
  4242. }
  4243. }
  4244. else
  4245. {
  4246. table.Rows.RemoveAt(12);
  4247. }
  4248. cloneTable.Rows.RemoveAt(12);
  4249. }
  4250. if (_AirTicketReservations.Count != 0)
  4251. {
  4252. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4253. if (FlightsCode.Length != 0)
  4254. {
  4255. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4256. if (_AirCompany != null)
  4257. {
  4258. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4259. }
  4260. else
  4261. {
  4262. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4263. }
  4264. }
  4265. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4266. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4267. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4268. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4269. string name = "";
  4270. foreach (string clientName in nameArray)
  4271. {
  4272. if (!name.Contains(clientName))
  4273. {
  4274. name += clientName + ",";
  4275. }
  4276. }
  4277. if (!string.IsNullOrWhiteSpace(name))
  4278. {
  4279. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4280. }
  4281. else
  4282. {
  4283. table.Range.Bookmarks["ClientName"].Text = "--";
  4284. }
  4285. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4286. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4287. table.Range.Bookmarks["JointTicket"].Text = "--";
  4288. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4289. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4290. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4291. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4292. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4293. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4294. }
  4295. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4296. //保存合并后的文档
  4297. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4298. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4299. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4300. return Ok(JsonView(true, "成功!", rst));
  4301. }
  4302. else
  4303. {
  4304. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4305. DocumentBuilder builder = new DocumentBuilder(doc);
  4306. int tableIndex = 0;//表格索引
  4307. //得到文档中的第一个表格
  4308. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4309. List<string> texts = new List<string>();
  4310. foreach (var item in _AirTicketReservations)
  4311. {
  4312. string[] FlightsCode = item.FlightsCode.Split('/');
  4313. if (FlightsCode.Length != 0)
  4314. {
  4315. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4316. if (_AirCompany != null)
  4317. {
  4318. if (!transDic.ContainsKey(_AirCompany.CnName))
  4319. {
  4320. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4321. }
  4322. }
  4323. else
  4324. {
  4325. if (!transDic.ContainsKey("--"))
  4326. {
  4327. transDic.Add("--", "--");
  4328. }
  4329. }
  4330. }
  4331. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4332. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4333. string name = "";
  4334. foreach (string clientName in nameArray)
  4335. {
  4336. name += clientName + ",";
  4337. }
  4338. if (!texts.Contains(name))
  4339. {
  4340. texts.Add(name);
  4341. }
  4342. List<AirInfo> airs = new List<AirInfo>();
  4343. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4344. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4345. for (int i = 0; i < FlightsCode.Length; i++)
  4346. {
  4347. AirInfo air = new AirInfo();
  4348. string[] tempstr = DayArray[i]
  4349. .Replace("\r\n", string.Empty)
  4350. .Replace("\\r\\n", string.Empty)
  4351. .TrimStart().TrimEnd()
  4352. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4353. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4354. if (star_Three != null)
  4355. {
  4356. if (!transDic.ContainsKey(star_Three.AirPort))
  4357. {
  4358. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4359. }
  4360. }
  4361. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4362. if (End_Three != null)
  4363. {
  4364. if (!transDic.ContainsKey(End_Three.AirPort))
  4365. {
  4366. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4367. }
  4368. }
  4369. if (!texts.Contains(item.CTypeName))
  4370. {
  4371. texts.Add(item.CTypeName);
  4372. }
  4373. }
  4374. }
  4375. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4376. if (transData.Count > 0)
  4377. {
  4378. foreach (TranslateResult item in transData)
  4379. {
  4380. if (!transDic.ContainsKey(item.Query))
  4381. {
  4382. transDic.Add(item.Query, item.Translation);
  4383. }
  4384. }
  4385. }
  4386. foreach (var item in _AirTicketReservations)
  4387. {
  4388. #region 处理固定数据
  4389. string[] FlightsCode = item.FlightsCode.Split('/');
  4390. if (FlightsCode.Length != 0)
  4391. {
  4392. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4393. if (_AirCompany != null)
  4394. {
  4395. string str = "--";
  4396. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4397. if (!string.IsNullOrEmpty(translateResult))
  4398. {
  4399. str = translateResult;
  4400. str = _airTicketResRep.Processing(str);
  4401. }
  4402. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4403. }
  4404. else
  4405. {
  4406. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4407. }
  4408. }
  4409. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4410. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4411. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4412. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4413. string names = "";
  4414. foreach (string clientName in nameArray)
  4415. {
  4416. names += clientName + ",";
  4417. }
  4418. if (!string.IsNullOrWhiteSpace(names))
  4419. {
  4420. string str = "--";
  4421. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4422. if (!string.IsNullOrEmpty(translateResult))
  4423. {
  4424. str = translateResult;
  4425. str = _airTicketResRep.Processing(str);
  4426. }
  4427. table.Range.Bookmarks["ClientName"].Text = str;
  4428. }
  4429. else
  4430. {
  4431. table.Range.Bookmarks["ClientName"].Text = "--";
  4432. }
  4433. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4434. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4435. table.Range.Bookmarks["JointTicket"].Text = "--";
  4436. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4437. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4438. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4439. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4440. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4441. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4442. #endregion
  4443. #region 循环数据处理
  4444. List<AirInfo> airs = new List<AirInfo>();
  4445. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4446. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4447. for (int i = 0; i < FlightsCode.Length; i++)
  4448. {
  4449. AirInfo air = new AirInfo();
  4450. string[] tempstr = DayArray[i]
  4451. .Replace("\r\n", string.Empty)
  4452. .Replace("\\r\\n", string.Empty)
  4453. .TrimStart().TrimEnd()
  4454. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4455. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4456. string starCity = "";
  4457. if (star_Three != null)
  4458. {
  4459. string str2 = "--";
  4460. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4461. if (!string.IsNullOrEmpty(translateResult2))
  4462. {
  4463. str2 = translateResult2;
  4464. str2 = _airTicketResRep.Processing(str2);
  4465. }
  4466. starCity = str2;
  4467. }
  4468. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4469. string EndCity = "";
  4470. if (End_Three != null)
  4471. {
  4472. string str1 = "--";
  4473. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4474. if (!string.IsNullOrEmpty(translateResult1))
  4475. {
  4476. str1 = translateResult1;
  4477. str1 = _airTicketResRep.Processing(str1);
  4478. }
  4479. EndCity = str1;
  4480. }
  4481. air.Destination = starCity + "/" + EndCity;
  4482. air.Flight = FlightsCode[i];
  4483. string str = "--";
  4484. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4485. if (!string.IsNullOrEmpty(translateResult))
  4486. {
  4487. str = translateResult;
  4488. str = _airTicketResRep.Processing(str);
  4489. }
  4490. air.SeatingClass = str;
  4491. string dateTime = tempstr[2];
  4492. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4493. air.FlightDate = DateTemp;
  4494. air.DepartureTime = tempstr[5];
  4495. air.LandingTime = tempstr[6];
  4496. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4497. air.TicketStatus = "--";
  4498. air.Luggage = "--";
  4499. air.DepartureTerminal = "--";
  4500. air.LandingTerminal = "--";
  4501. airs.Add(air);
  4502. }
  4503. int row = 13;
  4504. for (int i = 0; i < airs.Count; i++)
  4505. {
  4506. if (airs.Count > 2)
  4507. {
  4508. for (int j = 0; j < airs.Count - 2; j++)
  4509. {
  4510. var CopyRow = table.Rows[12].Clone(true);
  4511. table.Rows.Add(CopyRow);
  4512. }
  4513. }
  4514. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4515. int index = 0;
  4516. foreach (PropertyInfo property in properties)
  4517. {
  4518. string value = property.GetValue(airs[i]).ToString();
  4519. Cell ishcel0 = table.Rows[row].Cells[index];
  4520. Paragraph p = new Paragraph(doc);
  4521. string s = value;
  4522. p.AppendChild(new Run(doc, s));
  4523. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4524. ishcel0.AppendChild(p);
  4525. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4526. //ishcel0.CellFormat.VerticalAlignment=
  4527. index++;
  4528. }
  4529. row++;
  4530. }
  4531. #endregion
  4532. Paragraph lastParagraph = new Paragraph(doc);
  4533. //第一个表格末尾加段落
  4534. table.ParentNode.InsertAfter(lastParagraph, table);
  4535. //复制第一个表格
  4536. Table cloneTable = (Table)table.Clone(true);
  4537. //在文档末尾段落后面加入复制的表格
  4538. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4539. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4540. {
  4541. int rownewsIndex = 13;
  4542. for (int i = 0; i < 2; i++)
  4543. {
  4544. var CopyRow = table.Rows[12].Clone(true);
  4545. table.Rows.RemoveAt(13);
  4546. table.Rows.Add(CopyRow);
  4547. rownewsIndex++;
  4548. }
  4549. }
  4550. else
  4551. {
  4552. table.Rows.RemoveAt(12);
  4553. }
  4554. cloneTable.Rows.RemoveAt(12);
  4555. }
  4556. if (_AirTicketReservations.Count != 0)
  4557. {
  4558. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4559. if (FlightsCode.Length != 0)
  4560. {
  4561. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4562. if (_AirCompany != null)
  4563. {
  4564. string str = "--";
  4565. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4566. if (!string.IsNullOrEmpty(translateResult))
  4567. {
  4568. str = translateResult;
  4569. str = _airTicketResRep.Processing(str);
  4570. }
  4571. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4572. }
  4573. else
  4574. {
  4575. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4576. }
  4577. }
  4578. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4579. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4580. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4581. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4582. string names = "";
  4583. foreach (string clientName in nameArray)
  4584. {
  4585. names += clientName + ",";
  4586. }
  4587. if (!string.IsNullOrWhiteSpace(names))
  4588. {
  4589. string str = "--";
  4590. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4591. if (!string.IsNullOrEmpty(translateResult))
  4592. {
  4593. str = translateResult;
  4594. str = _airTicketResRep.Processing(str);
  4595. }
  4596. table.Range.Bookmarks["ClientName"].Text = str;
  4597. }
  4598. else
  4599. {
  4600. table.Range.Bookmarks["ClientName"].Text = "--";
  4601. }
  4602. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4603. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4604. table.Range.Bookmarks["JointTicket"].Text = "--";
  4605. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4606. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4607. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4608. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4609. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4610. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4611. }
  4612. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4613. //保存合并后的文档
  4614. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4615. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4616. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4617. return Ok(JsonView(true, "成功!", rst));
  4618. }
  4619. }
  4620. }
  4621. catch (Exception ex)
  4622. {
  4623. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4624. throw;
  4625. }
  4626. }
  4627. #endregion
  4628. #region 团组增减款项 --> 其他款项
  4629. /// <summary>
  4630. /// 团组增减款项下拉框绑定
  4631. /// </summary>
  4632. /// <param name="dto"></param>
  4633. /// <returns></returns>
  4634. [HttpPost]
  4635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4636. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4637. {
  4638. #region 参数验证
  4639. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4640. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4641. #endregion
  4642. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4643. }
  4644. /// <summary>
  4645. /// 根据团组Id查询团组增减款项
  4646. /// </summary>
  4647. /// <param name="dto"></param>
  4648. /// <returns></returns>
  4649. [HttpPost]
  4650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4651. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4652. {
  4653. #region 参数验证
  4654. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4655. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4656. #endregion
  4657. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4658. }
  4659. /// <summary>
  4660. /// 团组增减款项操作(Status:1.新增,2.修改)
  4661. /// </summary>
  4662. /// <param name="dto"></param>
  4663. /// <returns></returns>
  4664. [HttpPost]
  4665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4666. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4667. {
  4668. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4669. if (groupData.Code != 200)
  4670. {
  4671. return Ok(JsonView(false, groupData.Msg));
  4672. }
  4673. #region 应用推送
  4674. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4675. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4676. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4677. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4678. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4679. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4680. //自动审核
  4681. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4682. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4683. //2024-10-21 新增LZ UID
  4684. var userIds = new List<int>() { 21 };
  4685. string title = $"系统通知";
  4686. string content = "";
  4687. var diId = dto.DiId;
  4688. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4689. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4690. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4691. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4692. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4693. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4694. #endregion
  4695. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4696. }
  4697. /// <summary>
  4698. /// 团组增减款项操作 删除
  4699. /// </summary>
  4700. /// <param name="dto"></param>
  4701. /// <returns></returns>
  4702. [HttpPost]
  4703. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4704. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4705. {
  4706. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4707. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4708. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4709. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  4710. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  4711. }
  4712. /// <summary>
  4713. /// 根据团组增减款项Id查询
  4714. /// </summary>
  4715. /// <param name="dto"></param>
  4716. /// <returns></returns>
  4717. [HttpPost]
  4718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4719. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4720. {
  4721. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4722. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4723. }
  4724. /// <summary>
  4725. /// 查询供应商名称
  4726. /// </summary>
  4727. /// <param name="dto"></param>
  4728. /// <returns></returns>
  4729. [HttpPost]
  4730. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4731. {
  4732. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4733. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4734. ?? new List<Grp_DecreasePayments>();
  4735. dbResult = dbResult.Distinct(new
  4736. ProductComparer()).ToList();
  4737. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4738. {
  4739. x.Id,
  4740. x.SupplierAddress,
  4741. x.SupplierArea,
  4742. x.SupplierContact,
  4743. x.SupplierContactNumber,
  4744. x.SupplierEmail,
  4745. x.SupplierName,
  4746. x.SupplierSocialAccount,
  4747. x.SupplierTypeId,
  4748. }).ToList());
  4749. return Ok(jw);
  4750. }
  4751. /// <summary>
  4752. /// 团组增减款项 OTA匹配
  4753. /// </summary>
  4754. /// <param name="file"></param>
  4755. /// <returns></returns>
  4756. [HttpPost]
  4757. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4758. {
  4759. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4760. string fileName = file.FileName;
  4761. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4762. {
  4763. return Ok(JsonView(false, "请上传Excel文件!"));
  4764. }
  4765. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4766. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4767. if (!Directory.Exists(path))
  4768. {
  4769. Directory.CreateDirectory(path);
  4770. }
  4771. var filePath = @$"{path}/{fileName}";
  4772. //保存文件
  4773. using (FileStream fs = System.IO.File.Create(filePath))
  4774. {
  4775. file.CopyTo(fs);
  4776. fs.Flush();
  4777. }
  4778. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4779. //读取ExcelFile
  4780. DataTable dt = ConvertExcelToDataTable(filePath);
  4781. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4782. dt.TableName = "TB";
  4783. //修改table列名
  4784. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4785. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4786. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4787. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4788. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4789. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4790. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4791. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4792. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4793. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4794. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4795. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4796. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4797. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4798. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4799. var otaOrderNos = new List<string>();
  4800. foreach (DataRow item in dt.Rows)
  4801. {
  4802. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4803. }
  4804. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4805. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4806. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4807. .Select((dp, di) => new
  4808. {
  4809. dp.PriceName,
  4810. dp.OTAOrderNo,
  4811. dp.FeeTotal,
  4812. di.TeamName,
  4813. })
  4814. .ToListAsync();
  4815. foreach (DataRow item in dt.Rows)
  4816. {
  4817. var otaOrderNo = item["OTAOrderNo"].ToString();
  4818. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4819. if (oaData == null) continue;
  4820. item["GroupName"] = oaData.TeamName;
  4821. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4822. }
  4823. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4824. Dictionary<string, object> pairs = new Dictionary<string, object>();
  4825. List<DataTable> datas = new List<DataTable>();
  4826. datas.Add(dt);
  4827. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  4828. return Ok(JsonView(true, "操作成功", new { url = url }));
  4829. }
  4830. #region
  4831. private DataTable ConvertExcelToDataTable(string excelFilePath)
  4832. {
  4833. // 创建Workbook对象
  4834. Workbook workbook = new Workbook(excelFilePath);
  4835. // 获取第一个工作表
  4836. Worksheet worksheet = workbook.Worksheets[0];
  4837. // 将工作表转换为DataTable
  4838. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  4839. return dataTable;
  4840. }
  4841. #endregion
  4842. #endregion
  4843. #region 文件上传、删除
  4844. /// <summary>
  4845. /// region 文件上传 可以带参数
  4846. /// </summary>
  4847. /// <param name="file"></param>
  4848. /// <returns></returns>
  4849. [HttpPost]
  4850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4851. public async Task<IActionResult> UploadProject(IFormFile file)
  4852. {
  4853. //var TypeName = Request.Headers["TypeName"].ToString();
  4854. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  4855. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4856. ////文件名称
  4857. //string projectFileName = file.FileName;
  4858. ////上传的文件的路径
  4859. //string filePath = $"{fileDir}/{projectFileName}";
  4860. //if (TypeName == "A")//A代表团组增减款项
  4861. //{
  4862. // filePath = fileDir + $@"\团组增减款项相关文件";
  4863. // if (!Directory.Exists(filePath))
  4864. // {
  4865. // Directory.CreateDirectory(filePath);
  4866. // }
  4867. // //上传的文件的路径
  4868. // filePath += $@"\{projectFileName}";
  4869. //}
  4870. //else if (TypeName == "B")//B代表商邀相关文件
  4871. //{
  4872. // //上传的文件的路径
  4873. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4874. // if (!Directory.Exists(filePath))
  4875. // {
  4876. // Directory.CreateDirectory(filePath);
  4877. // }
  4878. // //上传的文件的路径
  4879. // filePath = $@"\{projectFileName}";
  4880. //}
  4881. //try
  4882. //{
  4883. // using (FileStream fs = System.IO.File.Create(filePath))
  4884. // {
  4885. // file.CopyTo(fs);
  4886. // fs.Flush();
  4887. // }
  4888. //}
  4889. //catch (Exception ex)
  4890. //{
  4891. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  4892. //}
  4893. //return Ok(JsonView(true, "上传成功!", projectFileName));
  4894. try
  4895. {
  4896. var TypeName = Request.Headers["TypeName"].ToString();
  4897. if (file != null)
  4898. {
  4899. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4900. //文件名称
  4901. string projectFileName = file.FileName;
  4902. //上传的文件的路径
  4903. string filePath = $"{fileDir}/{projectFileName}";
  4904. if (TypeName == "A")//A代表团组增减款项
  4905. {
  4906. if (!Directory.Exists(fileDir))
  4907. {
  4908. Directory.CreateDirectory(fileDir);
  4909. }
  4910. //上传的文件的路径
  4911. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4912. }
  4913. else if (TypeName == "B")//B代表商邀相关文件
  4914. {
  4915. if (!Directory.Exists(fileDir))
  4916. {
  4917. Directory.CreateDirectory(fileDir);
  4918. }
  4919. //上传的文件的路径
  4920. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4921. }
  4922. using (FileStream fs = System.IO.File.Create(filePath))
  4923. {
  4924. file.CopyTo(fs);
  4925. fs.Flush();
  4926. }
  4927. return Ok(JsonView(true, "上传成功!", projectFileName));
  4928. }
  4929. else
  4930. {
  4931. return Ok(JsonView(false, "上传失败!"));
  4932. }
  4933. }
  4934. catch (Exception ex)
  4935. {
  4936. return Ok(JsonView(false, "程序错误!"));
  4937. }
  4938. }
  4939. /// <summary>
  4940. /// 删除指定文件
  4941. /// </summary>
  4942. /// <param name="dto"></param>
  4943. /// <returns></returns>
  4944. [HttpPost]
  4945. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4946. public async Task<IActionResult> DelFile(DelFileDto dto)
  4947. {
  4948. try
  4949. {
  4950. var TypeName = Request.Headers["TypeName"].ToString();
  4951. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4952. string filePath = "";
  4953. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4954. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4955. int id = 0;
  4956. if (TypeName == "A")
  4957. {
  4958. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  4959. // 删除该文件
  4960. System.IO.File.Delete(filePath);
  4961. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  4962. .Where(a => a.Id == dto.Id)
  4963. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  4964. .ExecuteCommandAsync();
  4965. }
  4966. else if (TypeName == "B")
  4967. {
  4968. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  4969. // 删除该文件
  4970. System.IO.File.Delete(filePath);
  4971. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  4972. if (info != null)
  4973. {
  4974. string[] files = new string[] { };
  4975. if (!string.IsNullOrEmpty(info.Attachment))
  4976. {
  4977. try
  4978. {
  4979. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  4980. }
  4981. catch (Exception)
  4982. {
  4983. files = new List<string>() { info.Attachment }.ToArray();
  4984. }
  4985. }
  4986. if (files.Length > 0)
  4987. {
  4988. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  4989. string filePath2 = string.Empty;
  4990. if (files1.Length > 0)
  4991. {
  4992. filePath2 = JsonConvert.SerializeObject(files1);
  4993. }
  4994. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4995. .Where(a => a.Id == dto.Id)
  4996. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  4997. .ExecuteCommandAsync();
  4998. }
  4999. }
  5000. }
  5001. if (id != 0)
  5002. {
  5003. return Ok(JsonView(true, "成功!"));
  5004. }
  5005. else
  5006. {
  5007. return Ok(JsonView(false, "失败!"));
  5008. }
  5009. }
  5010. catch (Exception ex)
  5011. {
  5012. return Ok(JsonView(false, "程序错误!"));
  5013. throw;
  5014. }
  5015. }
  5016. /// <summary>
  5017. /// 文件上传多个文件 可以带参数
  5018. /// </summary>
  5019. /// <param name="files"></param>
  5020. /// <returns></returns>
  5021. [HttpPost]
  5022. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5023. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  5024. {
  5025. try
  5026. {
  5027. var TypeName = Request.Headers["TypeName"].ToString();
  5028. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5029. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  5030. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5031. var filePahts = new List<string>();
  5032. foreach (var file in files)
  5033. {
  5034. //文件名称
  5035. string projectFileName = file.FileName;
  5036. //上传的文件的路径
  5037. string filePath = $"{fileDir}/{projectFileName}";
  5038. if (TypeName == "A")//A代表团组增减款项
  5039. {
  5040. if (!Directory.Exists(fileDir))
  5041. {
  5042. Directory.CreateDirectory(fileDir);
  5043. }
  5044. //上传的文件的路径
  5045. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5046. }
  5047. else if (TypeName == "B")//B代表商邀相关文件
  5048. {
  5049. if (!Directory.Exists(fileDir))
  5050. {
  5051. Directory.CreateDirectory(fileDir);
  5052. }
  5053. //上传的文件的路径
  5054. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5055. }
  5056. using (FileStream fs = System.IO.File.Create(filePath))
  5057. {
  5058. file.CopyTo(fs);
  5059. fs.Flush();
  5060. }
  5061. filePahts.Add(projectFileName);
  5062. }
  5063. return Ok(JsonView(true, "上传成功!", filePahts));
  5064. }
  5065. catch (Exception ex)
  5066. {
  5067. return Ok(JsonView(false, "程序错误!"));
  5068. }
  5069. }
  5070. #endregion
  5071. #region 商邀费用录入
  5072. /// <summary>
  5073. /// 根据团组Id查询商邀费用列表
  5074. /// </summary>
  5075. /// <param name="dto"></param>
  5076. /// <returns></returns>
  5077. [HttpPost]
  5078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5079. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  5080. {
  5081. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  5082. if (groupData.Code != 0)
  5083. {
  5084. return Ok(JsonView(false, groupData.Msg));
  5085. }
  5086. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5087. }
  5088. /// <summary>
  5089. /// 商邀费用列表
  5090. /// 下载文件
  5091. /// </summary>
  5092. /// <param name="id"></param>
  5093. /// <returns></returns>
  5094. [HttpGet("{id}")]
  5095. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5096. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  5097. {
  5098. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  5099. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  5100. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  5101. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  5102. var filePaths = new List<string>();
  5103. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  5104. try
  5105. {
  5106. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  5107. }
  5108. catch (Exception ex)
  5109. {
  5110. filePaths.Add(info.Attachment);
  5111. }
  5112. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  5113. for (int i = 0; i < filePaths.Count; i++)
  5114. {
  5115. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  5116. }
  5117. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  5118. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  5119. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  5120. {
  5121. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  5122. {
  5123. foreach (string filePath in filePaths)
  5124. {
  5125. if (System.IO.File.Exists(filePath))
  5126. {
  5127. // 获取文件名
  5128. string fileName = Path.GetFileName(filePath);
  5129. // 将文件添加到ZIP归档中
  5130. zipArchive.CreateEntryFromFile(filePath, fileName);
  5131. }
  5132. }
  5133. }
  5134. }
  5135. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5136. }
  5137. /// <summary>
  5138. /// 商邀费用 Info Page 基础数据源
  5139. /// </summary>
  5140. /// <returns></returns>
  5141. [HttpPost]
  5142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5143. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5144. {
  5145. try
  5146. {
  5147. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  5148. if (groupData.Code != 0)
  5149. {
  5150. return Ok(JsonView(false, groupData.Msg));
  5151. }
  5152. return Ok(JsonView(true, "操作成功", groupData.Data));
  5153. }
  5154. catch (Exception ex)
  5155. {
  5156. return Ok(JsonView(false, ex.Message));
  5157. throw;
  5158. }
  5159. }
  5160. /// <summary>
  5161. /// 根据商邀费用ID查询C表和商邀费用数据
  5162. /// </summary>
  5163. /// <param name="dto"></param>
  5164. /// <returns></returns>
  5165. [HttpPost]
  5166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5167. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5168. {
  5169. try
  5170. {
  5171. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5172. if (groupData.Code != 0)
  5173. {
  5174. return Ok(JsonView(false, groupData.Msg));
  5175. }
  5176. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5177. }
  5178. catch (Exception ex)
  5179. {
  5180. return Ok(JsonView(false, ex.Message));
  5181. throw;
  5182. }
  5183. }
  5184. /// <summary>
  5185. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5186. /// </summary>
  5187. /// <param name="dto"></param>
  5188. /// <returns></returns>
  5189. [HttpPost]
  5190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5191. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5192. {
  5193. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5194. if (groupData.Code != 0)
  5195. {
  5196. return Ok(JsonView(false, groupData.Msg));
  5197. }
  5198. #region 应用推送
  5199. try
  5200. {
  5201. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5202. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5203. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5204. //2024-10-21 新增LZ UID
  5205. var userIds = new List<int>() { 21 };
  5206. string title = $"系统通知";
  5207. string content = "";
  5208. var diId = dto.DiId;
  5209. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5210. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5211. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5212. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5213. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5214. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5215. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5216. }
  5217. catch (Exception ex)
  5218. {
  5219. }
  5220. #endregion
  5221. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5222. }
  5223. /// <summary>
  5224. /// 商邀删除
  5225. /// </summary>
  5226. /// <param name="dto"></param>
  5227. /// <returns></returns>
  5228. [HttpPost]
  5229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5230. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5231. {
  5232. try
  5233. {
  5234. _sqlSugar.BeginTran();
  5235. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5236. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5237. {
  5238. IsDel = 1,
  5239. DeleteUserId = dto.DeleteUserId,
  5240. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5241. })
  5242. .Where(it => it.Id == dto.Id)
  5243. .ExecuteCommand();
  5244. if (res1 > 0)
  5245. {
  5246. int _diId = 0;
  5247. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5248. if (_ioaInfo != null)
  5249. {
  5250. _diId = _ioaInfo.DiId;
  5251. }
  5252. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5253. .SetColumns(a => new Grp_CreditCardPayment()
  5254. {
  5255. IsDel = 1,
  5256. DeleteUserId = dto.DeleteUserId,
  5257. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5258. })
  5259. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5260. .ExecuteCommand();
  5261. if (res2 > 0)
  5262. {
  5263. _sqlSugar.CommitTran();
  5264. return Ok(JsonView(true, "删除成功!"));
  5265. }
  5266. }
  5267. _sqlSugar.RollbackTran();
  5268. return Ok(JsonView(false, "删除失败"));
  5269. }
  5270. catch (Exception ex)
  5271. {
  5272. _sqlSugar.RollbackTran();
  5273. return Ok(JsonView(false, ex.Message));
  5274. }
  5275. }
  5276. #endregion
  5277. #region 票据上传
  5278. /// <summary>
  5279. /// 团组模块文件上传
  5280. /// </summary>
  5281. /// <param name="dto"></param>
  5282. /// <returns></returns>
  5283. [HttpPost]
  5284. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5285. {
  5286. var jw = JsonView(false);
  5287. long M = 1024 * 1024;
  5288. if (dto.Files == null || dto.Files.Count == 0)
  5289. {
  5290. jw.Msg = "无文件信息!";
  5291. return Ok(jw);
  5292. }
  5293. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5294. {
  5295. jw.Msg = "文件大小超过20M!";
  5296. return Ok(jw);
  5297. }
  5298. //var nameSp = dto.File.FileName.Split(".");
  5299. //if (nameSp.Length < 2)
  5300. //{
  5301. // jw.Msg = "拓展名称有误!";
  5302. // return Ok(jw);
  5303. //}
  5304. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5305. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5306. //{
  5307. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5308. // return Ok(jw);
  5309. //}
  5310. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5311. if (Ctable == null)
  5312. {
  5313. jw.Msg = "Ctable指向有误!";
  5314. return Ok(jw);
  5315. }
  5316. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5317. if (groupInfo == null)
  5318. {
  5319. jw.Msg = "团组信息不存在!";
  5320. return Ok(jw);
  5321. }
  5322. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5323. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5324. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5325. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5326. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5327. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5328. try
  5329. {
  5330. if (!Directory.Exists(fileBase))
  5331. {
  5332. Directory.CreateDirectory(fileBase);
  5333. }
  5334. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  5335. foreach (var fileStream in dto.Files)
  5336. {
  5337. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5338. Grp_GroupModelFile file = new Grp_GroupModelFile()
  5339. {
  5340. Cid = dto.Cid,
  5341. CreateTime = DateTime.Now,
  5342. CreateUserId = dto.Userid,
  5343. Ctable = dto.Ctable,
  5344. Diid = dto.Diid,
  5345. IsDel = 0,
  5346. FilePath = saveFilePath,
  5347. FileName = fileStream.FileName
  5348. };
  5349. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5350. {
  5351. fileStream.CopyTo(fs);
  5352. fs.Flush();
  5353. }
  5354. saveArr.Add(file);
  5355. }
  5356. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5357. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5358. jw = JsonView(true, "保存成功!", new
  5359. {
  5360. count = addResult,
  5361. filesName = saveArr.Select(x => x.FileName)
  5362. });
  5363. }
  5364. catch (Exception ex)
  5365. {
  5366. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5367. {
  5368. count = 0,
  5369. filesName = new string[0],
  5370. });
  5371. }
  5372. return Ok(jw);
  5373. }
  5374. /// <summary>
  5375. /// 查询各模块已保存文件
  5376. /// </summary>
  5377. /// <param name="dto"></param>
  5378. /// <returns></returns>
  5379. [HttpPost]
  5380. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5381. {
  5382. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5383. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5384. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5385. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5386. {
  5387. expression = Expressionable.Create<Grp_GroupModelFile>()
  5388. .And(x => visaIds.Contains(x.CreateUserId));
  5389. }
  5390. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5391. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5392. .Where(expression.ToExpression())
  5393. .ToList();
  5394. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5395. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5396. {
  5397. x.FileName,
  5398. x.Id,
  5399. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5400. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5401. })));
  5402. }
  5403. /// <summary>
  5404. /// 下载该团组下的所有文件
  5405. /// </summary>
  5406. /// <param name="dto"></param>
  5407. /// <returns></returns>
  5408. [HttpPost]
  5409. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5410. {
  5411. var jw = JsonView(false);
  5412. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5413. if (groupInfo == null)
  5414. {
  5415. jw.Msg = "团组信息不存在!";
  5416. return Ok(jw);
  5417. }
  5418. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5419. var isModule = Convert.ToBoolean(dto.isModule);
  5420. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5421. IOOperatorHelper io = new IOOperatorHelper();
  5422. if (isModule)
  5423. {
  5424. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5425. foreach (var moduleArr in moduleGroup)
  5426. {
  5427. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5428. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5429. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5430. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  5431. foreach (var item in moduleArr)
  5432. {
  5433. if (System.IO.File.Exists(item.FilePath))
  5434. {
  5435. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5436. {
  5437. byte[] bytes = new byte[fileStream.Length];
  5438. fileStream.Read(bytes, 0, bytes.Length);
  5439. fileStream.Close();
  5440. Stream stream = new MemoryStream(bytes);
  5441. chiZips.Add(item.FileName, stream);
  5442. }
  5443. }
  5444. }
  5445. if (chiZips.Count > 0)
  5446. {
  5447. var byts = io.ConvertZipStream(chiZips);
  5448. Stream stream = new MemoryStream(byts);
  5449. Zips.Add(key.Name + "_.zip", stream);
  5450. }
  5451. }
  5452. }
  5453. else
  5454. {
  5455. foreach (var item in dbQuery)
  5456. {
  5457. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5458. {
  5459. byte[] bytes = new byte[fileStream.Length];
  5460. fileStream.Read(bytes, 0, bytes.Length);
  5461. fileStream.Close();
  5462. Stream stream = new MemoryStream(bytes);
  5463. while (Zips.Keys.Contains(item.FileName))
  5464. {
  5465. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5466. }
  5467. Zips.Add(item.FileName, stream);
  5468. }
  5469. }
  5470. }
  5471. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5472. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5473. if (Zips.Count > 0)
  5474. {
  5475. var byts = io.ConvertZipStream(Zips);
  5476. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5477. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5478. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5479. }
  5480. else
  5481. {
  5482. jw.Msg = "暂无生成文件!";
  5483. }
  5484. return Ok(jw);
  5485. }
  5486. /// <summary>
  5487. /// 下载该团组下此模块的所有文件
  5488. /// </summary>
  5489. /// <param name="dto"></param>
  5490. /// <returns></returns>
  5491. [HttpPost]
  5492. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5493. {
  5494. var jw = JsonView(false);
  5495. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5496. if (groupInfo == null)
  5497. {
  5498. jw.Msg = "团组信息不存在!";
  5499. return Ok(jw);
  5500. }
  5501. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5502. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5503. && x.IsDel == 0);
  5504. if (key == null)
  5505. {
  5506. jw.Msg = "Ctable指向错误!";
  5507. return Ok(jw);
  5508. }
  5509. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5510. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5511. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5512. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5513. IOOperatorHelper io = new IOOperatorHelper();
  5514. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5515. foreach (var item in dbQuery)
  5516. {
  5517. if (System.IO.File.Exists(item.FilePath))
  5518. {
  5519. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5520. {
  5521. byte[] bytes = new byte[fileStream.Length];
  5522. fileStream.Read(bytes, 0, bytes.Length);
  5523. fileStream.Close();
  5524. Stream stream = new MemoryStream(bytes);
  5525. while (Zips.Keys.Contains(item.FileName))
  5526. {
  5527. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5528. }
  5529. Zips.Add(item.FileName, stream);
  5530. }
  5531. }
  5532. }
  5533. if (Zips.Count > 0)
  5534. {
  5535. var byts = io.ConvertZipStream(Zips);
  5536. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5537. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5538. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5539. }
  5540. else
  5541. {
  5542. jw.Msg = "暂无生成文件!";
  5543. }
  5544. return Ok(jw);
  5545. }
  5546. /// <summary>
  5547. /// 删除该团组下的指定文件
  5548. /// </summary>
  5549. /// <param name="dto"></param>
  5550. /// <returns></returns>
  5551. [HttpPost]
  5552. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5553. {
  5554. var jw = JsonView(false);
  5555. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5556. if (sing == null)
  5557. {
  5558. jw.Msg = "暂无";
  5559. return Ok(jw);
  5560. }
  5561. if (System.IO.File.Exists(sing.FilePath))
  5562. {
  5563. try
  5564. {
  5565. System.IO.File.Delete(sing.FilePath);
  5566. }
  5567. catch (Exception ex)
  5568. {
  5569. jw.Msg = "删除失败!" + ex.Message;
  5570. return Ok(jw);
  5571. }
  5572. }
  5573. sing.IsDel = 1;
  5574. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5575. sing.DeleteUserId = dto.UserId;
  5576. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5577. jw = JsonView(true, "删除成功!");
  5578. return Ok(jw);
  5579. }
  5580. #endregion
  5581. #region 共享文件上传
  5582. /// <summary>
  5583. /// 共享文件数据初始化
  5584. /// </summary>
  5585. /// <returns></returns>
  5586. [HttpGet]
  5587. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  5588. {
  5589. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  5590. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5591. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5592. .Select(x => x.Id)
  5593. .ToList()
  5594. .Contains(userid);
  5595. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5596. .Where(x => x.STid == 111 && x.IsDel == 0)
  5597. .Select(x => new
  5598. {
  5599. x.Name,
  5600. x.Id,
  5601. }).ToList();
  5602. if (isMarketingDepartment)
  5603. {
  5604. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5605. }
  5606. if (portType == 1)
  5607. {
  5608. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5609. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5610. .Where(x => x.IsDel == 0)
  5611. .OrderByDescending(x => x.VisitDate)
  5612. .Select(x => new
  5613. {
  5614. x.TeamName,
  5615. x.Id,
  5616. x.CityId,
  5617. })
  5618. .ToList()
  5619. .Select(x =>
  5620. {
  5621. var provinceId = x.CityId;
  5622. var isDefualtVal = true;
  5623. if (provinceId > 0)
  5624. {
  5625. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5626. if (parentId != null)
  5627. {
  5628. isDefualtVal = false;
  5629. provinceId = (int)parentId;
  5630. }
  5631. }
  5632. if (isDefualtVal)
  5633. {
  5634. provinceId = 122; //默认四川
  5635. }
  5636. return new
  5637. {
  5638. x.TeamName,
  5639. x.Id,
  5640. provinceId,
  5641. };
  5642. })
  5643. .ToList();
  5644. return Ok(JsonView(true, "SUCCESS!", new
  5645. {
  5646. dropDownType,
  5647. dropDownGroupList,
  5648. isMarketingDepartment
  5649. }));
  5650. }
  5651. else if (portType == 2 || portType == 3)
  5652. {
  5653. return Ok(JsonView(true, "SUCCESS!", new
  5654. {
  5655. dropDownType,
  5656. isMarketingDepartment
  5657. }));
  5658. }
  5659. else
  5660. {
  5661. return Ok(JsonView(false, "portType有误!"));
  5662. }
  5663. }
  5664. /// <summary>
  5665. /// 共享文件上传
  5666. /// </summary>
  5667. /// <param name="dto"></param>
  5668. /// <returns></returns>
  5669. [HttpPost]
  5670. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5671. {
  5672. var isGroup = new List<int> { 1412 };
  5673. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5674. {
  5675. return Ok(JsonView(false, "该文件需要关联团组!"));
  5676. }
  5677. if (dto.Files == null || dto.Files.Count == 0)
  5678. {
  5679. return Ok(JsonView(false, "无文件信息!"));
  5680. }
  5681. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5682. {
  5683. return Ok(JsonView(false, "文件大小超过20M!"));
  5684. }
  5685. if (dto.Userid < 1)
  5686. {
  5687. return Ok(JsonView(false, "请传入有效的Userid!"));
  5688. }
  5689. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5690. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5691. .Select((u, j) => new
  5692. {
  5693. u.CnName,
  5694. UserId = u.Id,
  5695. j.JobName,
  5696. })
  5697. .First();
  5698. if (jobInfo == null)
  5699. {
  5700. return Ok(JsonView(false, "请传入有效的Userid!"));
  5701. }
  5702. List<string> commonFileExtensions = new List<string>
  5703. {
  5704. // 文本文件
  5705. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5706. // 图片文件
  5707. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5708. // 视频文件
  5709. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5710. // 音频文件
  5711. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5712. // 压缩文件
  5713. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5714. // 数据文件
  5715. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5716. };
  5717. try
  5718. {
  5719. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5720. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5721. commonFileExtensions.AddRange(settingExtend);
  5722. }
  5723. catch (Exception)
  5724. { }
  5725. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5726. if (setdata == null)
  5727. {
  5728. return Ok(JsonView(false, "请传入有效的FileType!"));
  5729. }
  5730. List<Grp_GroupShareFile> insertList = new List<Grp_GroupShareFile>();
  5731. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5732. if (!Directory.Exists(winPath))
  5733. {
  5734. Directory.CreateDirectory(winPath);
  5735. }
  5736. foreach (var item in dto.Files)
  5737. {
  5738. var houzui = Path.GetExtension(item.FileName);
  5739. if (!commonFileExtensions.Contains(houzui))
  5740. {
  5741. return Ok(JsonView(false, "未知后缀名称!"));
  5742. }
  5743. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5744. var saveFilePath = winPath + fileName;
  5745. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5746. {
  5747. item.CopyTo(fs);
  5748. fs.Flush();
  5749. }
  5750. var fileDetail = new Grp_GroupShareFile()
  5751. {
  5752. CreateUserId = dto.Userid,
  5753. CreateTime = DateTime.Now,
  5754. UploadJob = jobInfo.JobName,
  5755. FileName = fileName,
  5756. FileType = dto.FileType,
  5757. Diid = dto.Diid,
  5758. FilePath = winPath + fileName,
  5759. };
  5760. insertList.Add(fileDetail);
  5761. }
  5762. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5763. return Ok(JsonView(true, "保存成功!"));
  5764. }
  5765. /// <summary>
  5766. /// 查询共享文件列表
  5767. /// </summary>
  5768. /// <param name="dto"></param>
  5769. /// <returns></returns>
  5770. [HttpPost]
  5771. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5772. {
  5773. var isGroup = new List<int> { 1412 };
  5774. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5775. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5776. .And(x => x.Diid == dto.Diid)
  5777. .And(x => x.FileType == dto.FileType)
  5778. .And(x => x.IsDel == 0)
  5779. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5780. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5781. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5782. int totalCount = 0;
  5783. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5784. .Where(queryExpression.ToExpression())
  5785. .OrderBy(x => x.UploadJob)
  5786. .Select(x => new
  5787. {
  5788. x.Id,
  5789. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5790. x.FileName,
  5791. x.FileType,
  5792. x.CreateTime,
  5793. })
  5794. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5795. return Ok(JsonView(true, "SUCCESS!", new
  5796. {
  5797. FileList = dbQuery,
  5798. dto.PageSize,
  5799. dto.PageIndex,
  5800. totalCount
  5801. }));
  5802. }
  5803. /// <summary>
  5804. /// 删除共享文件模块下的指定文件
  5805. /// </summary>
  5806. /// <param name="dto"></param>
  5807. /// <returns></returns>
  5808. [HttpPost]
  5809. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  5810. {
  5811. var jw = JsonView(false);
  5812. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5813. if (sing == null)
  5814. {
  5815. jw.Msg = "暂无文件信息!";
  5816. return Ok(jw);
  5817. }
  5818. if (sing.CreateUserId != dto.UserId)
  5819. {
  5820. jw.Msg = "只能删除自己上传的文件!";
  5821. return Ok(jw);
  5822. }
  5823. if (System.IO.File.Exists(sing.FilePath))
  5824. {
  5825. try
  5826. {
  5827. System.IO.File.Delete(sing.FilePath);
  5828. }
  5829. catch (Exception ex)
  5830. {
  5831. jw.Msg = "删除失败!" + ex.Message;
  5832. return Ok(jw);
  5833. }
  5834. }
  5835. sing.IsDel = 1;
  5836. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5837. sing.DeleteUserId = dto.UserId;
  5838. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  5839. jw = JsonView(true, "删除成功!");
  5840. return Ok(jw);
  5841. }
  5842. #endregion
  5843. #region 团组英文资料
  5844. /// <summary>
  5845. /// 查询团组英文所有资料
  5846. /// </summary>
  5847. /// <param name="dto"></param>
  5848. /// <returns></returns>
  5849. [HttpPost]
  5850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5851. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  5852. {
  5853. try
  5854. {
  5855. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  5856. if (groupData.Code != 0)
  5857. {
  5858. return Ok(JsonView(false, groupData.Msg));
  5859. }
  5860. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5861. }
  5862. catch (Exception ex)
  5863. {
  5864. return Ok(JsonView(false, "程序错误!"));
  5865. throw;
  5866. }
  5867. }
  5868. /// <summary>
  5869. /// 团组英文资料操作(Status:1.新增,2.修改)
  5870. /// </summary>
  5871. /// <param name="dto"></param>
  5872. /// <returns></returns>
  5873. [HttpPost]
  5874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5875. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  5876. {
  5877. try
  5878. {
  5879. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  5880. if (groupData.Code != 0)
  5881. {
  5882. return Ok(JsonView(false, groupData.Msg));
  5883. }
  5884. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5885. }
  5886. catch (Exception ex)
  5887. {
  5888. return Ok(JsonView(false, "程序错误!"));
  5889. throw;
  5890. }
  5891. }
  5892. /// <summary>
  5893. /// 团组英文资料Id查询数据
  5894. /// </summary>
  5895. /// <param name="dto"></param>
  5896. /// <returns></returns>
  5897. [HttpPost]
  5898. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5899. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  5900. {
  5901. try
  5902. {
  5903. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  5904. if (_DelegationEnData != null)
  5905. {
  5906. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  5907. }
  5908. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  5909. }
  5910. catch (Exception ex)
  5911. {
  5912. return Ok(JsonView(false, "程序错误!"));
  5913. throw;
  5914. }
  5915. }
  5916. /// <summary>
  5917. /// 团组英文资料删除
  5918. /// </summary>
  5919. /// <param name="dto"></param>
  5920. /// <returns></returns>
  5921. [HttpPost]
  5922. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5923. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  5924. {
  5925. try
  5926. {
  5927. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  5928. if (!res)
  5929. {
  5930. return Ok(JsonView(false, "删除失败"));
  5931. }
  5932. return Ok(JsonView(true, "删除成功!"));
  5933. }
  5934. catch (Exception ex)
  5935. {
  5936. return Ok(JsonView(false, "程序错误!"));
  5937. throw;
  5938. }
  5939. }
  5940. #endregion
  5941. #region 导出邀请函
  5942. /// <summary>
  5943. /// 导出邀请函页面初始化
  5944. /// </summary>
  5945. /// <param name="dto"></param>
  5946. /// <returns></returns>
  5947. [HttpPost]
  5948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5949. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  5950. {
  5951. try
  5952. {
  5953. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  5954. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  5955. if (dto.DiId == 0)
  5956. {
  5957. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  5958. }
  5959. else
  5960. {
  5961. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  5962. }
  5963. return Ok(JsonView(true, "查询成功!", new
  5964. {
  5965. deleClient = crm_Deles,
  5966. delegations = grp_Delegations
  5967. }));
  5968. }
  5969. catch (Exception ex)
  5970. {
  5971. return Ok(JsonView(false, "程序错误!"));
  5972. throw;
  5973. }
  5974. }
  5975. /// <summary>
  5976. /// 导出邀请函
  5977. /// </summary>
  5978. /// <param name="dto"></param>
  5979. /// <returns></returns>
  5980. [HttpPost]
  5981. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5982. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  5983. {
  5984. #region 参数验证
  5985. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5986. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5987. #endregion
  5988. try
  5989. {
  5990. Dictionary<string, string> transDic = new Dictionary<string, string>();
  5991. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  5992. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  5993. From Grp_TourClientList tcl
  5994. Left Join
  5995. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  5996. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  5997. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  5998. From Crm_DeleClient dc
  5999. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  6000. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  6001. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  6002. Where dc.IsDel = 0) temp
  6003. On temp.DcId =tcl.ClientId
  6004. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  6005. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  6006. List<string> texts = new List<string>();
  6007. if (datas.Count != 0)
  6008. {
  6009. foreach (TourClientListDetailsView item in datas)
  6010. {
  6011. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  6012. {
  6013. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  6014. }
  6015. else
  6016. {
  6017. string name = item.LastName + item.FirstName;
  6018. texts.Add(name);
  6019. }
  6020. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  6021. {
  6022. if (!transDic.ContainsKey(item.Job))
  6023. {
  6024. texts.Add(item.Job);
  6025. }
  6026. }
  6027. if (!string.IsNullOrEmpty(item.CompanyFullName))
  6028. {
  6029. texts.Add(item.CompanyFullName);
  6030. }
  6031. }
  6032. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  6033. if (transData.Count > 0)
  6034. {
  6035. foreach (TranslateResult item in transData)
  6036. {
  6037. if (!transDic.ContainsKey(item.Query))
  6038. {
  6039. transDic.Add(item.Query, item.Translation);
  6040. }
  6041. }
  6042. }
  6043. List<GuestList> list = new List<GuestList>();
  6044. foreach (TourClientListDetailsView dele in datas)
  6045. {
  6046. GuestList guestList = new GuestList();
  6047. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  6048. {
  6049. guestList.Name = dele.Pinyin;
  6050. }
  6051. else
  6052. {
  6053. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  6054. guestList.Name = Name;
  6055. }
  6056. if (dele.Sex == 0)
  6057. {
  6058. guestList.Sex = "Male";
  6059. }
  6060. else if (dele.Sex == 1)
  6061. {
  6062. guestList.Sex = "Female";
  6063. }
  6064. guestList.DOB = dele.BirthDay.Replace('-', '.');
  6065. if (!string.IsNullOrEmpty(dele.Job))
  6066. {
  6067. guestList.Job = dele.Job;
  6068. }
  6069. list.Add(guestList);
  6070. }
  6071. //载入模板
  6072. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  6073. DocumentBuilder builder = new DocumentBuilder(doc);
  6074. //获取word里所有表格
  6075. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6076. //获取所填表格的序数
  6077. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6078. var rowStart = tableOne.Rows[0]; //获取第1行
  6079. //循环赋值
  6080. for (int i = 0; i < list.Count; i++)
  6081. {
  6082. builder.MoveToCell(0, i + 1, 0, 0);
  6083. builder.Write(list[i].Name.ToString());
  6084. builder.MoveToCell(0, i + 1, 1, 0);
  6085. builder.Write(list[i].Sex.ToString());
  6086. builder.MoveToCell(0, i + 1, 2, 0);
  6087. builder.Write(list[i].DOB.ToString());
  6088. builder.MoveToCell(0, i + 1, 3, 0);
  6089. builder.Write(list[i].Job.ToString());
  6090. }
  6091. //删除多余行
  6092. while (tableOne.Rows.Count > list.Count + 1)
  6093. {
  6094. tableOne.Rows.RemoveAt(list.Count + 1);
  6095. }
  6096. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6097. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  6098. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  6099. doc.Save(filePath);
  6100. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  6101. return Ok(JsonView(true, "操作成功!", Url));
  6102. }
  6103. else
  6104. {
  6105. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  6106. }
  6107. }
  6108. catch (Exception ex)
  6109. {
  6110. return Ok(JsonView(false, ex.Message));
  6111. throw;
  6112. }
  6113. }
  6114. #endregion
  6115. #region 团组经理模块 出入境费用
  6116. /// <summary>
  6117. /// 团组模块 - 出入境费用 - 省份基础数据源
  6118. /// </summary>
  6119. /// <returns></returns>
  6120. [HttpGet]
  6121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6122. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  6123. {
  6124. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  6125. }
  6126. /// <summary>
  6127. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6128. /// </summary>
  6129. /// <returns></returns>
  6130. [HttpPost]
  6131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6132. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6133. {
  6134. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6135. var groupNamFirst = groupNameData.FirstOrDefault();
  6136. //SetDataInfoView
  6137. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6138. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6139. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6140. //验证城市归属并给默认值
  6141. int provinceId = 122;
  6142. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6143. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6144. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6145. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6146. return Ok(JsonView(true, "查询成功!", new
  6147. {
  6148. GroupNameData = groupNameData,
  6149. CurrencyData = _CurrencyData,
  6150. WordTypeData = wordTypeData,
  6151. ExcelTypeData = excelTypeData,
  6152. CurrencyInit = _currencyInfos,
  6153. ViewPermissionData = viewPermissionData
  6154. }));
  6155. }
  6156. /// <summary>
  6157. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6158. /// </summary>
  6159. /// <returns></returns>
  6160. [HttpGet("{provinceId}")]
  6161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6162. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6163. {
  6164. //验证城市归属并给默认值
  6165. if (provinceId < 1) provinceId = 122;
  6166. /*
  6167. * 122 四川
  6168. * 108 贵州
  6169. * 103 重庆
  6170. * 132 云南
  6171. */
  6172. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6173. return Ok(JsonView(true, "查询成功!", new
  6174. {
  6175. WordTypeData = wordTypeData,
  6176. ExcelTypeData = excelTypeData,
  6177. }));
  6178. }
  6179. /// <summary>
  6180. /// 团组模块 - 出入境费用
  6181. /// 实时汇率 tips
  6182. /// 签证费用 tips
  6183. /// 机票费用 tips
  6184. /// </summary>
  6185. /// <returns></returns>
  6186. [HttpPost]
  6187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6188. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6189. {
  6190. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6191. //默认币种显示
  6192. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6193. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6194. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6195. return Ok(JsonView(true, "查询成功!", new
  6196. {
  6197. //GroupNameData = groupNameData.Data,
  6198. visaData = visaData.Data,
  6199. airData = airData,
  6200. reteInfos = reteInfos
  6201. }));
  6202. }
  6203. /// <summary>
  6204. /// 团组模块 - 出入境费用 - Info
  6205. /// </summary>
  6206. /// <returns></returns>
  6207. [HttpPost]
  6208. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6210. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6211. {
  6212. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6213. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6214. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6215. }
  6216. /// <summary>
  6217. /// 团组模块 - 出入境费用 - 设置view权限
  6218. /// </summary>
  6219. /// <returns></returns>
  6220. [HttpPost]
  6221. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6222. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6223. {
  6224. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6225. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6226. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6227. var permissions = new List<Grp_EnterExitCostPermission>();
  6228. foreach (var userId in dto.UserIds)
  6229. {
  6230. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6231. }
  6232. if (permissions.Any())
  6233. {
  6234. _sqlSugar.BeginTran();
  6235. try
  6236. {
  6237. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6238. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6239. if (result < 1)
  6240. {
  6241. _sqlSugar.RollbackTran();
  6242. return Ok(JsonView(false));
  6243. }
  6244. }
  6245. catch (Exception ex)
  6246. {
  6247. _sqlSugar.RollbackTran();
  6248. return Ok(JsonView(false, ex.Message));
  6249. }
  6250. _sqlSugar.CommitTran();
  6251. return Ok(JsonView(true));
  6252. }
  6253. return Ok(JsonView(false));
  6254. }
  6255. /// <summary>
  6256. /// 团组模块 - 出入境费用 - Add And Update
  6257. /// </summary>
  6258. /// <returns></returns>
  6259. [HttpPost]
  6260. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6261. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6262. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6263. {
  6264. try
  6265. {
  6266. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6267. if (dto.DayOtherPriceData.Any())
  6268. {
  6269. var inserList = dto.DayOtherPriceData
  6270. .Where(x => x.Id == 0)
  6271. .Select(x => new Grp_DayOtherPrice
  6272. {
  6273. Cost = x.Cost,
  6274. Id = x.Id,
  6275. CreateTime = DateTime.Now,
  6276. CreateUserId = dto.UserId,
  6277. Currency = x.Currency,
  6278. Diid = x.DiId,
  6279. Index = x.Index,
  6280. IsDel = 0,
  6281. SetDataId = x.SetDataId,
  6282. SubTotal = x.SubTotal,
  6283. Remark = x.Remark
  6284. })
  6285. .ToList();
  6286. var updateList = dto.DayOtherPriceData
  6287. .Where(x => x.Id != 0)
  6288. .Select(x => new Grp_DayOtherPrice
  6289. {
  6290. Cost = x.Cost,
  6291. Id = x.Id,
  6292. CreateTime = DateTime.Now,
  6293. CreateUserId = dto.UserId,
  6294. Currency = x.Currency,
  6295. Diid = x.DiId,
  6296. Index = x.Index,
  6297. IsDel = 0,
  6298. SetDataId = x.SetDataId,
  6299. SubTotal = x.SubTotal,
  6300. Remark = x.Remark
  6301. })
  6302. .ToList();
  6303. //添加
  6304. _sqlSugar.BeginTran();
  6305. if (inserList.Any())
  6306. {
  6307. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6308. }
  6309. if (updateList.Any())
  6310. {
  6311. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6312. }
  6313. _sqlSugar.CommitTran();
  6314. }
  6315. if (data.Code != 0)
  6316. {
  6317. return Ok(JsonView(false, data.Msg));
  6318. }
  6319. //生成默认文件pdf并且通知人员
  6320. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6321. {
  6322. DiId = dto.DiId,
  6323. ExportType = 1,
  6324. SubTypeId = 1005
  6325. }, "pdf");
  6326. //发送通知
  6327. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6328. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6329. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6330. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6331. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6332. //汇率信息记录
  6333. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6334. return Ok(JsonView(true, data.Msg, data.Data));
  6335. }
  6336. catch (Exception ex)
  6337. {
  6338. return Ok(JsonView(false, ex.Message));
  6339. }
  6340. }
  6341. /// <summary>
  6342. /// 团组模块 - 出入境费用 - Confirm 费用
  6343. /// </summary>
  6344. /// <returns></returns>
  6345. [HttpPost]
  6346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6347. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6348. {
  6349. //TODO:测试完毕需把对应的用户ID更改
  6350. //1、数据表添加字段
  6351. //2、更改字段接口()
  6352. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6353. //3、确认成功 给财务发送消息
  6354. if (_view.Code == 200)
  6355. {
  6356. if (dto.Type == 1)
  6357. {
  6358. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6359. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6360. }
  6361. }
  6362. return Ok(_view);
  6363. }
  6364. /// <summary>
  6365. /// 团组模块 - 出入境费用 - File download
  6366. /// </summary>
  6367. /// <param name="dto"></param>
  6368. /// <returns></returns>
  6369. [HttpPost]
  6370. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6372. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6373. {
  6374. try
  6375. {
  6376. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6377. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6378. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6379. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6380. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6381. 3 团组成员名单 1 团组成员名单", ""));
  6382. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6383. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6384. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6385. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6386. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6387. //数据源
  6388. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6389. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6390. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6391. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6392. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6393. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6394. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6395. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6396. .Select((x, a, b) => new
  6397. {
  6398. x.Index,
  6399. itemName = a.Name,
  6400. CurrencyStr = b.Name,
  6401. x.Cost,
  6402. x.SubTotal,
  6403. x.Remark
  6404. })
  6405. .OrderBy((x) => x.Index)
  6406. .ToList(); //其他款项费用
  6407. var peiceItemCurrencys = new List<string>();
  6408. if (_DayAndCosts.Any())
  6409. {
  6410. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6411. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6412. }
  6413. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6414. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6415. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6416. {
  6417. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6418. }
  6419. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6420. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6421. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6422. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6423. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6424. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6425. .Select((tcl, dc, cc) => new ClientInfo
  6426. {
  6427. LastName = dc.LastName,
  6428. FirstName = dc.FirstName,
  6429. Sex = dc.Sex,
  6430. Birthday = dc.BirthDay,
  6431. Company = cc.CompanyFullName,
  6432. Job = dc.Job
  6433. })
  6434. .ToList();
  6435. foreach (var item in DeleClientList)
  6436. {
  6437. EncryptionProcessor.DecryptProperties(item);
  6438. }
  6439. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6440. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6441. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6442. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6443. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6444. if (dto.ExportType == 1) //明细表
  6445. {
  6446. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6447. {
  6448. //获取模板
  6449. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6450. //载入模板
  6451. Document doc = new Document(tempPath);
  6452. DocumentBuilder builder = new DocumentBuilder(doc);
  6453. //利用键值对存放数据
  6454. Dictionary<string, string> dic = new Dictionary<string, string>();
  6455. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6456. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6457. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6458. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6459. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6460. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6461. //境内费用(其他费用)
  6462. if (_EnterExitCosts.ChoiceOne == 1)
  6463. {
  6464. string row1_1 = "";
  6465. if (_EnterExitCosts.Visa > 0)
  6466. {
  6467. //insidePayTotal += _EnterExitCosts.Visa;
  6468. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6469. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6470. //{
  6471. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6472. //}
  6473. }
  6474. string row1_2 = "";
  6475. if (_EnterExitCosts.YiMiao > 0)
  6476. {
  6477. //insidePayTotal += _EnterExitCosts.YiMiao;
  6478. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6479. }
  6480. if (_EnterExitCosts.HeSuan > 0)
  6481. {
  6482. //insidePayTotal += _EnterExitCosts.HeSuan;
  6483. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6484. }
  6485. if (_EnterExitCosts.Service > 0)
  6486. {
  6487. //insidePayTotal += _EnterExitCosts.Service;
  6488. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6489. }
  6490. string row1_3 = "";
  6491. if (_EnterExitCosts.Safe > 0)
  6492. {
  6493. //insidePayTotal += _EnterExitCosts.Safe;
  6494. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6495. }
  6496. if (_EnterExitCosts.Ticket > 0)
  6497. {
  6498. //insidePayTotal += _EnterExitCosts.Ticket;
  6499. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6500. }
  6501. string row1 = "";
  6502. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6503. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6504. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6505. row1 += $"备注:{_EnterExitCosts.Remark}";
  6506. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6507. dic.Add("Row1Str", row1);
  6508. }
  6509. string airTotalStr = string.Empty,
  6510. airPriceStr = string.Empty;
  6511. //经济舱
  6512. if (_EnterExitCosts.SumJJC == 1)
  6513. {
  6514. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6515. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6516. }
  6517. //公务舱
  6518. if (_EnterExitCosts.SumGWC == 1)
  6519. {
  6520. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6521. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6522. }
  6523. //头等舱
  6524. if (_EnterExitCosts.SumTDC == 1)
  6525. {
  6526. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6527. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6528. }
  6529. //汇率描述
  6530. string rateStr = "";
  6531. if (peiceItemCurrencyInfos.Any())
  6532. {
  6533. rateStr = "\r\n汇率描述:";
  6534. foreach (var item in peiceItemCurrencyInfos)
  6535. {
  6536. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6537. }
  6538. }
  6539. string twoItemRemark = "备注:";
  6540. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6541. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6542. dic.Add("AirTotalStr", airTotalStr);
  6543. dic.Add("AirPriceStr", airPriceStr);
  6544. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6545. dic.Add("TwoItemRemark", twoItemRemark);
  6546. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6547. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6548. int table1Row = 0,
  6549. table2Row = 0,
  6550. table3Row = 0,
  6551. table4Row = 0,
  6552. table5Row = 0;
  6553. //住宿费
  6554. if (_EnterExitCosts.ChoiceThree == 1)
  6555. {
  6556. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6557. table1Row = dac1.Count;
  6558. #region 填充word表格内容
  6559. for (int i = 0; i < dac1.Count; i++)
  6560. {
  6561. Grp_DayAndCost dac = dac1[i];
  6562. if (dac == null) continue;
  6563. builder.MoveToCell(0, i, 0, 0);
  6564. builder.Write("第" + dac.Days.ToString() + "晚:");
  6565. builder.MoveToCell(0, i, 1, 0);
  6566. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6567. //builder.Write(dac.Place == null ? "" : dac.Place);
  6568. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6569. builder.MoveToCell(0, i, 2, 0);
  6570. builder.Write("费用标准:");
  6571. string curr = "";
  6572. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6573. if (currData != null)
  6574. {
  6575. curr = currData.Name;
  6576. }
  6577. builder.MoveToCell(0, i, 3, 0);
  6578. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6579. builder.MoveToCell(0, i, 4, 0);
  6580. builder.Write("费用小计:");
  6581. builder.MoveToCell(0, i, 5, 0);
  6582. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6583. }
  6584. #endregion
  6585. }
  6586. else dic.Add("SubZS", "0.00");
  6587. //删除多余行
  6588. while (table1.Rows.Count > table1Row)
  6589. {
  6590. table1.Rows.RemoveAt(table1Row);
  6591. }
  6592. //伙食费
  6593. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6594. if (_EnterExitCosts.ChoiceFour == 1)
  6595. {
  6596. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6597. table2Row = dac2.Count;
  6598. #region 填充word表格内容
  6599. for (int i = 0; i < dac2.Count; i++)
  6600. {
  6601. Grp_DayAndCost dac = dac2[i];
  6602. if (dac == null) continue;
  6603. builder.MoveToCell(1, i, 0, 0);
  6604. builder.Write("第" + dac.Days.ToString() + "天:");
  6605. builder.MoveToCell(1, i, 1, 0);
  6606. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6607. builder.MoveToCell(1, i, 2, 0);
  6608. builder.Write("费用标准:");
  6609. string curr = "";
  6610. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6611. if (currData != null)
  6612. {
  6613. curr = currData.Name;
  6614. }
  6615. builder.MoveToCell(1, i, 3, 0);
  6616. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6617. builder.MoveToCell(1, i, 4, 0);
  6618. builder.Write("费用小计:");
  6619. builder.MoveToCell(1, i, 5, 0);
  6620. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6621. }
  6622. #endregion
  6623. }
  6624. else dic.Add("SubHS", "0.00");
  6625. //删除多余行
  6626. while (table2.Rows.Count > table2Row)
  6627. {
  6628. table2.Rows.RemoveAt(table2Row);
  6629. }
  6630. //公杂费
  6631. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6632. if (_EnterExitCosts.ChoiceFive == 1)
  6633. {
  6634. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6635. table3Row = dac3.Count;
  6636. #region 填充word表格内容
  6637. for (int i = 0; i < dac3.Count; i++)
  6638. {
  6639. Grp_DayAndCost dac = dac3[i];
  6640. if (dac == null) continue;
  6641. builder.MoveToCell(2, i, 0, 0);
  6642. builder.Write("第" + dac.Days.ToString() + "天:");
  6643. builder.MoveToCell(2, i, 1, 0);
  6644. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6645. builder.MoveToCell(2, i, 2, 0);
  6646. builder.Write("费用标准:");
  6647. string curr = "";
  6648. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6649. if (currData != null)
  6650. {
  6651. curr = currData.Name;
  6652. }
  6653. builder.MoveToCell(2, i, 3, 0);
  6654. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6655. builder.MoveToCell(2, i, 4, 0);
  6656. builder.Write("费用小计:");
  6657. builder.MoveToCell(2, i, 5, 0);
  6658. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6659. }
  6660. //删除多余行
  6661. while (table3.Rows.Count > table3Row)
  6662. {
  6663. table3.Rows.RemoveAt(table3Row);
  6664. }
  6665. #endregion
  6666. }
  6667. else dic.Add("SubGZF", "0.00");
  6668. //删除多余行
  6669. while (table3.Rows.Count > table3Row)
  6670. {
  6671. table3.Rows.RemoveAt(table3Row);
  6672. }
  6673. //培训费
  6674. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6675. if (_EnterExitCosts.ChoiceSix == 1)
  6676. {
  6677. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6678. dic.Add("SubPX", pxStr);
  6679. table4Row = dac4.Count;
  6680. #region 填充word表格内容
  6681. for (int i = 0; i < dac4.Count; i++)
  6682. {
  6683. Grp_DayAndCost dac = dac4[i];
  6684. if (dac == null) continue;
  6685. builder.MoveToCell(3, i, 0, 0);
  6686. builder.Write("第" + dac.Days.ToString() + "天:");
  6687. builder.MoveToCell(3, i, 1, 0);
  6688. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6689. builder.MoveToCell(3, i, 2, 0);
  6690. builder.Write("费用标准:");
  6691. string curr = "";
  6692. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6693. if (currData != null)
  6694. {
  6695. curr = currData.Name;
  6696. }
  6697. builder.MoveToCell(3, i, 3, 0);
  6698. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6699. builder.MoveToCell(3, i, 4, 0);
  6700. builder.Write("费用小计:");
  6701. builder.MoveToCell(3, i, 5, 0);
  6702. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6703. }
  6704. #endregion
  6705. }
  6706. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6707. //删除多余行
  6708. while (table4.Rows.Count > table4Row)
  6709. {
  6710. table4.Rows.RemoveAt(table4Row);
  6711. }
  6712. //其他费用
  6713. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6714. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6715. {
  6716. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6717. dic.Add("titleQi", qtStr);
  6718. table5Row = dac5.Count;
  6719. #region 填充word表格内容
  6720. for (int i = 0; i < dac5.Count; i++)
  6721. {
  6722. var dac = dac5[i];
  6723. if (dac == null) continue;
  6724. builder.MoveToCell(4, i, 0, 0);
  6725. builder.Write("第" + dac.Index.ToString() + "项:");
  6726. builder.MoveToCell(4, i, 1, 0);
  6727. builder.Write(dac.itemName);
  6728. builder.MoveToCell(4, i, 2, 0);
  6729. builder.Write("费用标准:");
  6730. builder.MoveToCell(4, i, 3, 0);
  6731. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6732. builder.MoveToCell(4, i, 4, 0);
  6733. builder.Write("费用小计:");
  6734. builder.MoveToCell(4, i, 5, 0);
  6735. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6736. builder.MoveToCell(4, i, 6, 0);
  6737. builder.Write("备注:");
  6738. builder.MoveToCell(4, i, 7, 0);
  6739. builder.Write(dac.Remark);
  6740. }
  6741. #endregion
  6742. }
  6743. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6744. //删除多余行
  6745. while (table5.Rows.Count > table5Row)
  6746. {
  6747. table5.Rows.RemoveAt(table5Row);
  6748. }
  6749. //加上其他费用
  6750. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6751. decimal subJJC = 0.00M,
  6752. subGWC = 0.00M,
  6753. subTDC = 0.00M;
  6754. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6755. string totalLabel = string.Format("全部费用总计:");
  6756. //经济舱
  6757. if (_EnterExitCosts.SumJJC == 1)
  6758. {
  6759. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6760. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  6761. }
  6762. //公务舱
  6763. if (_EnterExitCosts.SumGWC == 1)
  6764. {
  6765. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6766. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  6767. }
  6768. //头等舱
  6769. if (_EnterExitCosts.SumTDC == 1)
  6770. {
  6771. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6772. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  6773. }
  6774. //TotalLabel
  6775. dic.Add("TotalLabel", totalLabel);
  6776. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6777. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6778. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6779. #region 填充word模板书签内容
  6780. foreach (var key in dic.Keys)
  6781. {
  6782. Bookmark bookmark = doc.Range.Bookmarks[key];
  6783. if (bookmark != null)
  6784. {
  6785. builder.MoveToBookmark(key);
  6786. builder.Write(dic[key]);
  6787. }
  6788. }
  6789. #endregion
  6790. #region 设置页眉
  6791. string userLabel = string.Empty;
  6792. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6793. if (currUserInfo != null)
  6794. {
  6795. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6796. if (userInfo != null)
  6797. {
  6798. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6799. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  6800. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  6801. }
  6802. }
  6803. //设置页脚
  6804. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  6805. #endregion
  6806. //文件名
  6807. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  6808. AsposeHelper.removewatermark_v2180();
  6809. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6810. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6811. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6812. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6813. }
  6814. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6815. {
  6816. //获取模板
  6817. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6818. //载入模板
  6819. Document doc = new Document(tempPath);
  6820. DocumentBuilder builder = new DocumentBuilder(doc);
  6821. Dictionary<string, string> dic = new Dictionary<string, string>();
  6822. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6823. {
  6824. List<string> list = new List<string>();
  6825. try
  6826. {
  6827. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6828. foreach (var item in spilitArr)
  6829. {
  6830. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6831. var depCode = spDotandEmpty[2].Substring(0, 3);
  6832. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6833. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6834. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6835. list.Add(depName);
  6836. list.Add(arrName);
  6837. }
  6838. list = list.Distinct().ToList();
  6839. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6840. }
  6841. catch (Exception)
  6842. {
  6843. dic.Add("ReturnCode", "行程录入不正确!");
  6844. }
  6845. }
  6846. else
  6847. {
  6848. dic.Add("ReturnCode", "未录入行程!");
  6849. }
  6850. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6851. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6852. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6853. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6854. {
  6855. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6856. dic.Add("Day", sp.Days.ToString());
  6857. }
  6858. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6859. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6860. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6861. //dic.Add("Names", Names);
  6862. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6863. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6864. decimal dac1totalPrice = 0.00M;
  6865. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  6866. foreach (var dac in dac1)
  6867. {
  6868. if (dac.SubTotal == 0.00M)
  6869. {
  6870. continue;
  6871. }
  6872. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6873. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6874. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6875. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6876. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6877. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6878. builder.Write(currency);//币种
  6879. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6880. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6881. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6882. builder.Write("");//人数
  6883. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6884. builder.Write("");//天数
  6885. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6886. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6887. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6888. decimal rate = 0.00M;
  6889. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6890. builder.Write(rate.ToString("#0.0000"));//汇率
  6891. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6892. decimal rbmPrice = dac.SubTotal;
  6893. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6894. accommodationStartIndex++;
  6895. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6896. }
  6897. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6898. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  6899. {
  6900. table1.Rows.RemoveAt(i - 1);
  6901. foodandotherStartIndex--;
  6902. }
  6903. if (dac2.Count == dac3.Count)//国家 币种 金额
  6904. {
  6905. for (int i = 0; i < dac2.Count; i++)
  6906. {
  6907. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6908. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6909. }
  6910. }
  6911. decimal dac2totalPrice = 0.00M;
  6912. foreach (var dac in dac2)
  6913. {
  6914. if (dac.SubTotal == 0)
  6915. {
  6916. continue;
  6917. }
  6918. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6919. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6920. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6921. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6922. builder.Write(currency);//币种
  6923. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6924. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6925. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6926. builder.Write("");//人数
  6927. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6928. builder.Write("");//天数
  6929. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6930. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6931. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6932. decimal rate = 0.00M;
  6933. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6934. builder.Write(rate.ToString("#0.0000"));//汇率
  6935. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6936. decimal rbmPrice = dac.SubTotal;
  6937. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6938. foodandotherStartIndex++;
  6939. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6940. }
  6941. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6942. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  6943. {
  6944. table1.Rows.RemoveAt(i - 1);
  6945. }
  6946. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6947. string otherFeeStr = "";
  6948. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  6949. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  6950. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  6951. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6952. foreach (var otherInfo in dac5)
  6953. {
  6954. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6955. }
  6956. #endregion
  6957. if (otherFeeStr.Length > 0)
  6958. {
  6959. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6960. otherFeeStr = $"({otherFeeStr})";
  6961. dic.Add("OtherFeeStr", otherFeeStr);
  6962. }
  6963. //总计
  6964. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  6965. //国际旅费
  6966. string outsideAir = string.Empty;
  6967. string allPriceAir = string.Empty;
  6968. if (_EnterExitCosts.SumJJC == 1)
  6969. {
  6970. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6971. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  6972. }
  6973. if (_EnterExitCosts.SumGWC == 1)
  6974. {
  6975. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  6976. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6977. }
  6978. if (_EnterExitCosts.SumTDC == 1)
  6979. {
  6980. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  6981. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  6982. }
  6983. dic.Add("InTravelPrice", $"({outsideAir})");
  6984. dic.Add("FinalSumPrice", $"({allPriceAir})");
  6985. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  6986. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  6987. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  6988. foreach (var key in dic.Keys)
  6989. {
  6990. builder.MoveToBookmark(key);
  6991. builder.Write(dic[key]);
  6992. }
  6993. //模板文件名
  6994. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6995. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6996. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6997. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6998. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6999. }
  7000. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7001. {
  7002. //获取模板
  7003. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7004. //载入模板
  7005. WorkbookDesigner designer = new WorkbookDesigner();
  7006. designer.Workbook = new Workbook(tempPath);
  7007. Dictionary<string, string> dic = new Dictionary<string, string>();
  7008. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7009. {
  7010. List<string> list = new List<string>();
  7011. try
  7012. {
  7013. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7014. foreach (var item in spilitArr)
  7015. {
  7016. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7017. var depCode = spDotandEmpty[2].Substring(0, 3);
  7018. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7019. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  7020. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  7021. list.Add(depName);
  7022. list.Add(arrName);
  7023. }
  7024. list = list.Distinct().ToList();
  7025. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7026. }
  7027. catch (Exception)
  7028. {
  7029. dic.Add("ReturnCode", "行程录入不正确!");
  7030. }
  7031. }
  7032. else
  7033. {
  7034. dic.Add("ReturnCode", "未录入行程!");
  7035. }
  7036. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7037. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7038. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7039. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7040. {
  7041. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7042. dic.Add("Day", sp.Days.ToString());
  7043. }
  7044. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7045. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7046. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7047. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  7048. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  7049. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  7050. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  7051. designer.SetDataSource("Name", Names);
  7052. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  7053. designer.SetDataSource("Day", dic["Day"] + "天");
  7054. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  7055. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  7056. int startIndex = 10;
  7057. const int startIndexcopy = 10;
  7058. if (dac2.Count == dac3.Count)//国家 币种 金额
  7059. {
  7060. for (int i = 0; i < dac2.Count; i++)
  7061. {
  7062. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7063. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7064. }
  7065. }
  7066. DataTable dtdac1 = new DataTable();
  7067. List<string> place = new List<string>();
  7068. dtdac1.Columns.AddRange(new DataColumn[] {
  7069. new DataColumn(){ ColumnName = "city"},
  7070. new DataColumn(){ ColumnName = "curr"},
  7071. new DataColumn(){ ColumnName = "criterion"},
  7072. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7073. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7074. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7075. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7076. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7077. });
  7078. DataTable dtdac2 = new DataTable();
  7079. dtdac2.Columns.AddRange(new DataColumn[] {
  7080. new DataColumn(){ ColumnName = "city"},
  7081. new DataColumn(){ ColumnName = "curr"},
  7082. new DataColumn(){ ColumnName = "criterion"},
  7083. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7084. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7085. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7086. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7087. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7088. });
  7089. dtdac1.TableName = "tb1";
  7090. dtdac2.TableName = "tb2";
  7091. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7092. foreach (var item in dac1)
  7093. {
  7094. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7095. if (place.Contains(item.Place))
  7096. {
  7097. continue;
  7098. }
  7099. DataRow row = dtdac1.NewRow();
  7100. row["city"] = item.Place;
  7101. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7102. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7103. row["curr"] = currency;
  7104. row["rate"] = rate.ToString("#0.0000");
  7105. row["criterion"] = item.Cost.ToString("#0.00");
  7106. row["number"] = 1;
  7107. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7108. //row["costRMB"] = rbmPrice;
  7109. dtdac1.Rows.Add(row);
  7110. place.Add(item.Place);
  7111. }
  7112. place = new List<string>();
  7113. foreach (var item in dac2)
  7114. {
  7115. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7116. if (place.Contains(item.Place))
  7117. {
  7118. continue;
  7119. }
  7120. DataRow row = dtdac2.NewRow();
  7121. row["city"] = item.Place;
  7122. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7123. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7124. row["curr"] = currency;
  7125. row["rate"] = rate.ToString("#0.0000");
  7126. row["criterion"] = item.Cost.ToString("#0.00");
  7127. row["number"] = 1;
  7128. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7129. //row["cost"] = item.SubTotal;
  7130. //row["costRMB"] = rbmPrice;
  7131. dtdac2.Rows.Add(row);
  7132. place.Add(item.Place);
  7133. //dac2totalPrice += rbmPrice;
  7134. }
  7135. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7136. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7137. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7138. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7139. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  7140. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  7141. string cell4Str1 = string.Empty;
  7142. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  7143. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  7144. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  7145. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7146. string cellStr = $" 5.其他费用(";
  7147. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7148. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7149. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7150. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7151. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7152. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7153. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7154. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7155. foreach (var otherInfo in dac5)
  7156. {
  7157. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7158. }
  7159. #endregion
  7160. if (cellStr.Length > 8)
  7161. {
  7162. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7163. }
  7164. cellStr += ")";
  7165. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7166. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7167. decimal pxFee = dac4.Sum(it => it.Cost);
  7168. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7169. string celllastStr1 = "";
  7170. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  7171. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  7172. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  7173. celllastStr1 += $",国际旅费 元";
  7174. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  7175. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7176. designer.SetDataSource("cell4Str", cell4Str);
  7177. designer.SetDataSource("cellStr", cellStr);
  7178. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7179. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7180. designer.SetDataSource("celllastStr", celllastStr);
  7181. Workbook wb = designer.Workbook;
  7182. var sheet = wb.Worksheets[0];
  7183. //绑定datatable数据集
  7184. designer.SetDataSource(dtdac1);
  7185. designer.SetDataSource(dtdac2);
  7186. designer.Process();
  7187. var rowStart = dtdac1.Rows.Count;
  7188. while (rowStart > 0)
  7189. {
  7190. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7191. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7192. startIndex++;
  7193. rowStart--;
  7194. }
  7195. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7196. startIndex += 1; //总计行
  7197. rowStart = dtdac2.Rows.Count;
  7198. while (rowStart > 0)
  7199. {
  7200. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7201. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7202. startIndex++;
  7203. rowStart--;
  7204. }
  7205. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7206. wb.CalculateFormula(true);
  7207. //模板文件名
  7208. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7209. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7210. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7211. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7212. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7213. }
  7214. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7215. {
  7216. //获取模板
  7217. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7218. //载入模板
  7219. Document doc = new Document(tempPath);
  7220. DocumentBuilder builder = new DocumentBuilder(doc);
  7221. Dictionary<string, string> dic = new Dictionary<string, string>();
  7222. dic.Add("GroupName", _DelegationInfo.TeamName);
  7223. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7224. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7225. string missionLeaderJob = "";//负责人job
  7226. //int groupNumber = 0; //团人数
  7227. if (DeleClientList.Count > 0)
  7228. {
  7229. missionLeader = DeleClientList[0]?.Name ?? "";
  7230. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7231. }
  7232. dic.Add("MissionLeader", missionLeader); //团负责人
  7233. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7234. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7235. #region MyRegion
  7236. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7237. //{
  7238. // List<string> list = new List<string>();
  7239. // try
  7240. // {
  7241. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7242. // foreach (var item in spilitArr)
  7243. // {
  7244. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7245. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7246. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7247. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7248. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7249. // list.Add(depName);
  7250. // list.Add(arrName);
  7251. // }
  7252. // list = list.Distinct().ToList();
  7253. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7254. // }
  7255. // catch (Exception)
  7256. // {
  7257. // dic.Add("ReturnCode", "行程录入不正确!");
  7258. // }
  7259. //}
  7260. //else
  7261. //{
  7262. // dic.Add("ReturnCode", "未录入行程!");
  7263. //}
  7264. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7265. dic.Add("ReturnCode", string.Join("、", countrys));
  7266. #endregion
  7267. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7268. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7269. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7270. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7271. //{
  7272. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7273. // dic.Add("Day", sp.Days.ToString());
  7274. //}
  7275. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7276. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7277. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7278. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7279. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7280. //培训人员名单
  7281. int cultivateRowIndex = 7;
  7282. foreach (var item in DeleClientList)
  7283. {
  7284. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7285. builder.Write(item.Name);
  7286. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7287. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7288. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7289. string birthDay = "";
  7290. if (item.Birthday != null)
  7291. {
  7292. DateTime dt = Convert.ToDateTime(item.Birthday);
  7293. birthDay = $"{dt.Year}.{dt.Month}";
  7294. }
  7295. builder.Write(birthDay);
  7296. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7297. builder.Write(item.Company);
  7298. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7299. builder.Write(item.Job);
  7300. cultivateRowIndex++;
  7301. }
  7302. //删除多余行
  7303. //cultivateRowIndex -= 2;
  7304. int delRows = 10 + 7 - cultivateRowIndex;
  7305. if (delRows > 0)
  7306. {
  7307. for (int i = 0; i < delRows; i++)
  7308. {
  7309. table1.Rows.RemoveAt(cultivateRowIndex);
  7310. //cultivateRowIndex++;
  7311. }
  7312. }
  7313. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7314. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7315. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7316. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7317. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7318. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7319. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7320. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7321. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7322. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7323. //其他费用
  7324. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7325. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7326. //其他费用合计
  7327. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7328. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7329. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7330. //公务舱合计
  7331. //国际旅费
  7332. //string outsideJJ = "";
  7333. //string allPriceJJ = "";
  7334. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7335. {
  7336. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7337. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7338. }
  7339. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7340. {
  7341. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7342. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7343. }
  7344. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7345. {
  7346. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7347. dic.Add("AirFeeTotal", airFeeTotalStr);
  7348. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7349. dic.Add("FeeTotal", feeTotalStr);
  7350. }
  7351. foreach (var key in dic.Keys)
  7352. {
  7353. builder.MoveToBookmark(key);
  7354. builder.Write(dic[key]);
  7355. }
  7356. //模板文件名
  7357. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7358. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7359. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7360. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7361. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7362. }
  7363. }
  7364. else if (dto.ExportType == 2) //表格
  7365. {
  7366. //利用键值对存放数据
  7367. Dictionary<string, string> dic = new Dictionary<string, string>();
  7368. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7369. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7370. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7371. dic.Add("Day", sp.Days.ToString());
  7372. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7373. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7374. {
  7375. //获取模板
  7376. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7377. //载入模板
  7378. Document doc = new Document(tempPath);
  7379. DocumentBuilder builder = new DocumentBuilder(doc);
  7380. dic.Add("TeamName", _DelegationInfo.TeamName);
  7381. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7382. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7383. string missionLeaderName = "",
  7384. missionLeaderJob = "";
  7385. if (DeleClientList.Count > 0)
  7386. {
  7387. missionLeaderName = DeleClientList[0].Name;
  7388. missionLeaderJob = DeleClientList[0].Job;
  7389. }
  7390. dic.Add("MissionLeaderName", missionLeaderName);
  7391. dic.Add("MissionLeaderJob", missionLeaderJob);
  7392. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7393. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7394. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7395. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7396. int rowCount = 10;//总人数行
  7397. int startRowIndex = 7; //起始行
  7398. for (int i = 0; i < DeleClientList.Count; i++)
  7399. {
  7400. builder.MoveToCell(0, startRowIndex, 0, 0);
  7401. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7402. builder.MoveToCell(0, startRowIndex, 1, 0);
  7403. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7404. builder.Write(sex);//性别
  7405. builder.MoveToCell(0, startRowIndex, 2, 0);
  7406. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7407. builder.MoveToCell(0, startRowIndex, 3, 0);
  7408. builder.Write(DeleClientList[i].Company);//工作单位
  7409. builder.MoveToCell(0, startRowIndex, 4, 0);
  7410. builder.Write(DeleClientList[i].Job);//职务及级别
  7411. builder.MoveToCell(0, startRowIndex, 5, 0);
  7412. builder.Write("");//人员属性
  7413. builder.MoveToCell(0, startRowIndex, 6, 0);
  7414. builder.Write("");//上次出国时间
  7415. startRowIndex++;
  7416. }
  7417. int nullRow = rowCount - DeleClientList.Count;//空行
  7418. for (int i = 0; i < nullRow; i++)
  7419. {
  7420. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7421. }
  7422. foreach (var key in dic.Keys)
  7423. {
  7424. builder.MoveToBookmark(key);
  7425. builder.Write(dic[key]);
  7426. }
  7427. //模板文件名
  7428. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7429. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7430. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7431. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7432. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7433. }
  7434. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7435. {
  7436. //获取模板
  7437. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7438. //载入模板
  7439. Document doc = new Document(tempPath);
  7440. DocumentBuilder builder = new DocumentBuilder(doc);
  7441. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7442. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7443. dic.Add("Names", Names);
  7444. int accommodationRows = 12;
  7445. //int foodandotherRows = 12;
  7446. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7447. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7448. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7449. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7450. int accommodationStartIndex = 6;
  7451. decimal dac1totalPrice = 0.00M;
  7452. foreach (var dac in dac1)
  7453. {
  7454. if (dac.SubTotal == 0)
  7455. {
  7456. continue;
  7457. }
  7458. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7459. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7460. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7461. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7462. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7463. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7464. builder.Write(currency);//币种
  7465. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7466. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7467. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7468. builder.Write("");//人数
  7469. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7470. builder.Write("");//天数
  7471. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7472. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7473. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7474. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7475. builder.Write(rate.ToString("#0.0000"));//汇率
  7476. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7477. decimal rbmPrice = rate * dac.SubTotal;
  7478. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7479. accommodationStartIndex++;
  7480. dac1totalPrice += rbmPrice;
  7481. }
  7482. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7483. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7484. builder.Write("小计");
  7485. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7486. builder.Write(dac1totalPrice.ToString("#0.00"));
  7487. accommodationStartIndex++;
  7488. int nullRow = accommodationRows - dac1.Count;
  7489. //删除空行
  7490. //if (nullRow > 0)
  7491. //{
  7492. // int rowIndex = accommodationStartIndex;
  7493. // for (int i = 0; i < nullRow; i++)
  7494. // {
  7495. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7496. // row.Remove();
  7497. // rowIndex++;
  7498. // }
  7499. //}
  7500. if (dac2.Count == dac3.Count)//国家 币种 金额
  7501. {
  7502. for (int i = 0; i < dac2.Count; i++)
  7503. {
  7504. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7505. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7506. }
  7507. }
  7508. int foodandotherStartIndex = 19;//
  7509. decimal dac2totalPrice = 0.00M;
  7510. foreach (var dac in dac2)
  7511. {
  7512. if (dac.SubTotal == 0)
  7513. {
  7514. continue;
  7515. }
  7516. //foodandotherStartIndex = 12;
  7517. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7518. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7519. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7520. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7521. builder.Write(currency);//币种
  7522. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7523. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7524. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7525. builder.Write("");//人数
  7526. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7527. builder.Write("");//天数
  7528. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7529. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7530. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7531. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7532. builder.Write(rate.ToString("#0.0000"));//汇率
  7533. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7534. decimal rbmPrice = rate * dac.SubTotal;
  7535. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7536. foodandotherStartIndex++;
  7537. dac2totalPrice += rbmPrice;
  7538. }
  7539. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7540. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7541. //删除空行
  7542. //if (dac2.Count < foodandotherRows)
  7543. //{
  7544. // while (table2.Rows.Count > dac2.Count)
  7545. // {
  7546. // table2.Rows.RemoveAt(dac2.Count);
  7547. // }
  7548. //}
  7549. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7550. string otherFeeStr = "";
  7551. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7552. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7553. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7554. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7555. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7556. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7557. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7558. foreach (var otherInfo in dac5)
  7559. {
  7560. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7561. }
  7562. #endregion
  7563. if (otherFeeStr.Length > 0)
  7564. {
  7565. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7566. otherFeeStr = $"({otherFeeStr})";
  7567. dic.Add("OtherFeeStr", otherFeeStr);
  7568. }
  7569. foreach (var key in dic.Keys)
  7570. {
  7571. builder.MoveToBookmark(key);
  7572. builder.Write(dic[key]);
  7573. }
  7574. //模板文件名
  7575. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7576. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7577. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7578. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7579. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7580. }
  7581. }
  7582. else if (dto.ExportType == 3)
  7583. {
  7584. if (dto.SubTypeId == 1) //团组成员名单
  7585. {
  7586. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7587. //获取模板
  7588. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7589. //载入模板
  7590. Document doc = new Document(tempPath);
  7591. DocumentBuilder builder = new DocumentBuilder(doc);
  7592. //获取word里所有表格
  7593. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7594. //获取所填表格的序数
  7595. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7596. var rowStart = tableOne.Rows[0]; //获取第1行
  7597. //循环赋值
  7598. for (int i = 0; i < DeleClientList.Count; i++)
  7599. {
  7600. builder.MoveToCell(0, i + 1, 0, 0);
  7601. builder.Write(DeleClientList[i].Name);
  7602. builder.MoveToCell(0, i + 1, 1, 0);
  7603. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7604. builder.Write(sex);
  7605. builder.MoveToCell(0, i + 1, 2, 0);
  7606. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7607. builder.MoveToCell(0, i + 1, 3, 0);
  7608. builder.Write(DeleClientList[i].Company);
  7609. builder.MoveToCell(0, i + 1, 4, 0);
  7610. builder.Write(DeleClientList[i].Job);
  7611. }
  7612. //删除多余行
  7613. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7614. {
  7615. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7616. }
  7617. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7618. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7619. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7620. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7621. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7622. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7623. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7624. }
  7625. }
  7626. return Ok(JsonView(400, "操作失败!", ""));
  7627. }
  7628. catch (Exception ex)
  7629. {
  7630. return Ok(JsonView(400, ex.Message, ""));
  7631. }
  7632. }
  7633. /// <summary>
  7634. /// 获取三公费用标准city
  7635. /// </summary>
  7636. /// <param name="placeData"></param>
  7637. /// <param name="nationalTravelFeeId"></param>
  7638. /// <returns></returns>
  7639. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7640. {
  7641. string _city = string.Empty;
  7642. if (placeData.Count < 1) return _city;
  7643. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7644. if (data == null) return _city;
  7645. string country = data.Country;
  7646. string city = data.City;
  7647. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7648. else _city = city;
  7649. return _city;
  7650. }
  7651. ///// <summary>
  7652. ///// 团组模块 - 出入境费用 - 明细表导出
  7653. ///// </summary>
  7654. ///// <returns></returns>
  7655. //[HttpPost]
  7656. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7657. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7658. //{
  7659. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7660. // if (data.Code != 0)
  7661. // {
  7662. // return Ok(JsonView(false, data.Msg));
  7663. // }
  7664. // return Ok(JsonView(true, data.Msg, data.Data));
  7665. //}
  7666. /// <summary>
  7667. /// 团组模块 - 出入境费用 - 一键清空
  7668. /// </summary>
  7669. /// <returns></returns>
  7670. [HttpPost]
  7671. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7673. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7674. {
  7675. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7676. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7677. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7678. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7679. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7680. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7681. .SetColumns(x => new Grp_DayOtherPrice
  7682. {
  7683. IsDel = 1,
  7684. DeleteUserId = dto.UserId,
  7685. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7686. })
  7687. .ExecuteCommandAsync();
  7688. if (_view.Code == 0)
  7689. {
  7690. return Ok(JsonView(true, "操作成功"));
  7691. }
  7692. return Ok(JsonView(false, "操作失败"));
  7693. }
  7694. /// <summary>
  7695. /// 团组模块 - 出入境费用 - 子项删除
  7696. /// </summary>
  7697. /// <returns></returns>
  7698. [HttpPost]
  7699. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7701. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7702. {
  7703. try
  7704. {
  7705. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7706. if (data.Code != 0)
  7707. {
  7708. return Ok(JsonView(false, data.Msg));
  7709. }
  7710. return Ok(JsonView(true, "操作成功!", data.Data));
  7711. }
  7712. catch (Exception ex)
  7713. {
  7714. return Ok(JsonView(false, ex.Message));
  7715. }
  7716. }
  7717. /// <summary>
  7718. /// 删除三公其他费用
  7719. /// </summary>
  7720. /// <param name="dto"></param>
  7721. /// <returns></returns>
  7722. [HttpPost]
  7723. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7724. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7725. {
  7726. var jw = JsonView(false, "删除失败!");
  7727. var data = new Grp_DayOtherPrice()
  7728. {
  7729. Id = dto.Id,
  7730. IsDel = 1,
  7731. DeleteUserId = dto.DeleteUserId,
  7732. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7733. };
  7734. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7735. if (del > 0)
  7736. {
  7737. jw.Code = 200;
  7738. jw.Msg = "删除成功!";
  7739. }
  7740. return Ok(jw);
  7741. }
  7742. /// <summary>
  7743. /// 团组模块 - 出入境国家费用标准 List
  7744. /// </summary>
  7745. /// <returns></returns>
  7746. [HttpPost]
  7747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7748. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7749. {
  7750. int provinceId = dto.ProvinceId;
  7751. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7752. var nftData = await _sqlSugar
  7753. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7754. JoinType.Left, ntf.Currency == sd1.Id,
  7755. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7756. JoinType.Left, ntf.ProvinceId == c.Id
  7757. ))
  7758. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7759. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7760. {
  7761. Id = ntf.Id,
  7762. ProvinceId = ntf.ProvinceId,
  7763. ProvinceName = c.Name_CN,
  7764. Continent = ntf.Continent,
  7765. Country = ntf.Country,
  7766. City = ntf.City,
  7767. Currency = ntf.Currency,
  7768. CurrencyCode = sd1.Name,
  7769. CurrencyName = sd1.Remark,
  7770. RoomCost = ntf.RoomCost,
  7771. FoodCost = ntf.FoodCost,
  7772. PublicCost = ntf.PublicCost,
  7773. LastUpdateUserId = ntf.LastUpdateUserId,
  7774. LastUpdateUserName = u.CnName,
  7775. LastUpdateTime = ntf.LastUpdateTime
  7776. })
  7777. .ToListAsync();
  7778. return Ok(JsonView(true, "查询成功!", nftData));
  7779. }
  7780. /// <summary>
  7781. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7782. /// </summary>
  7783. /// <returns></returns>
  7784. [HttpPost]
  7785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7786. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7787. {
  7788. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7789. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7790. List<string> countryData = new List<string>();
  7791. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7792. countryData = countryData.Distinct().ToList();
  7793. List<dynamic> dataSource = new List<dynamic>();
  7794. foreach (var item in countryData)
  7795. {
  7796. var cityData1 = new List<string>();
  7797. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7798. var countryData2 = new
  7799. {
  7800. CountryName = item,
  7801. CityData = cityData1
  7802. };
  7803. if (!dataSource.Contains(countryData2))
  7804. {
  7805. dataSource.Add(countryData2);
  7806. }
  7807. }
  7808. return Ok(JsonView(true, "查询成功!", dataSource));
  7809. }
  7810. /// <summary>
  7811. /// 团组模块 - 出入境国家费用标准 Page List
  7812. /// </summary>
  7813. /// <returns></returns>
  7814. [HttpPost]
  7815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7816. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  7817. {
  7818. int portId = dto.PortType,
  7819. pageIndex = dto.PageIndex,
  7820. pageSize = dto.PageSize;
  7821. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7822. if (pageIndex == 0) pageIndex = 1;
  7823. if (pageSize == 0) pageSize = 10;
  7824. RefAsync<int> total = 0;
  7825. var nationalTravelFeeData = await _sqlSugar
  7826. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  7827. JoinType.Left, ntf.Currency == sd1.Id,
  7828. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7829. JoinType.Left, ntf.ProvinceId == sd2.Id
  7830. ))
  7831. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  7832. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  7833. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  7834. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  7835. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  7836. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  7837. {
  7838. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  7839. Id = ntf.Id,
  7840. ProvinceId = ntf.ProvinceId,
  7841. ProvinceName = sd2.Name_CN,
  7842. Continent = ntf.Continent,
  7843. Country = ntf.Country,
  7844. City = ntf.City,
  7845. Currency = ntf.Currency,
  7846. CurrencyCode = sd1.Name,
  7847. CurrencyName = sd1.Remark,
  7848. RoomCost = ntf.RoomCost,
  7849. FoodCost = ntf.FoodCost,
  7850. PublicCost = ntf.PublicCost,
  7851. LastUpdateUserId = ntf.LastUpdateUserId,
  7852. LastUpdateUserName = u.CnName,
  7853. LastUpdateTime = ntf.LastUpdateTime,
  7854. Remark = ntf.Remark
  7855. })
  7856. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7857. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  7858. }
  7859. /// <summary>
  7860. /// 团组模块 - 出入境国家费用标准 根据城市查询
  7861. /// </summary>
  7862. /// <returns></returns>
  7863. [HttpPost]
  7864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7865. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  7866. {
  7867. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  7868. int portId = dto.PortType;
  7869. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7870. string whereSql = string.Empty;
  7871. if (!string.IsNullOrEmpty(dto.Country))
  7872. {
  7873. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  7874. }
  7875. if (!string.IsNullOrEmpty(dto.City))
  7876. {
  7877. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  7878. }
  7879. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  7880. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  7881. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  7882. From Grp_NationalTravelFee gntf
  7883. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  7884. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  7885. Where gntf.Isdel = 0 {0} ", whereSql);
  7886. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  7887. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  7888. }
  7889. /// <summary>
  7890. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  7891. /// </summary>
  7892. /// <returns></returns>
  7893. [HttpPost]
  7894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7895. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  7896. {
  7897. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  7898. }
  7899. /// <summary>
  7900. /// 团组模块 - 出入境国家费用标准 - Del
  7901. /// </summary>
  7902. /// <returns></returns>
  7903. [HttpPost]
  7904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7905. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  7906. {
  7907. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  7908. {
  7909. Id = dto.Id,
  7910. DeleteUserId = dto.DeleteUserId,
  7911. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7912. IsDel = 1
  7913. };
  7914. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  7915. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  7916. .WhereColumns(it => new { it.Id })
  7917. .ExecuteCommandAsync();
  7918. if (delStatus <= 0)
  7919. {
  7920. return Ok(JsonView(false, "删除失败!"));
  7921. }
  7922. return Ok(JsonView(true, "操作成功!"));
  7923. }
  7924. /// <summary>
  7925. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  7926. /// 注:Get 请求Headers 加 Token
  7927. /// </summary>
  7928. /// <param name="groupId"></param>
  7929. /// <returns></returns>
  7930. [HttpGet("{groupId}")]
  7931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7932. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  7933. {
  7934. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7935. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  7936. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  7937. data.ForEach(x =>
  7938. {
  7939. x.CreateUserId = _currUserInfo.UserId;
  7940. });
  7941. if (data.Any())
  7942. {
  7943. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  7944. if (add > 0)
  7945. {
  7946. return Ok(JsonView(true, "操作成功!"));
  7947. }
  7948. }
  7949. return Ok(JsonView(false, "未操作!"));
  7950. }
  7951. #endregion
  7952. #region 团组经理模块 出入境费用-草稿
  7953. /// <summary>
  7954. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  7955. /// </summary>
  7956. /// <returns></returns>
  7957. [HttpGet]
  7958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7959. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  7960. {
  7961. var provData = await _groupRepository.ProvinceBasicSource();
  7962. return Ok(JsonView(true, "查询成功!", provData));
  7963. }
  7964. /// <summary>
  7965. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  7966. /// </summary>
  7967. /// <returns></returns>
  7968. [HttpGet("{provinceId}")]
  7969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7970. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  7971. {
  7972. //验证城市归属并给默认值
  7973. if (provinceId < 1) provinceId = 122;
  7974. /*
  7975. * 122 四川
  7976. * 108 贵州
  7977. * 103 重庆
  7978. * 132 云南
  7979. */
  7980. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  7981. return Ok(JsonView(true, "查询成功!", new
  7982. {
  7983. WordTypeData = wordTypeData,
  7984. ExcelTypeData = excelTypeData,
  7985. }));
  7986. }
  7987. /// <summary>
  7988. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  7989. /// </summary>
  7990. /// <returns></returns>
  7991. [HttpPost]
  7992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7993. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  7994. {
  7995. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  7996. .Where(x => x.IsDel == 0)
  7997. .OrderByDescending(x => x.CreateTime)
  7998. .Select(x => new { x.Id, x.DraftName })
  7999. .ToListAsync();
  8000. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8001. //SetDataInfoView
  8002. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  8003. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  8004. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  8005. int provinceId = dto.ProvinceId;
  8006. if (provinceId < 1) provinceId = 122;
  8007. /*
  8008. * 122 四川
  8009. * 108 贵州
  8010. * 103 重庆
  8011. * 132 云南
  8012. */
  8013. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  8014. //默认币种显示
  8015. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  8016. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  8017. return Ok(JsonView(true, "查询成功!", new
  8018. {
  8019. DraftNameDatas = draftNameDatas,
  8020. CurrencyData = _CurrencyData,
  8021. WordTypeData = wordTypeData,
  8022. ExcelTypeData = excelTypeData,
  8023. CurrencyInit = _currencyInfos,
  8024. ViewPermissionData = viewPermissionData
  8025. }));
  8026. }
  8027. /// <summary>
  8028. /// 团组模块 - 出入境费用-草稿
  8029. /// 实时汇率 tips
  8030. /// 机票费用 tips
  8031. /// </summary>
  8032. /// <returns></returns>
  8033. [HttpPost]
  8034. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8035. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  8036. {
  8037. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  8038. return Ok(JsonView(true, "查询成功!", new
  8039. {
  8040. //GroupNameData = groupNameData.Data,
  8041. //visaData = visaData.Data,
  8042. //airData = airData.Data,
  8043. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  8044. }));
  8045. }
  8046. /// <summary>
  8047. /// 团组模块 - 出入境费用-草稿
  8048. /// 签证费用 tips
  8049. /// </summary>
  8050. /// <returns></returns>
  8051. [HttpPost]
  8052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8053. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  8054. {
  8055. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  8056. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  8057. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  8058. .Select(x => x.NationalTravelFeeId)
  8059. .Distinct()
  8060. .ToListAsync();
  8061. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8062. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8063. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  8064. .Select(x => x.Country)
  8065. .Distinct()
  8066. .ToArrayAsync();
  8067. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8068. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  8069. return Ok(JsonView(true, "查询成功!", new
  8070. {
  8071. totalAmt = totalAmt,
  8072. remark = remark
  8073. }));
  8074. }
  8075. /// <summary>
  8076. /// 团组模块 - 出入境费用-草稿 - Info
  8077. /// </summary>
  8078. /// <returns></returns>
  8079. [HttpPost]
  8080. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  8081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8082. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  8083. {
  8084. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  8085. }
  8086. /// <summary>
  8087. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  8088. /// </summary>
  8089. /// <returns></returns>
  8090. [HttpPost]
  8091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8092. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  8093. {
  8094. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8095. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  8096. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8097. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  8098. foreach (var userId in dto.UserIds)
  8099. {
  8100. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  8101. }
  8102. if (permissions.Any())
  8103. {
  8104. _sqlSugar.BeginTran();
  8105. try
  8106. {
  8107. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  8108. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8109. if (result < 1)
  8110. {
  8111. _sqlSugar.RollbackTran();
  8112. return Ok(JsonView(false));
  8113. }
  8114. }
  8115. catch (Exception ex)
  8116. {
  8117. _sqlSugar.RollbackTran();
  8118. return Ok(JsonView(false, ex.Message));
  8119. }
  8120. _sqlSugar.CommitTran();
  8121. return Ok(JsonView(true));
  8122. }
  8123. return Ok(JsonView(false));
  8124. }
  8125. /// <summary>
  8126. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8127. /// </summary>
  8128. /// <returns></returns>
  8129. [HttpPost]
  8130. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8132. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8133. {
  8134. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8135. if (data.Code != 0)
  8136. {
  8137. return Ok(JsonView(false, data.Msg));
  8138. }
  8139. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8140. //汇率信息记录
  8141. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8142. return Ok(JsonView(true, data.Msg, data.Data));
  8143. }
  8144. /// <summary>
  8145. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8146. /// </summary>
  8147. /// <param name="dto"></param>
  8148. /// <returns></returns>
  8149. [HttpPost]
  8150. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8151. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8152. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8153. {
  8154. try
  8155. {
  8156. var id = dto.Id;
  8157. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8158. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8159. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8160. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8161. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8162. 3 团组成员名单 1 团组成员名单", ""));
  8163. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8164. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8165. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8166. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8167. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8168. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8169. //数据源
  8170. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8171. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8172. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8173. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8174. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8175. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8176. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8177. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8178. .Select((x, a, b) => new
  8179. {
  8180. x.Index,
  8181. itemName = a.Name,
  8182. CurrencyStr = b.Name,
  8183. x.Cost,
  8184. x.SubTotal,
  8185. x.Remark
  8186. })
  8187. .OrderBy((x) => x.Index)
  8188. .ToList(); //其他款项费用
  8189. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8190. var peiceItemCurrencys = new List<string>();
  8191. if (_DayAndCosts.Any())
  8192. {
  8193. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8194. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8195. }
  8196. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8197. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8198. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8199. {
  8200. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8201. }
  8202. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8203. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8204. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8205. if (dto.ExportType == 1) //明细表
  8206. {
  8207. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8208. {
  8209. //获取模板
  8210. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8211. //载入模板
  8212. Document doc = new Document(tempPath);
  8213. DocumentBuilder builder = new DocumentBuilder(doc);
  8214. //利用键值对存放数据
  8215. Dictionary<string, string> dic = new Dictionary<string, string>();
  8216. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8217. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8218. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8219. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8220. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8221. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8222. //境内费用(其他费用)
  8223. if (_EnterExitCosts.ChoiceOne == 1)
  8224. {
  8225. string row1_1 = "";
  8226. if (_EnterExitCosts.Visa > 0)
  8227. {
  8228. //insidePayTotal += _EnterExitCosts.Visa;
  8229. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8230. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8231. //{
  8232. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8233. //}
  8234. }
  8235. string row1_2 = "";
  8236. if (_EnterExitCosts.YiMiao > 0)
  8237. {
  8238. //insidePayTotal += _EnterExitCosts.YiMiao;
  8239. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8240. }
  8241. if (_EnterExitCosts.HeSuan > 0)
  8242. {
  8243. //insidePayTotal += _EnterExitCosts.HeSuan;
  8244. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8245. }
  8246. if (_EnterExitCosts.Service > 0)
  8247. {
  8248. //insidePayTotal += _EnterExitCosts.Service;
  8249. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8250. }
  8251. string row1_3 = "";
  8252. if (_EnterExitCosts.Safe > 0)
  8253. {
  8254. //insidePayTotal += _EnterExitCosts.Safe;
  8255. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8256. }
  8257. if (_EnterExitCosts.Ticket > 0)
  8258. {
  8259. //insidePayTotal += _EnterExitCosts.Ticket;
  8260. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8261. }
  8262. string row1 = "";
  8263. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8264. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8265. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8266. row1 += $"备注:{_EnterExitCosts.Remark}";
  8267. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8268. dic.Add("Row1Str", row1);
  8269. }
  8270. string airTotalStr = string.Empty,
  8271. airPriceStr = string.Empty;
  8272. //经济舱
  8273. if (_EnterExitCosts.SumJJC == 1)
  8274. {
  8275. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8276. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8277. }
  8278. //公务舱
  8279. if (_EnterExitCosts.SumGWC == 1)
  8280. {
  8281. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8282. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8283. }
  8284. //头等舱
  8285. if (_EnterExitCosts.SumTDC == 1)
  8286. {
  8287. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8288. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8289. }
  8290. //汇率描述
  8291. string rateStr = "";
  8292. if (peiceItemCurrencyInfos.Any())
  8293. {
  8294. rateStr = "\r\n汇率描述:";
  8295. foreach (var item in peiceItemCurrencyInfos)
  8296. {
  8297. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8298. }
  8299. }
  8300. string twoItemRemark = "备注:";
  8301. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8302. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8303. dic.Add("AirTotalStr", airTotalStr);
  8304. dic.Add("AirPriceStr", airPriceStr);
  8305. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8306. dic.Add("TwoItemRemark", twoItemRemark);
  8307. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8308. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8309. int table1Row = 0,
  8310. table2Row = 0,
  8311. table3Row = 0,
  8312. table4Row = 0,
  8313. table5Row = 0;
  8314. //住宿费
  8315. if (_EnterExitCosts.ChoiceThree == 1)
  8316. {
  8317. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8318. table1Row = dac1.Count;
  8319. #region 填充word表格内容
  8320. for (int i = 0; i < dac1.Count; i++)
  8321. {
  8322. var dac = dac1[i];
  8323. if (dac == null) continue;
  8324. builder.MoveToCell(0, i, 0, 0);
  8325. builder.Write("第" + dac.Days.ToString() + "晚:");
  8326. builder.MoveToCell(0, i, 1, 0);
  8327. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8328. //builder.Write(dac.Place == null ? "" : dac.Place);
  8329. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8330. builder.MoveToCell(0, i, 2, 0);
  8331. builder.Write("费用标准:");
  8332. string curr = "";
  8333. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8334. if (currData != null)
  8335. {
  8336. curr = currData.Name;
  8337. }
  8338. builder.MoveToCell(0, i, 3, 0);
  8339. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8340. builder.MoveToCell(0, i, 4, 0);
  8341. builder.Write("费用小计:");
  8342. builder.MoveToCell(0, i, 5, 0);
  8343. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8344. }
  8345. #endregion
  8346. }
  8347. else dic.Add("SubZS", "0.00");
  8348. //删除多余行
  8349. while (table1.Rows.Count > table1Row)
  8350. {
  8351. table1.Rows.RemoveAt(table1Row);
  8352. }
  8353. //伙食费
  8354. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8355. if (_EnterExitCosts.ChoiceFour == 1)
  8356. {
  8357. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8358. table2Row = dac2.Count;
  8359. #region 填充word表格内容
  8360. for (int i = 0; i < dac2.Count; i++)
  8361. {
  8362. var dac = dac2[i];
  8363. if (dac == null) continue;
  8364. builder.MoveToCell(1, i, 0, 0);
  8365. builder.Write("第" + dac.Days.ToString() + "天:");
  8366. builder.MoveToCell(1, i, 1, 0);
  8367. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8368. builder.MoveToCell(1, i, 2, 0);
  8369. builder.Write("费用标准:");
  8370. string curr = "";
  8371. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8372. if (currData != null)
  8373. {
  8374. curr = currData.Name;
  8375. }
  8376. builder.MoveToCell(1, i, 3, 0);
  8377. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8378. builder.MoveToCell(1, i, 4, 0);
  8379. builder.Write("费用小计:");
  8380. builder.MoveToCell(1, i, 5, 0);
  8381. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8382. }
  8383. #endregion
  8384. }
  8385. else dic.Add("SubHS", "0.00");
  8386. //删除多余行
  8387. while (table2.Rows.Count > table2Row)
  8388. {
  8389. table2.Rows.RemoveAt(table2Row);
  8390. }
  8391. //公杂费
  8392. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8393. if (_EnterExitCosts.ChoiceFive == 1)
  8394. {
  8395. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8396. table3Row = dac3.Count;
  8397. #region 填充word表格内容
  8398. for (int i = 0; i < dac3.Count; i++)
  8399. {
  8400. var dac = dac3[i];
  8401. if (dac == null) continue;
  8402. builder.MoveToCell(2, i, 0, 0);
  8403. builder.Write("第" + dac.Days.ToString() + "天:");
  8404. builder.MoveToCell(2, i, 1, 0);
  8405. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8406. builder.MoveToCell(2, i, 2, 0);
  8407. builder.Write("费用标准:");
  8408. string curr = "";
  8409. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8410. if (currData != null)
  8411. {
  8412. curr = currData.Name;
  8413. }
  8414. builder.MoveToCell(2, i, 3, 0);
  8415. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8416. builder.MoveToCell(2, i, 4, 0);
  8417. builder.Write("费用小计:");
  8418. builder.MoveToCell(2, i, 5, 0);
  8419. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8420. }
  8421. //删除多余行
  8422. while (table3.Rows.Count > table3Row)
  8423. {
  8424. table3.Rows.RemoveAt(table3Row);
  8425. }
  8426. #endregion
  8427. }
  8428. else dic.Add("SubGZF", "0.00");
  8429. //删除多余行
  8430. while (table3.Rows.Count > table3Row)
  8431. {
  8432. table3.Rows.RemoveAt(table3Row);
  8433. }
  8434. //培训费
  8435. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8436. if (_EnterExitCosts.ChoiceSix == 1)
  8437. {
  8438. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8439. dic.Add("SubPX", pxStr);
  8440. table4Row = dac4.Count;
  8441. #region 填充word表格内容
  8442. for (int i = 0; i < dac4.Count; i++)
  8443. {
  8444. var dac = dac4[i];
  8445. if (dac == null) continue;
  8446. builder.MoveToCell(3, i, 0, 0);
  8447. builder.Write("第" + dac.Days.ToString() + "天:");
  8448. builder.MoveToCell(3, i, 1, 0);
  8449. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8450. builder.MoveToCell(3, i, 2, 0);
  8451. builder.Write("费用标准:");
  8452. string curr = "";
  8453. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8454. if (currData != null)
  8455. {
  8456. curr = currData.Name;
  8457. }
  8458. builder.MoveToCell(3, i, 3, 0);
  8459. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8460. builder.MoveToCell(3, i, 4, 0);
  8461. builder.Write("费用小计:");
  8462. builder.MoveToCell(3, i, 5, 0);
  8463. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8464. }
  8465. #endregion
  8466. }
  8467. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8468. //删除多余行
  8469. while (table4.Rows.Count > table4Row)
  8470. {
  8471. table4.Rows.RemoveAt(table4Row);
  8472. }
  8473. //其他费用
  8474. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8475. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8476. {
  8477. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8478. dic.Add("titleQi", qtStr);
  8479. table5Row = dac5.Count;
  8480. #region 填充word表格内容
  8481. for (int i = 0; i < dac5.Count; i++)
  8482. {
  8483. var dac = dac5[i];
  8484. if (dac == null) continue;
  8485. builder.MoveToCell(4, i, 0, 0);
  8486. builder.Write("第" + dac.Index.ToString() + "项:");
  8487. builder.MoveToCell(4, i, 1, 0);
  8488. builder.Write(dac.itemName);
  8489. builder.MoveToCell(4, i, 2, 0);
  8490. builder.Write("费用标准:");
  8491. builder.MoveToCell(4, i, 3, 0);
  8492. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8493. builder.MoveToCell(4, i, 4, 0);
  8494. builder.Write("费用小计:");
  8495. builder.MoveToCell(4, i, 5, 0);
  8496. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8497. builder.MoveToCell(4, i, 6, 0);
  8498. builder.Write("备注:");
  8499. builder.MoveToCell(4, i, 7, 0);
  8500. builder.Write(dac.Remark);
  8501. }
  8502. #endregion
  8503. }
  8504. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8505. //删除多余行
  8506. while (table5.Rows.Count > table5Row)
  8507. {
  8508. table5.Rows.RemoveAt(table5Row);
  8509. }
  8510. //加上其他费用
  8511. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8512. decimal subJJC = 0.00M,
  8513. subGWC = 0.00M,
  8514. subTDC = 0.00M;
  8515. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8516. string totalLabel = string.Format("全部费用总计:");
  8517. //经济舱
  8518. if (_EnterExitCosts.SumJJC == 1)
  8519. {
  8520. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8521. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8522. }
  8523. //公务舱
  8524. if (_EnterExitCosts.SumGWC == 1)
  8525. {
  8526. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8527. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8528. }
  8529. //头等舱
  8530. if (_EnterExitCosts.SumTDC == 1)
  8531. {
  8532. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8533. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8534. }
  8535. //TotalLabel
  8536. dic.Add("TotalLabel", totalLabel);
  8537. #region 填充word模板书签内容
  8538. foreach (var key in dic.Keys)
  8539. {
  8540. Bookmark bookmark = doc.Range.Bookmarks[key];
  8541. if (bookmark != null)
  8542. {
  8543. builder.MoveToBookmark(key);
  8544. builder.Write(dic[key]);
  8545. }
  8546. }
  8547. #endregion
  8548. //文件名
  8549. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8550. strFileName = CommonFun.ValidFileName(strFileName);
  8551. AsposeHelper.removewatermark_v2180();
  8552. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8553. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8554. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8555. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8556. }
  8557. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8558. {
  8559. //获取模板
  8560. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8561. //载入模板
  8562. Document doc = new Document(tempPath);
  8563. DocumentBuilder builder = new DocumentBuilder(doc);
  8564. Dictionary<string, string> dic = new Dictionary<string, string>();
  8565. string returnCodeLabel = string.Empty;
  8566. if (nationalTravelFeeData.Any())
  8567. {
  8568. List<string> list = new List<string>();
  8569. foreach (var item in nationalTravelFeeData)
  8570. {
  8571. list.Add($"{item.Country}({item.City})");
  8572. }
  8573. list = list.Distinct().ToList();
  8574. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8575. }
  8576. var countryLabel = string.Empty;
  8577. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8578. if (countryData.Any())
  8579. {
  8580. countryLabel = string.Join("、", countryData);
  8581. }
  8582. dic.Add("ReturnCodeAir", returnCodeLabel);
  8583. dic.Add("VisitStartDate", "-");
  8584. dic.Add("VisitEndDate", "-");
  8585. dic.Add("Day", "-");
  8586. dic.Add("VisitCountry", countryLabel);
  8587. dic.Add("ClientUnit", "-");
  8588. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8589. //dic.Add("Names", Names);
  8590. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8591. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8592. decimal dac1totalPrice = 0.00M;
  8593. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8594. foreach (var dac in dac1)
  8595. {
  8596. if (dac.SubTotal == 0.00M)
  8597. {
  8598. continue;
  8599. }
  8600. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8601. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8602. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8603. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8604. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8605. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8606. builder.Write(currency);//币种
  8607. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8608. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8609. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8610. builder.Write("");//人数
  8611. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8612. builder.Write("");//天数
  8613. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8614. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8615. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8616. decimal rate = 0.00M;
  8617. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8618. builder.Write(rate.ToString("#0.0000"));//汇率
  8619. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8620. decimal rbmPrice = dac.SubTotal;
  8621. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8622. accommodationStartIndex++;
  8623. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8624. }
  8625. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8626. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8627. {
  8628. table1.Rows.RemoveAt(i - 1);
  8629. foodandotherStartIndex--;
  8630. }
  8631. if (dac2.Count == dac3.Count)//国家 币种 金额
  8632. {
  8633. for (int i = 0; i < dac2.Count; i++)
  8634. {
  8635. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8636. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8637. }
  8638. }
  8639. decimal dac2totalPrice = 0.00M;
  8640. foreach (var dac in dac2)
  8641. {
  8642. if (dac.SubTotal == 0)
  8643. {
  8644. continue;
  8645. }
  8646. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8647. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8648. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8649. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8650. builder.Write(currency);//币种
  8651. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8652. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8653. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8654. builder.Write("");//人数
  8655. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8656. builder.Write("");//天数
  8657. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8658. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8659. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8660. decimal rate = 0.00M;
  8661. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8662. builder.Write(rate.ToString("#0.0000"));//汇率
  8663. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8664. decimal rbmPrice = dac.SubTotal;
  8665. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8666. foodandotherStartIndex++;
  8667. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8668. }
  8669. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8670. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8671. {
  8672. table1.Rows.RemoveAt(i - 1);
  8673. }
  8674. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8675. string otherFeeStr = "";
  8676. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8677. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8678. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8679. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8680. foreach (var otherInfo in dac5)
  8681. {
  8682. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8683. }
  8684. #endregion
  8685. if (otherFeeStr.Length > 0)
  8686. {
  8687. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8688. otherFeeStr = $"({otherFeeStr})";
  8689. dic.Add("OtherFeeStr", otherFeeStr);
  8690. }
  8691. //总计
  8692. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8693. //国际旅费
  8694. string outsideAir = string.Empty;
  8695. string allPriceAir = string.Empty;
  8696. if (_EnterExitCosts.SumJJC == 1)
  8697. {
  8698. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8699. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8700. }
  8701. if (_EnterExitCosts.SumGWC == 1)
  8702. {
  8703. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8704. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8705. }
  8706. if (_EnterExitCosts.SumTDC == 1)
  8707. {
  8708. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8709. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8710. }
  8711. dic.Add("InTravelPrice", $"({outsideAir})");
  8712. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8713. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8714. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8715. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8716. foreach (var key in dic.Keys)
  8717. {
  8718. builder.MoveToBookmark(key);
  8719. builder.Write(dic[key]);
  8720. }
  8721. //模板文件名
  8722. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8723. strFileName = CommonFun.ValidFileName(strFileName);
  8724. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8725. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8726. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8727. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8728. }
  8729. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8730. {
  8731. //获取模板
  8732. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8733. //载入模板
  8734. WorkbookDesigner designer = new WorkbookDesigner();
  8735. designer.Workbook = new Workbook(tempPath);
  8736. Dictionary<string, string> dic = new Dictionary<string, string>();
  8737. string returnCodeLabel = string.Empty;
  8738. if (nationalTravelFeeData.Any())
  8739. {
  8740. List<string> list = new List<string>();
  8741. foreach (var item in nationalTravelFeeData)
  8742. {
  8743. list.Add($"{item.Country}({item.City})");
  8744. }
  8745. list = list.Distinct().ToList();
  8746. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8747. }
  8748. var countryLabel = string.Empty;
  8749. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8750. if (countryData.Any())
  8751. {
  8752. countryLabel = string.Join("、", countryData);
  8753. }
  8754. dic.Add("ReturnCodeAir", returnCodeLabel);
  8755. dic.Add("VisitStartDate", "-");
  8756. dic.Add("VisitEndDate", "-");
  8757. dic.Add("Day", "0");
  8758. dic.Add("VisitCountry", countryLabel);
  8759. dic.Add("ClientUnit", "-");
  8760. designer.SetDataSource("ClientUnit", "-");
  8761. designer.SetDataSource("VisitCountry", countryLabel);
  8762. designer.SetDataSource("Group", "-");
  8763. designer.SetDataSource("ClientUnitTitle", "-");
  8764. designer.SetDataSource("Name", "-");
  8765. designer.SetDataSource("VisitStartDate", "-");
  8766. designer.SetDataSource("Day", "0");
  8767. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8768. designer.SetDataSource("ReturnCodeAir", "-");
  8769. int startIndex = 10;
  8770. const int startIndexcopy = 10;
  8771. if (dac2.Count == dac3.Count)//国家 币种 金额
  8772. {
  8773. for (int i = 0; i < dac2.Count; i++)
  8774. {
  8775. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8776. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8777. }
  8778. }
  8779. DataTable dtdac1 = new DataTable();
  8780. List<string> place = new List<string>();
  8781. dtdac1.Columns.AddRange(new DataColumn[] {
  8782. new DataColumn(){ ColumnName = "city"},
  8783. new DataColumn(){ ColumnName = "curr"},
  8784. new DataColumn(){ ColumnName = "criterion"},
  8785. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8786. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8787. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8788. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8789. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8790. });
  8791. DataTable dtdac2 = new DataTable();
  8792. dtdac2.Columns.AddRange(new DataColumn[] {
  8793. new DataColumn(){ ColumnName = "city"},
  8794. new DataColumn(){ ColumnName = "curr"},
  8795. new DataColumn(){ ColumnName = "criterion"},
  8796. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8797. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8798. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8799. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8800. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8801. });
  8802. dtdac1.TableName = "tb1";
  8803. dtdac2.TableName = "tb2";
  8804. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8805. foreach (var item in dac1)
  8806. {
  8807. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8808. if (place.Contains(item.Place))
  8809. {
  8810. continue;
  8811. }
  8812. DataRow row = dtdac1.NewRow();
  8813. row["city"] = item.Place;
  8814. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8815. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8816. row["curr"] = currency;
  8817. row["rate"] = rate.ToString("#0.0000");
  8818. row["criterion"] = item.Cost.ToString("#0.00");
  8819. row["number"] = 1;
  8820. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8821. //row["costRMB"] = rbmPrice;
  8822. dtdac1.Rows.Add(row);
  8823. place.Add(item.Place);
  8824. }
  8825. place = new List<string>();
  8826. foreach (var item in dac2)
  8827. {
  8828. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8829. if (place.Contains(item.Place))
  8830. {
  8831. continue;
  8832. }
  8833. DataRow row = dtdac2.NewRow();
  8834. row["city"] = item.Place;
  8835. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8836. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8837. row["curr"] = currency;
  8838. row["rate"] = rate.ToString("#0.0000");
  8839. row["criterion"] = item.Cost.ToString("#0.00");
  8840. row["number"] = 1;
  8841. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8842. //row["cost"] = item.SubTotal;
  8843. //row["costRMB"] = rbmPrice;
  8844. dtdac2.Rows.Add(row);
  8845. place.Add(item.Place);
  8846. //dac2totalPrice += rbmPrice;
  8847. }
  8848. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8849. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8850. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8851. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8852. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8853. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8854. string cell4Str1 = string.Empty;
  8855. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8856. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8857. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8858. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8859. string cellStr = $" 5.其他费用(";
  8860. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8861. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8862. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8863. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8864. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8865. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8866. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8867. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8868. foreach (var otherInfo in dac5)
  8869. {
  8870. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8871. }
  8872. #endregion
  8873. if (cellStr.Length > 8)
  8874. {
  8875. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8876. }
  8877. cellStr += ")";
  8878. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8879. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8880. decimal pxFee = dac4.Sum(it => it.Cost);
  8881. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8882. string celllastStr1 = "";
  8883. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8884. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8885. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8886. celllastStr1 += $",国际旅费 元";
  8887. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8888. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8889. designer.SetDataSource("cell4Str", cell4Str);
  8890. designer.SetDataSource("cellStr", cellStr);
  8891. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8892. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8893. designer.SetDataSource("celllastStr", celllastStr);
  8894. Workbook wb = designer.Workbook;
  8895. var sheet = wb.Worksheets[0];
  8896. //绑定datatable数据集
  8897. designer.SetDataSource(dtdac1);
  8898. designer.SetDataSource(dtdac2);
  8899. designer.Process();
  8900. var rowStart = dtdac1.Rows.Count;
  8901. while (rowStart > 0)
  8902. {
  8903. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8904. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8905. startIndex++;
  8906. rowStart--;
  8907. }
  8908. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8909. startIndex += 1; //总计行
  8910. rowStart = dtdac2.Rows.Count;
  8911. while (rowStart > 0)
  8912. {
  8913. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8914. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8915. startIndex++;
  8916. rowStart--;
  8917. }
  8918. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8919. wb.CalculateFormula(true);
  8920. //模板文件名
  8921. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8922. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8923. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8924. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8925. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8926. }
  8927. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8928. {
  8929. //获取模板
  8930. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8931. //载入模板
  8932. Document doc = new Document(tempPath);
  8933. DocumentBuilder builder = new DocumentBuilder(doc);
  8934. Dictionary<string, string> dic = new Dictionary<string, string>();
  8935. dic.Add("GroupName", "-");
  8936. dic.Add("ClientUnit", "-");
  8937. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8938. //string missionLeaderJob = "";//负责人job
  8939. //int groupNumber = 0; //团人数
  8940. dic.Add("MissionLeader", "-"); //团负责人
  8941. dic.Add("MissionLeaderJob", "-"); //团负责人job
  8942. dic.Add("GroupNumber", "0"); //团人数
  8943. dic.Add("Day", "0");
  8944. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8945. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8946. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8947. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8948. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8949. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8950. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8951. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8952. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8953. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8954. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8955. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8956. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8957. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  8958. //其他费用
  8959. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8960. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8961. //其他费用合计
  8962. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8963. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  8964. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  8965. //公务舱合计
  8966. //国际旅费
  8967. //string outsideJJ = "";
  8968. //string allPriceJJ = "";
  8969. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8970. {
  8971. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8972. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8973. }
  8974. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8975. {
  8976. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  8977. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8978. }
  8979. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  8980. {
  8981. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  8982. dic.Add("AirFeeTotal", airFeeTotalStr);
  8983. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  8984. dic.Add("FeeTotal", feeTotalStr);
  8985. }
  8986. foreach (var key in dic.Keys)
  8987. {
  8988. builder.MoveToBookmark(key);
  8989. builder.Write(dic[key]);
  8990. }
  8991. //模板文件名
  8992. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  8993. strFileName = CommonFun.ValidFileName(strFileName);
  8994. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8995. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8996. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8997. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8998. }
  8999. }
  9000. else if (dto.ExportType == 2) //表格
  9001. {
  9002. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9003. }
  9004. else if (dto.ExportType == 3)
  9005. {
  9006. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9007. }
  9008. return Ok(JsonView(400, "只可导出明细表!", ""));
  9009. }
  9010. catch (Exception ex)
  9011. {
  9012. return Ok(JsonView(400, ex.Message, ""));
  9013. }
  9014. }
  9015. /// <summary>
  9016. /// 获取三公费用标准city
  9017. /// </summary>
  9018. /// <param name="placeData"></param>
  9019. /// <param name="nationalTravelFeeId"></param>
  9020. /// <returns></returns>
  9021. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9022. {
  9023. string _city = string.Empty;
  9024. if (!placeData.Any()) return _city;
  9025. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9026. if (data == null) return _city;
  9027. string country = data.Country;
  9028. string city = data.City;
  9029. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9030. else _city = city;
  9031. return _city;
  9032. }
  9033. /// <summary>
  9034. /// 团组模块 - 出入境费用-草稿 - 一键清空
  9035. /// </summary>
  9036. /// <returns></returns>
  9037. [HttpPost]
  9038. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9040. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  9041. {
  9042. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9043. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9044. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  9045. if (_view.Code == 0)
  9046. {
  9047. return Ok(JsonView(true, "操作成功"));
  9048. }
  9049. return Ok(JsonView(false, "操作失败"));
  9050. }
  9051. /// <summary>
  9052. /// 团组模块 - 出入境费用-草稿 - 子项删除
  9053. /// </summary>
  9054. /// <returns></returns>
  9055. [HttpPost]
  9056. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9057. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9058. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  9059. {
  9060. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  9061. if (data.Code != 0)
  9062. {
  9063. return Ok(JsonView(false, data.Msg));
  9064. }
  9065. return Ok(JsonView(true, "操作成功!", data.Data));
  9066. }
  9067. /// <summary>
  9068. /// 三公其他费用草稿 删除
  9069. /// </summary>
  9070. /// <param name="dto"></param>
  9071. /// <returns></returns>
  9072. [HttpPost]
  9073. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9074. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  9075. {
  9076. var jw = JsonView(false, "删除失败!");
  9077. var data = new Grp_DayOtherPriceDraft()
  9078. {
  9079. Id = dto.Id,
  9080. IsDel = 1,
  9081. DeleteUserId = dto.DeleteUserId,
  9082. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9083. };
  9084. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9085. if (del > 0)
  9086. {
  9087. jw.Code = 200;
  9088. jw.Msg = "删除成功!";
  9089. }
  9090. return Ok(jw);
  9091. }
  9092. /// <summary>
  9093. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  9094. /// </summary>
  9095. /// <returns></returns>
  9096. [HttpPost]
  9097. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  9098. {
  9099. var jw = JsonView(false);
  9100. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  9101. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  9102. jw.Code = StatusCodes.Status200OK;
  9103. jw.Msg = "操作成功!";
  9104. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  9105. return Ok(jw);
  9106. }
  9107. /// <summary>
  9108. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  9109. /// </summary>
  9110. /// <param name="dto"></param>
  9111. /// <returns></returns>
  9112. [HttpPost]
  9113. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  9114. {
  9115. int userId = dto.UserId,
  9116. portId = dto.PortType,
  9117. groupId = dto.GroupId,
  9118. draftId = dto.DraftId;
  9119. _portTypeData.Add(1);
  9120. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9121. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  9122. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  9123. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  9124. _sqlSugar.BeginTran();
  9125. try
  9126. {
  9127. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9128. if (draftDatas == null)
  9129. {
  9130. _sqlSugar.RollbackTran();
  9131. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9132. }
  9133. //验证可覆盖已有数据 两边创建人需为同一人;
  9134. int draftCreateUserId = draftDatas.CreateUserId,
  9135. formalCreateUserId = 0;
  9136. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9137. if (formalData != null)
  9138. {
  9139. formalCreateUserId = formalData.CreateUserId;
  9140. if (draftCreateUserId != formalCreateUserId)
  9141. {
  9142. _sqlSugar.RollbackTran();
  9143. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9144. }
  9145. }
  9146. //默认添加查看、编辑权限(创建人、自己)
  9147. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9148. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9149. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9150. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9151. newExterData.DiId = groupId;
  9152. newExterData.CreateUserId = userId;
  9153. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9154. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9155. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9156. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9157. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9158. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9159. //数据如果存在执行删除
  9160. if (enterExitCostInfo != null)
  9161. {
  9162. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9163. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9164. .Where(x => x.Id == enterExitCostInfo.Id)
  9165. .ExecuteCommand();
  9166. _sqlSugar.Updateable<Grp_DayAndCost>()
  9167. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9168. .Where(x => x.DiId == groupId)
  9169. .ExecuteCommand();
  9170. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9171. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9172. .Where(x => x.Diid == groupId)
  9173. .ExecuteCommand();
  9174. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9175. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9176. .Where(x => x.GroupId == groupId)
  9177. .ExecuteCommand();
  9178. }
  9179. //执行insert
  9180. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9181. if (insertId < 1)
  9182. {
  9183. _sqlSugar.RollbackTran();
  9184. return Ok(JsonView(false, "草稿数据导入失败!"));
  9185. }
  9186. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9187. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9188. #region 默认添加权限
  9189. #endregion
  9190. _sqlSugar.CommitTran();
  9191. //执行操作之后
  9192. //生成默认文件pdf并且通知人员
  9193. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9194. {
  9195. DiId = groupId,
  9196. ExportType = 1,
  9197. SubTypeId = 1005
  9198. }, "pdf");
  9199. //发送通知
  9200. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9201. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9202. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9203. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9204. //汇率信息记录
  9205. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9206. return Ok(JsonView(true));
  9207. }
  9208. catch (Exception ex)
  9209. {
  9210. _sqlSugar.RollbackTran();
  9211. return Ok(JsonView(false, ex.Message));
  9212. }
  9213. }
  9214. #endregion
  9215. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9216. /// <summary>
  9217. /// 获取币种基础数据(含逻辑处理)
  9218. /// </summary>
  9219. /// <returns></returns>
  9220. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9221. {
  9222. return await GeneralMethod.EnterExitCostInitRate();
  9223. }
  9224. /// <summary>
  9225. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9226. /// </summary>
  9227. /// <returns></returns>
  9228. [HttpPost]
  9229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9230. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9231. {
  9232. //验证城市归属并给默认值
  9233. int provinceId = dto.ProvinceId;
  9234. if (provinceId < 1) provinceId = 122;
  9235. var dataSource = await _sqlSugar
  9236. .Queryable<Sys_SetData>()
  9237. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9238. .ToListAsync();
  9239. var fileTypes = new List<EecSetDataInfoView>();
  9240. //三公费用-Word明细类型
  9241. var wordTypeData = dataSource
  9242. .Where(it => it.STid == 72)
  9243. .Select(x => new EecSetDataInfoView
  9244. {
  9245. ParentId = 1,
  9246. Id = x.Id,
  9247. Name = x.Name
  9248. })
  9249. .ToArray();
  9250. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9251. var excelTypeData = dataSource
  9252. .Where(it => it.STid == 73)
  9253. .Select(x => new EecSetDataInfoView
  9254. {
  9255. ParentId = 2,
  9256. Id = x.Id,
  9257. Name = x.Name
  9258. })
  9259. .ToArray();
  9260. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9261. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9262. fileTypes.Add(groupNameList);
  9263. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9264. //默认币种显示
  9265. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9266. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9267. return Ok(JsonView(true, "查询成功!", new
  9268. {
  9269. FileTypeData = fileTypes,
  9270. CurrencyInit = _currencyInfos,
  9271. viewPermissionData = viewPermissionData
  9272. }));
  9273. }
  9274. /// <summary>
  9275. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9276. /// </summary>
  9277. /// <returns></returns>
  9278. [HttpPost]
  9279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9280. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9281. {
  9282. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9283. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9284. RefAsync<int> total = 0;
  9285. int diId = 0;
  9286. var status = int.TryParse(dto.GroupName, out diId);
  9287. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9288. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9289. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9290. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9291. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9292. .OrderByDescending(x => x.VisitStartDate)
  9293. .Select(x => new EnterExitCostMobileGroupView()
  9294. {
  9295. Id = x.Id,
  9296. GroupName = x.TeamName,
  9297. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9298. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9299. ProvinceId = x.CityId
  9300. })
  9301. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9302. //处理省份Id
  9303. if (data.Any())
  9304. {
  9305. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9306. if (provCityDatas.Any())
  9307. {
  9308. foreach (var item in data)
  9309. {
  9310. var provinceId = item.ProvinceId;
  9311. var isDefualtVal = true;
  9312. if (provinceId > 0)
  9313. {
  9314. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9315. if (parentId != null)
  9316. {
  9317. isDefualtVal = false;
  9318. item.ProvinceId = (int)parentId;
  9319. }
  9320. }
  9321. if (isDefualtVal)
  9322. {
  9323. item.ProvinceId = 122; //默认四川
  9324. }
  9325. }
  9326. }
  9327. }
  9328. //处理是否显示
  9329. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9330. {
  9331. foreach (var item in data)
  9332. {
  9333. item.IsView = true;
  9334. }
  9335. }
  9336. return Ok(JsonView(true, "查询成功!", data, total));
  9337. }
  9338. /// <summary>
  9339. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9340. /// </summary>
  9341. /// <returns></returns>
  9342. [HttpPost]
  9343. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9344. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9345. {
  9346. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9347. RefAsync<int> total = 0;
  9348. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9349. .Where(x => x.IsDel == 0 && x.STid == 66)
  9350. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9351. .Select(x => new
  9352. {
  9353. id = x.Id,
  9354. name = x.Name,
  9355. remark = x.Remark,
  9356. })
  9357. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9358. return Ok(JsonView(true, "查询成功!", data, total));
  9359. }
  9360. /// <summary>
  9361. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9362. /// </summary>
  9363. /// <returns></returns>
  9364. [HttpPost]
  9365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9366. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9367. {
  9368. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9369. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9370. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9371. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9372. var groupOtherRateData = groupRateData.TeamRates;
  9373. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9374. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9375. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9376. groupOtherRateData = groupOtherRateData
  9377. .Select(x => new TeamRateDescAddCurrencyIdView
  9378. {
  9379. CurrencyId = x.CurrencyId,
  9380. CurrencyName = x.CurrencyName,
  9381. CurrencyCode = x.CurrencyCode,
  9382. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9383. }).ToList();
  9384. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9385. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9386. }
  9387. /// <summary>
  9388. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9389. /// </summary>
  9390. /// <returns></returns>
  9391. [HttpPost]
  9392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9393. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9394. {
  9395. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9396. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9397. var tipsData = new List<int>() { 1, 2, 3 };
  9398. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9399. if (dto.TipsType == 1)
  9400. {
  9401. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9402. }
  9403. else if (dto.TipsType == 2)
  9404. {
  9405. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9406. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9407. }
  9408. else if (dto.TipsType == 3)
  9409. {
  9410. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9411. return Ok(JsonView(true, "查询成功!", airData));
  9412. }
  9413. return Ok(JsonView(false));
  9414. }
  9415. /// <summary>
  9416. /// 团组模块 - 出入境国家费用标准-移动端 List
  9417. /// </summary>
  9418. /// <returns></returns>
  9419. [HttpPost]
  9420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9421. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9422. {
  9423. Stopwatch sw = new Stopwatch();
  9424. sw.Start();
  9425. int provinceId = dto.ProvinceId;
  9426. if (provinceId < 1) provinceId = 122; // 默认四川
  9427. RefAsync<int> total = 0;
  9428. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9429. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9430. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9431. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9432. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9433. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9434. .Select((ntf, sd, u, sd1) => new
  9435. {
  9436. Id = ntf.Id,
  9437. Area = $"{ntf.Country}-{ntf.City}",
  9438. Currency = ntf.Currency,
  9439. CurrencyCode = sd.Name,
  9440. CurrencyName = sd.Remark,
  9441. RoomCost = ntf.RoomCost,
  9442. FoodCost = ntf.FoodCost,
  9443. PublicCost = ntf.PublicCost,
  9444. TrainCost = ntf.TrainCost,
  9445. LastUpdateUserId = ntf.LastUpdateUserId,
  9446. LastUpdateUserName = u.CnName,
  9447. LastUpdateTime = ntf.LastUpdateTime
  9448. })
  9449. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9450. sw.Stop();
  9451. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9452. }
  9453. /// <summary>
  9454. /// 团组模块 - 出入境费用-移动端 - Info
  9455. /// </summary>
  9456. /// <returns></returns>
  9457. [HttpPost]
  9458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9459. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9460. {
  9461. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9462. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9463. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9464. return Ok(data);
  9465. }
  9466. /// <summary>
  9467. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9468. /// </summary>
  9469. /// <returns></returns>
  9470. [HttpPost]
  9471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9472. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9473. {
  9474. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9475. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9476. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9477. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9478. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9479. mobileInfo.DiId = dto.DiId;
  9480. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9481. if (eecInfo == null) return Ok(mobileInfo);
  9482. //验证查看权限
  9483. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9484. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9485. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9486. mobileInfo.IsAssignPerm = isSet;
  9487. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9488. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9489. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9490. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9491. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9492. {
  9493. SubId = dac.Id,
  9494. DiId = dac.DiId,
  9495. Type = dac.Type,
  9496. Days = dac.Days,
  9497. NationalTravelFeeId = dac.NationalTravelFeeId,
  9498. Arae = $"{ntf.Country}-{ntf.City}",
  9499. Cost = dac.Cost,
  9500. Currency = dac.Currency,
  9501. CurrencyName = sd.Name,
  9502. SubTotal = dac.SubTotal,
  9503. })
  9504. .ToList();
  9505. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9506. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9507. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9508. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9509. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9510. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9511. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9512. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9513. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9514. //其他款项
  9515. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9516. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9517. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9518. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9519. .OrderBy((dop, sd1, sd2) => dop.Index)
  9520. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9521. {
  9522. SubId = dop.Id,
  9523. DiId = dop.Diid,
  9524. Index = dop.Index,
  9525. SetDataId = dop.SetDataId,
  9526. SetDataName = sd1.Name,
  9527. Cost = dop.Cost,
  9528. Currency = dop.Currency,
  9529. CurrencyName = sd2.Remark,
  9530. SubTotal = dop.SubTotal,
  9531. Remark = dop.Remark,
  9532. })
  9533. .ToArray();
  9534. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9535. return Ok(mobileInfo);
  9536. }
  9537. /// <summary>
  9538. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9539. /// </summary>
  9540. /// <returns></returns>
  9541. [HttpPost]
  9542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9543. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9544. {
  9545. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9546. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9547. //验证查看权限
  9548. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9549. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9550. var userIds = await _sqlSugar
  9551. .Queryable<Grp_EnterExitCostPermission>()
  9552. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9553. .Select(x => x.UserId)
  9554. .ToArrayAsync();
  9555. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9556. var perUsersView = new List<dynamic>();
  9557. foreach (var item in perUsers)
  9558. {
  9559. bool isView1 = false;
  9560. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9561. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9562. }
  9563. return Ok(JsonView(perUsersView));
  9564. }
  9565. /// <summary>
  9566. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9567. /// </summary>
  9568. /// <returns></returns>
  9569. [HttpPost]
  9570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9571. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9572. {
  9573. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9574. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9575. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9576. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9577. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9578. //验证查看权限
  9579. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9580. //if (!isView) return Ok(JsonView(false, msg));
  9581. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9582. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9583. var subType = dto.SubType;
  9584. if (subType == 1) //1:境内费用
  9585. {
  9586. var oneData = new ChoiceOneMobileSubInfoView()
  9587. {
  9588. Id = eecInfo.Id,
  9589. ChoiceOne = eecInfo.ChoiceOne,
  9590. ChoiceOneTotalCost = eecInfo.InsidePay,
  9591. Visa = eecInfo.Visa,
  9592. VisaRemark = eecInfo.VisaRemark,
  9593. YiMiao = eecInfo.YiMiao,
  9594. HeSuan = eecInfo.HeSuan,
  9595. Service = eecInfo.Service,
  9596. Ticket = eecInfo.Ticket,
  9597. Safe = eecInfo.Safe,
  9598. FirstItemRemark = eecInfo.FirstItemRemark
  9599. };
  9600. return Ok(JsonView(oneData));
  9601. }
  9602. else if (subType == 2) //2:国际旅费
  9603. {
  9604. var twoData = new ChoiceTwoMobileSubInfoView()
  9605. {
  9606. Id = eecInfo.Id,
  9607. ChoiceTwoJJ = eecInfo.SumJJC,
  9608. OutsideJJPay = eecInfo.OutsideJJPay,
  9609. ChoiceTwoGW = eecInfo.SumGWC,
  9610. OutsideGWPay = eecInfo.OutsideGWPay,
  9611. ChoiceTwoTD = eecInfo.SumTDC,
  9612. OutsideTDPay = eecInfo.OutsideTDPay,
  9613. AirJJ = eecInfo.AirJJ,
  9614. AirGW = eecInfo.AirGW,
  9615. AirTD = eecInfo.AirTD,
  9616. CityTranffic = eecInfo.CityTranffic,
  9617. TwoItemRemark = eecInfo.TwoItemRemark
  9618. };
  9619. return Ok(JsonView(twoData));
  9620. }
  9621. else if (subType == 3) //3:住宿费
  9622. {
  9623. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9624. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9625. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9626. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9627. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9628. {
  9629. SubId = dac.Id,
  9630. DiId = dac.DiId,
  9631. Type = dac.Type,
  9632. Days = dac.Days,
  9633. NationalTravelFeeId = dac.NationalTravelFeeId,
  9634. Arae = $"{ntf.Country}-{ntf.City}",
  9635. Cost = dac.Cost,
  9636. Currency = dac.Currency,
  9637. CurrencyName = sd.Name,
  9638. SubTotal = dac.SubTotal,
  9639. })
  9640. .ToArray();
  9641. var data = new ChoiceMobileSubInfo3To6View()
  9642. {
  9643. ParentId = eecInfo.Id,
  9644. Choice = eecInfo.ChoiceThree,
  9645. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9646. Details = dayAndCostDatas
  9647. };
  9648. return Ok(JsonView(data));
  9649. }
  9650. else if (subType == 4) //4:伙食费
  9651. {
  9652. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9653. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9654. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9655. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9656. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9657. {
  9658. SubId = dac.Id,
  9659. DiId = dac.DiId,
  9660. Type = dac.Type,
  9661. Days = dac.Days,
  9662. NationalTravelFeeId = dac.NationalTravelFeeId,
  9663. Arae = $"{ntf.Country}-{ntf.City}",
  9664. Cost = dac.Cost,
  9665. Currency = dac.Currency,
  9666. CurrencyName = sd.Name,
  9667. SubTotal = dac.SubTotal,
  9668. })
  9669. .ToArray();
  9670. var data = new ChoiceMobileSubInfo3To6View()
  9671. {
  9672. ParentId = eecInfo.Id,
  9673. Choice = eecInfo.ChoiceFour,
  9674. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9675. Details = dayAndCostDatas
  9676. };
  9677. return Ok(JsonView(data));
  9678. }
  9679. else if (subType == 5) //5:公杂费
  9680. {
  9681. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9682. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9683. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9684. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9685. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9686. {
  9687. SubId = dac.Id,
  9688. DiId = dac.DiId,
  9689. Type = dac.Type,
  9690. Days = dac.Days,
  9691. NationalTravelFeeId = dac.NationalTravelFeeId,
  9692. Arae = $"{ntf.Country}-{ntf.City}",
  9693. Cost = dac.Cost,
  9694. Currency = dac.Currency,
  9695. CurrencyName = sd.Name,
  9696. SubTotal = dac.SubTotal,
  9697. })
  9698. .ToArray();
  9699. var data = new ChoiceMobileSubInfo3To6View()
  9700. {
  9701. ParentId = eecInfo.Id,
  9702. Choice = eecInfo.ChoiceFive,
  9703. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9704. Details = dayAndCostDatas
  9705. };
  9706. return Ok(JsonView(data));
  9707. }
  9708. else if (subType == 6) //6:培训费
  9709. {
  9710. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9711. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9712. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9713. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9714. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9715. {
  9716. SubId = dac.Id,
  9717. DiId = dac.DiId,
  9718. Type = dac.Type,
  9719. Days = dac.Days,
  9720. NationalTravelFeeId = dac.NationalTravelFeeId,
  9721. Arae = $"{ntf.Country}-{ntf.City}",
  9722. Cost = dac.Cost,
  9723. Currency = dac.Currency,
  9724. CurrencyName = sd.Name,
  9725. SubTotal = dac.SubTotal,
  9726. })
  9727. .ToArray();
  9728. var data = new ChoiceMobileSubInfo3To6View()
  9729. {
  9730. ParentId = eecInfo.Id,
  9731. Choice = eecInfo.ChoiceSix,
  9732. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9733. Details = dayAndCostDatas
  9734. };
  9735. return Ok(JsonView(data));
  9736. }
  9737. else if (subType == 7) //7:其他
  9738. {
  9739. //其他款项
  9740. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9741. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9742. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9743. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9744. .OrderBy((dop, sd1, sd2) => dop.Index)
  9745. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9746. {
  9747. SubId = dop.Id,
  9748. DiId = dop.Diid,
  9749. Index = dop.Index,
  9750. SetDataId = dop.SetDataId,
  9751. SetDataName = sd1.Name,
  9752. Cost = dop.Cost,
  9753. Currency = dop.Currency,
  9754. CurrencyName = sd2.Name,
  9755. SubTotal = dop.SubTotal,
  9756. Remark = dop.Remark,
  9757. })
  9758. .ToArray();
  9759. var data = new ChoiceSevenMobileSubInfoView()
  9760. {
  9761. ParentId = eecInfo.Id,
  9762. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9763. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9764. Details = otherData
  9765. };
  9766. return Ok(JsonView(data));
  9767. }
  9768. return Ok(JsonView(false));
  9769. }
  9770. #region op
  9771. /// <summary>
  9772. /// 移动端更新费用消息通知
  9773. /// </summary>
  9774. /// <param name="diid"></param>
  9775. /// <param name="id"></param>
  9776. /// <param name="currUserId"></param>
  9777. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9778. {
  9779. try
  9780. {
  9781. ////生成默认文件pdf并且通知人员
  9782. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9783. //{
  9784. // DiId = diid,
  9785. // ExportType = 1,
  9786. // SubTypeId = 1005
  9787. //}, "pdf");
  9788. ////发送通知
  9789. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9790. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9791. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9792. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9793. ////汇率信息记录
  9794. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9795. }
  9796. catch (Exception ex)
  9797. {
  9798. //记录日志
  9799. throw;
  9800. }
  9801. }
  9802. /// <summary>
  9803. /// 验证出入境费用数据是否存在
  9804. /// 不存在添加
  9805. /// </summary>
  9806. /// <param name="diId"></param>
  9807. /// <param name="currUserId"></param>
  9808. /// <returns></returns>
  9809. /// <exception cref="CustomException"></exception>
  9810. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9811. {
  9812. var parentId = 0;
  9813. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9814. if (info != null)
  9815. {
  9816. parentId = info.Id;
  9817. }
  9818. else
  9819. {
  9820. var currencys = await EnterExitCostMobileGetCurrencyInit();
  9821. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9822. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9823. parentId = addId;
  9824. }
  9825. return parentId;
  9826. }
  9827. /// <summary>
  9828. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  9829. /// </summary>
  9830. /// <returns></returns>
  9831. [HttpPost]
  9832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9833. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  9834. {
  9835. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9836. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9837. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9838. //验证编辑权限
  9839. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9840. //if (!isEdit) return Ok(JsonView(false, msg));
  9841. var permissions = new List<Grp_EnterExitCostPermission>();
  9842. foreach (var userId in dto.UserIds)
  9843. {
  9844. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  9845. }
  9846. if (permissions.Any())
  9847. {
  9848. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9849. {
  9850. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9851. }
  9852. _sqlSugar.BeginTran();
  9853. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  9854. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9855. if (result < 1)
  9856. {
  9857. _sqlSugar.RollbackTran();
  9858. return Ok(JsonView(false));
  9859. }
  9860. _sqlSugar.CommitTran();
  9861. return Ok(JsonView(true));
  9862. }
  9863. return Ok(JsonView(false));
  9864. }
  9865. /// <summary>
  9866. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  9867. /// </summary>
  9868. /// <returns></returns>
  9869. [HttpPost]
  9870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9871. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  9872. {
  9873. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9874. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9875. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9876. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9877. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9878. int id = dto.Id;
  9879. if (id <= 0) //add
  9880. {
  9881. //int provinceId = dto.ProvinceId;
  9882. int groupId = dto.DiId;
  9883. //if (provinceId < 1) provinceId = 122;
  9884. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  9885. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  9886. if (add < 1) return Ok(JsonView(false));
  9887. id = add;
  9888. }
  9889. else //update
  9890. {
  9891. ////验证编辑权限
  9892. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9893. //if (!isEdit) return Ok(JsonView(false, msg));
  9894. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  9895. if (upd < 1) return Ok(JsonView(false));
  9896. }
  9897. #region 汇率变更时更改币种相关费用
  9898. var opDayCosts = new List<Grp_DayAndCost>();
  9899. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  9900. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9901. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  9902. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9903. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9904. .Select((dac, sd) => new
  9905. {
  9906. dac.Id,
  9907. dac.DiId,
  9908. CurrencyCode = sd.Name,
  9909. dac.Cost
  9910. })
  9911. .ToList();
  9912. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9913. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9914. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9915. .Select((dop, sd) => new
  9916. {
  9917. dop.Id,
  9918. dop.Diid,
  9919. CurrencyCode = sd.Name,
  9920. dop.Cost
  9921. })
  9922. .ToList();
  9923. if (dayCosts.Count > 0)
  9924. {
  9925. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9926. foreach (var dc in new_dayCosts)
  9927. {
  9928. var thisCurrency = dc.Key.ToUpper();
  9929. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9930. if (thisRate == 0.00M) continue;
  9931. foreach (var dcSub in dc)
  9932. {
  9933. opDayCosts.Add(new Grp_DayAndCost()
  9934. {
  9935. Id = dcSub.Id,
  9936. DiId = dcSub.DiId,
  9937. Cost = dcSub.Cost,
  9938. SubTotal = dcSub.Cost * thisRate,
  9939. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9940. });
  9941. }
  9942. }
  9943. if (opDayCosts.Count > 0)
  9944. {
  9945. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9946. }
  9947. }
  9948. if (dayOtherCosts.Count > 0)
  9949. {
  9950. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9951. foreach (var dc in new_dayOtherCosts)
  9952. {
  9953. var thisCurrency = dc.Key.ToUpper();
  9954. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9955. if (thisRate == 0.00M) continue;
  9956. foreach (var dcSub in dc)
  9957. {
  9958. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  9959. {
  9960. Id = dcSub.Id,
  9961. Diid = dcSub.Diid,
  9962. Cost = dcSub.Cost,
  9963. SubTotal = dcSub.Cost * thisRate,
  9964. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9965. });
  9966. }
  9967. }
  9968. if (opDayOtherCosts.Count > 0)
  9969. {
  9970. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9971. }
  9972. }
  9973. #endregion
  9974. //消息通知
  9975. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9976. //汇率信息记录
  9977. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9978. return Ok(JsonView(new { parentId = id }));
  9979. }
  9980. /// <summary>
  9981. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  9982. /// </summary>
  9983. /// <returns></returns>
  9984. [HttpPost]
  9985. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9986. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  9987. {
  9988. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9989. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9990. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9991. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  9992. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  9993. int id = dto.Id;
  9994. if (id <= 0) //add
  9995. {
  9996. checkboxInfo.CreateUserId = dto.CurrUserId;
  9997. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9998. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9999. if (add < 1) return Ok(JsonView(false));
  10000. }
  10001. else //update
  10002. {
  10003. ////验证编辑权限
  10004. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10005. //if (!isEdit) return Ok(JsonView(false, msg));
  10006. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10007. .UpdateColumns(x => new
  10008. {
  10009. x.ChoiceOne,
  10010. x.ChoiceTwo,
  10011. x.SumJJC,
  10012. x.SumGWC,
  10013. x.SumTDC,
  10014. x.ChoiceThree,
  10015. x.ChoiceFour,
  10016. x.ChoiceFive,
  10017. x.ChoiceSix,
  10018. x.OtherExpenses_Checked
  10019. })
  10020. .Where(x => x.Id == id)
  10021. .ExecuteCommandAsync();
  10022. if (upd < 1) return Ok(JsonView(false));
  10023. }
  10024. return Ok(JsonView(new { parentId = id }));
  10025. }
  10026. /// <summary>
  10027. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  10028. /// </summary>
  10029. /// <returns></returns>
  10030. [HttpPost]
  10031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10032. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  10033. {
  10034. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  10035. // if (provinceId < 1) provinceId = 122;
  10036. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10037. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10038. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10039. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10040. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10041. var checkboxInfo = new Grp_EnterExitCost()
  10042. {
  10043. Id = id,
  10044. //ProvinceId = provinceId,
  10045. DiId = diId,
  10046. CreateUserId = currUserId
  10047. };
  10048. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10049. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10050. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10051. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10052. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10053. if (id <= 0) //add
  10054. {
  10055. checkboxInfo.CreateUserId = dto.CurrUserId;
  10056. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10057. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10058. if (add < 1) return Ok(JsonView(false));
  10059. }
  10060. else //update
  10061. {
  10062. ////验证编辑权限
  10063. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10064. //if (!isEdit) return Ok(JsonView(false, msg));
  10065. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  10066. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10067. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10068. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10069. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10070. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10071. .Where(x => x.Id == id)
  10072. .ExecuteCommandAsync();
  10073. if (upd < 1) return Ok(JsonView(false));
  10074. }
  10075. return Ok(JsonView(new { parentId = id }));
  10076. }
  10077. /// <summary>
  10078. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  10079. /// </summary>
  10080. /// <returns></returns>
  10081. [HttpPost]
  10082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10083. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  10084. {
  10085. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10086. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10087. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10088. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10089. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10090. info.FirstItemRemark = dto.FirstItemRemark;
  10091. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10092. int id = dto.Id;
  10093. if (id <= 0) //add
  10094. {
  10095. info.CreateUserId = dto.CurrUserId;
  10096. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10097. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10098. if (add < 1) return Ok(JsonView(false));
  10099. id = add;
  10100. }
  10101. else //update
  10102. {
  10103. ////验证编辑权限
  10104. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10105. //if (!isEdit) return Ok(JsonView(false, msg));
  10106. var upd = await _sqlSugar.Updateable(info)
  10107. .UpdateColumns(x => new
  10108. {
  10109. x.ChoiceOne,
  10110. x.InsidePay,
  10111. x.VisaRemark,
  10112. x.Visa,
  10113. x.Service,
  10114. x.Safe,
  10115. x.Ticket,
  10116. x.HeSuan,
  10117. x.YiMiao,
  10118. x.FirstItemRemark
  10119. })
  10120. .Where(x => x.Id == id)
  10121. .ExecuteCommandAsync();
  10122. if (upd < 1) return Ok(JsonView(false));
  10123. }
  10124. //消息通知
  10125. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10126. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10127. }
  10128. /// <summary>
  10129. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10130. /// </summary>
  10131. /// <returns></returns>
  10132. [HttpPost]
  10133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10134. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10135. {
  10136. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10137. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10138. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10139. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10140. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10141. info.DiId = dto.DiId;
  10142. //info.ProvinceId = dto.ProvinceId;
  10143. info.OutsideJJPay = dto.OutsideJJPay;
  10144. info.OutsideGWPay = dto.OutsideGWPay;
  10145. info.OutsideTDPay = dto.OutsideTDPay;
  10146. info.AirJJ = dto.AirJJ;
  10147. info.AirGW = dto.AirGW;
  10148. info.AirTD = dto.AirTD;
  10149. info.CityTranffic = dto.CityTranffic;
  10150. info.TwoItemRemark = dto.TwoItemRemark;
  10151. info.SumJJC = dto.ChoiceTwoJJ;
  10152. info.SumGWC = dto.ChoiceTwoGW;
  10153. info.SumTDC = dto.ChoiceTwoTD;
  10154. int id = dto.Id;
  10155. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10156. if (id <= 0) //add
  10157. {
  10158. info.CreateUserId = dto.CurrUserId;
  10159. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10160. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10161. if (addId <= 0) return Ok(JsonView(false));
  10162. id = addId;
  10163. }
  10164. else //update
  10165. {
  10166. ////验证编辑权限
  10167. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10168. //if (!isEdit) return Ok(JsonView(false, msg));
  10169. var upd = await _sqlSugar.Updateable(info)
  10170. .UpdateColumns(x => new
  10171. {
  10172. x.SumJJC,
  10173. x.OutsideJJPay,
  10174. x.SumGWC,
  10175. x.OutsideGWPay,
  10176. x.SumTDC,
  10177. x.OutsideTDPay,
  10178. x.AirJJ,
  10179. x.AirGW,
  10180. x.AirTD,
  10181. x.CityTranffic,
  10182. x.TwoItemRemark
  10183. })
  10184. .Where(x => x.Id == id)
  10185. .ExecuteCommandAsync();
  10186. if (upd < 1) return Ok(JsonView(false));
  10187. }
  10188. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10189. gwcItemTotal = info.AirGW + info.CityTranffic;
  10190. tdcItemTotal = info.AirTD + info.CityTranffic;
  10191. //消息通知
  10192. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10193. return Ok(JsonView(new
  10194. {
  10195. parentId = id,
  10196. choiceTwoJJ = dto.ChoiceTwoJJ,
  10197. jjcItemTotal = jjcItemTotal,
  10198. choiceTwoGW = dto.ChoiceTwoGW,
  10199. gwcItemTotal = gwcItemTotal,
  10200. choiceTwoTD = dto.ChoiceTwoTD,
  10201. tdcItemTotal = tdcItemTotal
  10202. }));
  10203. }
  10204. /// <summary>
  10205. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10206. /// </summary>
  10207. /// <returns></returns>
  10208. [HttpPost]
  10209. [ApiExplorerSettings(IgnoreApi = true)]
  10210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10211. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10212. {
  10213. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10214. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10215. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10216. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10217. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10218. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10219. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10220. var infos = infos1.Select(x => new Grp_DayAndCost
  10221. {
  10222. Id = x.Id,
  10223. DiId = dto.DiId,
  10224. Type = dto.FeeType,
  10225. Days = x.Days,
  10226. NationalTravelFeeId = x.NationalTravelFeeId,
  10227. Cost = x.Cost,
  10228. Currency = x.Currency,
  10229. SubTotal = x.SubTotal,
  10230. CreateUserId = dto.CurrUserId
  10231. })
  10232. .ToList();
  10233. var adds = infos.Where(x => x.Id <= 0).ToList();
  10234. var upds = infos.Where(x => x.Id > 0).ToList();
  10235. if (adds.Count > 0)
  10236. {
  10237. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10238. if (add < 1) return Ok(JsonView(false));
  10239. }
  10240. if (upds.Count > 0)
  10241. {
  10242. var upd = await _sqlSugar.Updateable(adds)
  10243. .UpdateColumns(x => new
  10244. {
  10245. x.Days,
  10246. x.NationalTravelFeeId,
  10247. x.Cost,
  10248. x.Currency,
  10249. x.SubTotal
  10250. })
  10251. .WhereColumns(x => new { x.Id })
  10252. .ExecuteCommandAsync();
  10253. if (upd < 1) return Ok(JsonView(false));
  10254. }
  10255. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10256. //消息通知
  10257. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10258. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10259. return Ok(JsonView(new { itemTotal = itemTotal }));
  10260. }
  10261. /// <summary>
  10262. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10263. /// </summary>
  10264. /// <returns></returns>
  10265. [HttpPost]
  10266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10267. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10268. {
  10269. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10270. int subId = dto.SubId, feeType = dto.FeeType;
  10271. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10272. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10273. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10274. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10275. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10276. subInfo.Id = subId;
  10277. subInfo.DiId = dto.DiId;
  10278. if (feeType == 3) subInfo.Type = 1;
  10279. else if (feeType == 4) subInfo.Type = 2;
  10280. else if (feeType == 5) subInfo.Type = 3;
  10281. else if (feeType == 6) subInfo.Type = 4;
  10282. subInfo.CreateUserId = dto.CurrUserId;
  10283. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10284. if (parentId < 1) return Ok(JsonView(false));
  10285. //子表op
  10286. if (subId < 1)
  10287. {
  10288. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10289. if (subAdd < 1) return Ok(JsonView(false));
  10290. }
  10291. else
  10292. {
  10293. ////验证编辑权限
  10294. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10295. //if (!isEdit) return Ok(JsonView(false, msg));
  10296. var subUpd = await _sqlSugar.Updateable(subInfo)
  10297. .UpdateColumns(x => new
  10298. {
  10299. x.Days,
  10300. x.NationalTravelFeeId,
  10301. x.Cost,
  10302. x.Currency,
  10303. x.SubTotal
  10304. })
  10305. .WhereColumns(x => new { x.Id })
  10306. .ExecuteCommandAsync();
  10307. if (subUpd < 1) return Ok(JsonView(false));
  10308. }
  10309. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10310. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10311. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10312. }
  10313. /// <summary>
  10314. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10315. /// </summary>
  10316. /// <returns></returns>
  10317. [HttpPost]
  10318. [ApiExplorerSettings(IgnoreApi = true)]
  10319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10320. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10321. {
  10322. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10323. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10324. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10325. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10326. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10327. {
  10328. Id = x.Id,
  10329. Diid = dto.DiId,
  10330. SetDataId = x.SetDataId,
  10331. Index = x.Index,
  10332. Cost = x.Cost,
  10333. Currency = x.Currency,
  10334. SubTotal = x.SubTotal,
  10335. CreateUserId = dto.CurrUserId,
  10336. Remark = x.Remark
  10337. }).ToList();
  10338. var adds = infos.Where(x => x.Id <= 0).ToList();
  10339. var upds = infos.Where(x => x.Id > 0).ToList();
  10340. if (adds.Count > 0)
  10341. {
  10342. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10343. if (add < 1) return Ok(JsonView(false));
  10344. }
  10345. if (upds.Count > 0)
  10346. {
  10347. var upd = await _sqlSugar.Updateable(adds)
  10348. .UpdateColumns(x => new
  10349. {
  10350. x.Index,
  10351. x.SetDataId,
  10352. x.Cost,
  10353. x.Currency,
  10354. x.SubTotal,
  10355. x.Remark
  10356. })
  10357. .WhereColumns(x => new { x.Id })
  10358. .ExecuteCommandAsync();
  10359. if (upd < 1) return Ok(JsonView(false));
  10360. }
  10361. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10362. //消息通知
  10363. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10364. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10365. return Ok(JsonView(new { itemTotal = itemTotal }));
  10366. }
  10367. /// <summary>
  10368. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10369. /// </summary>
  10370. /// <returns></returns>
  10371. [HttpPost]
  10372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10373. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10374. {
  10375. int subId = dto.SubId;
  10376. int diId = dto.Diid;
  10377. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10378. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10379. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10380. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10381. subInfo.Id = subId;
  10382. subInfo.Diid = dto.Diid;
  10383. subInfo.CreateUserId = dto.CurrUserId;
  10384. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10385. if (parentId < 1) return Ok(JsonView(false));
  10386. #region 子表op
  10387. if (subId < 1)//add
  10388. {
  10389. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10390. if (subAdd < 1) return Ok(JsonView(false));
  10391. }
  10392. else //upd
  10393. {
  10394. ////验证编辑权限
  10395. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10396. //if (!isEdit) return Ok(JsonView(false, msg));
  10397. var subUpd = await _sqlSugar.Updateable(subInfo)
  10398. .UpdateColumns(x => new
  10399. {
  10400. x.Index,
  10401. x.SetDataId,
  10402. x.Cost,
  10403. x.Currency,
  10404. x.SubTotal,
  10405. x.Remark
  10406. })
  10407. .WhereColumns(x => new { x.Id })
  10408. .ExecuteCommandAsync();
  10409. if (subUpd < 1) return Ok(JsonView(false));
  10410. }
  10411. #endregion
  10412. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10413. //消息通知
  10414. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10415. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10416. }
  10417. /// <summary>
  10418. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10419. /// </summary>
  10420. /// <returns></returns>
  10421. [HttpPost]
  10422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10423. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10424. {
  10425. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10426. if (data.Code != 0)
  10427. {
  10428. return Ok(JsonView(false, data.Msg));
  10429. }
  10430. return Ok(JsonView(true, "操作成功!", data.Data));
  10431. }
  10432. /// <summary>
  10433. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10434. /// </summary>
  10435. /// <param name="dto"></param>
  10436. /// <returns></returns>
  10437. [HttpPost]
  10438. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10439. {
  10440. var data = new Grp_DayOtherPrice()
  10441. {
  10442. Id = dto.Id,
  10443. IsDel = 1,
  10444. DeleteUserId = dto.DeleteUserId,
  10445. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10446. };
  10447. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10448. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10449. return Ok(JsonView(false, "删除失败!"));
  10450. }
  10451. #endregion
  10452. #endregion
  10453. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10454. /// <summary>
  10455. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10456. /// </summary>
  10457. /// <returns></returns>
  10458. [HttpGet]
  10459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10460. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10461. {
  10462. var provData = await _groupRepository.ProvinceBasicSource();
  10463. return Ok(JsonView(true, "查询成功!", provData));
  10464. }
  10465. /// <summary>
  10466. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10467. /// </summary>
  10468. /// <returns></returns>
  10469. [HttpPost]
  10470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10471. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10472. {
  10473. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10474. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10475. RefAsync<int> total = 0;
  10476. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10477. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10478. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10479. .Select(x => new
  10480. {
  10481. Id = x.Id,
  10482. DraftName = x.DraftName,
  10483. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10484. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10485. .Any()
  10486. })
  10487. .OrderByDescending(x => x.Id)
  10488. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10489. return Ok(JsonView(true, "查询成功!", data, total));
  10490. }
  10491. /// <summary>
  10492. /// 出入境费用-草稿 移动端
  10493. /// 获取币种基础数据(含逻辑处理)
  10494. /// </summary>
  10495. /// <returns></returns>
  10496. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10497. {
  10498. return await GeneralMethod.EnterExitCostInitRate();
  10499. }
  10500. /// <summary>
  10501. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10502. /// </summary>
  10503. /// <returns></returns>
  10504. [HttpPost]
  10505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10506. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10507. {
  10508. //验证城市归属并给默认值
  10509. int provinceId = dto.ProvinceId;
  10510. if (provinceId < 1) provinceId = 122;
  10511. var dataSource = await _sqlSugar
  10512. .Queryable<Sys_SetData>()
  10513. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10514. .ToListAsync();
  10515. //三公费用-Word明细类型
  10516. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10517. .Select(x => new SetDataInfoView
  10518. {
  10519. Id = x.Id,
  10520. Name = x.Name,
  10521. Remark = x.Remark
  10522. })
  10523. .ToList();
  10524. //三公费用-Excel明细类型
  10525. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10526. .Select(x => new SetDataInfoView
  10527. {
  10528. Id = x.Id,
  10529. Name = x.Name,
  10530. Remark = x.Remark
  10531. })
  10532. .ToList();
  10533. //默认币种显示
  10534. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10535. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10536. return Ok(JsonView(true, "查询成功!", new
  10537. {
  10538. WordTypeData = wordTypeData,
  10539. ExcelTypeData = excelTypeData,
  10540. CurrencyInit = _currencyInfos,
  10541. viewPermissionData = viewPermissionData
  10542. }));
  10543. }
  10544. /// <summary>
  10545. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10546. /// </summary>
  10547. /// <returns></returns>
  10548. [HttpPost]
  10549. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10550. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10551. {
  10552. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10553. RefAsync<int> total = 0;
  10554. int diId = 0;
  10555. var status = int.TryParse(dto.GroupName, out diId);
  10556. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10557. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10558. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10559. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10560. .OrderByDescending(x => x.VisitStartDate)
  10561. .Select(x => new
  10562. {
  10563. Id = x.Id,
  10564. GroupName = x.TeamName
  10565. })
  10566. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10567. return Ok(JsonView(true, "查询成功!", data, total));
  10568. }
  10569. /// <summary>
  10570. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10571. /// </summary>
  10572. /// <returns></returns>
  10573. [HttpPost]
  10574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10575. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10576. {
  10577. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10578. RefAsync<int> total = 0;
  10579. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10580. .Where(x => x.IsDel == 0 && x.STid == 66)
  10581. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10582. .Select(x => new
  10583. {
  10584. id = x.Id,
  10585. name = x.Name,
  10586. remark = x.Remark,
  10587. })
  10588. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10589. return Ok(JsonView(true, "查询成功!", data, total));
  10590. }
  10591. /// <summary>
  10592. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10593. /// </summary>
  10594. /// <returns></returns>
  10595. [HttpPost]
  10596. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10597. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10598. {
  10599. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10600. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10601. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10602. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10603. var groupOtherRateData = groupRateData.TeamRates;
  10604. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10605. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10606. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10607. groupOtherRateData = groupOtherRateData
  10608. .Select(x => new TeamRateDescAddCurrencyIdView
  10609. {
  10610. CurrencyId = x.CurrencyId,
  10611. CurrencyName = x.CurrencyName,
  10612. CurrencyCode = x.CurrencyCode,
  10613. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10614. }).ToList();
  10615. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10616. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10617. }
  10618. /// <summary>
  10619. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10620. /// </summary>
  10621. /// <returns></returns>
  10622. [HttpPost]
  10623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10624. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10625. {
  10626. int portType = dto.PortType;
  10627. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10628. var tipsData = new List<int>() { 1, 2, 3 };
  10629. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10630. if (dto.TipsType == 1)
  10631. {
  10632. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10633. }
  10634. else if (dto.TipsType == 2)
  10635. {
  10636. if (portType == 2)
  10637. {
  10638. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10639. }
  10640. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10641. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10642. .Select(x => x.NationalTravelFeeId)
  10643. .Distinct()
  10644. .ToListAsync();
  10645. if (portType == 2)
  10646. {
  10647. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10648. }
  10649. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10650. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10651. .Select(x => x.Country)
  10652. .Distinct()
  10653. .ToArrayAsync();
  10654. if (portType == 2)
  10655. {
  10656. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10657. }
  10658. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10659. return Ok(JsonView(true, "查询成功!", new
  10660. {
  10661. totalAmt = totalAmt,
  10662. remark = remark
  10663. }));
  10664. }
  10665. else if (dto.TipsType == 3)
  10666. {
  10667. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10668. }
  10669. return Ok(JsonView(false));
  10670. }
  10671. /// <summary>
  10672. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10673. /// </summary>
  10674. /// <returns></returns>
  10675. [HttpPost]
  10676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10677. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10678. {
  10679. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10680. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10681. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10682. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10683. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10684. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10685. var info = new Grp_EnterExitCostDraft()
  10686. {
  10687. ProvinceId = dto.ProvinceId,
  10688. DraftName = dto.DraftName,
  10689. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10690. CreateUserId = dto.CurrUserId
  10691. };
  10692. _sqlSugar.BeginTran();
  10693. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10694. if (draftId < 1)
  10695. {
  10696. _sqlSugar.RollbackTran();
  10697. return Ok(JsonView(false, "草稿创建失败!"));
  10698. }
  10699. //添加默认权限
  10700. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10701. _sqlSugar.CommitTran();
  10702. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10703. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10704. mobileInfo.Id = draftId;
  10705. mobileInfo.DraftName = dto.DraftName;
  10706. mobileInfo.Currencys = rateInfos;
  10707. mobileInfo.IsAssignPerm = assignPerm;
  10708. return Ok(JsonView(mobileInfo));
  10709. }
  10710. /// <summary>
  10711. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10712. /// </summary>
  10713. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10714. /// <summary>
  10715. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10716. /// </summary>
  10717. /// <returns></returns>
  10718. [HttpPost]
  10719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10720. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10721. {
  10722. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10723. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10724. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10725. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10726. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10727. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10728. //验证查看编辑权限
  10729. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10730. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10731. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10732. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10733. mobileInfo.IsAssignPerm = assignPerm;
  10734. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10735. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10736. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10737. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10738. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10739. {
  10740. ParentId = dac.ParentId,
  10741. SubId = dac.Id,
  10742. Type = dac.Type,
  10743. Days = dac.Days,
  10744. NationalTravelFeeId = dac.NationalTravelFeeId,
  10745. Arae = $"{ntf.Country}-{ntf.City}",
  10746. Cost = dac.Cost,
  10747. Currency = dac.Currency,
  10748. CurrencyName = sd.Name,
  10749. SubTotal = dac.SubTotal,
  10750. })
  10751. .ToList();
  10752. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10753. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10754. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10755. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10756. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10757. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10758. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10759. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10760. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10761. //其他款项
  10762. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10763. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10764. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10765. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10766. .OrderBy((dop, sd1, sd2) => dop.Index)
  10767. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10768. {
  10769. ParentId = dop.ParentId,
  10770. SubId = dop.Id,
  10771. Index = dop.Index,
  10772. SetDataId = dop.SetDataId,
  10773. SetDataName = sd1.Name,
  10774. Cost = dop.Cost,
  10775. Currency = dop.Currency,
  10776. CurrencyName = sd2.Remark,
  10777. SubTotal = dop.SubTotal,
  10778. Remark = dop.Remark,
  10779. })
  10780. .ToArray();
  10781. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10782. return Ok(mobileInfo);
  10783. }
  10784. /// <summary>
  10785. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10786. /// </summary>
  10787. /// <returns></returns>
  10788. [HttpPost]
  10789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10790. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10791. {
  10792. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10793. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10794. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10795. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10796. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10797. //验证查看编辑权限
  10798. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10799. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10800. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10801. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10802. var subType = dto.SubType;
  10803. if (subType == 1) //1:境内费用
  10804. {
  10805. var oneData = new ChoiceOneMobileSubInfoView()
  10806. {
  10807. Id = eecInfo.Id,
  10808. ChoiceOne = eecInfo.ChoiceOne,
  10809. ChoiceOneTotalCost = eecInfo.InsidePay,
  10810. Visa = eecInfo.Visa,
  10811. VisaRemark = eecInfo.VisaRemark,
  10812. YiMiao = eecInfo.YiMiao,
  10813. HeSuan = eecInfo.HeSuan,
  10814. Service = eecInfo.Service,
  10815. Ticket = eecInfo.Ticket,
  10816. Safe = eecInfo.Safe,
  10817. FirstItemRemark = eecInfo.FirstItemRemark
  10818. };
  10819. return Ok(JsonView(oneData));
  10820. }
  10821. else if (subType == 2) //2:国际旅费
  10822. {
  10823. var twoData = new ChoiceTwoMobileSubInfoView()
  10824. {
  10825. Id = eecInfo.Id,
  10826. ChoiceTwoJJ = eecInfo.SumJJC,
  10827. OutsideJJPay = eecInfo.OutsideJJPay,
  10828. ChoiceTwoGW = eecInfo.SumGWC,
  10829. OutsideGWPay = eecInfo.OutsideGWPay,
  10830. ChoiceTwoTD = eecInfo.SumTDC,
  10831. OutsideTDPay = eecInfo.OutsideTDPay,
  10832. AirJJ = eecInfo.AirJJ,
  10833. AirGW = eecInfo.AirGW,
  10834. AirTD = eecInfo.AirTD,
  10835. CityTranffic = eecInfo.CityTranffic,
  10836. TwoItemRemark = eecInfo.TwoItemRemark
  10837. };
  10838. return Ok(JsonView(twoData));
  10839. }
  10840. else if (subType == 3) //3:住宿费
  10841. {
  10842. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10843. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10844. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10845. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  10846. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10847. {
  10848. ParentId = dac.ParentId,
  10849. SubId = dac.Id,
  10850. Type = dac.Type,
  10851. Days = dac.Days,
  10852. NationalTravelFeeId = dac.NationalTravelFeeId,
  10853. Arae = $"{ntf.Country}-{ntf.City}",
  10854. Cost = dac.Cost,
  10855. Currency = dac.Currency,
  10856. CurrencyName = sd.Name,
  10857. SubTotal = dac.SubTotal,
  10858. })
  10859. .ToArray();
  10860. var data = new ChoiceDraftMobileSubInfo3To6View()
  10861. {
  10862. ParentId = eecInfo.Id,
  10863. Choice = eecInfo.ChoiceThree,
  10864. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10865. Details = dayAndCostDatas
  10866. };
  10867. return Ok(JsonView(data));
  10868. }
  10869. else if (subType == 4) //4:伙食费
  10870. {
  10871. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10872. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10873. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10874. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  10875. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10876. {
  10877. ParentId = dac.ParentId,
  10878. SubId = dac.Id,
  10879. Type = dac.Type,
  10880. Days = dac.Days,
  10881. NationalTravelFeeId = dac.NationalTravelFeeId,
  10882. Arae = $"{ntf.Country}-{ntf.City}",
  10883. Cost = dac.Cost,
  10884. Currency = dac.Currency,
  10885. CurrencyName = sd.Name,
  10886. SubTotal = dac.SubTotal,
  10887. })
  10888. .ToArray();
  10889. var data = new ChoiceDraftMobileSubInfo3To6View()
  10890. {
  10891. ParentId = eecInfo.Id,
  10892. Choice = eecInfo.ChoiceFour,
  10893. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10894. Details = dayAndCostDatas
  10895. };
  10896. return Ok(JsonView(data));
  10897. }
  10898. else if (subType == 5) //5:公杂费
  10899. {
  10900. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10901. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10902. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10903. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  10904. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10905. {
  10906. ParentId = dac.ParentId,
  10907. SubId = dac.Id,
  10908. Type = dac.Type,
  10909. Days = dac.Days,
  10910. NationalTravelFeeId = dac.NationalTravelFeeId,
  10911. Arae = $"{ntf.Country}-{ntf.City}",
  10912. Cost = dac.Cost,
  10913. Currency = dac.Currency,
  10914. CurrencyName = sd.Name,
  10915. SubTotal = dac.SubTotal,
  10916. })
  10917. .ToArray();
  10918. var data = new ChoiceDraftMobileSubInfo3To6View()
  10919. {
  10920. ParentId = eecInfo.Id,
  10921. Choice = eecInfo.ChoiceFive,
  10922. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10923. Details = dayAndCostDatas
  10924. };
  10925. return Ok(JsonView(data));
  10926. }
  10927. else if (subType == 6) //6:培训费
  10928. {
  10929. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10930. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10931. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10932. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  10933. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10934. {
  10935. ParentId = dac.ParentId,
  10936. SubId = dac.Id,
  10937. Type = dac.Type,
  10938. Days = dac.Days,
  10939. NationalTravelFeeId = dac.NationalTravelFeeId,
  10940. Arae = $"{ntf.Country}-{ntf.City}",
  10941. Cost = dac.Cost,
  10942. Currency = dac.Currency,
  10943. CurrencyName = sd.Name,
  10944. SubTotal = dac.SubTotal,
  10945. })
  10946. .ToArray();
  10947. var data = new ChoiceDraftMobileSubInfo3To6View()
  10948. {
  10949. ParentId = eecInfo.Id,
  10950. Choice = eecInfo.ChoiceSix,
  10951. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10952. Details = dayAndCostDatas
  10953. };
  10954. return Ok(JsonView(data));
  10955. }
  10956. else if (subType == 7) //7:其他
  10957. {
  10958. //其他款项
  10959. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10960. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10961. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10962. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10963. .OrderBy((dop, sd1, sd2) => dop.Index)
  10964. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10965. {
  10966. ParentId = dop.ParentId,
  10967. SubId = dop.Id,
  10968. Index = dop.Index,
  10969. SetDataId = dop.SetDataId,
  10970. SetDataName = sd1.Name,
  10971. Cost = dop.Cost,
  10972. Currency = dop.Currency,
  10973. CurrencyName = sd2.Name,
  10974. SubTotal = dop.SubTotal,
  10975. Remark = dop.Remark,
  10976. })
  10977. .ToArray();
  10978. var data = new ChoiceSevenDraftMobileSubInfoView()
  10979. {
  10980. ParentId = eecInfo.Id,
  10981. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  10982. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  10983. Details = otherData
  10984. };
  10985. return Ok(JsonView(data));
  10986. }
  10987. return Ok(JsonView(false));
  10988. }
  10989. #region op
  10990. /// <summary>
  10991. /// 移动端更新费用消息通知
  10992. /// </summary>
  10993. /// <param name="draftId"></param>
  10994. /// <param name="id"></param>
  10995. /// <param name="currUserId"></param>
  10996. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  10997. {
  10998. try
  10999. {
  11000. ////生成默认文件pdf并且通知人员
  11001. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11002. //{
  11003. // DiId = draftId,
  11004. // ExportType = 1,
  11005. // SubTypeId = 1005
  11006. //}, "pdf");
  11007. ////发送通知
  11008. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11009. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11010. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11011. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  11012. ////汇率信息记录
  11013. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11014. }
  11015. catch (Exception ex)
  11016. {
  11017. //记录日志
  11018. throw;
  11019. }
  11020. }
  11021. /// <summary>
  11022. /// 验证出入境费用数据是否存在
  11023. /// 不存在添加
  11024. /// </summary>
  11025. /// <param name="draftId"></param>
  11026. /// <param name="currUserId"></param>
  11027. /// <returns></returns>
  11028. /// <exception cref="CustomException"></exception>
  11029. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  11030. {
  11031. var parentId = 0;
  11032. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11033. if (info != null) parentId = info.Id;
  11034. else
  11035. {
  11036. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  11037. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11038. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11039. parentId = addId;
  11040. }
  11041. return parentId;
  11042. }
  11043. /// <summary>
  11044. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  11045. /// </summary>
  11046. /// <returns></returns>
  11047. [HttpPost]
  11048. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11049. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  11050. {
  11051. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11052. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11053. //验证查看权限
  11054. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11055. if (!isView) return Ok(JsonView(false, _viewPermStr));
  11056. var userIds = await _sqlSugar
  11057. .Queryable<Grp_EnterExitCostDraftPermission>()
  11058. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  11059. .Select(x => x.UserId)
  11060. .ToArrayAsync();
  11061. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11062. var perUsersView = new List<dynamic>();
  11063. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  11064. var viewPermissionData = new List<PermissionViewUserview>();
  11065. if (feeBasePerm.Any())
  11066. {
  11067. foreach (var item in feeBasePerm)
  11068. {
  11069. if (item.Users.Any())
  11070. {
  11071. viewPermissionData.AddRange(item.Users);
  11072. }
  11073. }
  11074. }
  11075. foreach (var item in perUsers)
  11076. {
  11077. bool isView1 = false;
  11078. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11079. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  11080. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11081. }
  11082. return Ok(JsonView(perUsersView));
  11083. }
  11084. /// <summary>
  11085. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  11086. /// </summary>
  11087. /// <returns></returns>
  11088. [HttpPost]
  11089. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11090. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  11091. {
  11092. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11093. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11094. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11095. //验证查看编辑权限
  11096. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11097. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11098. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  11099. foreach (var userId in dto.UserIds)
  11100. {
  11101. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11102. }
  11103. if (permissions.Any())
  11104. {
  11105. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11106. {
  11107. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11108. }
  11109. _sqlSugar.BeginTran();
  11110. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11111. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11112. if (result < 1)
  11113. {
  11114. _sqlSugar.RollbackTran();
  11115. return Ok(JsonView(false));
  11116. }
  11117. _sqlSugar.CommitTran();
  11118. return Ok(JsonView(true));
  11119. }
  11120. return Ok(JsonView(false));
  11121. }
  11122. /// <summary>
  11123. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  11124. /// </summary>
  11125. /// <returns></returns>
  11126. [HttpPost]
  11127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11128. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11129. {
  11130. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11131. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11132. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11133. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11134. int id = dto.DraftId;
  11135. if (id <= 0) //add
  11136. {
  11137. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11138. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11139. if (add < 1) return Ok(JsonView(false));
  11140. id = add;
  11141. }
  11142. else //update
  11143. {
  11144. //验证查看编辑权限
  11145. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11146. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11147. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11148. if (upd < 1) return Ok(JsonView(false));
  11149. }
  11150. return Ok(JsonView(new { parentId = id }));
  11151. }
  11152. /// <summary>
  11153. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11154. /// </summary>
  11155. /// <returns></returns>
  11156. [HttpPost]
  11157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11158. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11159. {
  11160. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11161. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11162. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11163. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11164. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11165. int id = dto.DraftId;
  11166. if (id <= 0) //add
  11167. {
  11168. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11169. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11170. if (add < 1) return Ok(JsonView(false));
  11171. id = add;
  11172. }
  11173. else //update
  11174. {
  11175. //验证查看编辑权限
  11176. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11177. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11178. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11179. if (upd < 1) return Ok(JsonView(false));
  11180. }
  11181. #region 汇率变更时更改币种相关费用
  11182. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11183. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11184. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11185. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11186. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11187. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11188. .Select((dac, sd) => new
  11189. {
  11190. dac.Id,
  11191. dac.ParentId,
  11192. CurrencyCode = sd.Name,
  11193. dac.Cost
  11194. })
  11195. .ToList();
  11196. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11197. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11198. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11199. .Select((dop, sd) => new
  11200. {
  11201. dop.Id,
  11202. dop.ParentId,
  11203. CurrencyCode = sd.Name,
  11204. dop.Cost
  11205. })
  11206. .ToList();
  11207. if (dayCosts.Count > 0)
  11208. {
  11209. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11210. foreach (var dc in new_dayCosts)
  11211. {
  11212. var thisCurrency = dc.Key.ToUpper();
  11213. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11214. if (thisRate == 0.00M) continue;
  11215. foreach (var dcSub in dc)
  11216. {
  11217. opDayCosts.Add(new Grp_DayAndCostDraft()
  11218. {
  11219. Id = dcSub.Id,
  11220. ParentId = dcSub.ParentId,
  11221. Cost = dcSub.Cost,
  11222. SubTotal = dcSub.Cost * thisRate,
  11223. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11224. });
  11225. }
  11226. }
  11227. if (opDayCosts.Count > 0)
  11228. {
  11229. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11230. }
  11231. }
  11232. if (dayOtherCosts.Count > 0)
  11233. {
  11234. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11235. foreach (var dc in new_dayOtherCosts)
  11236. {
  11237. var thisCurrency = dc.Key.ToUpper();
  11238. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11239. if (thisRate == 0.00M) continue;
  11240. foreach (var dcSub in dc)
  11241. {
  11242. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11243. {
  11244. Id = dcSub.Id,
  11245. ParentId = dcSub.ParentId,
  11246. Cost = dcSub.Cost,
  11247. SubTotal = dcSub.Cost * thisRate,
  11248. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11249. });
  11250. }
  11251. }
  11252. if (opDayOtherCosts.Count > 0)
  11253. {
  11254. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11255. }
  11256. }
  11257. #endregion
  11258. ////消息通知
  11259. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11260. ////汇率信息记录
  11261. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11262. return Ok(JsonView(new { parentId = id }));
  11263. }
  11264. /// <summary>
  11265. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11266. /// </summary>
  11267. /// <returns></returns>
  11268. [HttpPost]
  11269. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11270. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11271. {
  11272. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11273. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11274. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11275. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11276. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11277. int id = dto.DraftId;
  11278. if (id <= 0) //add
  11279. {
  11280. checkboxInfo.ProvinceId = dto.ProvinceId;
  11281. checkboxInfo.CreateUserId = dto.CurrUserId;
  11282. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11283. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11284. if (add < 1) return Ok(JsonView(false));
  11285. }
  11286. else //update
  11287. {
  11288. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11289. .UpdateColumns(x => new
  11290. {
  11291. x.ChoiceOne,
  11292. x.ChoiceTwo,
  11293. x.SumJJC,
  11294. x.SumGWC,
  11295. x.SumTDC,
  11296. x.ChoiceThree,
  11297. x.ChoiceFour,
  11298. x.ChoiceFive,
  11299. x.ChoiceSix,
  11300. x.OtherExpenses_Checked
  11301. })
  11302. .Where(x => x.Id == id)
  11303. .ExecuteCommandAsync();
  11304. if (upd < 1) return Ok(JsonView(false));
  11305. }
  11306. return Ok(JsonView(new { parentId = id }));
  11307. }
  11308. /// <summary>
  11309. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11310. /// </summary>
  11311. /// <returns></returns>
  11312. [HttpPost]
  11313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11314. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11315. {
  11316. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11317. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11318. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11319. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11320. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11321. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11322. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11323. var checkboxInfo = new Grp_EnterExitCostDraft()
  11324. {
  11325. Id = draftId,
  11326. ProvinceId = dto.ProvinceId,
  11327. CreateUserId = currUserId
  11328. };
  11329. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11330. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11331. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11332. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11333. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11334. if (draftId <= 0) //add
  11335. {
  11336. checkboxInfo.CreateUserId = dto.CurrUserId;
  11337. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11338. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11339. if (add < 1) return Ok(JsonView(false));
  11340. }
  11341. else //update
  11342. {
  11343. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11344. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11345. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11346. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11347. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11348. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11349. .Where(x => x.Id == draftId)
  11350. .ExecuteCommandAsync();
  11351. if (upd < 1) return Ok(JsonView(false));
  11352. }
  11353. return Ok(JsonView(new { parentId = draftId }));
  11354. }
  11355. /// <summary>
  11356. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11357. /// </summary>
  11358. /// <returns></returns>
  11359. [HttpPost]
  11360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11361. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11362. {
  11363. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11364. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11365. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11366. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11367. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11368. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11369. info.ProvinceId = dto.ProvinceId;
  11370. info.FirstItemRemark = dto.FirstItemRemark;
  11371. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11372. if (id <= 0) //add
  11373. {
  11374. info.CreateUserId = dto.CurrUserId;
  11375. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11376. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11377. if (add < 1) return Ok(JsonView(false));
  11378. id = add;
  11379. }
  11380. else //update
  11381. {
  11382. var upd = await _sqlSugar.Updateable(info)
  11383. .UpdateColumns(x => new
  11384. {
  11385. x.ChoiceOne,
  11386. x.InsidePay,
  11387. x.VisaRemark,
  11388. x.Visa,
  11389. x.Service,
  11390. x.Safe,
  11391. x.Ticket,
  11392. x.HeSuan,
  11393. x.YiMiao,
  11394. x.FirstItemRemark
  11395. })
  11396. .Where(x => x.Id == id)
  11397. .ExecuteCommandAsync();
  11398. if (upd < 1) return Ok(JsonView(false));
  11399. }
  11400. ////消息通知
  11401. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11402. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11403. }
  11404. /// <summary>
  11405. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11406. /// </summary>
  11407. /// <returns></returns>
  11408. [HttpPost]
  11409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11410. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11411. {
  11412. int id = dto.DraftId;
  11413. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11414. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11415. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11416. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11417. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11418. info.ProvinceId = dto.ProvinceId;
  11419. info.OutsideJJPay = dto.OutsideJJPay;
  11420. info.OutsideGWPay = dto.OutsideGWPay;
  11421. info.OutsideTDPay = dto.OutsideTDPay;
  11422. info.AirJJ = dto.AirJJ;
  11423. info.AirGW = dto.AirGW;
  11424. info.AirTD = dto.AirTD;
  11425. info.CityTranffic = dto.CityTranffic;
  11426. info.TwoItemRemark = dto.TwoItemRemark;
  11427. info.SumJJC = dto.ChoiceTwoJJ;
  11428. info.SumGWC = dto.ChoiceTwoGW;
  11429. info.SumTDC = dto.ChoiceTwoTD;
  11430. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11431. if (id <= 0) //add
  11432. {
  11433. info.CreateUserId = dto.CurrUserId;
  11434. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11435. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11436. if (addId <= 0) return Ok(JsonView(false));
  11437. id = addId;
  11438. }
  11439. else //update
  11440. {
  11441. var upd = await _sqlSugar.Updateable(info)
  11442. .UpdateColumns(x => new
  11443. {
  11444. x.SumJJC,
  11445. x.OutsideJJPay,
  11446. x.SumGWC,
  11447. x.OutsideGWPay,
  11448. x.SumTDC,
  11449. x.OutsideTDPay,
  11450. x.AirJJ,
  11451. x.AirGW,
  11452. x.AirTD,
  11453. x.CityTranffic,
  11454. x.TwoItemRemark
  11455. })
  11456. .Where(x => x.Id == id)
  11457. .ExecuteCommandAsync();
  11458. if (upd < 1) return Ok(JsonView(false));
  11459. }
  11460. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11461. gwcItemTotal = info.AirGW + info.CityTranffic;
  11462. tdcItemTotal = info.AirTD + info.CityTranffic;
  11463. ////消息通知
  11464. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11465. return Ok(JsonView(new
  11466. {
  11467. parentId = id,
  11468. choiceTwoJJ = dto.ChoiceTwoJJ,
  11469. jjcItemTotal = jjcItemTotal,
  11470. choiceTwoGW = dto.ChoiceTwoGW,
  11471. gwcItemTotal = gwcItemTotal,
  11472. choiceTwoTD = dto.ChoiceTwoTD,
  11473. tdcItemTotal = tdcItemTotal
  11474. }));
  11475. }
  11476. /// <summary>
  11477. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11478. /// </summary>
  11479. /// <returns></returns>
  11480. [HttpPost]
  11481. [ApiExplorerSettings(IgnoreApi = true)]
  11482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11483. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11484. {
  11485. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11486. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11487. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11488. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11489. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11490. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11491. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11492. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11493. {
  11494. Id = x.Id,
  11495. ParentId = dto.DraftId,
  11496. Type = dto.FeeType,
  11497. Days = x.Days,
  11498. NationalTravelFeeId = x.NationalTravelFeeId,
  11499. Cost = x.Cost,
  11500. Currency = x.Currency,
  11501. SubTotal = x.SubTotal,
  11502. CreateUserId = dto.CurrUserId
  11503. })
  11504. .ToList();
  11505. var adds = infos.Where(x => x.Id <= 0).ToList();
  11506. var upds = infos.Where(x => x.Id > 0).ToList();
  11507. if (adds.Count > 0)
  11508. {
  11509. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11510. if (add < 1) return Ok(JsonView(false));
  11511. }
  11512. if (upds.Count > 0)
  11513. {
  11514. var upd = await _sqlSugar.Updateable(adds)
  11515. .UpdateColumns(x => new
  11516. {
  11517. x.Days,
  11518. x.NationalTravelFeeId,
  11519. x.Cost,
  11520. x.Currency,
  11521. x.SubTotal
  11522. })
  11523. .WhereColumns(x => new { x.Id })
  11524. .ExecuteCommandAsync();
  11525. if (upd < 1) return Ok(JsonView(false));
  11526. }
  11527. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11528. ////消息通知
  11529. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11530. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11531. return Ok(JsonView(new { itemTotal = itemTotal }));
  11532. }
  11533. /// <summary>
  11534. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11535. /// </summary>
  11536. /// <returns></returns>
  11537. [HttpPost]
  11538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11539. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11540. {
  11541. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11542. int subId = dto.SubId, feeType = dto.FeeType;
  11543. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11544. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11545. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11546. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11547. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11548. subInfo.Id = subId;
  11549. subInfo.ParentId = dto.DraftId;
  11550. if (feeType == 3) subInfo.Type = 1;
  11551. else if (feeType == 4) subInfo.Type = 2;
  11552. else if (feeType == 5) subInfo.Type = 3;
  11553. else if (feeType == 6) subInfo.Type = 4;
  11554. subInfo.CreateUserId = dto.CurrUserId;
  11555. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11556. if (parentId < 1) return Ok(JsonView(false));
  11557. //子表op
  11558. if (subId < 1)
  11559. {
  11560. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11561. if (subAdd < 1) return Ok(JsonView(false));
  11562. }
  11563. else
  11564. {
  11565. var subUpd = await _sqlSugar.Updateable(subInfo)
  11566. .UpdateColumns(x => new
  11567. {
  11568. x.Days,
  11569. x.NationalTravelFeeId,
  11570. x.Cost,
  11571. x.Currency,
  11572. x.SubTotal
  11573. })
  11574. .WhereColumns(x => new { x.Id })
  11575. .ExecuteCommandAsync();
  11576. if (subUpd < 1) return Ok(JsonView(false));
  11577. }
  11578. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11579. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11580. }
  11581. /// <summary>
  11582. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11583. /// </summary>
  11584. /// <returns></returns>
  11585. [HttpPost]
  11586. [ApiExplorerSettings(IgnoreApi = true)]
  11587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11588. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11589. {
  11590. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11591. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11592. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11593. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11594. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11595. {
  11596. Id = x.Id,
  11597. ParentId = dto.DraftId,
  11598. SetDataId = x.SetDataId,
  11599. Index = x.Index,
  11600. Cost = x.Cost,
  11601. Currency = x.Currency,
  11602. SubTotal = x.SubTotal,
  11603. CreateUserId = dto.CurrUserId,
  11604. Remark = x.Remark
  11605. }).ToList();
  11606. var adds = infos.Where(x => x.Id <= 0).ToList();
  11607. var upds = infos.Where(x => x.Id > 0).ToList();
  11608. if (adds.Count > 0)
  11609. {
  11610. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11611. if (add < 1) return Ok(JsonView(false));
  11612. }
  11613. if (upds.Count > 0)
  11614. {
  11615. var upd = await _sqlSugar.Updateable(adds)
  11616. .UpdateColumns(x => new
  11617. {
  11618. x.Index,
  11619. x.SetDataId,
  11620. x.Cost,
  11621. x.Currency,
  11622. x.SubTotal,
  11623. x.Remark
  11624. })
  11625. .WhereColumns(x => new { x.Id })
  11626. .ExecuteCommandAsync();
  11627. if (upd < 1) return Ok(JsonView(false));
  11628. }
  11629. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11630. //消息通知
  11631. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11632. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11633. return Ok(JsonView(new { itemTotal = itemTotal }));
  11634. }
  11635. /// <summary>
  11636. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11637. /// </summary>
  11638. /// <returns></returns>
  11639. [HttpPost]
  11640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11641. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11642. {
  11643. int subId = dto.SubId, id = dto.DraftId;
  11644. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11645. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11646. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11647. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11648. subInfo.Id = subId;
  11649. subInfo.ParentId = id;
  11650. subInfo.CreateUserId = dto.CurrUserId;
  11651. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11652. if (parentId < 1) return Ok(JsonView(false));
  11653. #region 子表op
  11654. if (subId < 1)//add
  11655. {
  11656. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11657. if (subAdd < 1) return Ok(JsonView(false));
  11658. }
  11659. else //upd
  11660. {
  11661. var subUpd = await _sqlSugar.Updateable(subInfo)
  11662. .UpdateColumns(x => new
  11663. {
  11664. x.Index,
  11665. x.SetDataId,
  11666. x.Cost,
  11667. x.Currency,
  11668. x.SubTotal,
  11669. x.Remark
  11670. })
  11671. .WhereColumns(x => new { x.Id })
  11672. .ExecuteCommandAsync();
  11673. if (subUpd < 1) return Ok(JsonView(false));
  11674. }
  11675. #endregion
  11676. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11677. ////消息通知
  11678. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11679. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11680. }
  11681. /// <summary>
  11682. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11683. /// </summary>
  11684. /// <returns></returns>
  11685. [HttpPost]
  11686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11687. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11688. {
  11689. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11690. if (data.Code != 0)
  11691. {
  11692. return Ok(JsonView(false, data.Msg));
  11693. }
  11694. return Ok(JsonView(true, "操作成功!", data.Data));
  11695. }
  11696. /// <summary>
  11697. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11698. /// </summary>
  11699. /// <param name="dto"></param>
  11700. /// <returns></returns>
  11701. [HttpPost]
  11702. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11703. {
  11704. var data = new Grp_DayOtherPriceDraft()
  11705. {
  11706. Id = dto.Id,
  11707. IsDel = 1,
  11708. DeleteUserId = dto.DeleteUserId,
  11709. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11710. };
  11711. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11712. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11713. return Ok(JsonView(false, "删除失败!"));
  11714. }
  11715. #endregion
  11716. #endregion
  11717. #region 团组经理模块 出入境费用报价表
  11718. /// <summary>
  11719. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11720. /// </summary>
  11721. /// <returns></returns>
  11722. [HttpPost]
  11723. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11724. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11725. {
  11726. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11727. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11728. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11729. initRates.Insert(0, cnyInfo);
  11730. liveRates.Insert(0, cnyInfo);
  11731. return Ok(JsonView(true, "查询成功!", new
  11732. {
  11733. InitRates = initRates,
  11734. LiveRates = liveRates
  11735. }));
  11736. }
  11737. /// <summary>
  11738. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11739. /// </summary>
  11740. /// <returns></returns>
  11741. [HttpPost]
  11742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11743. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  11744. {
  11745. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11746. }
  11747. /// <summary>
  11748. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11749. /// </summary>
  11750. /// <returns></returns>
  11751. [HttpPost]
  11752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11753. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  11754. {
  11755. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11756. }
  11757. /// <summary>
  11758. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11759. /// </summary>
  11760. /// <returns></returns>
  11761. [HttpPost]
  11762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11763. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11764. {
  11765. int groupId = dto.DiId,
  11766. currUserId = dto.CurrUserId;
  11767. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11768. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11769. //验证报价数据是否存在
  11770. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  11771. if (isNull != null)
  11772. {
  11773. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  11774. if (!info1.Rates.Any())
  11775. {
  11776. var rates = await GeneralMethod.EnterExitCostInitRate();
  11777. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11778. info1.Rates = rates.ToArray();
  11779. }
  11780. return Ok(JsonView(info1));
  11781. }
  11782. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  11783. result.GroupId = groupId;
  11784. //处理报价名称
  11785. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11786. if (groupInfo != null)
  11787. {
  11788. var visitCountry = groupInfo.VisitCountry;
  11789. if (!string.IsNullOrEmpty(visitCountry))
  11790. {
  11791. string quoteName = string.Empty;
  11792. if (visitCountry.Contains("|"))
  11793. {
  11794. var countrys = visitCountry.Split("|");
  11795. quoteName = string.Join("、", countrys);
  11796. }
  11797. else quoteName = visitCountry;
  11798. quoteName += $"团组报价表";
  11799. result.Name = quoteName;
  11800. }
  11801. }
  11802. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  11803. if (info.Code != StatusCodes.Status200OK)
  11804. {
  11805. if (!result.Rates.Any())
  11806. {
  11807. var rates = await GeneralMethod.EnterExitCostInitRate();
  11808. result.Rates = rates.ToArray();
  11809. }
  11810. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  11811. }
  11812. var infoView = info.Data as EnterExitCostInfoView;
  11813. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  11814. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  11815. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  11816. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11817. var eecRates = infoView.Currencys;
  11818. //默认添加人名币
  11819. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  11820. {
  11821. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11822. }
  11823. //处理团组人数
  11824. int pplNum = 1;
  11825. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  11826. var views = new List<QuoteSubItemInfo>();
  11827. #region 数据填充
  11828. var intTravelCosts = new List<QuoteSubItemInfo>();
  11829. #region 机票费用 1354
  11830. int intTravelIndex = 1;
  11831. if (infoView.SumJJC == 1)
  11832. {
  11833. intTravelCosts.Add(new QuoteSubItemInfo
  11834. {
  11835. ItemId = 1354,
  11836. Index = intTravelIndex,
  11837. FeeName = "经济舱",
  11838. UnitPrice = infoView.AirJJ,
  11839. Currency = "CNY",
  11840. Quantity = 1,
  11841. PplNum = 1,
  11842. TotalAmt = infoView.AirJJ,
  11843. Remark = "",
  11844. });
  11845. intTravelIndex++;
  11846. }
  11847. if (infoView.SumGWC == 1)
  11848. {
  11849. intTravelCosts.Add(new QuoteSubItemInfo
  11850. {
  11851. ItemId = 1354,
  11852. Index = intTravelIndex,
  11853. FeeName = "公务舱",
  11854. UnitPrice = infoView.AirGW,
  11855. Currency = "CNY",
  11856. Quantity = 1,
  11857. PplNum = 1,
  11858. TotalAmt = infoView.AirGW,
  11859. Remark = "",
  11860. });
  11861. intTravelIndex++;
  11862. }
  11863. if (infoView.SumTDC == 1)
  11864. {
  11865. intTravelCosts.Add(new QuoteSubItemInfo
  11866. {
  11867. ItemId = 1354,
  11868. Index = intTravelIndex,
  11869. FeeName = "头等舱",
  11870. UnitPrice = infoView.AirTD,
  11871. Currency = "CNY",
  11872. Quantity = 1,
  11873. PplNum = 1,
  11874. TotalAmt = infoView.AirTD,
  11875. Remark = "",
  11876. });
  11877. intTravelIndex++;
  11878. }
  11879. intTravelCosts.Add(new QuoteSubItemInfo
  11880. {
  11881. ItemId = 1354,
  11882. Index = intTravelIndex,
  11883. FeeName = "城市间交通费用",
  11884. UnitPrice = infoView.CityTranffic,
  11885. Currency = "CNY",
  11886. Quantity = 1,
  11887. PplNum = pplNum,
  11888. TotalAmt = infoView.CityTranffic * pplNum,
  11889. Remark = "",
  11890. });
  11891. views.AddRange(intTravelCosts);
  11892. #endregion
  11893. var accomCosts = new List<QuoteSubItemInfo>();
  11894. #region 住宿费 1355
  11895. if (infoView.QuarterageData.Any())
  11896. {
  11897. int accomIndex = 1;
  11898. int accomItemTypeId = 1355;
  11899. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  11900. foreach (var item in groupData)
  11901. {
  11902. string feeName = string.Empty;
  11903. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11904. if (countryInfo != null)
  11905. {
  11906. feeName = countryInfo.Country;
  11907. var city = countryInfo.City;
  11908. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11909. {
  11910. feeName += $"-{city}";
  11911. }
  11912. }
  11913. var hotelInfo = item.FirstOrDefault();
  11914. if (hotelInfo == null) continue;
  11915. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  11916. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11917. int quantity = item.ToList().Count;
  11918. accomCosts.Add(new QuoteSubItemInfo
  11919. {
  11920. ItemId = accomItemTypeId,
  11921. Index = accomIndex,
  11922. FeeName = feeName,
  11923. UnitPrice = hotelInfo.Cost,
  11924. Currency = thisCurrency,
  11925. Quantity = quantity,
  11926. PplNum = pplNum,
  11927. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  11928. Remark = "",
  11929. });
  11930. accomIndex++;
  11931. }
  11932. views.AddRange(accomCosts);
  11933. }
  11934. #endregion
  11935. var mealCosts = new List<QuoteSubItemInfo>();
  11936. #region 餐饮费 1356
  11937. if (infoView.BoardWagesData.Any())
  11938. {
  11939. var mealIndex = 1;
  11940. int mealItemTypeId = 1356;
  11941. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  11942. foreach (var item in groupData)
  11943. {
  11944. string feeName = string.Empty;
  11945. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11946. if (countryInfo != null)
  11947. {
  11948. feeName = countryInfo.Country;
  11949. var city = countryInfo.City;
  11950. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11951. {
  11952. feeName += $"-{city}";
  11953. }
  11954. }
  11955. var mealInfo = item.FirstOrDefault();
  11956. if (mealInfo == null) continue;
  11957. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  11958. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11959. int quantity = item.ToList().Count;
  11960. mealCosts.Add(new QuoteSubItemInfo
  11961. {
  11962. ItemId = mealItemTypeId,
  11963. Index = mealIndex,
  11964. FeeName = feeName,
  11965. UnitPrice = mealInfo.Cost,
  11966. Currency = thisCurrency,
  11967. Quantity = quantity,
  11968. PplNum = pplNum,
  11969. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  11970. Remark = "",
  11971. });
  11972. mealIndex++;
  11973. }
  11974. views.AddRange(mealCosts);
  11975. }
  11976. #endregion
  11977. var miscCosts = new List<QuoteSubItemInfo>();
  11978. #region 公杂费 1364
  11979. if (infoView.MiscellaneousFeeData.Any())
  11980. {
  11981. var miscIndex = 1;
  11982. int miscItemTypeId = 1364;
  11983. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  11984. foreach (var item in groupData)
  11985. {
  11986. string feeName = string.Empty;
  11987. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11988. if (countryInfo != null)
  11989. {
  11990. feeName = countryInfo.Country;
  11991. var city = countryInfo.City;
  11992. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11993. {
  11994. feeName += $"-{city}";
  11995. }
  11996. }
  11997. var miscInfo = item.FirstOrDefault();
  11998. if (miscInfo == null) continue;
  11999. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  12000. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12001. int quantity = item.ToList().Count;
  12002. miscCosts.Add(new QuoteSubItemInfo
  12003. {
  12004. ItemId = miscItemTypeId,
  12005. Index = miscIndex,
  12006. FeeName = feeName,
  12007. UnitPrice = miscInfo.Cost,
  12008. Currency = thisCurrency,
  12009. Quantity = quantity,
  12010. PplNum = pplNum,
  12011. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  12012. Remark = "",
  12013. });
  12014. miscIndex++;
  12015. }
  12016. views.AddRange(miscCosts);
  12017. }
  12018. #endregion
  12019. #region 签证+保险 1362
  12020. int visaInsIndex = 1;
  12021. int visaInsItemTypeId = 1362;
  12022. if (infoView.Visa > 0)
  12023. {
  12024. views.Add(new QuoteSubItemInfo()
  12025. {
  12026. ItemId = visaInsItemTypeId,
  12027. Index = visaInsIndex,
  12028. FeeName = $"签证",
  12029. UnitPrice = infoView.Visa,
  12030. Currency = $"CNY",
  12031. Quantity = 1,
  12032. PplNum = pplNum,
  12033. TotalAmt = infoView.Visa * pplNum,
  12034. Remark = "",
  12035. });
  12036. visaInsIndex++;
  12037. }
  12038. if (infoView.Safe > 0)
  12039. {
  12040. views.Add(new QuoteSubItemInfo()
  12041. {
  12042. ItemId = visaInsItemTypeId,
  12043. Index = visaInsIndex,
  12044. FeeName = $"保险",
  12045. UnitPrice = infoView.Safe,
  12046. Currency = $"CNY",
  12047. Quantity = 1,
  12048. PplNum = pplNum,
  12049. TotalAmt = infoView.Safe * pplNum,
  12050. Remark = "",
  12051. });
  12052. }
  12053. #endregion
  12054. #region 服务费 1363
  12055. int serviceFeeIndex = 1;
  12056. int serviceFeeItemTypeId = 1363;
  12057. if (infoView.Service > 0)
  12058. {
  12059. views.Add(new QuoteSubItemInfo()
  12060. {
  12061. ItemId = serviceFeeItemTypeId,
  12062. Index = serviceFeeIndex,
  12063. FeeName = $"服务费",
  12064. UnitPrice = infoView.Service,
  12065. Currency = $"CNY",
  12066. Quantity = 1,
  12067. PplNum = pplNum,
  12068. TotalAmt = infoView.Service * pplNum,
  12069. Remark = "",
  12070. });
  12071. }
  12072. #endregion
  12073. #endregion
  12074. if (result.FeeItems.Any())
  12075. {
  12076. result.FeeItems.Select(x =>
  12077. {
  12078. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  12079. if (feeInfos.Any()) x.Infos = feeInfos;
  12080. return x;
  12081. }
  12082. ).OrderBy(x => x.Index)
  12083. .ToList();
  12084. if (!result.Rates.Any())
  12085. {
  12086. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  12087. else
  12088. {
  12089. var rates = await GeneralMethod.EnterExitCostInitRate();
  12090. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12091. result.Rates = rates.ToArray();
  12092. }
  12093. }
  12094. }
  12095. return Ok(JsonView(result));
  12096. }
  12097. /// <summary>
  12098. /// 团组模块 - 出入境费用报价表 - Info
  12099. /// </summary>
  12100. /// <returns></returns>
  12101. [HttpPost]
  12102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12103. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  12104. {
  12105. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  12106. if (!info.Rates.Any())
  12107. {
  12108. var rates = await GeneralMethod.EnterExitCostInitRate();
  12109. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12110. info.Rates = rates.ToArray();
  12111. }
  12112. return Ok(JsonView(info));
  12113. }
  12114. /// <summary>
  12115. /// 团组模块 - 出入境费用报价表 - OP
  12116. /// </summary>
  12117. /// <returns></returns>
  12118. [HttpPost]
  12119. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12120. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  12121. {
  12122. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  12123. }
  12124. /// <summary>
  12125. /// 团组模块 - 出入境费用报价表 - 删除 项
  12126. /// </summary>
  12127. /// <returns></returns>
  12128. [HttpPost]
  12129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12130. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12131. {
  12132. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12133. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12134. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12135. }
  12136. /// <summary>
  12137. /// 团组模块 - 出入境费用报价表 - 导出
  12138. /// </summary>
  12139. /// <returns></returns>
  12140. [HttpPost]
  12141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12142. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12143. {
  12144. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12145. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12146. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12147. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12148. var rates = info.Rates;
  12149. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12150. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12151. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12152. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12153. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12154. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12155. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12156. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12157. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12158. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12159. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12160. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12161. //获取模板
  12162. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12163. var designer = new WorkbookDesigner();
  12164. designer.Workbook = new Workbook(tempPath);
  12165. designer.SetDataSource("QuoteName", info.Name);
  12166. designer.SetDataSource("CompanyTitle", "公司名称");
  12167. designer.SetDataSource("CompanyLabel", "");
  12168. #region 国际旅费
  12169. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12170. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12171. {
  12172. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12173. StringBuilder label = new StringBuilder();
  12174. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12175. if (infos.Any())
  12176. {
  12177. label.Append(infos.Sum(x => x.PplNum));
  12178. label.Append("人全程机票:");
  12179. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12180. label.AppendLine("元");
  12181. }
  12182. foreach (var item in intTravelCosts.Infos)
  12183. {
  12184. label.Append(item.FeeName);
  12185. label.Append(":");
  12186. label.Append(item.UnitPrice.TruncDecimals(2));
  12187. label.Append("元/人*");
  12188. label.Append(item.PplNum);
  12189. label.AppendLine("人");
  12190. }
  12191. if (label.HasValue())
  12192. {
  12193. label.Append("\r\n以上小计:");
  12194. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12195. label.Append("元");
  12196. }
  12197. designer.SetDataSource("IntTravelLabel", label.ToString());
  12198. }
  12199. #endregion
  12200. #region 住宿费
  12201. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12202. if (accomCosts != null && accomCosts.Infos.Any())
  12203. {
  12204. string currencyName = string.Empty,
  12205. countryName = string.Empty;
  12206. decimal rate = 1.0000M;
  12207. StringBuilder label = new StringBuilder();
  12208. label.AppendLine("全程五星酒店,每人1间房");
  12209. foreach (var item in accomCosts.Infos)
  12210. {
  12211. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12212. string name = string.Empty, thisCountryName = string.Empty;
  12213. if (item.FeeName.Contains("-"))
  12214. {
  12215. var feeName = item.FeeName.Split('-');
  12216. thisCountryName = feeName[0];
  12217. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12218. name = feeName[1];
  12219. }
  12220. else name = item.FeeName;
  12221. string thisFeeName = string.Empty;
  12222. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12223. else thisFeeName = $"\r\n{name}:";
  12224. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12225. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12226. rate = rateInfo?.Rate ?? 1.0000M;
  12227. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12228. label.AppendLine(subLabel);
  12229. }
  12230. if (label.HasValue())
  12231. {
  12232. //以上小计:52440元(美金汇率:7.5 )
  12233. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12234. label.AppendLine(subLabel);
  12235. }
  12236. designer.SetDataSource("AccomLabel", label.ToString());
  12237. }
  12238. #endregion
  12239. #region 餐饮费
  12240. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12241. if (mealCosts != null && mealCosts.Infos.Any())
  12242. {
  12243. string currencyName = string.Empty;
  12244. decimal rate = 1.0000M;
  12245. StringBuilder label = new StringBuilder();
  12246. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12247. foreach (var item in mealCosts.Infos)
  12248. {
  12249. string name = string.Empty;
  12250. if (item.FeeName.Contains("-"))
  12251. {
  12252. var feeName = item.FeeName.Split('-');
  12253. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12254. }
  12255. else name = $"\r\n{item.FeeName}:";
  12256. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12257. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12258. rate = rateInfo?.Rate ?? 1.0000M;
  12259. label.Append(name);
  12260. label.Append(item.UnitPrice.TruncDecimals(2));
  12261. label.Append(currencyName);
  12262. label.Append("/天*");
  12263. label.Append(item.Quantity.ToString("#0"));
  12264. label.Append("*");
  12265. label.Append(item.PplNum);
  12266. label.Append("人\r\n");
  12267. }
  12268. if (label.HasValue())
  12269. {
  12270. label.Append("\r\n以上小计:");
  12271. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12272. label.Append("元\r\n(");
  12273. label.Append("汇率:");
  12274. label.Append(rate.TruncDecimals(4));
  12275. label.Append(")");
  12276. }
  12277. designer.SetDataSource("MealLabel", label.ToString());
  12278. }
  12279. #endregion
  12280. #region 车辆安排
  12281. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12282. if (vehArranges != null && vehArranges.Infos.Any())
  12283. {
  12284. string currencyName = string.Empty;
  12285. //decimal rate = 1.0000M;
  12286. StringBuilder label = new StringBuilder();
  12287. foreach (var item in vehArranges.Infos)
  12288. {
  12289. label.AppendLine();
  12290. label.AppendLine();
  12291. label.Append(item.FeeName);
  12292. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12293. }
  12294. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12295. }
  12296. #endregion
  12297. #region 邀请函发放对象
  12298. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12299. designer.SetDataSource("InviteToContent", "");
  12300. #endregion
  12301. #region 邀请函费
  12302. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12303. StringBuilder is_label = new StringBuilder();
  12304. if (inviteCosts != null && inviteCosts.Infos.Any())
  12305. {
  12306. string currencyName = string.Empty;
  12307. decimal rate = 1.0000M;
  12308. foreach (var item in inviteCosts.Infos)
  12309. {
  12310. //乌兹别克斯坦:2000美金
  12311. currencyName = item.Currency;
  12312. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12313. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12314. is_label.AppendLine(label);
  12315. }
  12316. if (is_label.HasValue())
  12317. {
  12318. //以上小计:28500元(美金汇率:7.5)
  12319. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12320. is_label.AppendLine(label);
  12321. }
  12322. }
  12323. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12324. #endregion
  12325. #region 邀请函发放时间
  12326. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12327. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12328. #endregion
  12329. #region 公务活动(含翻译)
  12330. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12331. StringBuilder oa_label = new StringBuilder();
  12332. if (officialActs != null && officialActs.Infos.Any())
  12333. {
  12334. string currencyName = string.Empty;
  12335. decimal rate = 1.0000M;
  12336. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12337. foreach (var item in officialActs.Infos)
  12338. {
  12339. //乌兹别克斯坦:1000美金/场
  12340. currencyName = item.Currency;
  12341. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12342. string label_remark = string.Empty;
  12343. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12344. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12345. }
  12346. label_content += "*总费用中未含超出公务活动价格";
  12347. //8场公务活动(以上小计:60000元)
  12348. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12349. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12350. oa_label.AppendLine(label_title);
  12351. oa_label.AppendLine(label_content);
  12352. }
  12353. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12354. #endregion
  12355. #region 签证+保险
  12356. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12357. StringBuilder vi_label = new StringBuilder();
  12358. if (visaIns != null && visaIns.Infos.Any())
  12359. {
  12360. foreach (var item in visaIns.Infos)
  12361. {
  12362. //签证:500元/人
  12363. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12364. vi_label.AppendLine(label);
  12365. }
  12366. if (vi_label.HasValue())
  12367. {
  12368. //以上小计:6000元
  12369. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12370. vi_label.AppendLine(label);
  12371. }
  12372. }
  12373. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12374. #endregion
  12375. #region 服务费
  12376. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12377. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12378. #endregion
  12379. #region 公杂费
  12380. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12381. StringBuilder pm_label = new StringBuilder();
  12382. if (pubMiscs != null && pubMiscs.Infos.Any())
  12383. {
  12384. string currencyName = string.Empty,
  12385. countryName = string.Empty;
  12386. decimal rate = 1.0000M;
  12387. foreach (var item in pubMiscs.Infos)
  12388. {
  12389. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12390. string name = string.Empty, thisCountryName = string.Empty;
  12391. if (item.FeeName.Contains("-"))
  12392. {
  12393. var feeName = item.FeeName.Split('-');
  12394. thisCountryName = feeName[0];
  12395. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12396. name = feeName[1];
  12397. }
  12398. else name = item.FeeName;
  12399. string thisFeeName = string.Empty;
  12400. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12401. else thisFeeName = $"\r\n{name}:";
  12402. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12403. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12404. rate = rateInfo?.Rate ?? 1.0000M;
  12405. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12406. pm_label.AppendLine(label);
  12407. }
  12408. if (pm_label.HasValue())
  12409. {
  12410. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12411. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12412. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12413. pm_label.AppendLine(string.Format("部分发放成员"));
  12414. }
  12415. }
  12416. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12417. #endregion
  12418. #region 税费
  12419. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12420. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12421. #endregion
  12422. #region 合计(单位:元)
  12423. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12424. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12425. #endregion
  12426. #region 汇率 Remark
  12427. var rate_label = new StringBuilder();
  12428. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12429. foreach (var item in rateGroups)
  12430. {
  12431. //美元汇率按\r\n1:7.5
  12432. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12433. rate_label.AppendLine(label);
  12434. }
  12435. designer.SetDataSource("RateLabel", rate_label.ToString());
  12436. #endregion
  12437. designer.Process();
  12438. //文件名
  12439. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12440. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12441. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12442. return Ok(JsonView(true, "成功", url));
  12443. }
  12444. #endregion
  12445. #region 签证费用录入
  12446. /// <summary>
  12447. /// 根据diid查询签证费用列表
  12448. /// </summary>
  12449. /// <param name="dto"></param>
  12450. /// <returns></returns>
  12451. [HttpPost]
  12452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12453. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12454. {
  12455. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12456. if (groupData.Code != 0)
  12457. {
  12458. return Ok(JsonView(false, groupData.Msg));
  12459. }
  12460. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12461. }
  12462. /// <summary>
  12463. /// 根据签证费用Id查询单条数据及c表数据
  12464. /// </summary>
  12465. /// <param name="dto"></param>
  12466. /// <returns></returns>
  12467. [HttpPost]
  12468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12469. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12470. {
  12471. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12472. if (groupData.Code != 0)
  12473. {
  12474. return Ok(JsonView(false, groupData.Msg));
  12475. }
  12476. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12477. }
  12478. /// <summary>
  12479. /// 签证费用删除
  12480. /// </summary>
  12481. /// <param name="dto"></param>
  12482. /// <returns></returns>
  12483. [HttpPost]
  12484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12485. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12486. {
  12487. _sqlSugar.BeginTran();
  12488. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12489. if (!res)
  12490. {
  12491. _sqlSugar.RollbackTran();
  12492. return Ok(JsonView(false, "删除失败"));
  12493. }
  12494. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12495. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12496. .SetColumns(a => new Grp_CreditCardPayment()
  12497. {
  12498. IsDel = 1,
  12499. DeleteUserId = dto.DeleteUserId,
  12500. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12501. })
  12502. .ExecuteCommand();
  12503. if (resSub < 1)
  12504. {
  12505. _sqlSugar.RollbackTran();
  12506. return Ok(JsonView(false, "删除失败"));
  12507. }
  12508. _sqlSugar.CommitTran();
  12509. return Ok(JsonView(true, "删除成功!"));
  12510. }
  12511. /// <summary>
  12512. /// 签证费用录入下拉框初始化
  12513. /// </summary>
  12514. /// <returns></returns>
  12515. [HttpPost]
  12516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12517. public async Task<IActionResult> VisaPriceAddSelect()
  12518. {
  12519. //支付方式
  12520. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12521. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12522. //币种
  12523. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12524. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12525. //乘客类型
  12526. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12527. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12528. //卡类型
  12529. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12530. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12531. //代办费类型
  12532. var agencyFeeTypeData = new List<dynamic>() {
  12533. new { id = 0 , Text = "未选择" },
  12534. new { id = 1 , Text = "小公务" },
  12535. new { id = 2 , Text = "大公务" },
  12536. };
  12537. //签证费用标准国家Data
  12538. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12539. var data = new
  12540. {
  12541. Payment = _Payment,
  12542. CurrencyList = _CurrencyList,
  12543. PassengerType = _PassengerType,
  12544. BankCard = _BankCard,
  12545. AgencyFeeType = agencyFeeTypeData,
  12546. CountryFeeData = visaCountryFeeData
  12547. };
  12548. return Ok(JsonView(true, "查询成功!", data));
  12549. }
  12550. /// <summary>
  12551. /// 签证费用录入操作(Status:1.新增,2.修改)
  12552. /// </summary>
  12553. /// <param name="dto"></param>
  12554. /// <returns></returns>
  12555. [HttpPost]
  12556. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12557. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12558. {
  12559. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12560. if (groupData.Code != 0)
  12561. {
  12562. return Ok(JsonView(false, groupData.Msg));
  12563. }
  12564. #region 应用推送
  12565. try
  12566. {
  12567. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12568. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12569. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12570. //2024-10-21 新增LZ UID
  12571. var userIds = new List<int>() { 21 };
  12572. string title = $"系统通知";
  12573. string content = "";
  12574. var diId = dto.DiId;
  12575. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12576. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12577. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12578. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12579. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12580. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12581. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12582. }
  12583. catch (Exception ex)
  12584. {
  12585. }
  12586. #endregion
  12587. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12588. }
  12589. #endregion
  12590. #region 签证提成录入
  12591. /// <summary>
  12592. /// 签证提成录入
  12593. /// 基础数据
  12594. /// </summary>
  12595. /// <returns></returns>
  12596. [HttpGet]
  12597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12598. public async Task<IActionResult> VisaCommissionInit()
  12599. {
  12600. return Ok(await _visaCommissionRep.Init());
  12601. }
  12602. /// <summary>
  12603. /// 签证提成录入
  12604. /// Item
  12605. /// </summary>
  12606. /// <param name="_dto"></param>
  12607. /// <returns></returns>
  12608. [HttpPost]
  12609. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12610. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12611. {
  12612. var validator = new VisaCommissionItemDtoValidator();
  12613. var validatorRes = await validator.ValidateAsync(_dto);
  12614. if (!validatorRes.IsValid)
  12615. {
  12616. StringBuilder sb = new StringBuilder();
  12617. foreach (var item in validatorRes.Errors)
  12618. {
  12619. sb.AppendLine(item.ErrorMessage);
  12620. }
  12621. return Ok(JsonView(false, sb.ToString()));
  12622. }
  12623. return Ok(await _visaCommissionRep.Item(_dto));
  12624. }
  12625. /// <summary>
  12626. /// 签证提成录入
  12627. /// Save
  12628. /// </summary>
  12629. /// <param name="_dto"></param>
  12630. /// <returns></returns>
  12631. [HttpPost]
  12632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12633. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12634. {
  12635. //参数验证
  12636. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12637. foreach (var item in _dto.Items)
  12638. {
  12639. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12640. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12641. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12642. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12643. }
  12644. return Ok(await _visaCommissionRep.Save(_dto));
  12645. }
  12646. /// <summary>
  12647. /// 签证提成录入
  12648. /// Create
  12649. /// </summary>
  12650. /// <param name="_dto"></param>
  12651. /// <returns></returns>
  12652. [HttpPost]
  12653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12654. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12655. {
  12656. var validator = new VisaCommissionCreateDtoValidator();
  12657. var validatorRes = await validator.ValidateAsync(_dto);
  12658. if (!validatorRes.IsValid)
  12659. {
  12660. StringBuilder sb = new StringBuilder();
  12661. foreach (var item in validatorRes.Errors)
  12662. {
  12663. sb.AppendLine(item.ErrorMessage);
  12664. }
  12665. return Ok(JsonView(false, sb.ToString()));
  12666. }
  12667. return Ok(await _visaCommissionRep.Create(_dto));
  12668. }
  12669. /// <summary>
  12670. /// 签证提成录入
  12671. /// Put(编辑)
  12672. /// </summary>
  12673. /// <param name="id"></param>
  12674. /// <param name="_dto"></param>
  12675. /// <returns></returns>
  12676. [HttpPut]
  12677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12678. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12679. {
  12680. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12681. var validator = new VisaCommissionCreateDtoValidator();
  12682. var validatorRes = await validator.ValidateAsync(_dto);
  12683. if (!validatorRes.IsValid)
  12684. {
  12685. StringBuilder sb = new StringBuilder();
  12686. foreach (var item in validatorRes.Errors)
  12687. {
  12688. sb.AppendLine(item.ErrorMessage);
  12689. }
  12690. return Ok(JsonView(false, sb.ToString()));
  12691. }
  12692. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12693. }
  12694. /// <summary>
  12695. /// 签证提成录入
  12696. /// Del
  12697. /// </summary>
  12698. /// <param name="id"></param>
  12699. /// <param name="currUserId"></param>
  12700. /// <returns></returns>
  12701. [HttpPost]
  12702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12703. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12704. {
  12705. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12706. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12707. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12708. }
  12709. #endregion
  12710. #region op费用录入
  12711. /// <summary>
  12712. /// 根据diid查询op费用列表
  12713. /// </summary>
  12714. /// <param name="dto"></param>
  12715. /// <returns></returns>
  12716. [HttpPost]
  12717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12718. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12719. {
  12720. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12721. if (groupData.Code != 0)
  12722. {
  12723. return Ok(JsonView(false, groupData.Msg));
  12724. }
  12725. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12726. }
  12727. /// <summary>
  12728. /// 根据op费用Id查询单条数据及c表数据
  12729. /// </summary>
  12730. /// <param name="dto"></param>
  12731. /// <returns></returns>
  12732. [HttpPost]
  12733. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12734. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12735. {
  12736. try
  12737. {
  12738. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12739. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12740. var data = new
  12741. {
  12742. CarTouristGuideGround = _groupData,
  12743. CreditCardPayment = _creditCardPayment
  12744. };
  12745. return Ok(JsonView(true, "查询成功!", data));
  12746. }
  12747. catch (Exception ex)
  12748. {
  12749. return Ok(JsonView(false, "程序错误!"));
  12750. }
  12751. }
  12752. /// <summary>
  12753. /// op费用删除
  12754. /// </summary>
  12755. /// <param name="dto"></param>
  12756. /// <returns></returns>
  12757. [HttpPost]
  12758. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12759. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12760. {
  12761. try
  12762. {
  12763. _sqlSugar.BeginTran();
  12764. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12765. if (!res)
  12766. {
  12767. return Ok(JsonView(false, "删除失败"));
  12768. }
  12769. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12770. {
  12771. IsDel = 1,
  12772. DeleteUserId = dto.DeleteUserId,
  12773. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12774. }).ExecuteCommandAsync();
  12775. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12776. {
  12777. IsDel = 1,
  12778. DeleteUserId = dto.DeleteUserId,
  12779. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12780. }).ExecuteCommandAsync();
  12781. #region 删除超支相关数据
  12782. //删除导入的超支数据
  12783. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12784. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12785. {
  12786. IsDel = 1,
  12787. DeleteUserId = dto.DeleteUserId,
  12788. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12789. }).ExecuteCommand();
  12790. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12791. {
  12792. IsDel = 1,
  12793. DeleteUserId = dto.DeleteUserId,
  12794. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12795. }).ExecuteCommand();
  12796. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12797. {
  12798. IsDel = 1,
  12799. DeleteUserId = dto.DeleteUserId,
  12800. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12801. }).ExecuteCommand();
  12802. #endregion
  12803. _sqlSugar.CommitTran();
  12804. return Ok(JsonView(true, "删除成功!"));
  12805. }
  12806. catch (Exception ex)
  12807. {
  12808. _sqlSugar.RollbackTran();
  12809. return Ok(JsonView(false, "程序错误!" + ex.Message));
  12810. }
  12811. }
  12812. /// <summary>
  12813. /// op费用录入操作(Status:1.新增,2.修改)
  12814. /// </summary>
  12815. /// <param name="dto"></param>
  12816. /// <returns></returns>
  12817. [HttpPost]
  12818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12819. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  12820. {
  12821. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  12822. if (groupData.Code != 0)
  12823. {
  12824. return Ok(JsonView(false, groupData.Msg));
  12825. }
  12826. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12827. }
  12828. /// <summary>
  12829. /// 填写费用详细页面初始化绑定
  12830. /// </summary>
  12831. /// <param name="dto"></param>
  12832. /// <returns></returns>
  12833. [HttpPost]
  12834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12835. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  12836. {
  12837. try
  12838. {
  12839. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  12840. if (groupData.Code != 0)
  12841. {
  12842. return Ok(JsonView(false, groupData.Msg));
  12843. }
  12844. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12845. }
  12846. catch (Exception ex)
  12847. {
  12848. return Ok(JsonView(false, ex.Message));
  12849. }
  12850. }
  12851. /// <summary>
  12852. /// 根据op费用Id查询详细数据
  12853. /// </summary>
  12854. /// <param name="dto"></param>
  12855. /// <returns></returns>
  12856. [HttpPost]
  12857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12858. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  12859. {
  12860. try
  12861. {
  12862. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  12863. if (groupData.Code != 0)
  12864. {
  12865. return Ok(JsonView(false, groupData.Msg));
  12866. }
  12867. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12868. }
  12869. catch (Exception ex)
  12870. {
  12871. return Ok(JsonView(false, ex.Message));
  12872. }
  12873. }
  12874. /// <summary>
  12875. /// OP费用录入填写详情
  12876. /// </summary>
  12877. /// <param name="dto"></param>
  12878. /// <returns></returns>
  12879. [HttpPost]
  12880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12881. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  12882. {
  12883. try
  12884. {
  12885. #region 参数校验
  12886. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  12887. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  12888. if (di == null) return Ok(JsonView(false, "团组错误!"));
  12889. #endregion
  12890. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  12891. if (groupData.Code != 0)
  12892. {
  12893. return Ok(JsonView(false, groupData.Msg));
  12894. }
  12895. //自动审核
  12896. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  12897. #region 应用推送
  12898. try
  12899. {
  12900. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12901. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12902. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12903. //2024-10-21 新增LZ UID
  12904. var userIds = new List<int>() { 21 };
  12905. string title = $"系统通知";
  12906. var diId = dto.DiId;
  12907. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12908. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12909. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  12910. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12911. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  12912. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12913. }
  12914. catch (Exception ex)
  12915. {
  12916. }
  12917. #endregion
  12918. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12919. }
  12920. catch (Exception ex)
  12921. {
  12922. return Ok(JsonView(false, ex.Message));
  12923. }
  12924. }
  12925. /// <summary>
  12926. /// 获取三公详细所有城市
  12927. /// </summary>
  12928. /// <returns></returns>
  12929. [HttpGet]
  12930. public IActionResult OpCarCityResult()
  12931. {
  12932. var jw = JsonView(false);
  12933. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  12934. {
  12935. x.Id,
  12936. x.Country,
  12937. x.City,
  12938. }).ToList();
  12939. if (data.Count > 0)
  12940. {
  12941. jw = JsonView(true, "获取成功!", data);
  12942. }
  12943. else
  12944. {
  12945. jw.Msg = "城市数据为空!";
  12946. jw.Data = new string[0];
  12947. }
  12948. return Ok(jw);
  12949. }
  12950. /// <summary>
  12951. /// 导出地接费用明细
  12952. /// </summary>
  12953. /// <param name="dto"></param>
  12954. /// <returns></returns>
  12955. [HttpPost]
  12956. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  12957. {
  12958. var jw = JsonView(false);
  12959. if (dto.Diid < 1)
  12960. {
  12961. jw.Msg = "请输入正确的diid!";
  12962. return Ok(jw);
  12963. }
  12964. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12965. if (group == null)
  12966. {
  12967. jw.Msg = "未找到团组信息!";
  12968. return Ok(jw);
  12969. }
  12970. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12971. if (localGuideArr.Count == 0)
  12972. {
  12973. jw.Msg = "该团组暂无地接信息!";
  12974. return Ok(jw);
  12975. }
  12976. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  12977. var overspendSoure = new Dictionary<int, int>
  12978. {
  12979. { 91, 982 }, //车
  12980. { 92 , 1059} ,//导游
  12981. { 994 , 1073}, //翻译
  12982. { 988 , 1074 }, //早餐
  12983. { 93 , 1075 }, //午餐
  12984. { 989 , 1076 }, //晚餐
  12985. };
  12986. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  12987. foreach (var groupArr in localGroup)
  12988. {
  12989. var keyValue = groupArr.Key;
  12990. if (int.TryParse(keyValue, out int cityid))
  12991. {
  12992. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  12993. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  12994. }
  12995. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  12996. foreach (var item in groupArr)
  12997. {
  12998. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  12999. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  13000. new Grp_CarTouristGuideGroundReservationsContentExtend
  13001. {
  13002. Count = a.Count,
  13003. CreateTime = a.CreateTime,
  13004. CreateUserId = a.CreateUserId,
  13005. CTGGRId = a.CTGGRId,
  13006. Currency = a.Currency,
  13007. DatePrice = a.DatePrice,
  13008. DeleteTime = a.DeleteTime,
  13009. DeleteUserId = a.DeleteUserId,
  13010. DiId = a.DiId,
  13011. Id = a.Id,
  13012. IsDel = a.IsDel,
  13013. Price = a.Price,
  13014. PriceContent = a.PriceContent,
  13015. Remark = a.Remark,
  13016. SId = a.SId,
  13017. SidName = b.Name,
  13018. Units = a.Units,
  13019. }
  13020. ).ToList();
  13021. if (content.Count > 0)
  13022. {
  13023. contentArr.Add(content);
  13024. }
  13025. }
  13026. //open excel
  13027. //set excel
  13028. //save excel
  13029. try
  13030. {
  13031. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  13032. IWorkbook workbook;
  13033. if (Path.GetExtension(filePath).ToLower() == ".xls")
  13034. {
  13035. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13036. }
  13037. else
  13038. {
  13039. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13040. }
  13041. ISheet sheet = workbook.GetSheetAt(0);
  13042. var rowStartIndex = 2;
  13043. var clounmCount = 10;
  13044. var initStyleRow = sheet.GetRow(2);
  13045. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  13046. //var overspendArrDetail =
  13047. var existsId = new List<CarCompare>();
  13048. var lastElem = arr.Last();
  13049. var thisSid = -1;
  13050. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  13051. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  13052. {
  13053. Name = "未知币种!",
  13054. Remark = "未知币种!",
  13055. };
  13056. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  13057. Action cloneRowFn = () =>
  13058. {
  13059. rowStartIndex++;
  13060. var cloneRow = sheet.CreateRow(rowStartIndex);
  13061. // 复制样式
  13062. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  13063. {
  13064. ICell sourceCell = initStyleRow.GetCell(i);
  13065. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  13066. // 确保单元格存在样式
  13067. if (sourceCell.CellStyle != null)
  13068. {
  13069. targetCell.CellStyle = sourceCell.CellStyle;
  13070. }
  13071. }
  13072. };
  13073. var mergeRow = () =>
  13074. {
  13075. for (int i = 2; i < sheet.LastRowNum; i++)
  13076. {
  13077. var row = sheet.GetRow(i);
  13078. var cellFirst = row.GetCell(0);
  13079. var thisIndex = i + 1;
  13080. while (thisIndex < sheet.LastRowNum)
  13081. {
  13082. var nextRow = sheet.GetRow(thisIndex);
  13083. var nextCellFirst = nextRow.GetCell(0);
  13084. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  13085. {
  13086. thisIndex++;
  13087. }
  13088. else
  13089. {
  13090. break;
  13091. }
  13092. }
  13093. thisIndex--;
  13094. if (thisIndex != i)
  13095. {
  13096. //合并row
  13097. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  13098. i, // 起始行索引(0-based)
  13099. thisIndex, // 结束行索引(0-based)
  13100. 0, // 起始列索引(0-based)
  13101. 0 // 结束列索引(0-based)
  13102. );
  13103. sheet.AddMergedRegion(cellRangeAddress);
  13104. i = thisIndex;
  13105. }
  13106. }
  13107. };
  13108. var chaoshiNumber = 0;
  13109. var totalNumber = 0.00M;
  13110. string lastStr = "";
  13111. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  13112. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  13113. {
  13114. b.IsAuditGM,
  13115. x.Id,
  13116. x.Area,
  13117. b.PayPercentage,
  13118. b.PayMoney,
  13119. }).ToList();
  13120. string yesPayment = "", noPayment = "";
  13121. foreach (var item in queryCarArrByCityAndDiid)
  13122. {
  13123. if (item.IsAuditGM == 1)
  13124. {
  13125. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13126. }
  13127. else
  13128. {
  13129. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13130. }
  13131. }
  13132. lastStr = yesPayment + noPayment;
  13133. foreach (var item in arr)
  13134. {
  13135. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  13136. {
  13137. if (thisSid != item.SId)
  13138. {
  13139. if (thisSid == -1)
  13140. {
  13141. thisSid = item.SId;
  13142. }
  13143. else
  13144. {
  13145. //合并小计行
  13146. //创建合并区域的实例
  13147. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  13148. rowStartIndex, // 起始行索引(0-based)
  13149. rowStartIndex, // 结束行索引(0-based)
  13150. 0, // 起始列索引(0-based)
  13151. 3 // 结束列索引(0-based)
  13152. );
  13153. sheet.AddMergedRegion(cellRangeAddress);
  13154. var CellStyle = workbook.CreateCellStyle();
  13155. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13156. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13157. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13158. for (int i = 0; i <= clounmCount; i++)
  13159. {
  13160. if (i > 6)
  13161. {
  13162. var CellStyle1 = workbook.CreateCellStyle();
  13163. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13164. IFont Font = workbook.CreateFont(); // 创建字体
  13165. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13166. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13167. CellStyle1.SetFont(Font);
  13168. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13169. }
  13170. else
  13171. {
  13172. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13173. }
  13174. }
  13175. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13176. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13177. //超时合计
  13178. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13179. //超时数
  13180. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13181. //超时合计费用
  13182. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13183. thisSid = item.SId;
  13184. cloneRowFn();
  13185. chaoshiNumber = 0;
  13186. totalNumber = 0;
  13187. }
  13188. }
  13189. IRow row = sheet.GetRow(rowStartIndex);
  13190. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13191. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  13192. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13193. if (isOpenOverspendSoure)
  13194. {
  13195. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13196. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13197. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13198. }
  13199. for (int i = 0; i <= clounmCount; i++)
  13200. {
  13201. var cell = row.GetCell(i);
  13202. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13203. if (cell == null)
  13204. {
  13205. cell = row.CreateCell(i);
  13206. }
  13207. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13208. fontRed.CloneStyleFrom(cell.CellStyle);
  13209. IFont Font = workbook.CreateFont(); // 创建字体
  13210. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13211. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13212. fontRed.SetFont(Font);
  13213. byte[] rgb = new byte[3] { 255, 242, 204 };
  13214. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13215. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13216. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13217. if (workbook is XSSFWorkbook)
  13218. {
  13219. BackgroundColor255_242_204.FillForegroundColor = 0;
  13220. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13221. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13222. }
  13223. else
  13224. {
  13225. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13226. }
  13227. if (i == 1 || i > 6)
  13228. {
  13229. if (i > 6)
  13230. {
  13231. fontRed.FillForegroundColor = 0;
  13232. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13233. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13234. }
  13235. cell.CellStyle = fontRed;
  13236. }
  13237. if (i > 2 && i < 7)
  13238. {
  13239. cell.CellStyle = BackgroundColor255_242_204;
  13240. }
  13241. cell.SetCellValue(setCellValue); //写入单元格
  13242. }
  13243. if (overspendSoure.ContainsKey(thisSid))
  13244. {
  13245. var overspendId = overspendSoure[thisSid];
  13246. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13247. }
  13248. cloneRowFn();
  13249. existsId.Add(new CarCompare
  13250. {
  13251. DataPrice = item.DatePrice.ObjToDate(),
  13252. Sid = item.SId
  13253. });
  13254. }
  13255. if (item.Equals(lastElem))
  13256. {
  13257. //合并小计行
  13258. //创建合并区域的实例
  13259. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  13260. rowStartIndex, // 起始行索引(0-based)
  13261. rowStartIndex, // 结束行索引(0-based)
  13262. 0, // 起始列索引(0-based)
  13263. 3 // 结束列索引(0-based)
  13264. );
  13265. sheet.AddMergedRegion(cellRangeAddress);
  13266. var CellStyle = workbook.CreateCellStyle();
  13267. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13268. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13269. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13270. for (int i = 0; i <= clounmCount; i++)
  13271. {
  13272. if (i > 6)
  13273. {
  13274. var CellStyle1 = workbook.CreateCellStyle();
  13275. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13276. IFont Font = workbook.CreateFont(); // 创建字体
  13277. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13278. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13279. CellStyle1.SetFont(Font);
  13280. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13281. }
  13282. else
  13283. {
  13284. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13285. }
  13286. }
  13287. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13288. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13289. //超时合计
  13290. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13291. //超时数
  13292. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13293. //超时合计费用
  13294. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13295. cloneRowFn();
  13296. // 创建合并区域的实例
  13297. cellRangeAddress = new CellRangeAddress(
  13298. rowStartIndex, // 起始行索引(0-based)
  13299. rowStartIndex, // 结束行索引(0-based)
  13300. 0, // 起始列索引(0-based)
  13301. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13302. );
  13303. // 添加合并区域
  13304. sheet.AddMergedRegion(cellRangeAddress);
  13305. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13306. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13307. }
  13308. }
  13309. mergeRow();
  13310. // 保存修改后的Excel文件到新文件
  13311. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13312. // new FileStream(newFilePath, FileMode.CreateNew)
  13313. using (var stream = new MemoryStream())
  13314. {
  13315. workbook.Write(stream, true);
  13316. stream.Flush();
  13317. stream.Seek(0, SeekOrigin.Begin);
  13318. MemoryStream memoryStream = new MemoryStream();
  13319. stream.CopyTo(memoryStream);
  13320. memoryStream.Seek(0, SeekOrigin.Begin);
  13321. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13322. }
  13323. workbook.Close();
  13324. workbook.Dispose();
  13325. }
  13326. catch (Exception ex)
  13327. {
  13328. jw.Msg = "出现异常!" + ex.Message;
  13329. return Ok(jw);
  13330. }
  13331. }
  13332. if (Zips.Count > 0)
  13333. {
  13334. IOOperatorHelper io = new IOOperatorHelper();
  13335. var byts = io.ConvertZipStream(Zips);
  13336. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13337. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13338. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13339. }
  13340. else
  13341. {
  13342. jw.Msg = "暂无生成文件!";
  13343. }
  13344. return Ok(jw);
  13345. }
  13346. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13347. {
  13348. string outStr = string.Empty;
  13349. switch (i)
  13350. {
  13351. case 0:
  13352. outStr = arr[0].SidName;
  13353. break;
  13354. case 1:
  13355. outStr = arr[0].DataPriceStr;
  13356. break;
  13357. case 2:
  13358. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13359. break;
  13360. case 4:
  13361. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13362. break;
  13363. case 7:
  13364. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13365. {
  13366. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13367. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13368. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13369. }
  13370. break;
  13371. case 8:
  13372. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13373. {
  13374. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13375. }
  13376. break;
  13377. case 9:
  13378. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13379. {
  13380. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13381. }
  13382. break;
  13383. case 10:
  13384. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13385. {
  13386. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13387. }
  13388. break;
  13389. }
  13390. return outStr;
  13391. }
  13392. #region OP行程单
  13393. /// <summary>
  13394. /// OP行程单初始化
  13395. /// </summary>
  13396. /// <param name="dto"></param>
  13397. /// <returns></returns>
  13398. [HttpPost]
  13399. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13400. {
  13401. var jw = JsonView(false);
  13402. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13403. var group = groupList.First();
  13404. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13405. if (group == null)
  13406. {
  13407. jw.Msg = "暂无团组!";
  13408. return Ok(jw);
  13409. }
  13410. group = groupList.Find(x => x.Id == diid);
  13411. if (group == null)
  13412. {
  13413. jw.Msg = "请输入正确的团组ID!";
  13414. return Ok(jw);
  13415. }
  13416. string city = string.Empty;
  13417. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13418. if (blackCode.Count > 0)
  13419. {
  13420. var black = blackCode.First();
  13421. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  13422. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13423. if (blackSp.Length > 0)
  13424. {
  13425. try
  13426. {
  13427. var cityArrCode = new List<string>(20);
  13428. foreach (var item in blackSp)
  13429. {
  13430. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13431. var IndexSelect = itemSp[2];
  13432. var cityArrCodeLength = cityArrCode.Count - 1;
  13433. var startCity = IndexSelect.Substring(0, 3);
  13434. if (cityArrCodeLength > 0)
  13435. {
  13436. var arrEndCity = cityArrCode[cityArrCodeLength];
  13437. if (arrEndCity != startCity)
  13438. {
  13439. cityArrCode.Add(startCity.ToUpper());
  13440. }
  13441. }
  13442. else
  13443. {
  13444. cityArrCode.Add(startCity.ToUpper());
  13445. }
  13446. var endCity = IndexSelect.Substring(3, 3);
  13447. cityArrCode.Add(endCity.ToUpper());
  13448. }
  13449. var cityThree = string.Empty;
  13450. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13451. cityThree = cityThree.TrimEnd(',');
  13452. if (string.IsNullOrWhiteSpace(cityThree))
  13453. {
  13454. throw new
  13455. Exception("error");
  13456. }
  13457. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13458. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13459. foreach (var item in cityArrCode)
  13460. {
  13461. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13462. if (find != null)
  13463. {
  13464. city += find.City + "/";
  13465. }
  13466. else
  13467. {
  13468. city += item + "三字码未收入/";
  13469. }
  13470. }
  13471. city = city.TrimEnd('/');
  13472. }
  13473. catch (Exception e)
  13474. {
  13475. city = "黑屏代码格式不正确!";
  13476. }
  13477. }
  13478. }
  13479. else
  13480. {
  13481. city = "未录入黑屏代码";
  13482. }
  13483. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13484. {
  13485. Date = x.Date,
  13486. Days = x.Days,
  13487. Diffgroup = x.Diffgroup,
  13488. Diid = x.Diid,
  13489. Traffic_First = x.Traffic_First,
  13490. Traffic_Second = x.Traffic_Second,
  13491. Trip = x.Trip,
  13492. WeekDay = x.WeekDay,
  13493. Id = x.Id
  13494. }).ToList();
  13495. jw.Data = new
  13496. {
  13497. groupList = groupList.Select(x => new
  13498. {
  13499. x.Id,
  13500. x.TeamName,
  13501. x.TourCode
  13502. }).ToList(),
  13503. groupInfo = new
  13504. {
  13505. group.VisitDays,
  13506. group.TourCode,
  13507. group.VisitPNumber,
  13508. group.TeamName,
  13509. city
  13510. },
  13511. OpTravelList
  13512. };
  13513. jw.Code = 200;
  13514. jw.Msg = "操作成功!";
  13515. return Ok(jw);
  13516. }
  13517. /// <summary>
  13518. /// 删除团组行程单
  13519. /// </summary>
  13520. /// <returns></returns>
  13521. [HttpPost]
  13522. public IActionResult DelTravel(DelOpTravelDto dto)
  13523. {
  13524. var jw = JsonView(false);
  13525. if (dto.UserId <= 0 || dto.Diid <= 0)
  13526. {
  13527. jw.Msg = "请输入正确的参数!";
  13528. return Ok(jw);
  13529. }
  13530. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13531. .SetColumns(x => new Grp_TravelList
  13532. {
  13533. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13534. DeleteUserId = dto.UserId,
  13535. IsDel = 1,
  13536. }).ExecuteCommand();
  13537. jw = JsonView(true);
  13538. return Ok(jw);
  13539. }
  13540. /// <summary>
  13541. /// 行程单保存
  13542. /// </summary>
  13543. /// <returns></returns>
  13544. [HttpPost]
  13545. public IActionResult TravelSave(TravelSaveDto dto)
  13546. {
  13547. var jw = JsonView(false);
  13548. if (dto.Arr.Count > 0)
  13549. {
  13550. try
  13551. {
  13552. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13553. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13554. .ToList();
  13555. _sqlSugar.BeginTran();
  13556. foreach (var item in dto.Arr)
  13557. {
  13558. if (item.Id == 0)
  13559. {
  13560. throw new Exception("请传入正确的Id");
  13561. }
  13562. //比较上一次的差异
  13563. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13564. if (findTravel != null)
  13565. {
  13566. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13567. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13568. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13569. }
  13570. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13571. .SetColumns(x => new Grp_TravelList
  13572. {
  13573. Trip = item.Trip
  13574. }).ExecuteCommand();
  13575. }
  13576. _sqlSugar.CommitTran();
  13577. jw = JsonView(true);
  13578. }
  13579. catch (Exception ex)
  13580. {
  13581. _sqlSugar.RollbackTran();
  13582. jw.Msg = "程序异常!" + ex.Message;
  13583. }
  13584. }
  13585. else
  13586. {
  13587. jw.Msg = "请传入正确的参数!";
  13588. }
  13589. return Ok(jw);
  13590. }
  13591. private string CheckStr(string original, string changed)
  13592. {
  13593. // 创建diff_match_patch对象
  13594. var dmp = new diff_match_patch();
  13595. // 计算差异
  13596. List<Diff> diffs = dmp.diff_main(original, changed);
  13597. // 清理和合并差异
  13598. dmp.diff_cleanupSemantic(diffs);
  13599. // 使用StringBuilder构建最终的字符串
  13600. StringBuilder finalString = new StringBuilder();
  13601. // 输出差异结果,并构建变动后的字符串
  13602. foreach (Diff diff in diffs)
  13603. {
  13604. switch (diff.operation)
  13605. {
  13606. case Operation.EQUAL:
  13607. // 相等的部分,直接添加到最终字符串
  13608. finalString.Append(diff.text);
  13609. break;
  13610. case Operation.INSERT:
  13611. // 插入的部分,添加标记并添加到最终字符串
  13612. finalString.Append("[++]" + diff.text + "[++]");
  13613. break;
  13614. case Operation.DELETE:
  13615. // 删除的部分,不添加到最终字符串
  13616. //finalString.Append("[++]" + diff.text + "[++]");
  13617. break;
  13618. }
  13619. }
  13620. // 输出变动后的字符串
  13621. return finalString.ToString();
  13622. }
  13623. private class tagContent
  13624. {
  13625. public DateTime Date { get; set; }
  13626. public string StartTag { get; set; }
  13627. public string EndTag { get; set; }
  13628. public string Content { get; set; }
  13629. public static int tagLength { get { return 3; } }
  13630. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13631. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13632. public bool IsFinally { get; set; }
  13633. }
  13634. private List<string> ExtractContentBetweenTags(string input, string tag)
  13635. {
  13636. List<string> results = new List<string>();
  13637. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13638. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13639. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13640. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13641. string[] strValueArr = new string[1];
  13642. foreach (System.Text.RegularExpressions.Match match in matches)
  13643. {
  13644. var strValue = match.Groups[1].Value;
  13645. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13646. }
  13647. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13648. return results;
  13649. }
  13650. /// <summary>
  13651. /// 导出行程单
  13652. /// </summary>
  13653. /// <param name="dto"></param>
  13654. /// <returns></returns>
  13655. [HttpPost]
  13656. public IActionResult ExportTravel(ExportTravelDto dto)
  13657. {
  13658. var jw = JsonView(false);
  13659. jw.Data = "";
  13660. int diid = 0;
  13661. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13662. if (Find == null)
  13663. {
  13664. jw.Msg = "请选择正确的团组!";
  13665. return Ok(jw);
  13666. }
  13667. else
  13668. {
  13669. diid = Find.Id;
  13670. }
  13671. //数据源
  13672. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  13673. DataTable dtBlack = null;
  13674. try
  13675. {
  13676. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13677. }
  13678. catch (Exception)
  13679. {
  13680. jw.Msg = "机票黑屏代码有误!";
  13681. return Ok(jw);
  13682. }
  13683. string CityStr = string.Empty;
  13684. if (dtBlack.Rows.Count == 0)
  13685. {
  13686. jw.Msg = "机票黑屏代码有误!";
  13687. return Ok(jw);
  13688. }
  13689. else
  13690. {
  13691. foreach (DataRow row in dtBlack.Rows)
  13692. {
  13693. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13694. {
  13695. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13696. return Ok(jw);
  13697. }
  13698. }
  13699. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13700. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13701. }
  13702. // 指定的文字
  13703. var targetTextDic = new Dictionary<string, List<string>>();
  13704. //创建数据源Table
  13705. DataTable dtSource = new DataTable();
  13706. dtSource.Columns.Add("Days", typeof(string));
  13707. dtSource.Columns.Add("Date", typeof(string));
  13708. dtSource.Columns.Add("Week", typeof(string));
  13709. dtSource.Columns.Add("Traffic", typeof(string));
  13710. dtSource.Columns.Add("Trip", typeof(string));
  13711. //获取数据,放到datatable
  13712. foreach (var item in _travelList)
  13713. {
  13714. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13715. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13716. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13717. .Replace("[++]", string.Empty);
  13718. DataRow dr = dtSource.NewRow();
  13719. dr["Days"] = item.Days;
  13720. dr["Date"] = item.Date;
  13721. dr["Week"] = item.WeekDay;
  13722. dr["Traffic"] = item.Traffic_First
  13723. + "\r\n"
  13724. + item.Traffic_Second;
  13725. dr["Trip"] = item.Trip;
  13726. dtSource.Rows.Add(dr);
  13727. }
  13728. Dictionary<string, string> dic = new Dictionary<string, string>();
  13729. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  13730. dic.Add("City", CityStr);
  13731. dic.Add("Days", Find.VisitDays.ToString());
  13732. dic.Add("DeleCode", Find.TourCode);
  13733. dic.Add("Pnum", Find.VisitPNumber.ToString());
  13734. //模板路径
  13735. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13736. //载入模板
  13737. Document doc = null;
  13738. DocumentBuilder builder = null;
  13739. try
  13740. {
  13741. //载入模板
  13742. doc = new Document(tempPath);
  13743. builder = new DocumentBuilder(doc);
  13744. }
  13745. catch (Exception)
  13746. {
  13747. jw.Msg = "模板位置不存在!";
  13748. return Ok(jw);
  13749. }
  13750. foreach (var key in dic.Keys)
  13751. {
  13752. Bookmark bookmark = doc.Range.Bookmarks[key];
  13753. if (bookmark != null)
  13754. {
  13755. builder.MoveToBookmark(key);
  13756. builder.Write(dic[key]);
  13757. }
  13758. }
  13759. //获取word里所有表格
  13760. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13761. //获取所填表格的序数
  13762. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13763. try
  13764. {
  13765. //循环赋值
  13766. for (int i = 0; i < dtSource.Rows.Count; i++)
  13767. {
  13768. builder.MoveToCell(0, i + 1, 0, 0);
  13769. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13770. builder.MoveToCell(0, i + 1, 1, 0);
  13771. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13772. builder.MoveToCell(0, i + 1, 2, 0);
  13773. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13774. var trip = dtSource.Rows[i]["Trip"].ToString();
  13775. builder.MoveToCell(0, i + 1, 3, 0);
  13776. builder.Write(trip);
  13777. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13778. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13779. // 获取特定索引的段落
  13780. Paragraph paragraph = (Paragraph)paragraphs[0];
  13781. Run run = paragraph.Runs[0];
  13782. Aspose.Words.Font font = run.Font;
  13783. font.Name = "黑体";
  13784. //设置双休红色
  13785. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13786. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13787. paragraph = (Paragraph)paragraphs[1];
  13788. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13789. {
  13790. run = paragraph.Runs[0];
  13791. font = run.Font;
  13792. font.Color = Color.Red;
  13793. }
  13794. }
  13795. }
  13796. catch (Exception ex)
  13797. {
  13798. }
  13799. //删除多余行
  13800. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  13801. {
  13802. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  13803. }
  13804. var targetTextList = new List<string>();
  13805. // 遍历文档中的表格
  13806. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13807. {
  13808. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13809. {
  13810. var cellIndex = 0;
  13811. foreach (Cell cell in row.Cells)
  13812. {
  13813. if (cellIndex == 1 && row.Cells.Count == 4)
  13814. {
  13815. foreach (var target in targetTextDic.Keys)
  13816. {
  13817. if (cell.GetText().Contains(target))
  13818. {
  13819. targetTextList = targetTextDic[target];
  13820. break;
  13821. }
  13822. }
  13823. }
  13824. // 遍历单元格中的所有段落
  13825. foreach (Paragraph paragraph in cell.Paragraphs)
  13826. {
  13827. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  13828. List<Run> runs = new List<Run>();
  13829. foreach (Run run in paragraph.Runs)
  13830. {
  13831. runs.Add(run);
  13832. }
  13833. foreach (Run run in runs)
  13834. {
  13835. foreach (var targetText in targetTextList)
  13836. {
  13837. // 检查文字是否包含指定文字
  13838. if (run.Text.Contains(targetText))
  13839. {
  13840. // 将包含的部分设置为红色
  13841. HighlightText(run, targetText, Color.Red);
  13842. }
  13843. }
  13844. }
  13845. }
  13846. cellIndex++;
  13847. }
  13848. }
  13849. }
  13850. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  13851. if (!Directory.Exists(savePath))
  13852. {
  13853. try
  13854. {
  13855. Directory.CreateDirectory(savePath);
  13856. }
  13857. catch
  13858. {
  13859. }
  13860. }
  13861. string path = savePath + Find.TeamName + "出访日程";
  13862. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  13863. try
  13864. {
  13865. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  13866. string postfix = ".docx";
  13867. if (dto.IsPDF == 1)
  13868. {
  13869. saveFormat = Aspose.Words.SaveFormat.Pdf;
  13870. postfix = ".pdf";
  13871. }
  13872. doc.Save(path + postfix, saveFormat);
  13873. jw = JsonView(true, "导出成功", ftpPath + postfix);
  13874. }
  13875. catch (Exception)
  13876. {
  13877. jw = JsonView(false);
  13878. }
  13879. return Ok(jw);
  13880. }
  13881. /// <summary>
  13882. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  13883. /// </summary>
  13884. /// <param name="num"></param>
  13885. /// <returns></returns>
  13886. string GetNum(string num)
  13887. {
  13888. string str = "";
  13889. switch (num)
  13890. {
  13891. case "1":
  13892. str = "一";
  13893. break;
  13894. case "2":
  13895. str = "二";
  13896. break;
  13897. case "3":
  13898. str = "三";
  13899. break;
  13900. case "4":
  13901. str = "四";
  13902. break;
  13903. case "5":
  13904. str = "五";
  13905. break;
  13906. case "6":
  13907. str = "六";
  13908. break;
  13909. case "7":
  13910. str = "七";
  13911. break;
  13912. case "8":
  13913. str = "八";
  13914. break;
  13915. case "9":
  13916. str = "九";
  13917. break;
  13918. case "10":
  13919. str = "十";
  13920. break;
  13921. case "11":
  13922. str = "十一";
  13923. break;
  13924. case "12":
  13925. str = "十二";
  13926. break;
  13927. case "一":
  13928. str = "1";
  13929. break;
  13930. case "二":
  13931. str = "2";
  13932. break;
  13933. case "三":
  13934. str = "3";
  13935. break;
  13936. case "四":
  13937. str = "4";
  13938. break;
  13939. case "五":
  13940. str = "5";
  13941. break;
  13942. case "六":
  13943. str = "6";
  13944. break;
  13945. case "七":
  13946. str = "7";
  13947. break;
  13948. case "八":
  13949. str = "8";
  13950. break;
  13951. case "九":
  13952. str = "9";
  13953. break;
  13954. case "十":
  13955. str = "10";
  13956. break;
  13957. case "十一":
  13958. str = "11";
  13959. break;
  13960. case "十二":
  13961. str = "12";
  13962. break;
  13963. }
  13964. return str;
  13965. }
  13966. // 高亮包含指定文字的部分
  13967. void HighlightText(Run run, string targetText, Color color)
  13968. {
  13969. string text = run.Text;
  13970. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  13971. if (startIndex >= 0)
  13972. {
  13973. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  13974. // 前部分
  13975. if (startIndex > 0)
  13976. {
  13977. Run beforeRun = (Run)run.Clone(true);
  13978. beforeRun.Text = text.Substring(0, startIndex);
  13979. parentParagraph.InsertBefore(beforeRun, run);
  13980. }
  13981. // 匹配部分
  13982. Run matchRun = (Run)run.Clone(true);
  13983. matchRun.Text = text.Substring(startIndex, targetText.Length);
  13984. matchRun.Font.Color = color;
  13985. parentParagraph.InsertBefore(matchRun, run);
  13986. // 后部分
  13987. if (startIndex + targetText.Length < text.Length)
  13988. {
  13989. Run afterRun = (Run)run.Clone(true);
  13990. afterRun.Text = text.Substring(startIndex + targetText.Length);
  13991. parentParagraph.InsertBefore(afterRun, run);
  13992. }
  13993. // 删除原始Run
  13994. run.Remove();
  13995. }
  13996. }
  13997. #endregion
  13998. #endregion
  13999. #region 团组成本
  14000. /// <summary>
  14001. /// 团组成本数据初始化
  14002. /// </summary>
  14003. /// <param name="dto"></param>
  14004. /// <returns></returns>
  14005. [HttpPost]
  14006. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  14007. {
  14008. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14009. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14010. WHEN COUNT(*) >= 0 THEN 'True'
  14011. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14012. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14013. ").ToList(); //团组列表
  14014. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  14015. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  14016. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  14017. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  14018. if (groupinfoValue != null)
  14019. {
  14020. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  14021. var spArr = new string[1] { countryArr };
  14022. if (countryArr.Contains("|"))
  14023. {
  14024. spArr = countryArr.Split("|");
  14025. }
  14026. else if (countryArr.Contains("、"))
  14027. {
  14028. spArr = countryArr.Split("、");
  14029. }
  14030. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  14031. {
  14032. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  14033. if (dbQueryCountry != null)
  14034. {
  14035. visaCountryInfoArr.Add(dbQueryCountry);
  14036. }
  14037. }
  14038. }
  14039. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  14040. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  14041. #region 屏蔽黑屏代码生成
  14042. //var create = _GroupCostRepository.
  14043. // CreateGroupCostByBlackCode(dto.Diid);
  14044. //if (groupCost.Count == 0 && create.Code == 0)
  14045. //{
  14046. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  14047. //}
  14048. #endregion
  14049. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  14050. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  14051. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  14052. groupCostMap = groupCostMap.Select(x =>
  14053. {
  14054. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  14055. {
  14056. x.Date = dataForamt.ToString("yyyy-MM-dd");
  14057. }
  14058. return x;
  14059. }).ToList();
  14060. //GroupCostParameter.Add(new
  14061. // Grp_GroupCostParameter());
  14062. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  14063. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  14064. return Ok(JsonView(new
  14065. {
  14066. groupList,
  14067. groupInfo,
  14068. groupChecks,
  14069. groupCost = groupCostMap,
  14070. hotelNumber,
  14071. GroupCostParameter = GroupCostParameterMap,
  14072. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  14073. {
  14074. x.VisaCountry,
  14075. x.VisaPrice,
  14076. x.Id,
  14077. }).ToList(),
  14078. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  14079. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  14080. hotelIsTrue = hotelIsTrue,
  14081. }));
  14082. }
  14083. /// <summary>
  14084. /// 团组成本信息保存
  14085. /// </summary>
  14086. /// <param name="dto"></param>
  14087. /// <returns></returns>
  14088. [HttpPost]
  14089. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  14090. {
  14091. if (dto.Diid <= 0 || dto.Userid <= 0)
  14092. {
  14093. return Ok(JsonView(false));
  14094. }
  14095. JsonView jw = null;
  14096. bool isTrue = false;
  14097. #region 复制团组成本
  14098. //if (dto.Diid == 2581)
  14099. //{
  14100. // dto.Diid = 2599;
  14101. // dto.CheckBoxs.ForEach(x =>
  14102. // {
  14103. // x.Diid = 2599;
  14104. // });
  14105. // dto.GroupCosts.ForEach(x =>
  14106. // {
  14107. // x.Diid = 2599;
  14108. // });
  14109. // dto.CostTypeHotelNumbers.ForEach(x =>
  14110. // {
  14111. // x.Diid = 2599;
  14112. // });
  14113. // dto.GroupCostParameters.ForEach(x =>
  14114. // {
  14115. // x.DiId = 2599;
  14116. // });
  14117. //}
  14118. #endregion
  14119. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14120. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14121. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14122. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14123. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14124. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14125. try
  14126. {
  14127. _sqlSugar.BeginTran();
  14128. isTrue = await _GroupCostRepository.
  14129. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14130. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14131. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14132. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14133. _sqlSugar.CommitTran();
  14134. jw = JsonView(true, "保存成功!", isTrue);
  14135. }
  14136. catch (Exception)
  14137. {
  14138. _sqlSugar.RollbackTran();
  14139. jw = JsonView(false);
  14140. }
  14141. return Ok(jw);
  14142. }
  14143. /// <summary>
  14144. /// 复制团组成本信息
  14145. /// </summary>
  14146. /// <param name="dto"></param>
  14147. /// <returns></returns>
  14148. [HttpPost]
  14149. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14150. {
  14151. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14152. {
  14153. return Ok(JsonView(false, "参数有误!"));
  14154. }
  14155. #region 复制团组成本
  14156. dto.Diid = dto.ToGroupId;
  14157. dto.CheckBoxs.ForEach(x =>
  14158. {
  14159. x.Diid = dto.ToGroupId;
  14160. });
  14161. dto.GroupCosts.ForEach(x =>
  14162. {
  14163. x.Diid = dto.ToGroupId;
  14164. });
  14165. dto.CostTypeHotelNumbers.ForEach(x =>
  14166. {
  14167. x.Diid = dto.ToGroupId;
  14168. });
  14169. dto.GroupCostParameters.ForEach(x =>
  14170. {
  14171. x.DiId = dto.ToGroupId;
  14172. });
  14173. #endregion
  14174. JsonView jw = null;
  14175. bool isTrue = false;
  14176. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14177. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14178. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14179. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14180. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14181. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14182. try
  14183. {
  14184. _sqlSugar.BeginTran();
  14185. isTrue = await _GroupCostRepository.
  14186. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14187. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14188. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14189. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14190. _sqlSugar.CommitTran();
  14191. jw = JsonView(true, "保存成功!", isTrue);
  14192. }
  14193. catch (Exception)
  14194. {
  14195. _sqlSugar.RollbackTran();
  14196. jw = JsonView(false);
  14197. }
  14198. return Ok(jw);
  14199. }
  14200. /// <summary>
  14201. /// 司兼导数据
  14202. /// </summary>
  14203. /// <param name="dto"></param>
  14204. /// <returns></returns>
  14205. [HttpPost]
  14206. public IActionResult GetCarGuides(CarGuidesDto dto)
  14207. {
  14208. JsonView jw = null;
  14209. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14210. jw = JsonView(true, "获取成功!", Data);
  14211. return Ok(jw);
  14212. }
  14213. /// <summary>
  14214. /// 导游数据
  14215. /// </summary>
  14216. /// <param name="dto"></param>
  14217. /// <returns></returns>
  14218. [HttpPost]
  14219. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14220. {
  14221. JsonView jw = null;
  14222. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14223. // 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
  14224. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14225. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14226. jw = JsonView(true, "获取成功!", Data);
  14227. return Ok(jw);
  14228. }
  14229. /// <summary>
  14230. /// 成本车数据
  14231. /// </summary>
  14232. /// <param name="dto"></param>
  14233. /// <returns></returns>
  14234. [HttpPost]
  14235. public IActionResult GetCarInfo(CarGuidesDto dto)
  14236. {
  14237. JsonView jw = null;
  14238. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14239. jw = JsonView(true, "获取成功!", Data);
  14240. return Ok(jw);
  14241. }
  14242. /// <summary>
  14243. /// 景点数据
  14244. /// </summary>
  14245. /// <param name="dto"></param>
  14246. /// <returns></returns>
  14247. [HttpPost]
  14248. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14249. {
  14250. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14251. return Ok(JsonView(true, "获取成功!", Data));
  14252. }
  14253. /// <summary>
  14254. /// 成本通知
  14255. /// </summary>
  14256. /// <param name="dto"></param>
  14257. /// <returns></returns>
  14258. [HttpPost]
  14259. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14260. {
  14261. if (dto.Diid < 0)
  14262. {
  14263. return Ok(JsonView(false));
  14264. }
  14265. JsonView jw = null;
  14266. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14267. if (GroupCostParameter != null)
  14268. {
  14269. int IsShare = 0;
  14270. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14271. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14272. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14273. string msg = string.Empty;
  14274. if (isTrue)
  14275. {
  14276. if (IsShare == 0)
  14277. {
  14278. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14279. }
  14280. else
  14281. {
  14282. #region 企微通知对应岗位用户
  14283. try
  14284. {
  14285. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14286. }
  14287. catch (Exception ex)
  14288. {
  14289. }
  14290. #endregion
  14291. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14292. }
  14293. jw = JsonView(isTrue, msg, new { IsShare });
  14294. }
  14295. else
  14296. {
  14297. msg = "修改失败!";
  14298. jw = JsonView(isTrue, msg);
  14299. }
  14300. }
  14301. else
  14302. {
  14303. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14304. }
  14305. return Ok(jw);
  14306. }
  14307. /// <summary>
  14308. /// 导出报价单
  14309. /// </summary>
  14310. /// <param name="dto"></param>
  14311. /// <returns></returns>
  14312. [HttpPost]
  14313. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14314. {
  14315. if (dto.Diid == 0)
  14316. {
  14317. return Ok(JsonView(false, "请传递团组id"));
  14318. }
  14319. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14320. if (deleInfo.Code != 0)
  14321. {
  14322. return Ok(JsonView(false, "团组信息查询失败!"));
  14323. }
  14324. var di = deleInfo.Data as DelegationInfoWebView;
  14325. if (di != null)
  14326. {
  14327. di.TeamName = di.TeamName.Replace("|", "、");
  14328. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14329. //文件名
  14330. string strFileName = di.TeamName + "-收款账单.doc";
  14331. //获取模板
  14332. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14333. //载入模板
  14334. Document doc = new Document(tmppath);
  14335. decimal TotalPrice = 0.00M;
  14336. string itemStr = string.Empty;
  14337. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14338. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14339. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14340. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14341. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14342. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14343. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14344. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14345. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14346. foreach (var cost in groupCostType)
  14347. {
  14348. var List = cost.ToList();
  14349. if (cost.Key == "A")
  14350. {
  14351. foreach (var ListItem in List)
  14352. {
  14353. if (ListItem.number > 0)
  14354. {
  14355. if (ListItem.code.Contains("TBR"))
  14356. {
  14357. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14358. }
  14359. else
  14360. {
  14361. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14362. }
  14363. TotalPrice += (ListItem.number * ListItem.price);
  14364. }
  14365. }
  14366. }
  14367. else
  14368. {
  14369. itemStr = itemStr.Insert(0, "A段\r\n");
  14370. itemStr += "B段\r\n";
  14371. foreach (var ListItem in List)
  14372. {
  14373. if (ListItem.number > 0)
  14374. {
  14375. if (ListItem.code.Contains("TBR"))
  14376. {
  14377. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14378. }
  14379. else
  14380. {
  14381. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14382. }
  14383. TotalPrice += (ListItem.number * ListItem.price);
  14384. }
  14385. }
  14386. }
  14387. }
  14388. #region 替换Word模板书签内容
  14389. Dictionary<string, string> marks = new Dictionary<string, string>();
  14390. marks.Add("To", di.ClientUnit);//付款方
  14391. marks.Add("ToTel", di.TellPhone);//付款方电话
  14392. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14393. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14394. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14395. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14396. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14397. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14398. marks.Add("PayItemContent", itemStr);//详细信息
  14399. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14400. #endregion
  14401. ////注
  14402. //if (doc.Range.Bookmarks["Attention"] != null)
  14403. //{
  14404. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14405. // mark.Text = frList[0].Attention;
  14406. //}
  14407. foreach (var item in marks.Keys)
  14408. {
  14409. if (doc.Range.Bookmarks[item] != null)
  14410. {
  14411. Bookmark mark = doc.Range.Bookmarks[item];
  14412. mark.Text = marks[item];
  14413. }
  14414. }
  14415. byte[] bytes = null;
  14416. using (MemoryStream stream = new MemoryStream())
  14417. {
  14418. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14419. bytes = stream.ToArray();
  14420. }
  14421. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14422. return Ok(JsonView(true, "", new
  14423. {
  14424. Data = bytes,
  14425. strFileName,
  14426. }));
  14427. }
  14428. else
  14429. {
  14430. return Ok(JsonView(false, "团组信息不存在!"));
  14431. }
  14432. }
  14433. /// <summary>
  14434. /// 导出团组成本
  14435. /// </summary>
  14436. /// <param name="dto"></param>
  14437. /// <returns></returns>
  14438. [HttpPost]
  14439. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14440. {
  14441. var jw = JsonView(false);
  14442. if (dto.Diid == 0)
  14443. {
  14444. return Ok(JsonView(false, "请传递团组id"));
  14445. }
  14446. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14447. if (deleInfo.Code != 0)
  14448. {
  14449. return Ok(JsonView(false, "团组信息查询失败!"));
  14450. }
  14451. var di = deleInfo.Data as DelegationInfoWebView;
  14452. if (di == null)
  14453. {
  14454. return Ok(JsonView(false, "团组信息查询失败!"));
  14455. }
  14456. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14457. WorkbookDesigner designer = new WorkbookDesigner();
  14458. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14459. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14460. for (int i = 0; i < List_GC.Count; i++)
  14461. {
  14462. GroupCost_Excel gc = new GroupCost_Excel();
  14463. gc.Id = List_GC[i].Id;
  14464. gc.Diid = List_GC[i].Diid.ToString();
  14465. gc.DAY = List_GC[i].DAY;
  14466. string week = "";
  14467. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14468. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14469. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14470. gc.ITIN = List_GC[i].ITIN;
  14471. gc.CarType = List_GC[i].CarType;
  14472. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  14473. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  14474. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  14475. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  14476. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  14477. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  14478. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  14479. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  14480. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  14481. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  14482. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  14483. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  14484. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14485. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14486. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  14487. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  14488. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  14489. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  14490. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  14491. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  14492. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  14493. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  14494. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  14495. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  14496. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  14497. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  14498. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  14499. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  14500. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  14501. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  14502. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  14503. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  14504. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  14505. List_GC1.Add(gc);
  14506. }
  14507. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  14508. dt.TableName = "TB";
  14509. //报表标题等不用dt的值
  14510. designer.SetDataSource("TeamName", dto.title.TeamName);
  14511. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  14512. designer.SetDataSource("Tax", dto.title.Tax);
  14513. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  14514. designer.SetDataSource("Currency", dto.title.Currency);
  14515. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  14516. designer.SetDataSource("Rate", dto.title.Rate);
  14517. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  14518. var Aparams = hotels.Find(x => x.Type == "Default");
  14519. if (Aparams == null)
  14520. {
  14521. return Ok(jw);
  14522. }
  14523. //酒店数量
  14524. var txtSGRNumber = Aparams.SGR.ToString();
  14525. var txtTBRNumber = Aparams.TBR.ToString();
  14526. var txtJSESNumber = Aparams.JSES.ToString();
  14527. var txtSUITENumbe = Aparams.SUITE.ToString();
  14528. if (dto.costType == "B")
  14529. {
  14530. Aparams = hotels.Find(x => x.Type == "A");
  14531. var Bparams = hotels.Find(x => x.Type == "B");
  14532. if (Aparams == null || Bparams == null)
  14533. {
  14534. return Ok(jw);
  14535. }
  14536. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  14537. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  14538. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  14539. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  14540. }
  14541. designer.SetDataSource("SGRNumber", txtSGRNumber);
  14542. designer.SetDataSource("TBRNumber", txtTBRNumber);
  14543. designer.SetDataSource("JSESNumber", txtJSESNumber);
  14544. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  14545. var ws = designer.Workbook.Worksheets[0];
  14546. int Row = List_GC.Count;
  14547. int startIndex = 11;
  14548. int HideRows = 0;
  14549. List<int> hideRowsList = new List<int>();
  14550. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14551. #region A段left数据
  14552. var left = dto.leftInfo.Find(x => x.Type == "A");
  14553. if (left == null)
  14554. {
  14555. return Ok(jw);
  14556. }
  14557. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14558. if (leftBindData != null)
  14559. {
  14560. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14561. designer.SetDataSource("VisaRS", leftBindData.rs);
  14562. designer.SetDataSource("VisaXS", leftBindData.xs);
  14563. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14564. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14565. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14566. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14567. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14568. }
  14569. else
  14570. {
  14571. hideRowsList.Add(Row + startIndex + HideRows);
  14572. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14573. }
  14574. HideRows += 2;
  14575. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14576. if (leftBindData != null)
  14577. {
  14578. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14579. designer.SetDataSource("BXRS", leftBindData.rs);
  14580. designer.SetDataSource("BXXS", leftBindData.xs);
  14581. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14582. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14583. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14584. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14585. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14586. }
  14587. else
  14588. {
  14589. hideRowsList.Add(Row + startIndex + HideRows);
  14590. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14591. }
  14592. HideRows += 2;
  14593. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14594. if (leftBindData != null)
  14595. {
  14596. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14597. designer.SetDataSource("HSRS", leftBindData.rs);
  14598. designer.SetDataSource("HSXS", leftBindData.xs);
  14599. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14600. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14601. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14602. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14603. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14604. }
  14605. else
  14606. {
  14607. hideRowsList.Add(Row + startIndex + HideRows);
  14608. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14609. }
  14610. HideRows += 2;
  14611. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14612. if (leftBindData != null)
  14613. {
  14614. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14615. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14616. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14617. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14618. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14619. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14620. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14621. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14622. }
  14623. else
  14624. {
  14625. hideRowsList.Add(Row + startIndex + HideRows);
  14626. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14627. }
  14628. HideRows += 2;
  14629. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14630. if (leftBindData != null)
  14631. {
  14632. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14633. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14634. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14635. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14636. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14637. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14638. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14639. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14640. }
  14641. else
  14642. {
  14643. hideRowsList.Add(Row + startIndex + HideRows);
  14644. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14645. }
  14646. HideRows += 2;
  14647. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14648. if (leftBindData != null)
  14649. {
  14650. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14651. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14652. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14653. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14654. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14655. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14656. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14657. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14658. }
  14659. else
  14660. {
  14661. hideRowsList.Add(Row + startIndex + HideRows);
  14662. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14663. }
  14664. HideRows += 2;
  14665. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14666. if (leftBindData != null)
  14667. {
  14668. ////TBR
  14669. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14670. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14671. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14672. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14673. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14674. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14675. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14676. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14677. }
  14678. else
  14679. {
  14680. hideRowsList.Add(Row + startIndex + HideRows);
  14681. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14682. }
  14683. HideRows += 2;
  14684. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14685. if (leftBindData != null)
  14686. {
  14687. ////SGR
  14688. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  14689. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  14690. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  14691. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14692. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14693. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14694. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14695. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14696. }
  14697. else
  14698. {
  14699. hideRowsList.Add(Row + startIndex + HideRows);
  14700. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14701. }
  14702. HideRows += 2;
  14703. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14704. if (leftBindData != null)
  14705. {
  14706. ////JS/ES
  14707. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  14708. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  14709. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  14710. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14711. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14712. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14713. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14714. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14715. }
  14716. else
  14717. {
  14718. hideRowsList.Add(Row + startIndex + HideRows);
  14719. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14720. }
  14721. HideRows += 2;
  14722. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14723. if (leftBindData != null)
  14724. {
  14725. ////SUITE
  14726. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  14727. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  14728. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  14729. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14730. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14731. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14732. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14733. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14734. }
  14735. else
  14736. {
  14737. hideRowsList.Add(Row + startIndex + HideRows);
  14738. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14739. }
  14740. HideRows += 2;
  14741. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14742. if (leftBindData != null)
  14743. {
  14744. designer.SetDataSource("DJDRCB", leftBindData.cb);
  14745. designer.SetDataSource("DJRS", leftBindData.rs);
  14746. designer.SetDataSource("DJXS", leftBindData.xs);
  14747. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14748. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14749. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14750. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14751. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14752. }
  14753. else
  14754. {
  14755. hideRowsList.Add(Row + startIndex + HideRows);
  14756. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14757. }
  14758. HideRows += 2;
  14759. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14760. if (leftBindData != null)
  14761. {
  14762. designer.SetDataSource("HCPCB", leftBindData.cb);
  14763. designer.SetDataSource("HCPRS", leftBindData.rs);
  14764. designer.SetDataSource("HCPXS", leftBindData.xs);
  14765. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14766. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14767. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14768. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14769. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14770. }
  14771. else
  14772. {
  14773. hideRowsList.Add(Row + startIndex + HideRows);
  14774. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14775. }
  14776. HideRows += 2;
  14777. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14778. if (leftBindData != null)
  14779. {
  14780. designer.SetDataSource("CPCB", leftBindData.cb);
  14781. designer.SetDataSource("CPRS", leftBindData.rs);
  14782. designer.SetDataSource("CPXS", leftBindData.xs);
  14783. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14784. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14785. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14786. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14787. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14788. }
  14789. else
  14790. {
  14791. hideRowsList.Add(Row + startIndex + HideRows);
  14792. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14793. }
  14794. HideRows += 2;
  14795. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14796. if (leftBindData != null)
  14797. {
  14798. designer.SetDataSource("GWDRCD", leftBindData.cb);
  14799. designer.SetDataSource("GWRS", leftBindData.rs);
  14800. designer.SetDataSource("GWXS", leftBindData.xs);
  14801. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14802. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14803. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14804. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14805. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14806. }
  14807. else
  14808. {
  14809. hideRowsList.Add(Row + startIndex + HideRows);
  14810. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14811. }
  14812. HideRows += 2;
  14813. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14814. if (leftBindData != null)
  14815. {
  14816. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  14817. designer.SetDataSource("LYJRS", leftBindData.rs);
  14818. designer.SetDataSource("LYJXS", leftBindData.xs);
  14819. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14820. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14821. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14822. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14823. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14824. }
  14825. else
  14826. {
  14827. hideRowsList.Add(Row + startIndex + HideRows);
  14828. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14829. }
  14830. #endregion
  14831. #region A段Right信息
  14832. var right = dto.rightInfo.Find(x => x.Type == "A");
  14833. if (right == null)
  14834. {
  14835. return Ok(jw);
  14836. }
  14837. HideRows += 4;
  14838. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14839. if (rightBindData != null)
  14840. {
  14841. //经济舱 + 双人间 TBR
  14842. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  14843. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  14844. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14845. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  14846. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14847. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14848. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14849. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14850. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14851. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14852. }
  14853. else
  14854. {
  14855. hideRowsList.Add(Row + startIndex + HideRows);
  14856. }
  14857. HideRows += 2;
  14858. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14859. if (rightBindData != null)
  14860. {
  14861. //经济舱 + 单人间 SGR
  14862. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  14863. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  14864. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14865. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  14866. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14867. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14868. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14869. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14870. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14871. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14872. }
  14873. else
  14874. {
  14875. hideRowsList.Add(Row + startIndex + HideRows);
  14876. }
  14877. HideRows += 2;
  14878. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14879. if (rightBindData != null)
  14880. {
  14881. //公务舱 + 单人间 SGR
  14882. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  14883. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  14884. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14885. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  14886. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14887. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14888. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14889. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14890. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14891. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14892. }
  14893. else
  14894. {
  14895. hideRowsList.Add(Row + startIndex + HideRows);
  14896. }
  14897. HideRows += 2;
  14898. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14899. if (rightBindData != null)
  14900. {
  14901. //公务舱 + 小套房 JSES
  14902. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  14903. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  14904. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14905. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  14906. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14907. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14908. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14909. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14910. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14911. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14912. }
  14913. else
  14914. {
  14915. hideRowsList.Add(Row + startIndex + HideRows);
  14916. }
  14917. HideRows += 2;
  14918. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14919. if (rightBindData != null)
  14920. {
  14921. //公务舱 + 小套房 JSES
  14922. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  14923. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  14924. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14925. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  14926. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14927. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14928. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14929. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14930. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14931. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14932. }
  14933. else
  14934. {
  14935. hideRowsList.Add(Row + startIndex + HideRows);
  14936. }
  14937. HideRows += 2;
  14938. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14939. if (rightBindData != null)
  14940. {
  14941. //经济舱 + 大套房
  14942. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  14943. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  14944. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14945. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  14946. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14947. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14948. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14949. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14950. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14951. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14952. }
  14953. else
  14954. {
  14955. hideRowsList.Add(Row + startIndex + HideRows);
  14956. }
  14957. HideRows += 2;
  14958. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  14959. if (rightBindData != null)
  14960. {
  14961. //头等舱 + 小套房 JSES
  14962. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  14963. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  14964. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14965. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  14966. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14967. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14968. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14969. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14970. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14971. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14972. }
  14973. else
  14974. {
  14975. hideRowsList.Add(Row + startIndex + HideRows);
  14976. }
  14977. HideRows += 2;
  14978. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  14979. if (rightBindData != null)
  14980. {
  14981. //头等舱 + 大套房
  14982. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  14983. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  14984. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14985. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  14986. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14987. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14988. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14989. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14990. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14991. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14992. }
  14993. else
  14994. {
  14995. hideRowsList.Add(Row + startIndex + HideRows);
  14996. }
  14997. #endregion
  14998. #region B段标题清空
  14999. designer.SetDataSource("CostBDRCB", "");
  15000. designer.SetDataSource("CostBRS", "");
  15001. designer.SetDataSource("CostBXS", "");
  15002. designer.SetDataSource("CostBZCB", "");
  15003. designer.SetDataSource("CostBDRBJ", "");
  15004. designer.SetDataSource("CostBZBJ", "");
  15005. designer.SetDataSource("CostBDRLR", "");
  15006. designer.SetDataSource("CostBZLR", "");
  15007. designer.SetDataSource("CostBDRCBOM", "");
  15008. designer.SetDataSource("CostBRSOM", "");
  15009. designer.SetDataSource("CostBZCBOM", "");
  15010. designer.SetDataSource("CostBDRBJOM", "");
  15011. designer.SetDataSource("CostBZBJOM", "");
  15012. designer.SetDataSource("CostBDRLROM", "");
  15013. designer.SetDataSource("CostBZLROM", "");
  15014. #endregion
  15015. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  15016. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  15017. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  15018. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  15019. designer.SetDataSource("DJName", "地接(CNY)");
  15020. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  15021. designer.SetDataSource("CPName", "地接-船票(CNY)");
  15022. designer.SetDataSource("GWName", "公务(CNY)");
  15023. designer.SetDataSource("YQHName", "邀请函(CNY)");
  15024. designer.SetDataSource("LYJName", "零用金(CNY)");
  15025. designer.SetDataSource("HSName", "核酸检测(CNY)");
  15026. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  15027. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  15028. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  15029. designer.SetDataSource("BXName", "保险(CNY)");
  15030. designer.SetDataSource("VisaName", "签证(CNY)");
  15031. #region B段基本数据
  15032. if (dto.costType == "B")
  15033. {
  15034. left = dto.leftInfo.Find(x => x.Type == "B");
  15035. if (left == null)
  15036. {
  15037. return Ok(jw);
  15038. }
  15039. #region B段left数据
  15040. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15041. if (leftBindData != null)
  15042. {
  15043. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  15044. designer.SetDataSource("BHSRS", leftBindData.rs);
  15045. designer.SetDataSource("BHSXS", leftBindData.xs);
  15046. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15047. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15048. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15049. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15050. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15051. }
  15052. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15053. if (leftBindData != null)
  15054. {
  15055. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  15056. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  15057. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  15058. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15059. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15060. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15061. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15062. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15063. }
  15064. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15065. if (leftBindData != null)
  15066. {
  15067. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  15068. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  15069. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  15070. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15071. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15072. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15073. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15074. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15075. }
  15076. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15077. if (leftBindData != null)
  15078. {
  15079. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  15080. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  15081. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  15082. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15083. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15084. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15085. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15086. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15087. }
  15088. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15089. if (leftBindData != null)
  15090. {
  15091. designer.SetDataSource("BHCPCB", leftBindData.cb);
  15092. designer.SetDataSource("BHCPRS", leftBindData.rs);
  15093. designer.SetDataSource("BHCPXS", leftBindData.xs);
  15094. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15095. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15096. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15097. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15098. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15099. }
  15100. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15101. if (leftBindData != null)
  15102. {
  15103. designer.SetDataSource("BCPCB", leftBindData.cb);
  15104. designer.SetDataSource("BCPRS", leftBindData.rs);
  15105. designer.SetDataSource("BCPXS", leftBindData.xs);
  15106. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15107. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15108. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15109. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15110. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15111. }
  15112. //TBR
  15113. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15114. if (leftBindData != null)
  15115. {
  15116. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  15117. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  15118. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  15119. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15120. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15121. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15122. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15123. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15124. }
  15125. //SGR
  15126. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15127. if (leftBindData != null)
  15128. {
  15129. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15130. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15131. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15132. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15133. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15134. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15135. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15136. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15137. }
  15138. //JS/ES
  15139. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15140. if (leftBindData != null)
  15141. {
  15142. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15143. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15144. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15145. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15146. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15147. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15148. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15149. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15150. }
  15151. //SUITE
  15152. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15153. if (leftBindData != null)
  15154. {
  15155. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15156. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15157. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15158. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15159. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15160. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15161. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15162. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15163. }
  15164. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15165. if (leftBindData != null)
  15166. {
  15167. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15168. designer.SetDataSource("BDJRS", leftBindData.rs);
  15169. designer.SetDataSource("BDJXS", leftBindData.xs);
  15170. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15171. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15172. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15173. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15174. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15175. }
  15176. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15177. if (leftBindData != null)
  15178. {
  15179. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15180. designer.SetDataSource("BGWRS", leftBindData.rs);
  15181. designer.SetDataSource("BGWXS", leftBindData.xs);
  15182. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15183. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15184. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15185. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15186. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15187. }
  15188. #region 优化方案
  15189. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15190. //excelBind.Add("零用金", new {
  15191. //cb="",
  15192. //rs="",
  15193. //xs ="",
  15194. //zcb = "",
  15195. //});
  15196. #endregion
  15197. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15198. if (leftBindData != null)
  15199. {
  15200. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15201. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15202. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15203. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15204. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15205. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15206. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15207. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15208. }
  15209. #endregion
  15210. #region B段Right信息
  15211. right = dto.rightInfo.Find(x => x.Type == "B");
  15212. if (right == null)
  15213. {
  15214. return Ok(jw);
  15215. }
  15216. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15217. if (rightBindData != null)
  15218. {
  15219. //经济舱 + 双人间 TBR
  15220. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15221. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15222. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15223. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15224. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15225. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15226. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15227. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15228. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15229. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15230. }
  15231. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15232. if (rightBindData != null)
  15233. {
  15234. //经济舱 + 单人间 SGR
  15235. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15236. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15237. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15238. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15239. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15240. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15241. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15242. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15243. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15244. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15245. }
  15246. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15247. if (rightBindData != null)
  15248. {
  15249. //公务舱 + 单人间 SGR
  15250. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15251. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15252. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15253. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15254. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15255. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15256. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15257. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15258. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15259. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15260. }
  15261. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15262. if (rightBindData != null)
  15263. {
  15264. //公务舱 + 小套房 JSES
  15265. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15266. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15267. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15268. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15269. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15270. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15271. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15272. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15273. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15274. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15275. }
  15276. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15277. if (rightBindData != null)
  15278. {
  15279. //公务舱 + 小套房 JSES
  15280. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15281. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15282. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15283. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15284. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15285. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15286. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15287. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15288. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15289. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15290. }
  15291. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15292. if (rightBindData != null)
  15293. {
  15294. //经济舱 + 大套房
  15295. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15296. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15297. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15298. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15299. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15300. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15301. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15302. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15303. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15304. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15305. }
  15306. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15307. if (rightBindData != null)
  15308. {
  15309. //头等舱 + 小套房 JSES
  15310. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15311. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15312. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15313. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15314. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15315. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15316. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15317. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15318. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15319. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15320. }
  15321. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15322. if (rightBindData != null)
  15323. {
  15324. //头等舱 + 大套房
  15325. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15326. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15327. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15328. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15329. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15330. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15331. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15332. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15333. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15334. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15335. }
  15336. #endregion
  15337. #region 标题
  15338. designer.SetDataSource("CostBDRCB", "单人成本");
  15339. designer.SetDataSource("CostBRS", "人数");
  15340. designer.SetDataSource("CostBXS", "系数");
  15341. designer.SetDataSource("CostBZCB", "总成本");
  15342. designer.SetDataSource("CostBDRBJ", "单人报价");
  15343. designer.SetDataSource("CostBZBJ", "总报价");
  15344. designer.SetDataSource("CostBDRLR", "单人利润");
  15345. designer.SetDataSource("CostBZLR", "总利润");
  15346. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15347. designer.SetDataSource("CostBRSOM", "人数");
  15348. designer.SetDataSource("CostBZCBOM", "总成本");
  15349. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15350. designer.SetDataSource("CostBZBJOM", "总报价");
  15351. designer.SetDataSource("CostBDRLROM", "单人利润");
  15352. designer.SetDataSource("CostBZLROM", "总利润");
  15353. #endregion
  15354. }
  15355. #endregion
  15356. designer.SetDataSource("TzZCB2", TzZCB2);
  15357. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15358. designer.SetDataSource("TzZLR2", TzZLR2);
  15359. string[] dataSourceKeys = new string[]
  15360. {
  15361. "VF",
  15362. "TGS",
  15363. "TGOF",
  15364. "TGM",
  15365. "TGA",
  15366. "TGTF",
  15367. "TGEF",
  15368. "CFM",
  15369. "CFOF",
  15370. "B",
  15371. "L",
  15372. "D",
  15373. "TBR",
  15374. "SGR",
  15375. "JSES",
  15376. "Suite",
  15377. "TV",
  15378. "1L",
  15379. "IF",
  15380. "EF",
  15381. "BRF",
  15382. "TE",
  15383. "TGT",
  15384. "DRVT",
  15385. "PC",
  15386. "TLF",
  15387. "ECT"
  15388. };
  15389. foreach (var item in dataSourceKeys)
  15390. {
  15391. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  15392. if (find != null)
  15393. {
  15394. designer.SetDataSource(item, find.text);
  15395. }
  15396. else
  15397. {
  15398. designer.SetDataSource(item, 0);
  15399. }
  15400. }
  15401. designer.SetDataSource(dt);
  15402. //根据数据源处理生成报表内容
  15403. designer.Process();
  15404. designer.Workbook.Worksheets[0].Name = "清单";
  15405. Worksheet sheet = designer.Workbook.Worksheets[0];
  15406. foreach (var Rowindex in hideRowsList)
  15407. {
  15408. ws.Cells.HideRows(Rowindex, 2);
  15409. }
  15410. byte[] bytes = null;
  15411. string strFileName = di.TeamName + "-团组-成本.xls";
  15412. using (MemoryStream stream = new MemoryStream())
  15413. {
  15414. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  15415. bytes = stream.ToArray();
  15416. }
  15417. return Ok(JsonView(true, "", new
  15418. {
  15419. Data = bytes,
  15420. strFileName,
  15421. }));
  15422. }
  15423. /// <summary>
  15424. /// 导出客户报表
  15425. /// </summary>
  15426. /// <returns></returns>
  15427. [HttpPost]
  15428. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  15429. {
  15430. var jw = JsonView(false);
  15431. if (dto.Diid == 0)
  15432. {
  15433. return Ok(JsonView(false, "请传递团组id"));
  15434. }
  15435. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15436. if (deleInfo.Code != 0)
  15437. {
  15438. return Ok(JsonView(false, "团组信息查询失败!"));
  15439. }
  15440. var di = deleInfo.Data as DelegationInfoWebView;
  15441. if (di == null)
  15442. {
  15443. return Ok(JsonView(false, "团组信息查询失败!"));
  15444. }
  15445. //文件名
  15446. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  15447. //获取模板
  15448. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  15449. //载入模板
  15450. Document doc = new Document(tmppath);
  15451. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  15452. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  15453. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  15454. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  15455. var AParameter = ParameterList.Find(x => x.CostType == "A");
  15456. var BParameter = ParameterList.Find(x => x.CostType == "B");
  15457. if (AParameter == null)
  15458. {
  15459. return Ok(JsonView(false, "系数不存在!"));
  15460. }
  15461. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  15462. , TzAirDesc, TzZCost;
  15463. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  15464. = TzAirDesc = TzZCost = string.Empty;
  15465. TzNumber = AParameter.CostTypenumber.ToString();
  15466. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  15467. CarGuides1 = dto.CarGuides1;
  15468. Meal = dto.Meal;
  15469. SubsidizedMeals = dto.SubsidizedMeals;
  15470. NightRepair = dto.NightRepair;
  15471. AttractionsTickets = dto.AttractionsTickets;
  15472. MiscellaneousFees = dto.MiscellaneousFees;
  15473. ATip = dto.ATip;
  15474. TzHotelDesc = "";
  15475. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  15476. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  15477. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  15478. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  15479. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  15480. TzAirDesc = "";
  15481. TzZCost = dto.TzZCost;
  15482. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  15483. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  15484. var index = 1;
  15485. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  15486. foreach (var item in TzHotelDescArr)
  15487. {
  15488. if (AinfoArr != null)
  15489. {
  15490. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15491. if (Ainfo != null)
  15492. {
  15493. if (int.Parse(Ainfo.rs) <= 0)
  15494. {
  15495. continue;
  15496. }
  15497. var hotelText = string.Empty;
  15498. switch (item)
  15499. {
  15500. case "SGR":
  15501. hotelText = "单人间";
  15502. break;
  15503. case "JSES":
  15504. hotelText = "小套房";
  15505. break;
  15506. case "SUITE":
  15507. hotelText = "套房";
  15508. break;
  15509. case "TBR":
  15510. hotelText = "双人间";
  15511. break;
  15512. }
  15513. if (item != "TBR")
  15514. {
  15515. 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";
  15516. }
  15517. else
  15518. {
  15519. 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";
  15520. }
  15521. index++;
  15522. }
  15523. }
  15524. }
  15525. index = 1;
  15526. foreach (var item in TzAirDescArr)
  15527. {
  15528. if (AinfoArr != null)
  15529. {
  15530. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15531. if (Ainfo != null)
  15532. {
  15533. if (int.Parse(Ainfo.rs) <= 0)
  15534. {
  15535. continue;
  15536. }
  15537. 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";
  15538. index++;
  15539. }
  15540. }
  15541. }
  15542. if (dto.costType == "B")
  15543. {
  15544. if (BParameter == null)
  15545. {
  15546. return Ok(JsonView(false, "B段系数不存在!"));
  15547. }
  15548. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  15549. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  15550. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  15551. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  15552. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15553. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15554. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15555. foreach (var item in TzHotelDescArr)
  15556. {
  15557. if (AinfoArr != null)
  15558. {
  15559. TzHotelDesc += "B段信息 \r\n";
  15560. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15561. if (Ainfo != null)
  15562. {
  15563. if (int.Parse(Ainfo.rs) <= 0)
  15564. {
  15565. continue;
  15566. }
  15567. var hotelText = string.Empty;
  15568. switch (item)
  15569. {
  15570. case "SGR":
  15571. hotelText = "单人间";
  15572. break;
  15573. case "JSES":
  15574. hotelText = "小套房";
  15575. break;
  15576. case "SUITE":
  15577. hotelText = "套房";
  15578. break;
  15579. case "TBR":
  15580. hotelText = "双人间";
  15581. break;
  15582. }
  15583. if (item != "TBR")
  15584. {
  15585. 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";
  15586. }
  15587. else
  15588. {
  15589. 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";
  15590. }
  15591. index++;
  15592. }
  15593. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15594. }
  15595. }
  15596. index = 1;
  15597. foreach (var item in TzAirDescArr)
  15598. {
  15599. if (AinfoArr != null)
  15600. {
  15601. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15602. if (Ainfo != null)
  15603. {
  15604. if (int.Parse(Ainfo.rs) <= 0)
  15605. {
  15606. continue;
  15607. }
  15608. 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";
  15609. index++;
  15610. }
  15611. }
  15612. }
  15613. }
  15614. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15615. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15616. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15617. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15618. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15619. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15620. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15621. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15622. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15623. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15624. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15625. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15626. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15627. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15628. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15629. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15630. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15631. DickeyValue.Add("TzZCost", TzZCost);
  15632. foreach (var key in DickeyValue.Keys)
  15633. {
  15634. if (doc.Range.Bookmarks[key] != null)
  15635. {
  15636. Bookmark mark = doc.Range.Bookmarks[key];
  15637. mark.Text = DickeyValue[key];
  15638. }
  15639. }
  15640. byte[] bytes = null;
  15641. string strFileName = di.TeamName + "-客户报价.doc";
  15642. using (MemoryStream stream = new MemoryStream())
  15643. {
  15644. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15645. bytes = stream.ToArray();
  15646. }
  15647. return Ok(JsonView(true, "", new
  15648. {
  15649. Data = bytes,
  15650. strFileName,
  15651. }));
  15652. }
  15653. /// <summary>
  15654. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15655. /// </summary>
  15656. /// <param name="dto"></param>
  15657. /// <returns></returns>
  15658. [HttpPost]
  15659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15660. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  15661. {
  15662. try
  15663. {
  15664. #region 参数验证
  15665. if (dto.DiId < 0)
  15666. {
  15667. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  15668. }
  15669. List<int> cTableIds = new List<int>() {
  15670. 76 ,//酒店预订
  15671. 77 ,//行程
  15672. 79 ,//车/导游地接
  15673. 80 ,//签证
  15674. 81 ,//邀请/公务活
  15675. 82 ,//团组客户保险
  15676. 85 ,//机票预订
  15677. 98 ,//其他款项
  15678. 285 ,//收款退还
  15679. 751 ,//酒店早餐
  15680. 1015 // 超支费用
  15681. };
  15682. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  15683. {
  15684. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  15685. }
  15686. #endregion
  15687. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  15688. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  15689. if (_GroupCostParameters.Count <= 0)
  15690. {
  15691. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  15692. }
  15693. if (_GroupCostParameters[0].IsShare == 0)
  15694. {
  15695. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  15696. }
  15697. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15698. //处理date为空问题
  15699. if (_GroupCosts.Count > 0)
  15700. {
  15701. for (int i = 0; i < _GroupCosts.Count; i++)
  15702. {
  15703. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  15704. {
  15705. if (i > 0)
  15706. {
  15707. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  15708. }
  15709. }
  15710. }
  15711. }
  15712. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  15713. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  15714. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  15715. string currCode = "";
  15716. #region currCode 验证
  15717. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  15718. if (isInt)
  15719. {
  15720. var currData = currDatas.Find(it => it.Id == intCurrency);
  15721. if (currData != null)
  15722. {
  15723. currCode = currData.Name;
  15724. }
  15725. }
  15726. else
  15727. {
  15728. currCode = _GroupCostParameters[0].Currency.Trim();
  15729. }
  15730. #endregion
  15731. //op,酒店单段模式存储
  15732. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  15733. {
  15734. CurrencyCode = currCode,
  15735. Rate = _GroupCostParameters[0].Rate,
  15736. CostType = _GroupCostParameters[0].CostType,
  15737. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  15738. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  15739. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  15740. };
  15741. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  15742. if (_GroupCostParameters.Count == 2)
  15743. {
  15744. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  15745. }
  15746. foreach (var item in _GroupCostParameters)
  15747. {
  15748. decimal _rate = 1;
  15749. decimal _rate1 = item.Rate;
  15750. decimal _scale = 1;
  15751. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  15752. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  15753. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  15754. //if (userInfo != null)
  15755. //{
  15756. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  15757. // {
  15758. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  15759. // {
  15760. // _scale = 1.00M;
  15761. // }
  15762. // }
  15763. //}
  15764. #endregion
  15765. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  15766. {
  15767. CurrencyCode = currCode,
  15768. Rate = _rate1,
  15769. CostType = item.CostType,
  15770. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  15771. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  15772. CostTypeNumber = item.CostTypenumber
  15773. };
  15774. if (_GroupCostParameters.Count > 1)
  15775. {
  15776. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  15777. }
  15778. else
  15779. {
  15780. modulePromptInfo.CostTypeNumber = item.LYJRS;
  15781. }
  15782. if (dto.CTable == 79)//
  15783. {
  15784. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  15785. modulePromptInfo.TotalCost = item.DJCB;
  15786. }
  15787. List<string> costTypes = new List<string>() { "A", "B" };
  15788. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  15789. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  15790. if (_GroupCostsDuplicates.Count() == 1)
  15791. {
  15792. _GroupCostsTypeData = _GroupCosts;
  15793. }
  15794. else
  15795. {
  15796. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  15797. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  15798. }
  15799. /*
  15800. * 76 酒店预订
  15801. * 77 行程
  15802. * 79 车/导游地接
  15803. * 80 签证
  15804. * 81 邀请/公务活动
  15805. * 82 团组客户保险
  15806. * 85 机票预订
  15807. * 98 其他款项
  15808. * 285 收款退还
  15809. * 751 酒店早餐
  15810. * 1015 超支费用
  15811. */
  15812. switch (dto.CTable)
  15813. {
  15814. case 76: // 酒店预订
  15815. _ModuleSubPromptInfo.AddRange(
  15816. _GroupCostsTypeData.Select(it => new
  15817. {
  15818. it.DAY,
  15819. it.Date,
  15820. it.ACCON,
  15821. it.ITIN,
  15822. it.SGR,
  15823. it.TBR,
  15824. it.JS_ES,
  15825. it.Suite
  15826. })
  15827. );
  15828. break;
  15829. case 79: // 车/导游地接
  15830. _ModuleSubPromptInfo.AddRange(
  15831. _GroupCostsTypeData.Select(it => new
  15832. {
  15833. Date = it.Date, //日期
  15834. CarFee = it.CarCost * _rate * _scale, //车费用
  15835. CarType = it.CarType, //车型
  15836. DriverFee = it.CFS * _rate * _scale, //司机工资
  15837. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  15838. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  15839. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  15840. GuideFee = it.TGS * _rate * _scale, //导游费用
  15841. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  15842. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  15843. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  15844. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  15845. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  15846. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  15847. Breakfast = it.B * _rate * _scale, //早餐费
  15848. Lunch = it.L * _rate * _scale, //午餐费
  15849. Dinner = it.D * _rate * _scale, //晚餐费
  15850. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  15851. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  15852. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  15853. TicketFee = it.EF * _rate * _scale, //门票费
  15854. TicketRemark = it.EFR, //门票费描述
  15855. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  15856. TravelSupplies = it.TE * _rate * _scale, //出行物资
  15857. SpentCash = it.PC * _rate * _scale, //零用金
  15858. LeadersFee = it.TLF * _rate * _scale, //领队费
  15859. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  15860. })
  15861. );
  15862. break;
  15863. case 85: // 机票
  15864. List<dynamic> datas = new List<dynamic>();
  15865. datas.Add(
  15866. new
  15867. {
  15868. AirType = "经济舱",
  15869. AirNum = item.JJCRS,
  15870. AirDRCB = item.JJCCB,
  15871. AirZCB = (item.JJCRS * item.JJCCB)
  15872. }
  15873. );
  15874. datas.Add(
  15875. new
  15876. {
  15877. AirType = "公务舱",
  15878. AirNum = item.GWCRS,
  15879. AirDRCB = item.GWCCB,
  15880. AirZCB = (item.GWCRS * item.GWCCB)
  15881. }
  15882. );
  15883. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15884. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  15885. modulePromptInfo.Data = new
  15886. {
  15887. airFeeData = datas,
  15888. airInitData = initDatas
  15889. };
  15890. _ModulePromptInfos.Add(modulePromptInfo);
  15891. break;
  15892. default:
  15893. break;
  15894. }
  15895. }
  15896. if (dto.CTable != 85)
  15897. {
  15898. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  15899. _ModulePromptInfos.Add(_ModulePromptInfo);
  15900. }
  15901. _view.ModulePromptInfos = _ModulePromptInfos;
  15902. return Ok(JsonView(true, "操作成功!", _view));
  15903. }
  15904. catch (Exception ex)
  15905. {
  15906. return Ok(JsonView(false, ex.Message));
  15907. }
  15908. }
  15909. /// <summary>
  15910. /// 根据黑屏代码重新生成行程
  15911. /// </summary>
  15912. /// <param name="dto"></param>
  15913. /// <returns></returns>
  15914. [HttpPost]
  15915. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  15916. {
  15917. var jw = JsonView(false, "Error");
  15918. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  15919. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  15920. .Select(x => new
  15921. {
  15922. x.Id,
  15923. x.Title
  15924. })
  15925. .ToList();
  15926. if (Create.Any())
  15927. {
  15928. jw.Msg = "获取成功!";
  15929. jw.Code = 200;
  15930. jw.Data = new
  15931. {
  15932. BlackCodeListSelect = Create,
  15933. blackCodeIsTrue = true
  15934. };
  15935. }
  15936. else
  15937. {
  15938. jw.Code = 400;
  15939. jw.Data = new
  15940. {
  15941. BlackCodeListSelect = Create,
  15942. blackCodeIsTrue = false,
  15943. };
  15944. }
  15945. return Ok(jw);
  15946. }
  15947. /// <summary>
  15948. /// 根据黑屏代码Id重新生成行程
  15949. /// </summary>
  15950. /// <param name="dto"></param>
  15951. /// <returns></returns>
  15952. [HttpPost]
  15953. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  15954. {
  15955. var jw = JsonView(false, "Error");
  15956. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  15957. if (result.Code == 0)
  15958. {
  15959. jw.Msg = "获取成功!";
  15960. jw.Code = 200;
  15961. jw.Data = new
  15962. {
  15963. groupCost = result.Data,
  15964. blackCodeIsTrue = true
  15965. };
  15966. }
  15967. else
  15968. {
  15969. jw.Code = 400;
  15970. jw.Data = new
  15971. {
  15972. groupCost = result.Data,
  15973. blackCodeIsTrue = false,
  15974. };
  15975. }
  15976. return Ok(jw);
  15977. }
  15978. /// <summary>
  15979. /// 成本获取OP历史车费用
  15980. /// </summary>
  15981. /// <param name="dto"></param>
  15982. /// <returns></returns>
  15983. [HttpPost]
  15984. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  15985. {
  15986. var jw = JsonView(false);
  15987. try
  15988. {
  15989. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  15990. //获取现有所有车的数据
  15991. if (!dto.Param.IsNullOrWhiteSpace())
  15992. {
  15993. string sql = $@"
  15994. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  15995. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  15996. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  15997. 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
  15998. AND gctggr.ServiceEndTime is not NULL
  15999. ORDER by gctggrc.id DESC
  16000. ";
  16001. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  16002. var numeberResult = await Task.Run(() =>
  16003. {
  16004. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  16005. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  16006. return numberArr;
  16007. });
  16008. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  16009. foreach (var item in numeberResult)
  16010. {
  16011. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  16012. {
  16013. Country = "数据异常!",
  16014. City = string.Empty,
  16015. };
  16016. item.Area = find.Country + " " + find.City;
  16017. }
  16018. dbResult.AddRange(numeberResult);
  16019. if (dto.Param.Contains("、"))
  16020. {
  16021. var sp = dto.Param.Split("、");
  16022. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16023. .Where(x =>
  16024. {
  16025. return System.Array.Exists(sp, e =>
  16026. {
  16027. bool where = false;
  16028. if (x.Area != null)
  16029. {
  16030. where = x.Area.Contains(e);
  16031. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16032. {
  16033. return false;
  16034. }
  16035. }
  16036. if (x.PriceName != null && !where)
  16037. {
  16038. where = x.PriceName.Contains(e);
  16039. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16040. {
  16041. return false;
  16042. }
  16043. }
  16044. return where;
  16045. });
  16046. }).ToList();
  16047. }
  16048. else
  16049. {
  16050. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16051. .Where(x =>
  16052. {
  16053. bool where = false;
  16054. if (x.Area != null)
  16055. {
  16056. where = x.Area.Contains(dto.Param);
  16057. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16058. {
  16059. return false;
  16060. }
  16061. }
  16062. if (x.PriceName != null && !where)
  16063. {
  16064. where = x.PriceName.Contains(dto.Param);
  16065. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16066. {
  16067. return false;
  16068. }
  16069. }
  16070. return where;
  16071. }
  16072. )
  16073. .ToList();
  16074. }
  16075. }
  16076. var view = dbResult.Select(x =>
  16077. {
  16078. decimal dp = 0.00M;
  16079. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  16080. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  16081. if (string.IsNullOrWhiteSpace(x.DatePrice))
  16082. {
  16083. if (startB && endB)
  16084. {
  16085. var timesp = endD.Subtract(startD);
  16086. if ((timesp.Days + 1) != 0)
  16087. {
  16088. dp = x.Price / (timesp.Days + 1);
  16089. }
  16090. }
  16091. }
  16092. else
  16093. {
  16094. dp = x.Price;
  16095. }
  16096. return new
  16097. {
  16098. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  16099. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  16100. x.Area,
  16101. x.id,
  16102. price = x.Price.ToString("F2"),
  16103. x.PriceName,
  16104. x.PriceContent,
  16105. x.TeamName,
  16106. x.DatePrice,
  16107. dayPrice = dp.ToString("F2"),
  16108. };
  16109. }).OrderByDescending(x => x.id).ToList();
  16110. jw = JsonView(true, "获取成功!", view);
  16111. }
  16112. catch (Exception e)
  16113. {
  16114. jw = JsonView(false, e.Message);
  16115. }
  16116. return Ok(jw);
  16117. }
  16118. [HttpPost]
  16119. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  16120. {
  16121. var jw = JsonView(true);
  16122. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  16123. if (string.IsNullOrWhiteSpace(dto.Keyword))
  16124. {
  16125. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16126. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16127. WHEN COUNT(*) >= 0 THEN 'True'
  16128. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16129. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16130. ")
  16131. .ToList();
  16132. }
  16133. else
  16134. {
  16135. string likeKey = string.Empty;
  16136. foreach (var item in dto.Keyword)
  16137. {
  16138. likeKey += "%" + item;
  16139. }
  16140. likeKey += "%";
  16141. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16142. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16143. WHEN COUNT(*) >= 0 THEN 'True'
  16144. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16145. Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16146. ")
  16147. .ToList();
  16148. }
  16149. if (matches.Any())
  16150. {
  16151. jw.Data = matches;
  16152. }
  16153. else
  16154. {
  16155. jw.Code = 201;
  16156. jw.Msg = "empty list";
  16157. jw.Data = new List<string>(1);
  16158. }
  16159. return Ok(jw);
  16160. }
  16161. /// <summary>
  16162. /// 报价Word下载
  16163. /// </summary>
  16164. /// <param name="dto"></param>
  16165. /// <returns></returns>
  16166. [HttpPost]
  16167. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16168. {
  16169. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16170. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16171. if (di == null)
  16172. {
  16173. return Ok(JsonView(false, "团组不存在!"));
  16174. }
  16175. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16176. if (mainPrice == null || mainPrice.IsShare == 0)
  16177. {
  16178. return Ok(JsonView(false, "团组成本不存在!"));
  16179. }
  16180. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16181. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16182. if (costTypeHotelNumbers == null)
  16183. {
  16184. return Ok(JsonView(false, "团组成本不存在!"));
  16185. }
  16186. //文件名
  16187. string strFileName = di.TeamName + "-收款账单.doc";
  16188. //获取模板
  16189. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16190. //载入模板
  16191. Document doc = new Document(tmppath);
  16192. decimal allPrice = 0.00M;
  16193. string itemStr = string.Empty;
  16194. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16195. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16196. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16197. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16198. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16199. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16200. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16201. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16202. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16203. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16204. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16205. {
  16206. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16207. ("BXRS", "BXCB", "BXXS", "bx"),
  16208. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16209. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16210. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16211. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16212. ("CPRS", "CPCB", "CPXS", "cp"),
  16213. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16214. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16215. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16216. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16217. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16218. ("DJRS", "DJCB", "DJXS", "dj"),
  16219. ("GWRS", "GWCB", "GWXS", "gw"),
  16220. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16221. };
  16222. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16223. var rightSum = 0.00M;
  16224. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16225. {
  16226. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16227. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16228. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16229. if (prefix == "tbr")
  16230. {
  16231. rsValue *= 2;
  16232. cbValue /= 2;
  16233. }
  16234. if (OtherCostPropertyBJ.Contains(prefix))
  16235. {
  16236. rightSum += cbValue * xsValue;
  16237. }
  16238. }
  16239. var hotelRooms = new Dictionary<string, int>
  16240. {
  16241. { "SGR", costTypeHotelNumbers.SGR },
  16242. { "TBR", costTypeHotelNumbers.TBR },
  16243. { "JSES", costTypeHotelNumbers.JSES },
  16244. { "SUITE", costTypeHotelNumbers.SUITE }
  16245. };
  16246. var flights = new Dictionary<string, int>
  16247. {
  16248. { "经济舱", mainPrice.JJCRS },
  16249. { "公务舱", mainPrice.GWCRS },
  16250. { "头等舱", mainPrice.TDCRS }
  16251. };
  16252. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16253. {
  16254. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16255. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16256. { "头等舱", new[] { "SUITE", "JSES" } }
  16257. };
  16258. var result = new Dictionary<string, int>();
  16259. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16260. foreach (var flight in flights.Keys)
  16261. {
  16262. // 获取当前舱位的匹配规则
  16263. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16264. {
  16265. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16266. }
  16267. }
  16268. #region right计算
  16269. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16270. {
  16271. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16272. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16273. airHotelPriceList.Add(new
  16274. AirHotelPrice
  16275. {
  16276. Name = "经济舱TBR",
  16277. Price = rightSum + air + hotel,
  16278. Count = result["经济舱TBR"] * 2
  16279. });
  16280. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16281. }
  16282. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16283. {
  16284. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16285. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16286. airHotelPriceList.Add(new
  16287. AirHotelPrice
  16288. {
  16289. Name = "经济舱SGR",
  16290. Price = rightSum + air + hotel,
  16291. Count = result["经济舱SGR"]
  16292. });
  16293. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16294. }
  16295. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16296. {
  16297. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16298. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16299. airHotelPriceList.Add(new
  16300. AirHotelPrice
  16301. {
  16302. Name = "公务舱SGR",
  16303. Price = rightSum + air + hotel,
  16304. Count = result["公务舱SGR"]
  16305. });
  16306. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16307. }
  16308. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16309. {
  16310. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16311. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16312. airHotelPriceList.Add(new
  16313. AirHotelPrice
  16314. {
  16315. Name = "公务舱JSES",
  16316. Price = rightSum + air + hotel,
  16317. Count = result["公务舱JSES"]
  16318. });
  16319. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16320. }
  16321. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16322. {
  16323. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16324. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16325. airHotelPriceList.Add(new
  16326. AirHotelPrice
  16327. {
  16328. Name = "公务舱SUITE",
  16329. Price = rightSum + air + hotel,
  16330. Count = result["公务舱SUITE"]
  16331. });
  16332. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16333. }
  16334. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16335. {
  16336. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16337. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16338. airHotelPriceList.Add(new
  16339. AirHotelPrice
  16340. {
  16341. Name = "经济舱SUITE",
  16342. Price = rightSum + air + hotel,
  16343. Count = result["经济舱SUITE"]
  16344. });
  16345. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16346. }
  16347. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16348. {
  16349. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16350. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16351. airHotelPriceList.Add(new
  16352. AirHotelPrice
  16353. {
  16354. Name = "头等舱JSES",
  16355. Price = rightSum + air + hotel,
  16356. Count = result["头等舱JSES"]
  16357. });
  16358. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16359. }
  16360. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16361. {
  16362. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16363. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16364. airHotelPriceList.Add(new
  16365. AirHotelPrice
  16366. {
  16367. Name = "头等舱SUITE",
  16368. Price = rightSum + air + hotel,
  16369. Count = result["头等舱SUITE"]
  16370. });
  16371. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16372. }
  16373. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16374. {
  16375. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16376. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16377. airHotelPriceList.Add(new
  16378. AirHotelPrice
  16379. {
  16380. Name = "经济舱JSES",
  16381. Price = rightSum + air + hotel,
  16382. Count = result["经济舱JSES"]
  16383. });
  16384. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16385. }
  16386. #endregion
  16387. foreach (var item in airSouer.Keys)
  16388. {
  16389. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  16390. if (find != null && find.Count > 0)
  16391. {
  16392. if (item.Contains("TBR"))
  16393. {
  16394. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16395. }
  16396. else
  16397. {
  16398. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16399. }
  16400. }
  16401. }
  16402. #region 替换Word模板书签内容
  16403. Dictionary<string, string> marks = new Dictionary<string, string>();
  16404. marks.Add("To", di.ClientUnit);//付款方
  16405. marks.Add("ToTel", di.TellPhone);//付款方电话
  16406. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  16407. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  16408. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  16409. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  16410. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  16411. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16412. marks.Add("PayItemContent", itemStr);//详细信息
  16413. marks.Add("Total", allPrice.ToString("F2"));//合计
  16414. #endregion
  16415. foreach (var item in marks.Keys)
  16416. {
  16417. if (doc.Range.Bookmarks[item] != null)
  16418. {
  16419. Bookmark mark = doc.Range.Bookmarks[item];
  16420. mark.Text = marks[item];
  16421. }
  16422. }
  16423. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  16424. doc.Save(savePaht);
  16425. var jw = new JsonView();
  16426. jw.Msg = "生成成功!";
  16427. jw.Code = 200;
  16428. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  16429. return Ok(jw);
  16430. }
  16431. /// <summary>
  16432. /// 详细报价费用Excel下载
  16433. /// </summary>
  16434. /// <param name="dto"></param>
  16435. /// <returns></returns>
  16436. [HttpPost]
  16437. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  16438. {
  16439. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16440. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16441. if (di == null)
  16442. {
  16443. return Ok(JsonView(false, "团组不存在!"));
  16444. }
  16445. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16446. if (mainPrice == null || mainPrice.IsShare == 0)
  16447. {
  16448. return Ok(JsonView(false, "团组成本不存在!"));
  16449. }
  16450. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16451. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16452. if (costTypeHotelNumbers == null)
  16453. {
  16454. return Ok(JsonView(false, "团组成本不存在!"));
  16455. }
  16456. WorkbookDesigner designer = new WorkbookDesigner();
  16457. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  16458. List<int> hideRowsList = new List<int>();
  16459. int conterStartIndex = 3;
  16460. int rowIndex = conterStartIndex;
  16461. designer.SetDataSource("GroupName", di.TeamName);
  16462. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16463. {
  16464. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16465. ("BXRS", "BXCB", "BXXS", "bx"),
  16466. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16467. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16468. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  16469. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  16470. ("CPRS", "CPCB", "CPXS", "cp") ,
  16471. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  16472. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  16473. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  16474. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16475. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16476. ("DJRS", "DJCB", "DJXS", "dj") ,
  16477. ("GWRS", "GWCB", "GWXS", "gw") ,
  16478. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16479. };
  16480. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16481. var rightSum = 0.00M;
  16482. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16483. {
  16484. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16485. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16486. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16487. if (prefix == "tbr")
  16488. {
  16489. rsValue *= 2;
  16490. cbValue /= 2;
  16491. }
  16492. if (OtherCostPropertyBJ.Contains(prefix))
  16493. {
  16494. rightSum += cbValue * xsValue;
  16495. }
  16496. if (rsValue == 0)
  16497. {
  16498. hideRowsList.Add(rowIndex);
  16499. }
  16500. else
  16501. {
  16502. designer.SetDataSource($"{prefix}rs", rsValue);
  16503. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  16504. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  16505. }
  16506. rowIndex += 2;
  16507. }
  16508. var hotelRooms = new Dictionary<string, int>
  16509. {
  16510. { "SGR", costTypeHotelNumbers.SGR },
  16511. { "TBR", costTypeHotelNumbers.TBR },
  16512. { "JSES", costTypeHotelNumbers.JSES },
  16513. { "SUITE", costTypeHotelNumbers.SUITE }
  16514. };
  16515. var flights = new Dictionary<string, int>
  16516. {
  16517. { "经济舱", mainPrice.JJCRS },
  16518. { "公务舱", mainPrice.GWCRS },
  16519. { "头等舱", mainPrice.TDCRS }
  16520. };
  16521. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16522. {
  16523. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16524. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16525. { "头等舱", new[] { "SUITE", "JSES" } }
  16526. };
  16527. var result = new Dictionary<string, int>();
  16528. foreach (var flight in flights.Keys)
  16529. {
  16530. // 获取当前舱位的匹配规则
  16531. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16532. {
  16533. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16534. }
  16535. }
  16536. var allPrice = 0.00M;
  16537. #region right计算
  16538. int airRowIndex = 35;
  16539. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16540. {
  16541. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16542. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16543. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  16544. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  16545. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  16546. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16547. }
  16548. else
  16549. {
  16550. hideRowsList.Add(airRowIndex);
  16551. }
  16552. airRowIndex += 2;
  16553. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16554. {
  16555. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16556. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16557. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  16558. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  16559. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  16560. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16561. }
  16562. else
  16563. {
  16564. hideRowsList.Add(airRowIndex);
  16565. }
  16566. airRowIndex += 2;
  16567. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16568. {
  16569. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16570. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16571. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  16572. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  16573. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  16574. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16575. }
  16576. else
  16577. {
  16578. hideRowsList.Add(airRowIndex);
  16579. }
  16580. airRowIndex += 2;
  16581. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16582. {
  16583. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16584. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16585. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  16586. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  16587. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  16588. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16589. }
  16590. else
  16591. {
  16592. hideRowsList.Add(airRowIndex);
  16593. }
  16594. airRowIndex += 2;
  16595. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16596. {
  16597. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16598. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16599. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  16600. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  16601. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  16602. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16603. }
  16604. else
  16605. {
  16606. hideRowsList.Add(airRowIndex);
  16607. }
  16608. airRowIndex += 2;
  16609. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16610. {
  16611. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16612. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16613. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  16614. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  16615. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  16616. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16617. }
  16618. else
  16619. {
  16620. hideRowsList.Add(airRowIndex);
  16621. }
  16622. airRowIndex += 2;
  16623. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16624. {
  16625. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16626. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16627. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  16628. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  16629. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  16630. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16631. }
  16632. else
  16633. {
  16634. hideRowsList.Add(airRowIndex);
  16635. }
  16636. airRowIndex += 2;
  16637. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16638. {
  16639. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16640. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16641. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  16642. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  16643. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  16644. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16645. }
  16646. else
  16647. {
  16648. hideRowsList.Add(airRowIndex);
  16649. }
  16650. airRowIndex += 2;
  16651. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16652. {
  16653. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16654. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16655. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  16656. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  16657. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  16658. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16659. }
  16660. else
  16661. {
  16662. hideRowsList.Add(airRowIndex);
  16663. }
  16664. #endregion
  16665. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  16666. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  16667. var ws = designer.Workbook.Worksheets[0];
  16668. foreach (var Rowindex in hideRowsList)
  16669. {
  16670. ws.Cells.HideRows(Rowindex, 2);
  16671. }
  16672. designer.Process();
  16673. designer.Workbook.Save(savePaht);
  16674. return Ok(JsonView(true, "生成成功!", new
  16675. {
  16676. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  16677. }));
  16678. }
  16679. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  16680. {
  16681. foreach (var roomType in roomTypes)
  16682. {
  16683. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  16684. {
  16685. hotelRooms[roomType]--;
  16686. flights[flightType]--;
  16687. if (roomType == "TBR")
  16688. {
  16689. flights[flightType]--; // 双人间在减少1
  16690. }
  16691. string key = flightType + roomType;
  16692. if (result.Keys.Contains(key))
  16693. {
  16694. result[key]++;
  16695. }
  16696. else
  16697. {
  16698. result.Add(key, 1);
  16699. }
  16700. }
  16701. }
  16702. }
  16703. private class AirHotelPrice
  16704. {
  16705. public string Name { get; set; }
  16706. public decimal Price { get; set; }
  16707. public int Count { get; set; }
  16708. }
  16709. #endregion
  16710. #region 酒店预订 New 2023-12-28 17:45
  16711. /// <summary>
  16712. /// 酒店预订
  16713. /// 酒店费用列表 根据团组Id查询
  16714. /// </summary>
  16715. /// <param name="_dto"></param>
  16716. /// <returns></returns>
  16717. [HttpPost]
  16718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16719. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  16720. {
  16721. #region 参数验证
  16722. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16723. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16724. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16725. #region 团组操作权限验证 76 酒店预定模块
  16726. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16727. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16728. #endregion
  16729. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16730. #region 页面操作权限验证
  16731. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16732. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16733. #endregion
  16734. #endregion
  16735. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  16736. }
  16737. /// <summary>
  16738. /// 酒店预订
  16739. /// 基础数据
  16740. /// </summary>
  16741. /// <param name="_dto"></param>
  16742. /// <returns></returns>
  16743. [HttpPost]
  16744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16745. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  16746. {
  16747. #region 参数验证
  16748. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16749. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16750. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16751. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16752. #region 页面操作权限验证
  16753. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16754. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16755. #endregion
  16756. #region 团组操作权限验证 76 酒店预定模块
  16757. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16758. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16759. #endregion
  16760. #endregion
  16761. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  16762. }
  16763. /// <summary>
  16764. /// 酒店预订
  16765. /// 创建 入住卷号码
  16766. /// </summary>
  16767. /// <param name="_dto"></param>
  16768. /// <returns></returns>
  16769. [HttpPost]
  16770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16771. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  16772. {
  16773. #region 参数验证
  16774. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16775. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16776. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16777. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16778. #region 页面操作权限验证
  16779. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16780. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16781. #endregion
  16782. #region 团组操作权限验证 76 酒店预定模块
  16783. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16784. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16785. #endregion
  16786. #endregion
  16787. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  16788. if (data.Code != 0)
  16789. {
  16790. return Ok(JsonView(false, data.Msg));
  16791. }
  16792. return Ok(JsonView(true, data.Msg, data.Data));
  16793. }
  16794. /// <summary>
  16795. /// 酒店预订
  16796. /// 详情
  16797. /// </summary>
  16798. /// <param name="_dto"></param>
  16799. /// <returns></returns>
  16800. [HttpPost]
  16801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16802. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  16803. {
  16804. #region 参数验证
  16805. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  16806. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16807. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  16808. #region 团组操作权限验证 76 酒店预定模块
  16809. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16810. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16811. #endregion
  16812. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16813. #region 页面操作权限验证
  16814. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16815. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16816. #endregion
  16817. #endregion
  16818. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  16819. }
  16820. /// <summary>
  16821. /// 酒店预订
  16822. /// Add Or Edit
  16823. /// </summary>
  16824. /// <param name="_dto"></param>
  16825. /// <returns></returns>
  16826. [HttpPost]
  16827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16828. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  16829. {
  16830. #region 参数验证
  16831. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16832. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16833. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16834. #region 团组操作权限验证 76 酒店预定模块
  16835. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16836. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16837. #endregion
  16838. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16839. #region 页面操作权限验证
  16840. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16841. if (_dto.Id == 0) // Add
  16842. {
  16843. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16844. }
  16845. else if (_dto.Id > 1) // Edit
  16846. {
  16847. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16848. }
  16849. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  16850. #endregion
  16851. #endregion
  16852. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  16853. if (_view.Code != 200)
  16854. {
  16855. return Ok(_view);
  16856. }
  16857. #region 成本无酒店价格数据进入超支
  16858. _sqlSugar.BeginTran();
  16859. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  16860. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  16861. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  16862. for (int i = 0; i < groupCost.Count; i++)
  16863. {
  16864. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  16865. {
  16866. groupCost[i].Date = groupCost[i - 1].Date;
  16867. }
  16868. }
  16869. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  16870. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  16871. List<Fin_GroupExtraCostDto_OP>();
  16872. if (start_Bool && end_Bool)
  16873. {
  16874. while (start_Time < end_Time)
  16875. {
  16876. foreach (var item in groupCost_Grp)
  16877. {
  16878. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  16879. {
  16880. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  16881. {
  16882. extraCostList.Add(new
  16883. Fin_GroupExtraCostDto_OP
  16884. {
  16885. Area = _dto.AreaId,
  16886. coefficient = 1.5M,
  16887. createUser = _dto.UserId,
  16888. currency = _dto.CardPriceCurrency,
  16889. diId = _dto.DiId,
  16890. ManagerConfirm = 0,
  16891. SupervisorConfirm = 0,
  16892. SYsupervisorConfirm = 0,
  16893. editType = 1,
  16894. PortType = 1,
  16895. price = _dto.CardPrice,
  16896. PriceCount = 1,
  16897. priceType = 1027,
  16898. priceDetailType = 1044,
  16899. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  16900. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  16901. });
  16902. }
  16903. }
  16904. }
  16905. start_Time = start_Time.AddDays(1);
  16906. }
  16907. }
  16908. if (extraCostList.Any())
  16909. {
  16910. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  16911. }
  16912. _sqlSugar.CommitTran();
  16913. #endregion
  16914. #region 应用推送
  16915. try
  16916. {
  16917. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  16918. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  16919. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  16920. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  16921. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  16922. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  16923. var diId = _dto.DiId;
  16924. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16925. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16926. #region 操作记录
  16927. var opInfo = new Crm_TableOperationRecord()
  16928. {
  16929. TableName = "Grp_HotelReservations",
  16930. PortType = _dto.PortType,
  16931. DataId = hotelId,
  16932. CreateUserId = _dto.UserId
  16933. };
  16934. //var opStatus = OperationEnum.NoOperation;
  16935. if (_dto.Id < 1) //添加操作
  16936. {
  16937. opInfo.OperationItem = OperationEnum.Add;
  16938. }
  16939. else if (_dto.Id > 0)
  16940. {
  16941. opInfo.OperationItem = OperationEnum.Edit;
  16942. }
  16943. string opRemark = string.Empty;
  16944. if (ccpInfo != null)
  16945. {
  16946. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  16947. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  16948. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  16949. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  16950. }
  16951. opInfo.Remark = opRemark;
  16952. await _tableorRep.AddAsync(opInfo);
  16953. #endregion
  16954. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  16955. //2024-10-21 新增LZ UID
  16956. var userIds = new List<int>() { 21 };
  16957. string title = $"费用审核";
  16958. string content = "";
  16959. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16960. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16961. try
  16962. {
  16963. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  16964. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  16965. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  16966. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  16967. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  16968. }
  16969. catch (Exception ex)
  16970. {
  16971. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  16972. }
  16973. }
  16974. catch (Exception ex)
  16975. {
  16976. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  16977. }
  16978. try
  16979. {
  16980. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  16981. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  16982. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  16983. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  16984. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  16985. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  16986. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16987. //自动审核
  16988. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  16989. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  16990. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  16991. //2024-10-21 新增LZ UID
  16992. var userIds = new List<int>() { 21 };
  16993. string title = $"系统通知";
  16994. var diId = _dto.DiId;
  16995. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16996. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16997. string content = "";
  16998. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16999. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17000. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17001. }
  17002. catch (Exception ex)
  17003. {
  17004. }
  17005. #endregion
  17006. return Ok(_view);
  17007. }
  17008. /// <summary>
  17009. /// 酒店自动审核测试
  17010. /// Add Or Edit
  17011. /// </summary>
  17012. /// <param name="diid"></param>
  17013. /// <param name="dataId"></param>
  17014. /// <returns></returns>
  17015. [HttpPost]
  17016. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17017. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  17018. {
  17019. #region 应用推送
  17020. try
  17021. {
  17022. //自动审核
  17023. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  17024. }
  17025. catch (Exception ex)
  17026. {
  17027. return Ok(JsonView(false, "操作失败"));
  17028. }
  17029. #endregion
  17030. return Ok(JsonView(false, "操作成功"));
  17031. }
  17032. /// <summary>
  17033. /// 酒店预订
  17034. /// Del
  17035. /// </summary>
  17036. /// <param name="_dto"></param>
  17037. /// <returns></returns>
  17038. [HttpPost]
  17039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17040. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  17041. {
  17042. #region 参数验证
  17043. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17044. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17045. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17046. #region 团组操作权限验证 76 酒店预定模块
  17047. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17048. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17049. #endregion
  17050. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17051. #region 页面操作权限验证
  17052. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17053. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  17054. #endregion
  17055. #endregion
  17056. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  17057. #region 操作记录
  17058. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  17059. {
  17060. TableName = "Grp_HotelReservations",
  17061. PortType = _dto.PortType,
  17062. OperationItem = OperationEnum.Del,
  17063. DataId = _dto.Id,
  17064. CreateUserId = _dto.UserId
  17065. });
  17066. #endregion
  17067. return Ok(data);
  17068. }
  17069. /// <summary>
  17070. /// 酒店预订
  17071. /// 生成VOUCHER
  17072. /// 2024.05.06 之前版本
  17073. /// </summary>
  17074. /// <param name="_dto"></param>
  17075. /// <returns></returns>
  17076. [HttpPost]
  17077. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17078. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  17079. {
  17080. try
  17081. {
  17082. #region 参数验证
  17083. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17084. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17085. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17086. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  17087. #region 团组操作权限验证 76 酒店预定模块
  17088. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17089. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17090. #endregion
  17091. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17092. #region 页面操作权限验证
  17093. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17094. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17095. #endregion
  17096. #endregion
  17097. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  17098. //判断数据是否完整
  17099. if (hr != null)
  17100. {
  17101. if (!string.IsNullOrEmpty(hr.DetermineNo))
  17102. {
  17103. string strFileName = "HotelStatement/";
  17104. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17105. if (dele != null)
  17106. strFileName += dele.TourCode;
  17107. //载入模板
  17108. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  17109. Document doc = new Document(sss);
  17110. DocumentBuilder builder = new DocumentBuilder(doc);
  17111. #region 替换Word模板书签内容
  17112. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  17113. //入住卷预定号码
  17114. if (doc.Range.Bookmarks["VNO"] != null)
  17115. {
  17116. Bookmark mark = doc.Range.Bookmarks["VNO"];
  17117. mark.Text = hr.CheckNumber;
  17118. }
  17119. //酒店时间
  17120. if (doc.Range.Bookmarks["Date"] != null)
  17121. {
  17122. Bookmark mark = doc.Range.Bookmarks["Date"];
  17123. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17124. }
  17125. //团号
  17126. if (doc.Range.Bookmarks["TNo"] != null)
  17127. {
  17128. Bookmark mark = doc.Range.Bookmarks["TNo"];
  17129. mark.Text = dele.TourCode;
  17130. }
  17131. //预定号码
  17132. if (doc.Range.Bookmarks["BookingId"] != null)
  17133. {
  17134. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  17135. mark.Text = hr.ReservationsNo;
  17136. }
  17137. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  17138. {
  17139. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  17140. mark.Text = hr.DetermineNo;
  17141. }
  17142. //酒店城市
  17143. if (doc.Range.Bookmarks["City"] != null)
  17144. {
  17145. Bookmark mark = doc.Range.Bookmarks["City"];
  17146. mark.Text = hr.City;
  17147. }
  17148. //酒店名称
  17149. if (doc.Range.Bookmarks["HName"] != null)
  17150. {
  17151. Bookmark mark = doc.Range.Bookmarks["HName"];
  17152. mark.Text = hr.HotelName;
  17153. }
  17154. //酒店地址
  17155. if (doc.Range.Bookmarks["Address"] != null)
  17156. {
  17157. Bookmark mark = doc.Range.Bookmarks["Address"];
  17158. mark.Text = hr.HotelAddress;
  17159. }
  17160. //酒店电话
  17161. if (doc.Range.Bookmarks["Tel"] != null)
  17162. {
  17163. Bookmark mark = doc.Range.Bookmarks["Tel"];
  17164. mark.Text = hr.HotelTel;
  17165. }
  17166. //酒店传真
  17167. if (doc.Range.Bookmarks["Fax"] != null)
  17168. {
  17169. Bookmark mark = doc.Range.Bookmarks["Fax"];
  17170. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  17171. {
  17172. mark.Text = hr.HotelFax;
  17173. }
  17174. }
  17175. //入住时间
  17176. if (doc.Range.Bookmarks["CIn"] != null)
  17177. {
  17178. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17179. Bookmark mark = doc.Range.Bookmarks["CIn"];
  17180. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  17181. }
  17182. //退房时间
  17183. if (doc.Range.Bookmarks["COut"] != null)
  17184. {
  17185. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17186. Bookmark mark = doc.Range.Bookmarks["COut"];
  17187. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17188. }
  17189. //客户名称
  17190. if (doc.Range.Bookmarks["GName"] != null)
  17191. {
  17192. string guestName = "";
  17193. string[] clients = new string[] { };
  17194. if (hr.GuestName.Contains(","))
  17195. {
  17196. clients = hr.GuestName.Split(",");
  17197. }
  17198. else
  17199. {
  17200. clients = new string[] { hr.GuestName };
  17201. }
  17202. List<int> clientIds_int = new List<int>();
  17203. if (clients.Length > 0)
  17204. {
  17205. foreach (var item in clients)
  17206. {
  17207. if (item.IsNumeric())
  17208. {
  17209. clientIds_int.Add(int.Parse(item));
  17210. }
  17211. }
  17212. }
  17213. if (clientIds_int.Count > 0)
  17214. {
  17215. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  17216. foreach (var client in _clientDatas)
  17217. {
  17218. //男
  17219. if (client.Sex == 0) guestName += $"Mr.";
  17220. //女
  17221. else if (client.Sex == 1) guestName += $"Ms.";
  17222. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  17223. {
  17224. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  17225. }
  17226. //guestName += $"{client.Pinyin},";
  17227. }
  17228. if (guestName.Length > 0)
  17229. {
  17230. guestName = guestName.Substring(0, guestName.Length - 1);
  17231. }
  17232. }
  17233. else
  17234. {
  17235. guestName = hr.GuestName;
  17236. }
  17237. Bookmark mark = doc.Range.Bookmarks["GName"];
  17238. mark.Text = guestName;
  17239. }
  17240. //房间介绍
  17241. if (doc.Range.Bookmarks["ROOM"] != null)
  17242. {
  17243. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  17244. mark.Text = hr.RoomExplanation;
  17245. }
  17246. //报价描述
  17247. if (doc.Range.Bookmarks["NOTE"] != null)
  17248. {
  17249. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  17250. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  17251. if (ss != null)
  17252. mark.Text = ss.Name;
  17253. }
  17254. //入住时间
  17255. if (doc.Range.Bookmarks["CheckIn"] != null)
  17256. {
  17257. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17258. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  17259. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17260. }
  17261. //退房时间
  17262. if (doc.Range.Bookmarks["CheckOut"] != null)
  17263. {
  17264. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17265. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  17266. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17267. }
  17268. //日期
  17269. if (doc.Range.Bookmarks["DT"] != null)
  17270. {
  17271. Bookmark mark = doc.Range.Bookmarks["DT"];
  17272. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17273. }
  17274. //名称
  17275. if (doc.Range.Bookmarks["VName"] != null)
  17276. {
  17277. Bookmark mark = doc.Range.Bookmarks["VName"];
  17278. mark.Text = hr.HotelName;
  17279. }
  17280. //号码
  17281. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  17282. {
  17283. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  17284. mark.Text = hr.CheckNumber;
  17285. }
  17286. #endregion
  17287. strFileName += "VOUCHER.doc";
  17288. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17289. doc.Save(fileDir);
  17290. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17291. return Ok(JsonView(true, "操作成功!", Url));
  17292. }
  17293. else
  17294. {
  17295. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  17296. }
  17297. }
  17298. else
  17299. {
  17300. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  17301. }
  17302. }
  17303. catch (Exception ex)
  17304. {
  17305. return Ok(JsonView(false, ex.Message));
  17306. }
  17307. }
  17308. /// <summary>
  17309. /// 酒店预订
  17310. /// 生成VOUCHER
  17311. /// 2024.05.06 之后版本
  17312. /// </summary>
  17313. /// <param name="_dto"></param>
  17314. /// <returns></returns>
  17315. [HttpPost]
  17316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17317. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  17318. {
  17319. #region 参数验证
  17320. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17321. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17322. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17323. #region 团组操作权限验证 76 酒店预定模块
  17324. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17325. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17326. #endregion
  17327. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17328. #region 页面操作权限验证
  17329. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17330. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17331. #endregion
  17332. #endregion
  17333. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  17334. //判断数据是否完整
  17335. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17336. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17337. string strFileName = "HotelStatement/";
  17338. string guestNames = ""; //格式Mr.xxx Ms.xxx
  17339. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  17340. #region 数据处理
  17341. List<int> guestIds = new List<int>();
  17342. //int index = 0;
  17343. foreach (var item in hrDtas)
  17344. {
  17345. if (item.GuestName.Contains(","))
  17346. {
  17347. string[] guestIdArr = item.GuestName.Split(',');
  17348. foreach (var guestIdStr in guestIdArr)
  17349. {
  17350. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  17351. if (guestBool)
  17352. {
  17353. guestIds.Add(guestId);
  17354. }
  17355. }
  17356. }
  17357. else guestNames += item.GuestName;
  17358. var voucherInfo = new HotelVoucherInfoView()
  17359. {
  17360. HotelName = item.HotelName,
  17361. CheckInDate = item.CheckInDate,
  17362. CheckOutDate = item.CheckOutDate,
  17363. ConfirmationNumber = item.DetermineNo.Trim(),
  17364. RoomType = item.RoomExplanation
  17365. };
  17366. vouchers.Add(voucherInfo);
  17367. }
  17368. if (guestIds.Count > 0)
  17369. {
  17370. guestIds = guestIds.Distinct().ToList();
  17371. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  17372. if (guestDatas.Count > 0)
  17373. {
  17374. guestNames = "";
  17375. foreach (var guest in guestDatas)
  17376. {
  17377. string guestName = "";
  17378. if (guest.Sex == 0) guestName += @"MR.";
  17379. else if (guest.Sex == 1) guestName += @"MS.";
  17380. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17381. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17382. guestNames += @$"{guestName.Trim()}、";
  17383. }
  17384. if (guestNames.Length > 0)
  17385. {
  17386. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17387. }
  17388. }
  17389. }
  17390. #endregion
  17391. //载入模板
  17392. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  17393. Document doc = new Document(sss);
  17394. DocumentBuilder builder = new DocumentBuilder(doc);
  17395. if (doc.Range.Bookmarks["GuestName"] != null)
  17396. {
  17397. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  17398. mark.Text = guestNames;
  17399. }
  17400. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17401. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  17402. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  17403. for (int i = 1; i <= vouchers.Count; i++)
  17404. {
  17405. HotelVoucherInfoView hviv = vouchers[i - 1];
  17406. builder.MoveToCell(0, i, 0, 0);
  17407. builder.Write(hviv.HotelName);
  17408. builder.MoveToCell(0, i, 1, 0);
  17409. builder.Write(hviv.CheckInDate);
  17410. builder.MoveToCell(0, i, 2, 0);
  17411. builder.Write(hviv.CheckOutDate);
  17412. builder.MoveToCell(0, i, 3, 0);
  17413. builder.Write(hviv.RoomType);
  17414. builder.MoveToCell(0, i, 4, 0);
  17415. builder.Write(hviv.ConfirmationNumber);
  17416. }
  17417. //删除多余行
  17418. int currRowIndex = vouchers.Count + 1;
  17419. int delRows = 21 - currRowIndex;
  17420. if (delRows > 0)
  17421. {
  17422. for (int i = 0; i < delRows; i++)
  17423. {
  17424. table.Rows.RemoveAt(currRowIndex);
  17425. //cultivateRowIndex++;
  17426. }
  17427. }
  17428. strFileName += "VOUCHER.docx";
  17429. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17430. doc.Save(fileDir);
  17431. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17432. return Ok(JsonView(true, "操作成功!", Url));
  17433. }
  17434. /// <summary>
  17435. /// 酒店预订
  17436. /// 生成VOUCHER 批量生成
  17437. /// New
  17438. /// </summary>
  17439. /// <param name="_dto"></param>
  17440. /// <returns></returns>
  17441. [HttpPost]
  17442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17443. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  17444. {
  17445. #region 参数验证
  17446. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17447. if (_dto.PageId < 1) _dto.PageId = 28;
  17448. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17449. #region 团组操作权限验证 76 酒店预定模块
  17450. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17451. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17452. #endregion
  17453. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17454. #region 页面操作权限验证
  17455. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17456. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17457. #endregion
  17458. #endregion
  17459. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  17460. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  17461. .OrderBy(x => x.CheckInDate)
  17462. .ToListAsync();
  17463. //判断数据是否完整
  17464. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17465. string strFileName = "HotelStatement/";
  17466. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17467. if (dele != null)
  17468. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  17469. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  17470. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  17471. .Where(it => it.IsDel == 0)
  17472. .ToListAsync();
  17473. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  17474. for (int i = 0; i < hrDtas.Count; i++)
  17475. {
  17476. string guestNames = string.Empty;
  17477. List<int> guestIds = new List<int>();
  17478. var item = hrDtas[i];
  17479. //处理客户姓名
  17480. if (item.GuestName.Contains(","))
  17481. {
  17482. string[] guestIdArr = item.GuestName.Split(',');
  17483. foreach (var guestIdStr in guestIdArr)
  17484. if (int.TryParse(guestIdStr, out int guestId))
  17485. guestIds.Add(guestId);
  17486. }
  17487. else
  17488. {
  17489. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  17490. if (guestIdBool)
  17491. {
  17492. guestIds.Add(guestId);
  17493. }
  17494. //NaN
  17495. if (item.GuestName.Contains("NaN"))
  17496. {
  17497. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  17498. }
  17499. }
  17500. if (guestIds.Count > 0)
  17501. {
  17502. guestIds = guestIds.Distinct().ToList();
  17503. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  17504. if (guestDatas1.Count > 0)
  17505. {
  17506. guestNames = "";
  17507. foreach (var guest in guestDatas1)
  17508. {
  17509. string guestName = "";
  17510. if (guest.Sex == 0) guestName += @"MR.";
  17511. else if (guest.Sex == 1) guestName += @"MS.";
  17512. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17513. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17514. guestNames += @$"{guestName.Trim()}、";
  17515. }
  17516. if (guestNames.Length > 0)
  17517. {
  17518. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17519. }
  17520. }
  17521. }
  17522. //if (!string.IsNullOrEmpty(guestNames))
  17523. //{
  17524. hrDtas[i].GuestName = guestNames;
  17525. //}
  17526. }
  17527. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  17528. Document doc = new Document();
  17529. DocumentBuilder builder = new DocumentBuilder(doc);
  17530. try
  17531. {
  17532. builder.MoveToDocumentStart();
  17533. foreach (var item in hrDtas)
  17534. {
  17535. //标题
  17536. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17537. builder.ParagraphFormat.LineSpacing = 1;
  17538. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17539. builder.ParagraphFormat.Style.Font.Size = 9;
  17540. builder.ParagraphFormat.Style.Font.Bold = true;
  17541. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17542. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  17543. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17544. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17545. builder.ParagraphFormat.LineSpacing = 1;
  17546. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17547. builder.ParagraphFormat.Style.Font.Size = 9;
  17548. builder.ParagraphFormat.Style.Font.Bold = true;
  17549. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  17550. builder.StartTable();
  17551. // 设置边框颜色
  17552. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  17553. //设置边框样式
  17554. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  17555. //表格
  17556. #region 第一行
  17557. builder.InsertCell();
  17558. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17559. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17560. //builder.CellFormat.AllowAutoFit = false;
  17561. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17562. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17563. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17564. builder.CellFormat.WrapText = true; //自动换行
  17565. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17566. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  17567. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17568. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17569. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17570. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17571. builder.Write("TOUR NO:");
  17572. builder.InsertCell();
  17573. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17574. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17575. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17576. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17577. builder.ParagraphFormat.Style.Font.Bold = false;
  17578. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17579. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17580. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17581. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17582. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17583. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17584. builder.Write($"{dele?.TourCode ?? "-"}");
  17585. builder.InsertCell();
  17586. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17587. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17588. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17589. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17590. builder.ParagraphFormat.Style.Font.Bold = false;
  17591. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17592. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17593. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17594. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17595. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17596. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17597. builder.Write($"CITY:");
  17598. builder.InsertCell();
  17599. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17600. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17601. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17602. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17603. builder.ParagraphFormat.Style.Font.Bold = false;
  17604. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17605. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17606. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17607. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17608. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17609. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17610. builder.Write($"{item.City}");
  17611. builder.EndRow();
  17612. #endregion
  17613. #region 第二行
  17614. builder.InsertCell();
  17615. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17616. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17617. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17618. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17619. builder.ParagraphFormat.Style.Font.Bold = false;
  17620. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17621. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17622. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17623. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17624. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17625. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17626. builder.Write("CONFIRMATION NO:");
  17627. builder.InsertCell();
  17628. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17629. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17630. builder.ParagraphFormat.Style.Font.Size = 8;
  17631. builder.ParagraphFormat.Style.Font.Bold = false;
  17632. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17633. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17634. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17635. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17636. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17637. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17638. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17639. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17640. builder.Write($"{item.DetermineNo}");
  17641. builder.InsertCell();
  17642. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17643. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17644. builder.InsertCell();
  17645. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17646. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17647. builder.EndRow();
  17648. #endregion
  17649. #region 第三行
  17650. builder.InsertCell();
  17651. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17652. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17653. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17654. builder.ParagraphFormat.Style.Font.Bold = false;
  17655. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17656. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17657. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17658. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17659. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17660. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17661. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17662. builder.Write($"HOTEL NAME:");
  17663. builder.InsertCell();
  17664. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17665. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17666. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17667. builder.ParagraphFormat.Style.Font.Bold = false;
  17668. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17669. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17670. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17671. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17672. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17673. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17674. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17675. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17676. builder.Write($"{item.HotelName}");
  17677. builder.InsertCell();
  17678. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17679. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17680. builder.InsertCell();
  17681. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17682. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17683. builder.EndRow();
  17684. #endregion
  17685. #region 第四行
  17686. builder.InsertCell();
  17687. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17688. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17689. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17690. builder.ParagraphFormat.Style.Font.Bold = false;
  17691. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17692. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17693. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17694. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17695. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17696. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17697. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17698. builder.Write($"HOTEL ADDRESS:");
  17699. builder.InsertCell();
  17700. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17701. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17702. builder.ParagraphFormat.Style.Font.Size = 8;
  17703. builder.ParagraphFormat.Style.Font.Bold = false;
  17704. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17705. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17706. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17707. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17708. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17709. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17710. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17711. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17712. builder.Write($"{item.HotelAddress}");
  17713. builder.InsertCell();
  17714. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17715. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17716. builder.InsertCell();
  17717. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17718. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17719. builder.EndRow();
  17720. #endregion
  17721. #region 第五行
  17722. builder.InsertCell();
  17723. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17724. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17725. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17726. builder.ParagraphFormat.Style.Font.Bold = false;
  17727. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17728. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17729. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17730. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17731. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17732. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17733. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17734. builder.Write("TEL:");
  17735. builder.InsertCell();
  17736. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17737. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17738. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17739. builder.ParagraphFormat.Style.Font.Bold = false;
  17740. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17741. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17742. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17743. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17744. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17745. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17746. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17747. builder.Write($"{item.HotelTel}");
  17748. builder.InsertCell();
  17749. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17750. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17751. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17752. builder.ParagraphFormat.Style.Font.Bold = false;
  17753. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17754. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17755. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17756. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17757. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17758. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17759. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17760. builder.Write($"FAX:");
  17761. builder.InsertCell();
  17762. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17763. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17764. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17765. builder.ParagraphFormat.Style.Font.Bold = false;
  17766. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17767. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17768. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17769. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17770. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17771. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17772. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17773. builder.Write($"{item.HotelFax}");
  17774. builder.EndRow();
  17775. #endregion
  17776. #region 第六行
  17777. builder.InsertCell();
  17778. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17779. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17780. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17781. builder.ParagraphFormat.Style.Font.Bold = false;
  17782. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17783. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17784. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17785. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17786. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17787. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17788. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17789. builder.Write("CHECK IN:");
  17790. builder.InsertCell();
  17791. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17792. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17793. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17794. builder.ParagraphFormat.Style.Font.Bold = false;
  17795. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17796. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17797. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17798. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17799. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17800. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17801. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17802. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  17803. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17804. builder.Write($"{checkInStr}");
  17805. builder.InsertCell();
  17806. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17807. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17808. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17809. builder.ParagraphFormat.Style.Font.Bold = false;
  17810. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17811. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17812. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17813. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17814. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17815. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17816. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17817. builder.Write($"CHECK OUT:");
  17818. builder.InsertCell();
  17819. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17820. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17821. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17822. builder.ParagraphFormat.Style.Font.Bold = false;
  17823. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17824. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17825. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17826. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17827. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17828. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17829. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17830. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  17831. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  17832. builder.Write($"{checkOutStr}");
  17833. builder.EndRow();
  17834. #endregion
  17835. #region 第七行
  17836. builder.InsertCell();
  17837. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17838. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17839. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17840. builder.ParagraphFormat.Style.Font.Bold = false;
  17841. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17842. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17843. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17844. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17845. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17846. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17847. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17848. builder.Write($"GUEST NAME:");
  17849. builder.InsertCell();
  17850. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17851. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17852. builder.ParagraphFormat.Style.Font.Size = 8;
  17853. builder.ParagraphFormat.Style.Font.Bold = false;
  17854. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17855. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17856. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17857. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17858. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17859. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17860. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17861. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17862. builder.Write($"{item.GuestName.Trim()}");
  17863. builder.InsertCell();
  17864. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17865. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17866. builder.InsertCell();
  17867. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17868. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17869. builder.EndRow();
  17870. #endregion
  17871. #region 第八行
  17872. builder.InsertCell();
  17873. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17874. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17875. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17876. builder.ParagraphFormat.Style.Font.Bold = false;
  17877. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17878. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17879. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17880. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17881. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17882. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17883. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17884. builder.Write($"ROOM TYPE:");
  17885. builder.InsertCell();
  17886. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17887. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17888. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17889. builder.ParagraphFormat.Style.Font.Bold = false;
  17890. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17891. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17892. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17893. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17894. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17895. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17896. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17897. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17898. builder.Write($"{item.RoomExplanation}");
  17899. builder.InsertCell();
  17900. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17901. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17902. builder.InsertCell();
  17903. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17904. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17905. builder.EndRow();
  17906. #endregion
  17907. #region 第九行
  17908. builder.InsertCell();
  17909. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17910. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17911. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17912. builder.ParagraphFormat.Style.Font.Bold = false;
  17913. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17914. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17915. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17916. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17917. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17918. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17919. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17920. builder.Write($"NOTE:");
  17921. builder.InsertCell();
  17922. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17923. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17924. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17925. builder.ParagraphFormat.Style.Font.Bold = false;
  17926. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17927. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17928. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17929. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17930. 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.");
  17931. builder.InsertCell();
  17932. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17933. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17934. builder.InsertCell();
  17935. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17936. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17937. builder.EndRow();
  17938. #endregion
  17939. builder.EndTable();
  17940. //换行
  17941. builder.Writeln("");
  17942. builder.Writeln("");
  17943. }
  17944. #region 获取文档中的所有表格 设置文字自适应
  17945. // 获取文档中的所有表格。
  17946. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  17947. {
  17948. // 遍历表格中的所有行。
  17949. foreach (Aspose.Words.Tables.Row row in table.Rows)
  17950. {
  17951. foreach (Cell cell in row.Cells)
  17952. {
  17953. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  17954. cellFormat.Width = 0;
  17955. }
  17956. }
  17957. }
  17958. #endregion
  17959. #region 设置页眉
  17960. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  17961. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  17962. if (System.IO.File.Exists(voucherHeaderPath))
  17963. {
  17964. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  17965. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  17966. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  17967. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  17968. // 调整图片位置
  17969. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  17970. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  17971. shape.Top = 50; // 将图片距离页眉上边缘的距离
  17972. shape.Left = 0; // 将图片距离页面左边缘的距离
  17973. shape.Width = 81; // 设置图片宽度
  17974. shape.Height = 36; // 设置图片高度
  17975. }
  17976. //靠右
  17977. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17978. //// 设置页脚上下边距
  17979. //builder.PageSetup.HeaderDistance = 42;
  17980. // 添加页眉线
  17981. Aspose.Words.Border borderHeader = null;
  17982. try
  17983. {
  17984. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  17985. }
  17986. catch (Exception e)
  17987. {
  17988. // TODO Auto-generated catch block
  17989. //e.printStackTrace();
  17990. }
  17991. borderHeader.Shadow = true;
  17992. borderHeader.DistanceFromText = 2;
  17993. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  17994. #endregion
  17995. }
  17996. catch (Exception ex)
  17997. {
  17998. }
  17999. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18000. doc.Save(fileDir);
  18001. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18002. return Ok(JsonView(true, "操作成功!", Url));
  18003. }
  18004. /// <summary>
  18005. /// 酒店预订
  18006. /// 生成 预定成本 Excel
  18007. /// </summary>
  18008. /// <param name="_dto"></param>
  18009. /// <returns></returns>
  18010. [HttpPost]
  18011. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18012. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  18013. {
  18014. #region 参数验证
  18015. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  18016. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  18017. if (!vadalitorRes.IsValid)
  18018. {
  18019. var errors = new StringBuilder();
  18020. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  18021. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  18022. }
  18023. #region 团组操作权限验证 76 酒店预定模块
  18024. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18025. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18026. #endregion
  18027. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18028. #region 页面操作权限验证
  18029. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18030. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18031. #endregion
  18032. #endregion
  18033. decimal _rate = 1.00M;
  18034. string _currency = string.Empty;
  18035. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  18036. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18037. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  18038. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18039. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  18040. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  18041. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  18042. if (_GroupCostParameter == null)
  18043. {
  18044. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  18045. bool isIntType = int.TryParse(_currency, out int currId);
  18046. if (isIntType)
  18047. {
  18048. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18049. }
  18050. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18051. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18052. if (currInfo == null)
  18053. {
  18054. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18055. }
  18056. else _rate = currInfo.Rate;
  18057. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  18058. {
  18059. _rate = _GroupCostParameter.Rate;
  18060. }
  18061. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18062. //string strFileName = "HotelStatement/";
  18063. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18064. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18065. var rateDatas = new List<dynamic>();
  18066. #region 数据处理
  18067. foreach (var item in hrDtas)
  18068. {
  18069. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18070. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18071. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18072. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18073. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18074. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  18075. {
  18076. continue;
  18077. }
  18078. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18079. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  18080. string singleRoomFeeStr = string.Empty,
  18081. doubleRoomFeeStr = string.Empty,
  18082. suiteRoomFeeStr = string.Empty,
  18083. otherRoomFeeStr = string.Empty,
  18084. payMoneyStr = string.Empty,
  18085. cardPriceStr = string.Empty;
  18086. if (roomCurr.Equals("CNY"))
  18087. {
  18088. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  18089. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18090. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18091. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18092. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18093. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  18094. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  18095. }
  18096. else
  18097. {
  18098. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18099. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18100. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18101. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18102. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18103. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18104. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18105. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18106. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18107. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18108. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  18109. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  18110. if (ccpPaymentCurrency.Equals("CNY"))
  18111. {
  18112. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  18113. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18114. }
  18115. else
  18116. {
  18117. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  18118. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  18119. }
  18120. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  18121. if (hotelcardPriceCurrency.Equals("CNY"))
  18122. {
  18123. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18124. }
  18125. else
  18126. {
  18127. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  18128. }
  18129. }
  18130. string breakfastPriceStr = string.Empty,
  18131. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18132. governmentRentStr = string.Empty,
  18133. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18134. cityTaxStr = string.Empty,
  18135. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18136. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  18137. if (!string.IsNullOrEmpty(breakfastCurrency1))
  18138. {
  18139. if (breakfastCurrency1.Equals("CNY"))
  18140. {
  18141. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18142. }
  18143. else
  18144. {
  18145. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  18146. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  18147. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  18148. }
  18149. }
  18150. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18151. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  18152. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  18153. {
  18154. if (governmentRentCurrency.Equals("CNY"))
  18155. {
  18156. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18157. }
  18158. else
  18159. {
  18160. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  18161. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  18162. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  18163. }
  18164. }
  18165. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18166. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  18167. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  18168. {
  18169. if (cityTaxStrCurrency1.Equals("CNY"))
  18170. {
  18171. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18172. }
  18173. else
  18174. {
  18175. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  18176. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  18177. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  18178. }
  18179. }
  18180. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18181. int payDId = roomInfo?.PayDId ?? 0;
  18182. pcfds.Add(new HotelReservations_PCFD_View()
  18183. {
  18184. City = item.City,
  18185. HotelName = item.HotelName,
  18186. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18187. // SingleRoomCount = item.SingleRoomCount,
  18188. SingleRoomPrice = singleRoomFeeStr,
  18189. // DoubleRoomCount = item.DoubleRoomCount,
  18190. DoubleRoomPrice = doubleRoomFeeStr,
  18191. //SuiteRoomCount = item.SuiteRoomCount,
  18192. SuiteRoomPrice = suiteRoomFeeStr,
  18193. OtherRoomPrice = otherRoomFeeStr,
  18194. //OtherRoomCount = item.OtherRoomCount,
  18195. BreakfastPrice = breakfastPriceStr,
  18196. GovernmentRent = governmentRentStr,
  18197. CityTax = cityTaxStr,
  18198. RoomExplanation = item.RoomExplanation,
  18199. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18200. PayTime = roomInfo?.ConsumptionDate,
  18201. BankNo = roomInfo?.BankNo,
  18202. PayMoney = payMoneyStr,
  18203. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18204. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18205. CardPrice = cardPriceStr,
  18206. Remark = ccpInfo.Remark
  18207. });
  18208. }
  18209. #endregion
  18210. //载入模板
  18211. WorkbookDesigner designer = new WorkbookDesigner();
  18212. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18213. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18214. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18215. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18216. var rateDatas1 = rateDatas.Distinct();
  18217. var rateStr = string.Empty;
  18218. foreach (var item in rateDatas1)
  18219. {
  18220. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  18221. }
  18222. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  18223. designer.SetDataSource("Opertor", userInfo.CnName);
  18224. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18225. dt.TableName = "ViewMyHotelReservations";
  18226. designer.SetDataSource(dt);
  18227. designer.Process();
  18228. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18229. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18230. designer.Workbook.Save(serverPath);
  18231. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18232. #region 删除指定行
  18233. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18234. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18235. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18236. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18237. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18238. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18239. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18240. cssIndex = dt.Columns["CityTax"].Ordinal,
  18241. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18242. remarkIndex = dt.Columns["Remark"].Ordinal;
  18243. //删除指定列
  18244. foreach (DataRow item in dt.Rows)
  18245. {
  18246. string singleStr = item["SingleRoomPrice"].ToString();
  18247. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18248. if (containsDigitButNotZero1) singleDel = false;
  18249. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18250. string doubleStr = item["DoubleRoomPrice"].ToString();
  18251. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18252. if (containsDigitButNotZero2) doubleDel = false;
  18253. string suiteStr = item["SuiteRoomPrice"].ToString();
  18254. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18255. if (containsDigitButNotZero3) suiteDel = false;
  18256. string otherStr = item["OtherRoomPrice"].ToString();
  18257. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18258. if (containsDigitButNotZero4) otherDel = false;
  18259. string zcStr = item["BreakfastPrice"].ToString();
  18260. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18261. if (containsDigitButNotZero5) zcDel = false;
  18262. string dsStr = item["GovernmentRent"].ToString();
  18263. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18264. if (containsDigitButNotZero6) dsDel = false;
  18265. string cssStr = item["CityTax"].ToString();
  18266. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18267. if (containsDigitButNotZero7) cssDel = false;
  18268. string cpStr = item["ConsumptionPatterns"].ToString();
  18269. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18270. string remarkStr = item["Remark"].ToString();
  18271. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18272. }
  18273. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18274. DeleteColumn(serverPath, cpIndex, cpDel);
  18275. DeleteColumn(serverPath, dsIndex, dsDel);
  18276. DeleteColumn(serverPath, cssIndex, cssDel);
  18277. DeleteColumn(serverPath, zcIndex, zcDel);
  18278. DeleteColumn(serverPath, otherIndex, otherDel);
  18279. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18280. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18281. DeleteColumn(serverPath, singleIndex, singleDel);
  18282. #endregion
  18283. //只保留第一个表格
  18284. DeleteSheet(serverPath);
  18285. return Ok(JsonView(true, "操作成功", url = rst));
  18286. }
  18287. else
  18288. {
  18289. _currency = _GroupCostParameter.Currency;
  18290. bool isIntType = int.TryParse(_currency, out int currId);
  18291. if (isIntType)
  18292. {
  18293. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18294. }
  18295. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18296. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18297. if (currInfo == null)
  18298. {
  18299. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18300. }
  18301. if (!_currency.ToUpper().Equals("CNY"))
  18302. {
  18303. _rate = _GroupCostParameter.Rate;
  18304. }
  18305. _rate = currInfo.Rate;
  18306. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18307. //string strFileName = "HotelStatement/";
  18308. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18309. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18310. #region 数据处理
  18311. foreach (var item in hrDtas)
  18312. {
  18313. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18314. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18315. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18316. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18317. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18318. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18319. string singleRoomFeeStr = string.Empty,
  18320. doubleRoomFeeStr = string.Empty,
  18321. suiteRoomFeeStr = string.Empty,
  18322. otherRoomFeeStr = string.Empty,
  18323. payMoneyStr = string.Empty,
  18324. cardPriceStr = string.Empty;
  18325. if (roomCurr.Equals(_currency))
  18326. {
  18327. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  18328. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  18329. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  18330. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  18331. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  18332. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  18333. }
  18334. else
  18335. {
  18336. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18337. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18338. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18339. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18340. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18341. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18342. }
  18343. string breakfastPriceStr = string.Empty,
  18344. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18345. governmentRentStr = string.Empty,
  18346. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18347. cityTaxStrStr = string.Empty,
  18348. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18349. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  18350. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  18351. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  18352. int payDId = roomInfo?.PayDId ?? 0;
  18353. pcfds.Add(new HotelReservations_PCFD_View()
  18354. {
  18355. City = item.City,
  18356. HotelName = item.HotelName,
  18357. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18358. // SingleRoomCount = item.SingleRoomCount,
  18359. SingleRoomPrice = singleRoomFeeStr,
  18360. // DoubleRoomCount = item.DoubleRoomCount,
  18361. DoubleRoomPrice = doubleRoomFeeStr,
  18362. //SuiteRoomCount = item.SuiteRoomCount,
  18363. SuiteRoomPrice = suiteRoomFeeStr,
  18364. OtherRoomPrice = otherRoomFeeStr,
  18365. //OtherRoomCount = item.OtherRoomCount,
  18366. BreakfastPrice = breakfastPriceStr,
  18367. GovernmentRent = governmentRentStr,
  18368. CityTax = cityTaxStrStr,
  18369. RoomExplanation = item.RoomExplanation,
  18370. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18371. PayTime = roomInfo?.ConsumptionDate,
  18372. BankNo = roomInfo?.BankNo,
  18373. PayMoney = payMoneyStr,
  18374. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18375. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18376. CardPrice = cardPriceStr,
  18377. Remark = ccpInfo.Remark
  18378. });
  18379. }
  18380. #endregion
  18381. //载入模板
  18382. WorkbookDesigner designer = new WorkbookDesigner();
  18383. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18384. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18385. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18386. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18387. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  18388. designer.SetDataSource("Opertor", userInfo.CnName);
  18389. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18390. dt.TableName = "ViewMyHotelReservations";
  18391. designer.SetDataSource(dt);
  18392. designer.Process();
  18393. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18394. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18395. designer.Workbook.Save(serverPath);
  18396. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18397. #region 删除指定行
  18398. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18399. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18400. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18401. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18402. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18403. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18404. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18405. cssIndex = dt.Columns["CityTax"].Ordinal,
  18406. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18407. remarkIndex = dt.Columns["Remark"].Ordinal;
  18408. //删除指定列
  18409. foreach (DataRow item in dt.Rows)
  18410. {
  18411. string singleStr = item["SingleRoomPrice"].ToString();
  18412. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18413. if (containsDigitButNotZero1) singleDel = false;
  18414. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18415. string doubleStr = item["DoubleRoomPrice"].ToString();
  18416. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18417. if (containsDigitButNotZero2) doubleDel = false;
  18418. string suiteStr = item["SuiteRoomPrice"].ToString();
  18419. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18420. if (containsDigitButNotZero3) suiteDel = false;
  18421. string otherStr = item["OtherRoomPrice"].ToString();
  18422. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18423. if (containsDigitButNotZero4) otherDel = false;
  18424. string zcStr = item["BreakfastPrice"].ToString();
  18425. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18426. if (containsDigitButNotZero5) zcDel = false;
  18427. string dsStr = item["GovernmentRent"].ToString();
  18428. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18429. if (containsDigitButNotZero6) dsDel = false;
  18430. string cssStr = item["CityTax"].ToString();
  18431. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18432. if (containsDigitButNotZero7) cssDel = false;
  18433. string cpStr = item["ConsumptionPatterns"].ToString();
  18434. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18435. string remarkStr = item["Remark"].ToString();
  18436. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18437. }
  18438. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18439. DeleteColumn(serverPath, cpIndex, cpDel);
  18440. DeleteColumn(serverPath, dsIndex, dsDel);
  18441. DeleteColumn(serverPath, cssIndex, cssDel);
  18442. DeleteColumn(serverPath, zcIndex, zcDel);
  18443. DeleteColumn(serverPath, otherIndex, otherDel);
  18444. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18445. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18446. DeleteColumn(serverPath, singleIndex, singleDel);
  18447. #endregion
  18448. //只保留第一个表格
  18449. DeleteSheet(serverPath);
  18450. return Ok(JsonView(true, "操作成功", url = rst));
  18451. }
  18452. //return Ok(JsonView(false));
  18453. }
  18454. /// <summary>
  18455. /// 删除指定列
  18456. /// </summary>
  18457. /// <param name="file"></param>
  18458. /// <param name="columnIndex"></param>
  18459. /// <param name="isDel"></param>
  18460. private void DeleteColumn(string file, int columnIndex, bool isDel)
  18461. {
  18462. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18463. //wb.Save(file);
  18464. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  18465. if (sheet1 != null)
  18466. {
  18467. if (isDel)
  18468. {
  18469. Cells cells = sheet1.Cells;
  18470. cells.DeleteColumn(columnIndex);
  18471. }
  18472. }
  18473. wb.Save(file);
  18474. }
  18475. /// <summary>
  18476. /// 删除sheet
  18477. /// </summary>
  18478. /// <param name="file"></param>
  18479. /// <param name="sheetName"></param>
  18480. private void DeleteSheet(string file, string sheetName = "")
  18481. {
  18482. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18483. //wb.Save(file);
  18484. List<string> sheets = new List<string>();
  18485. foreach (var item in wb.Worksheets)
  18486. {
  18487. sheets.Add(item.Name);
  18488. }
  18489. if (sheets.Count > 0)
  18490. {
  18491. sheets.RemoveAt(0);//不删除第一个sheet
  18492. foreach (var item in sheets)
  18493. {
  18494. wb.Worksheets.RemoveAt(item);
  18495. }
  18496. }
  18497. wb.Save(file);
  18498. }
  18499. /// <summary>
  18500. /// 酒店预订
  18501. /// 确认单
  18502. /// </summary>
  18503. /// <param name="_dto"></param>
  18504. /// <returns></returns>
  18505. [HttpPost]
  18506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18507. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  18508. {
  18509. try
  18510. {
  18511. #region 参数验证
  18512. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18513. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18514. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18515. #region 团组操作权限验证 76 酒店预定模块
  18516. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18517. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18518. #endregion
  18519. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18520. #region 页面操作权限验证
  18521. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18522. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18523. #endregion
  18524. #endregion
  18525. //团组信息
  18526. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  18527. //酒店数据
  18528. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  18529. if (listhoteldata.Count < 0)
  18530. {
  18531. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  18532. }
  18533. //利datatable存储
  18534. DataTable dt = new DataTable();
  18535. dt.Columns.Add("CheckInDate", typeof(string));
  18536. dt.Columns.Add("City", typeof(string));
  18537. dt.Columns.Add("Hotel", typeof(string));
  18538. dt.Columns.Add("Room", typeof(string));
  18539. for (int i = 0; i < listhoteldata.Count; i++)
  18540. {
  18541. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  18542. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  18543. while (dayStart < dayEnd)
  18544. {
  18545. string temp = "";
  18546. DataRow row = dt.NewRow();
  18547. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  18548. row["City"] = listhoteldata[i].City;
  18549. row["Hotel"] = listhoteldata[i].HotelName;
  18550. if (listhoteldata[i].SingleRoomCount > 0)
  18551. {
  18552. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  18553. }
  18554. if (listhoteldata[i].DoubleRoomCount > 0)
  18555. {
  18556. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  18557. }
  18558. if (listhoteldata[i].SuiteRoomCount > 0)
  18559. {
  18560. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  18561. }
  18562. if (listhoteldata[i].OtherRoomCount > 0)
  18563. {
  18564. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  18565. }
  18566. row["Room"] = temp;
  18567. dt.Rows.Add(row);
  18568. dayStart = dayStart.AddDays(1);
  18569. }
  18570. }
  18571. Dictionary<string, string> dic = new Dictionary<string, string>();
  18572. dic.Add("Dele", di.TeamName);
  18573. dic.Add("City", di.VisitCountry);
  18574. //模板路径
  18575. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  18576. //载入模板
  18577. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  18578. DocumentBuilder builder = new DocumentBuilder(doc);
  18579. foreach (var key in dic.Keys)
  18580. {
  18581. builder.MoveToBookmark(key);
  18582. builder.Write(dic[key]);
  18583. }
  18584. //获取word里所有表格
  18585. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18586. //获取所填表格的序数
  18587. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18588. var rowStart = tableOne.Rows[0]; //获取第1行
  18589. //循环赋值
  18590. for (int i = 0; i < dt.Rows.Count; i++)
  18591. {
  18592. builder.MoveToCell(0, i + 1, 0, 0);
  18593. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  18594. builder.MoveToCell(0, i + 1, 1, 0);
  18595. builder.Write(dt.Rows[i]["City"].ToString());
  18596. builder.MoveToCell(0, i + 1, 2, 0);
  18597. builder.Write(dt.Rows[i]["Hotel"].ToString());
  18598. builder.MoveToCell(0, i + 1, 3, 0);
  18599. builder.Write(dt.Rows[i]["Room"].ToString());
  18600. }
  18601. //删除多余行
  18602. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  18603. {
  18604. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  18605. }
  18606. string strFileName = di.TeamName + "酒店确认单.doc";
  18607. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  18608. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  18609. return Ok(JsonView(true, "成功", url));
  18610. }
  18611. catch (Exception ex)
  18612. {
  18613. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  18614. }
  18615. }
  18616. #endregion
  18617. #region 团组状态
  18618. /// <summary>
  18619. /// 团组状态列表 Page
  18620. /// </summary>
  18621. /// <param name="dto">团组列表请求dto</param>
  18622. /// <returns></returns>
  18623. [HttpPost]
  18624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18625. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  18626. {
  18627. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18628. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  18629. {
  18630. string sqlWhere = string.Empty;
  18631. if (dto.IsSure == 0) //未完成
  18632. {
  18633. sqlWhere += string.Format(@" And IsSure = 0");
  18634. }
  18635. else if (dto.IsSure == 1) //已完成
  18636. {
  18637. sqlWhere += string.Format(@" And IsSure = 1");
  18638. }
  18639. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  18640. {
  18641. string tj = dto.SearchCriteria;
  18642. 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}%')",
  18643. tj, tj, tj, tj, tj);
  18644. }
  18645. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  18646. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  18647. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  18648. From (
  18649. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  18650. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  18651. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  18652. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  18653. From Grp_DelegationInfo gdi
  18654. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  18655. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  18656. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  18657. Where gdi.IsDel = 0 {0}
  18658. ) temp ", sqlWhere);
  18659. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  18660. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  18661. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  18662. }
  18663. else
  18664. {
  18665. return Ok(JsonView(false, "查询失败"));
  18666. }
  18667. }
  18668. /// <summary>
  18669. /// 团组状态
  18670. /// 设置操作完成
  18671. /// </summary>
  18672. /// <param name="dto">团组列表请求dto</param>
  18673. /// <returns></returns>
  18674. [HttpPost]
  18675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18676. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  18677. {
  18678. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18679. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  18680. {
  18681. Id = dto.Id,
  18682. IsSure = 1
  18683. };
  18684. var result = await _sqlSugar.Updateable(_DelegationInfo)
  18685. .UpdateColumns(it => new { it.IsSure })
  18686. .WhereColumns(it => new { it.Id })
  18687. .ExecuteCommandAsync();
  18688. if (result > 0)
  18689. {
  18690. return Ok(JsonView(true, "操作完成!"));
  18691. }
  18692. return Ok(JsonView(false, "操作失败!"));
  18693. }
  18694. #endregion
  18695. #region 保险费用录入
  18696. /// <summary>
  18697. /// 根据团组Id查询保险费用列表
  18698. /// </summary>
  18699. /// <param name="dto"></param>
  18700. /// <returns></returns>
  18701. [HttpPost]
  18702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18703. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  18704. {
  18705. Result groupData = await _customersRep.CustomersByDiId(dto);
  18706. if (groupData.Code != 0)
  18707. {
  18708. return Ok(JsonView(false, groupData.Msg));
  18709. }
  18710. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18711. }
  18712. /// <summary>
  18713. /// 根据保险费用Id查询保险费用详细
  18714. /// </summary>
  18715. /// <param name="dto"></param>
  18716. /// <returns></returns>
  18717. [HttpPost]
  18718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18719. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  18720. {
  18721. try
  18722. {
  18723. Result groupData = await _customersRep.CustomersById(dto);
  18724. if (groupData.Code != 0)
  18725. {
  18726. return Ok(JsonView(false, groupData.Msg));
  18727. }
  18728. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18729. }
  18730. catch (Exception ex)
  18731. {
  18732. return Ok(JsonView(false, ex.Message));
  18733. }
  18734. }
  18735. /// <summary>
  18736. /// 保险费用录入页面初始化绑定
  18737. /// </summary>
  18738. /// <param name="dto"></param>
  18739. /// <returns></returns>
  18740. [HttpPost]
  18741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18742. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  18743. {
  18744. try
  18745. {
  18746. Result groupData = await _customersRep.CustomersInitialize(dto);
  18747. if (groupData.Code != 0)
  18748. {
  18749. return Ok(JsonView(false, groupData.Msg));
  18750. }
  18751. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18752. }
  18753. catch (Exception ex)
  18754. {
  18755. return Ok(JsonView(false, ex.Message));
  18756. }
  18757. }
  18758. /// <summary>
  18759. /// 保险费用操作(Status:1.新增,2.修改)
  18760. /// </summary>
  18761. /// <param name="dto"></param>
  18762. /// <returns></returns>
  18763. [HttpPost]
  18764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18765. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  18766. {
  18767. Result groupData = await _customersRep.OpCustomers(dto);
  18768. if (groupData.Code != 0)
  18769. {
  18770. return Ok(JsonView(false, groupData.Msg));
  18771. }
  18772. #region 应用推送
  18773. try
  18774. {
  18775. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  18776. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  18777. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  18778. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  18779. //自动审核
  18780. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  18781. //2024-10-21 新增LZ UID
  18782. var userIds = new List<int>() { 21 };
  18783. string title = $"系统通知";
  18784. var diId = dto.DiId;
  18785. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18786. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18787. string content = "";
  18788. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18789. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18790. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18791. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  18792. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  18793. }
  18794. catch (Exception ex)
  18795. {
  18796. }
  18797. #endregion
  18798. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18799. }
  18800. /// <summary>
  18801. /// 保险文件上传
  18802. /// </summary>
  18803. /// <param name="file"></param>
  18804. /// <returns></returns>
  18805. [HttpPost]
  18806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18807. public async Task<IActionResult> UploadCus(IFormFile file)
  18808. {
  18809. try
  18810. {
  18811. if (file != null)
  18812. {
  18813. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18814. //文件名称
  18815. string projectFileName = file.FileName;
  18816. //上传的文件的路径
  18817. string filePath = "";
  18818. if (!Directory.Exists(fileDir))
  18819. {
  18820. Directory.CreateDirectory(fileDir);
  18821. }
  18822. //上传的文件的路径
  18823. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  18824. using (FileStream fs = System.IO.File.Create(filePath))
  18825. {
  18826. file.CopyTo(fs);
  18827. fs.Flush();
  18828. }
  18829. return Ok(JsonView(true, "上传成功!", projectFileName));
  18830. }
  18831. else
  18832. {
  18833. return Ok(JsonView(false, "上传失败!"));
  18834. }
  18835. }
  18836. catch (Exception ex)
  18837. {
  18838. return Ok(JsonView(false, "程序错误!"));
  18839. throw;
  18840. }
  18841. }
  18842. /// <summary>
  18843. /// 保险删除指定文件
  18844. /// </summary>
  18845. /// <param name="dto"></param>
  18846. /// <returns></returns>
  18847. [HttpPost]
  18848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18849. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  18850. {
  18851. try
  18852. {
  18853. string filePath = "";
  18854. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18855. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  18856. //int id = 0;
  18857. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  18858. // 删除该文件
  18859. try
  18860. {
  18861. System.IO.File.Delete(filePath);
  18862. 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()
  18863. {
  18864. Attachment = "",
  18865. }).ExecuteCommandAsync();
  18866. if (result != 0)
  18867. {
  18868. return Ok(JsonView(true, "成功!"));
  18869. }
  18870. else
  18871. {
  18872. return Ok(JsonView(false, "失败!"));
  18873. }
  18874. }
  18875. catch (Exception)
  18876. {
  18877. 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()
  18878. {
  18879. Attachment = "",
  18880. }).ExecuteCommandAsync();
  18881. if (result != 0)
  18882. {
  18883. return Ok(JsonView(true, "成功!"));
  18884. }
  18885. else
  18886. {
  18887. return Ok(JsonView(false, "失败!"));
  18888. }
  18889. }
  18890. }
  18891. catch (Exception ex)
  18892. {
  18893. return Ok(JsonView(false, "程序错误!"));
  18894. throw;
  18895. }
  18896. }
  18897. /// <summary>
  18898. /// 保险费用操作(删除)
  18899. /// </summary>
  18900. /// <param name="dto"></param>
  18901. /// <returns></returns>
  18902. [HttpPost]
  18903. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18904. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  18905. {
  18906. try
  18907. {
  18908. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  18909. if (!res)
  18910. {
  18911. return Ok(JsonView(false, "删除失败"));
  18912. }
  18913. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  18914. {
  18915. IsDel = 1,
  18916. DeleteUserId = dto.DeleteUserId,
  18917. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  18918. }).ExecuteCommandAsync();
  18919. return Ok(JsonView(true, "删除成功!"));
  18920. }
  18921. catch (Exception ex)
  18922. {
  18923. return Ok(JsonView(false, "程序错误!"));
  18924. throw;
  18925. }
  18926. }
  18927. #endregion
  18928. #region 接团客户名单 PageId 104
  18929. /// <summary>
  18930. /// 接团客户名单
  18931. /// 迁移数据(慎用!)
  18932. /// </summary>
  18933. /// <returns></returns>
  18934. [HttpPost]
  18935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18936. public async Task<IActionResult> PostTourClientListChange()
  18937. {
  18938. try
  18939. {
  18940. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  18941. //var groupClinetData1
  18942. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  18943. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  18944. int updateCount = 0;
  18945. if (oldOAClientList.Count > 0)
  18946. {
  18947. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  18948. _sqlSugar.BeginTran();
  18949. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  18950. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  18951. foreach (var item in oldOAClientList)
  18952. {
  18953. int comId = 0;
  18954. string format = "yyyy-MM-dd HH:mm:ss";
  18955. string data11 = "1990-01-01 00:00";
  18956. var data1 = IsValidDate(item.OPdate, format);
  18957. if (data1) data11 = item.OPdate;
  18958. //客户公司验证
  18959. if (!string.IsNullOrEmpty(item.Company))
  18960. {
  18961. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  18962. if (clientComInfo == null) // add
  18963. {
  18964. var addInfo = new Crm_CustomerCompany()
  18965. {
  18966. CompanyAbbreviation = "",
  18967. CompanyFullName = item.Company,
  18968. Address = "",
  18969. PostCodes = "",
  18970. LastedOpUserId = item.OPer,
  18971. LastedOpDt = Convert.ToDateTime(data11),
  18972. CreateUserId = item.OPer,
  18973. CreateTime = Convert.ToDateTime(data11),
  18974. IsDel = 0
  18975. };
  18976. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  18977. if (comId1 > 0) comId = comId1;
  18978. }
  18979. else comId = clientComInfo.Id;
  18980. }
  18981. //客户人员验证
  18982. int clientId = 0;
  18983. string name = item.LastName + item.Name;
  18984. if (!string.IsNullOrEmpty(name))
  18985. {
  18986. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  18987. if (clientInfo == null)
  18988. {
  18989. DateTime? dateTime = null;
  18990. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  18991. if (isDt) dateTime = birthDayDt;
  18992. var addInfo1 = new Crm_DeleClient()
  18993. {
  18994. CrmCompanyId = comId,
  18995. DiId = -1,
  18996. LastName = item.LastName,
  18997. FirstName = item.Name,
  18998. OldName = "",
  18999. Pinyin = item.Pinyin,
  19000. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  19001. Marriage = 0,
  19002. Phone = item.Phone,
  19003. Job = item.Job,
  19004. BirthDay = dateTime
  19005. };
  19006. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  19007. if (clientId1 > 0) clientId = clientId1;
  19008. }
  19009. else clientId = clientInfo.Id;
  19010. }
  19011. if (clientId < 1)
  19012. {
  19013. continue;
  19014. }
  19015. int airType = 0;
  19016. if (item.AirType == "超经舱") airType = 459;
  19017. else if (item.AirType == "公务舱") airType = 458;
  19018. else if (item.AirType == "经济舱") airType = 460;
  19019. else if (item.AirType == "其他") airType = 565;
  19020. else if (item.AirType == "头等舱") airType = 457;
  19021. var _TourClientListEntity = new Grp_TourClientList()
  19022. {
  19023. DiId = item.Diid,
  19024. ClientId = clientId,
  19025. CreateUserId = item.OPer,
  19026. CreateTime = Convert.ToDateTime(data11),
  19027. Remark = item.Remark,
  19028. IsDel = item.Isdel,
  19029. ShippingSpaceTypeId = airType,
  19030. ShippingSpaceSpecialNeeds = item.AirRemark,
  19031. HotelSpecialNeeds = item.RoomType
  19032. };
  19033. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  19034. if (_TourClientList > 0)
  19035. {
  19036. updateCount++;
  19037. }
  19038. }
  19039. _sqlSugar.CommitTran();
  19040. }
  19041. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  19042. }
  19043. catch (Exception ex)
  19044. {
  19045. _sqlSugar.RollbackTran();
  19046. return Ok(JsonView(false, ex.Message));
  19047. }
  19048. //return Ok(JsonView(true));
  19049. }
  19050. private bool IsValidDate(string dateString, string format)
  19051. {
  19052. DateTime dateValue;
  19053. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  19054. return valid;
  19055. }
  19056. /// <summary>
  19057. /// 接团客户名单
  19058. /// 根据团组Id查询List
  19059. /// </summary>
  19060. /// <param name="_dto"></param>
  19061. /// <returns></returns>
  19062. [HttpPost]
  19063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19064. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  19065. {
  19066. #region 参数验证
  19067. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  19068. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  19069. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  19070. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19071. #region 页面操作权限验证
  19072. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19073. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19074. #endregion
  19075. #endregion
  19076. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  19077. if (viewData.Code != 0)
  19078. {
  19079. return Ok(JsonView(false, viewData.Msg));
  19080. }
  19081. return Ok(JsonView(viewData.Data));
  19082. }
  19083. /// <summary>
  19084. /// 接团客户名单
  19085. /// 基础数据 Init
  19086. /// </summary>
  19087. /// <param name="_dto"></param>
  19088. /// <returns></returns>
  19089. [HttpPost]
  19090. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19091. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  19092. {
  19093. #region 参数验证
  19094. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19095. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19096. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19097. #region 页面操作权限验证
  19098. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19099. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19100. #endregion
  19101. #endregion
  19102. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  19103. }
  19104. /// <summary>
  19105. /// 接团客户名单
  19106. /// 根据 Id查询 Details
  19107. /// </summary>
  19108. /// <param name="_dto"></param>
  19109. /// <returns></returns>
  19110. [HttpPost]
  19111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19112. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  19113. {
  19114. #region 参数验证
  19115. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19116. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19117. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19118. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19119. #region 页面操作权限验证
  19120. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19121. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19122. #endregion
  19123. #endregion
  19124. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  19125. if (viewData.Code != 0)
  19126. {
  19127. return Ok(JsonView(false, viewData.Msg));
  19128. }
  19129. return Ok(JsonView(viewData.Data));
  19130. }
  19131. /// <summary>
  19132. /// 接团客户名单
  19133. /// Add Or Edit
  19134. /// </summary>
  19135. /// <param name="_dto"></param>
  19136. /// <returns></returns>
  19137. [HttpPost]
  19138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19139. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  19140. {
  19141. #region 参数验证
  19142. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19143. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19144. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19145. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19146. #region 页面操作权限验证
  19147. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19148. if (_dto.Id == 0) //添加
  19149. {
  19150. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19151. }
  19152. else if (_dto.Id >= 0) //修改
  19153. {
  19154. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  19155. }
  19156. #endregion
  19157. #endregion
  19158. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  19159. if (viewData.Code != 0)
  19160. {
  19161. return Ok(JsonView(false, viewData.Msg));
  19162. }
  19163. return Ok(JsonView(true));
  19164. }
  19165. /// <summary>
  19166. /// 接团客户名单
  19167. /// json字符串 AddMultiple(添加多个)
  19168. /// </summary>
  19169. /// <param name="_dto"></param>
  19170. /// <returns></returns>
  19171. [HttpPost]
  19172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19173. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  19174. {
  19175. #region 参数验证
  19176. string jsonLabel = _dto.JsonLabel;
  19177. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19178. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19179. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19180. #region 页面操作权限验证
  19181. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19182. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19183. #endregion
  19184. #endregion
  19185. var request = new TourClientListAddMultipleDto();
  19186. request.DiId = _dto.DiId;
  19187. request.UserId = _dto.UserId;
  19188. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  19189. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  19190. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  19191. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  19192. var infos = new List<TourClientListInfo>();
  19193. foreach (var data in datas)
  19194. {
  19195. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  19196. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  19197. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  19198. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  19199. {
  19200. continue;
  19201. }
  19202. infos.Add(new TourClientListInfo()
  19203. {
  19204. IsAccompany = 1,
  19205. LastName = lastName,
  19206. FirstName = firstName,
  19207. Pinyin = lastNameEn + @"/" + firstNameEn,
  19208. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  19209. CompanyFullName = data.CompanyFullName,
  19210. Job = data.Job
  19211. });
  19212. }
  19213. if (infos.Any())
  19214. {
  19215. var viewData = await _tourClientListRep._AddMultiple(request);
  19216. if (viewData.Code != 0)
  19217. {
  19218. return Ok(JsonView(false, viewData.Msg));
  19219. }
  19220. return Ok(JsonView(true));
  19221. }
  19222. return Ok(JsonView(false));
  19223. }
  19224. /// <summary>
  19225. /// 接团客户名单
  19226. /// AddMultiple(添加多个)
  19227. /// </summary>
  19228. /// <param name="_dto"></param>
  19229. /// <returns></returns>
  19230. [HttpPost]
  19231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19232. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  19233. {
  19234. #region 参数验证
  19235. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19236. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19237. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19238. #region 页面操作权限验证
  19239. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19240. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19241. #endregion
  19242. #endregion
  19243. var viewData = await _tourClientListRep._AddMultiple(_dto);
  19244. if (viewData.Code != 0)
  19245. {
  19246. return Ok(JsonView(false, viewData.Msg));
  19247. }
  19248. return Ok(JsonView(true));
  19249. }
  19250. /// <summary>
  19251. /// 接团客户名单
  19252. /// Del
  19253. /// </summary>
  19254. /// <param name="_dto"></param>
  19255. /// <returns></returns>
  19256. [HttpPost]
  19257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19258. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  19259. {
  19260. #region 参数验证
  19261. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19262. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19263. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19264. #region 页面操作权限验证
  19265. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19266. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  19267. #endregion
  19268. #endregion
  19269. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  19270. if (viewData.Code != 0)
  19271. {
  19272. return Ok(JsonView(false, viewData.Msg));
  19273. }
  19274. return Ok(JsonView(true));
  19275. }
  19276. /// <summary>
  19277. /// 接团客户名单
  19278. /// 文件下载 客户名单
  19279. /// </summary>
  19280. /// <param name="_dto"></param>
  19281. /// <returns></returns>
  19282. [HttpPost]
  19283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19284. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  19285. {
  19286. #region 参数验证
  19287. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19288. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19289. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  19290. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19291. #region 页面操作权限验证
  19292. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19293. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19294. #endregion
  19295. #endregion
  19296. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  19297. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  19298. From Grp_TourClientList tcl
  19299. Left Join
  19300. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  19301. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  19302. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  19303. From Crm_DeleClient dc
  19304. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  19305. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  19306. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  19307. Where dc.IsDel = 0) temp
  19308. On temp.DcId =tcl.ClientId
  19309. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  19310. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  19311. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  19312. //载入模板
  19313. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  19314. if (_dto.Language == 1)
  19315. {
  19316. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  19317. }
  19318. //载入模板
  19319. var doc = new Document(tempPath);
  19320. DocumentBuilder builder = new DocumentBuilder(doc);
  19321. //获取word里所有表格
  19322. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19323. //获取所填表格的序数
  19324. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19325. var rowStart = tableOne.Rows[0]; //获取第1行
  19326. if (_dto.Language == 0)
  19327. {
  19328. //循环赋值
  19329. for (int i = 0; i < DcList.Count; i++)
  19330. {
  19331. EncryptionProcessor.DecryptProperties(DcList[i]);
  19332. builder.MoveToCell(0, i + 1, 0, 0);
  19333. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  19334. builder.MoveToCell(0, i + 1, 1, 0);
  19335. int sex = DcList[i].Sex;
  19336. string sexStr = string.Empty;
  19337. if (sex == 0) sexStr = "男";
  19338. else if (sex == 1) sexStr = "女";
  19339. else sexStr = "未设置";
  19340. builder.Write(sexStr);
  19341. builder.MoveToCell(0, i + 1, 2, 0);
  19342. string birthDay = DcList[i].BirthDay;
  19343. string birthDayStr = string.Empty;
  19344. if (!string.IsNullOrEmpty(birthDay))
  19345. {
  19346. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  19347. }
  19348. builder.Write(birthDayStr);
  19349. builder.MoveToCell(0, i + 1, 3, 0);
  19350. string company = "";
  19351. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19352. {
  19353. company = DcList[i].CompanyFullName.ToString();
  19354. }
  19355. builder.Write(company);
  19356. builder.MoveToCell(0, i + 1, 4, 0);
  19357. builder.Write(DcList[i].Job);
  19358. }
  19359. }
  19360. else if (_dto.Language == 1)
  19361. {
  19362. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  19363. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  19364. List<string> transArrayStr = new List<string>();
  19365. string transStrRes1 = "";
  19366. for (int i = 0; i < DcList.Count; i++)
  19367. {
  19368. var dc = DcList[i];
  19369. EncryptionProcessor.DecryptProperties(dc);
  19370. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  19371. if (dc.Job.Equals("暂无")) dc.Job = "-";
  19372. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  19373. if (DcList.Count - 1 == i) transStrRes1 += str1;
  19374. else transStrRes1 += $"{str1}|";
  19375. }
  19376. #region AI转英文
  19377. string jsonValue = JsonConvert.SerializeObject(DcList);
  19378. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  19379. List<SeedMessages> messages = new List<SeedMessages>()
  19380. {
  19381. new SeedMessages
  19382. {
  19383. Role = KimiRole.user,
  19384. Content = jsonValue + text
  19385. }
  19386. };
  19387. KiMiApiClient client = new KiMiApiClient();
  19388. var kimiApiResult = await client.SeedMessage(messages);
  19389. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19390. string clients = kimiApiResult_JObject["content"].ToString();
  19391. string startStr = "```json", endStr = "```";
  19392. // 判断并清除开头部分
  19393. if (clients.StartsWith(startStr))
  19394. {
  19395. clients = clients.Remove(0, startStr.Length);
  19396. }
  19397. // 判断并清除结尾部分
  19398. if (clients.EndsWith(endStr))
  19399. {
  19400. clients = clients.Remove(clients.Length - endStr.Length);
  19401. }
  19402. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  19403. //循环赋值
  19404. for (int i = 0; i < en_Json.Count; i++)
  19405. {
  19406. var dc = en_Json[i];
  19407. var dc1 = DcList.Find(x => x.Id == dc.Id);
  19408. string PYName = dc.FirstName + " " + dc.LastName;
  19409. builder.MoveToCell(0, i + 1, 0, 0);
  19410. builder.Write(PYName);
  19411. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  19412. builder.MoveToCell(0, i + 1, 1, 0);
  19413. builder.Write(sex);
  19414. DateTime birthDt;
  19415. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  19416. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19417. builder.MoveToCell(0, i + 1, 2, 0);
  19418. builder.Write(birthday);
  19419. string company = string.Empty, job = string.Empty;
  19420. company = dc.CompanyFullName;
  19421. job = dc.Job;
  19422. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  19423. {
  19424. //查询对照表
  19425. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  19426. if (tempCec != null)
  19427. {
  19428. company = tempCec.enName;
  19429. }
  19430. }
  19431. builder.MoveToCell(0, i + 1, 3, 0);
  19432. builder.Write(company);
  19433. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  19434. {
  19435. //查询对照表
  19436. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  19437. if (tempPec != null)
  19438. {
  19439. job = tempPec.enName;
  19440. }
  19441. }
  19442. builder.MoveToCell(0, i + 1, 4, 0);
  19443. builder.Write(job);
  19444. }
  19445. #endregion
  19446. #region 旧翻译英文处理
  19447. ////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";
  19448. //string transStrRes = "";
  19449. //if (transStrRes1.Length > 0)
  19450. //{
  19451. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  19452. //}
  19453. ////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
  19454. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  19455. ////List<string> transArray = new List<string> { };
  19456. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  19457. //if (transStrRes.Contains("|"))
  19458. //{
  19459. // string[] transArray1 = transStrRes.Split('|');
  19460. // if (transArray1.Length > 0)
  19461. // {
  19462. // foreach (var item in transArray1)
  19463. // {
  19464. // if (item.Contains("&"))
  19465. // {
  19466. // string[] transArray2 = item.Split('&');
  19467. // int index = 0;
  19468. // string companyName = "", job = "";
  19469. // if (transArray2.Length > 0)
  19470. // {
  19471. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  19472. // if (1 < transArray2.Length) companyName = transArray2[1];
  19473. // if (2 < transArray2.Length) job = transArray2[2];
  19474. // }
  19475. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  19476. // }
  19477. // }
  19478. // }
  19479. //}
  19480. ////循环赋值
  19481. //for (int i = 0; i < DcList.Count; i++)
  19482. //{
  19483. // string PYName = "";
  19484. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  19485. // {
  19486. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  19487. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  19488. // PYName = PY_First + " " + PY_Last;
  19489. // }
  19490. // else
  19491. // {
  19492. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  19493. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  19494. // PYName = PY_First + " " + PY_Last;
  19495. // }
  19496. // builder.MoveToCell(0, i + 1, 0, 0);
  19497. // builder.Write(PYName);
  19498. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  19499. // builder.MoveToCell(0, i + 1, 1, 0);
  19500. // builder.Write(sex);
  19501. // DateTime birthDt;
  19502. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  19503. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19504. // builder.MoveToCell(0, i + 1, 2, 0);
  19505. // builder.Write(birthday);
  19506. // string company = string.Empty, job = string.Empty;
  19507. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  19508. // if (dcTransInfo != null)
  19509. // {
  19510. // company = dcTransInfo.CompanyName;
  19511. // job = dcTransInfo.Job;
  19512. // }
  19513. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19514. // {
  19515. // //查询对照表
  19516. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  19517. // if (tempCec != null)
  19518. // {
  19519. // company = tempCec.enName;
  19520. // }
  19521. // //翻译
  19522. // else
  19523. // {
  19524. // }
  19525. // }
  19526. // builder.MoveToCell(0, i + 1, 3, 0);
  19527. // builder.Write(company);
  19528. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  19529. // {
  19530. // //查询对照表
  19531. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  19532. // if (tempPec != null)
  19533. // {
  19534. // job = tempPec.enName;
  19535. // }
  19536. // //翻译
  19537. // else
  19538. // {
  19539. // }
  19540. // }
  19541. // builder.MoveToCell(0, i + 1, 4, 0);
  19542. // builder.Write(job);
  19543. //}
  19544. #endregion
  19545. }
  19546. //删除多余行
  19547. while (tableOne.Rows.Count > DcList.Count + 1)
  19548. {
  19549. tableOne.Rows.RemoveAt(DcList.Count + 1);
  19550. }
  19551. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  19552. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  19553. doc.Save(fileDir);
  19554. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  19555. return Ok(JsonView(true, "操作成功!", Url));
  19556. }
  19557. private class TranslateInfo
  19558. {
  19559. public int Index { get; set; }
  19560. public string CompanyName { get; set; }
  19561. public string Job { get; set; }
  19562. }
  19563. [HttpPost]
  19564. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  19565. {
  19566. if (files.Count == 0)
  19567. {
  19568. return Ok(JsonView(false, "文件为空"));
  19569. }
  19570. KiMiApiClient KiMiApi = new KiMiApiClient();
  19571. var seedConter = await KiMiApi.UploadFilesAsync(files);
  19572. if (seedConter.Count == 0)
  19573. {
  19574. return Ok(JsonView(false, "上传结果为空!"));
  19575. }
  19576. var messages = new List<SeedMessages>
  19577. {
  19578. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  19579. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理,文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  19580. };
  19581. messages.InsertRange(1, seedConter);
  19582. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  19583. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19584. string clients = kimiApiResult_JObject["content"].ToString();
  19585. string startStr = "```json", endStr = "```";
  19586. // 判断并清除开头部分
  19587. if (clients.StartsWith(startStr))
  19588. {
  19589. clients = clients.Remove(0, startStr.Length);
  19590. }
  19591. // 判断并清除结尾部分
  19592. if (clients.EndsWith(endStr))
  19593. {
  19594. clients = clients.Remove(clients.Length - endStr.Length);
  19595. }
  19596. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  19597. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  19598. {
  19599. {"姓", "LastName" },
  19600. {"名", "FirstName" },
  19601. {"姓名拼音", "Pinyin" },
  19602. {"性别", "Sex" },
  19603. {"单位", "CompanyFullName" },
  19604. {"职务", "Job" },
  19605. {"出生日期", "Birthday" },
  19606. };
  19607. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  19608. foreach (var item in clients_JObject)
  19609. {
  19610. BaiduClientOCRView cdc = new BaiduClientOCRView();
  19611. foreach (var field in clientFieldMap.Keys)
  19612. {
  19613. if (item.TryGetValue(field, out JToken value))
  19614. {
  19615. var getValue = value.ToString();
  19616. System.Type type = cdc.GetType();
  19617. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  19618. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  19619. propertyInfo.SetValue(cdc, propertyValue);
  19620. }
  19621. }
  19622. crmClients.Add(cdc);
  19623. }
  19624. return Ok(JsonView(new
  19625. {
  19626. fileCount = files.Count,
  19627. UploadCount = seedConter.Count,
  19628. ApiResult = clients,
  19629. CrmClients = crmClients
  19630. }));
  19631. }
  19632. #endregion
  19633. #region 团组倒推表
  19634. /// <summary>
  19635. /// 倒推表基础数据
  19636. /// Init
  19637. /// </summary>
  19638. /// <returns></returns>
  19639. [HttpPost]
  19640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19641. public async Task<IActionResult> PostInvertedListInit()
  19642. {
  19643. var viewData = await _invertedListRep._Init();
  19644. if (viewData.Code != 0)
  19645. {
  19646. return Ok(JsonView(false, viewData.Msg));
  19647. }
  19648. return Ok(JsonView(viewData.Data));
  19649. }
  19650. /// <summary>
  19651. /// 倒推表
  19652. /// Info
  19653. /// </summary>
  19654. /// <param name="dto"></param>
  19655. /// <returns></returns>
  19656. [HttpPost]
  19657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19658. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  19659. {
  19660. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  19661. if (viewData.Code != 0)
  19662. {
  19663. return Ok(JsonView(false, viewData.Msg));
  19664. }
  19665. return Ok(JsonView(viewData.Data));
  19666. }
  19667. /// <summary>
  19668. /// 倒推表
  19669. /// Create
  19670. /// </summary>
  19671. /// <param name="dto"></param>
  19672. /// <returns></returns>
  19673. [HttpPost]
  19674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19675. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  19676. {
  19677. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  19678. if (viewData.Code != 0)
  19679. {
  19680. return Ok(JsonView(false, viewData.Msg));
  19681. }
  19682. return Ok(JsonView(viewData.Data));
  19683. }
  19684. /// <summary>
  19685. /// 倒推表
  19686. /// Update
  19687. /// </summary>
  19688. /// <param name="dto"></param>
  19689. /// <returns></returns>
  19690. [HttpPost]
  19691. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19692. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  19693. {
  19694. var viewData = await _invertedListRep._Update(dto);
  19695. if (viewData.Code != 0)
  19696. {
  19697. return Ok(JsonView(false, viewData.Msg));
  19698. }
  19699. return Ok(JsonView(viewData.Data));
  19700. }
  19701. /// <summary>
  19702. /// 倒推表
  19703. /// File Download
  19704. /// </summary>
  19705. /// <param name="dto"></param>
  19706. /// <returns></returns>
  19707. [HttpPost]
  19708. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19709. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  19710. {
  19711. var info2 = await _invertedListRep._Info(1, dto.DiId);
  19712. if (info2.Code != 0)
  19713. {
  19714. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  19715. }
  19716. var info1 = info2.Data as InvertedListInfoView;
  19717. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  19718. string teamName = "";
  19719. if (info != null) teamName = info.TeamName;
  19720. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  19721. var doc = new Document();
  19722. var builder = new DocumentBuilder(doc);
  19723. #region old insert
  19724. ////载入模板
  19725. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  19726. //Document doc = new Document(tempPath);
  19727. //DocumentBuilder builder = new DocumentBuilder(doc);
  19728. //利用键值对存放数据
  19729. //Dictionary<string, string> dic = new Dictionary<string, string>();
  19730. //dic.Add("TeamName", teamName);
  19731. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  19732. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  19733. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  19734. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  19735. //dic.Add("SQRemark", info1.ApprovalRemark);
  19736. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  19737. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  19738. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  19739. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  19740. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  19741. //dic.Add("QZRemark", info1.VisaInformationRemark);
  19742. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  19743. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  19744. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  19745. //dic.Add("CQRemark", info1.IssueVisaRemark);
  19746. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  19747. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  19748. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  19749. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  19750. //#region 填充word模板书签内容
  19751. //foreach (var key in dic.Keys)
  19752. //{
  19753. // builder.MoveToBookmark(key);
  19754. // builder.Write(dic[key]);
  19755. //}
  19756. //#endregion
  19757. #endregion
  19758. #region New Insert
  19759. string titleFont = $"仿宋",
  19760. contentFont = $"仿宋";
  19761. var fontColor = Color.FromArgb(64, 64, 64);
  19762. //设置标题 团组名称
  19763. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19764. builder.Font.Name = titleFont;
  19765. builder.Font.Color = fontColor;
  19766. builder.Font.Size = 12;
  19767. builder.Font.Bold = true;
  19768. builder.Writeln(teamName);
  19769. //设置副标题 团组出访时间
  19770. builder.Font.Size = 12;
  19771. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  19772. builder.Writeln();
  19773. var backgroundColor = Color.FromArgb(199, 199, 199);
  19774. var table = builder.StartTable();
  19775. builder.InsertCell();
  19776. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  19777. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  19778. builder.CellFormat.Borders.LineWidth = 1;
  19779. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  19780. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  19781. builder.RowFormat.Height = 40;
  19782. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19783. builder.Font.Name = contentFont;
  19784. builder.Font.Size = 12;
  19785. builder.Font.Bold = true;
  19786. builder.Font.Color = fontColor;
  19787. builder.Write("时间");
  19788. builder.InsertCell();
  19789. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  19790. builder.Write("流程");
  19791. builder.InsertCell();
  19792. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  19793. builder.Write("说明");
  19794. builder.EndRow();
  19795. //报批资料准备
  19796. if (info1.IsSelectedAirportd)
  19797. {
  19798. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  19799. }
  19800. //报批/提供送签资料
  19801. if (info1.IsSelectedApprovalData)
  19802. {
  19803. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  19804. }
  19805. //出批件护照办理
  19806. if (info1.IsSelectedIssueApproval)
  19807. {
  19808. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  19809. }
  19810. //签证资料准备
  19811. if (info1.IsSelectedVisaInfo)
  19812. {
  19813. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  19814. }
  19815. //送签
  19816. if (info1.IsSelectedSendVisa)
  19817. {
  19818. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  19819. }
  19820. //出签
  19821. if (info1.IsSelectedIssueVisa)
  19822. {
  19823. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  19824. }
  19825. //机票
  19826. if (info1.IsSelectedAirTicket)
  19827. {
  19828. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  19829. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  19830. }
  19831. //酒店
  19832. if (info1.IsSelectedHotel)
  19833. {
  19834. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  19835. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  19836. }
  19837. //开行前会
  19838. if (info1.IsSelectedPreTripMeeting)
  19839. {
  19840. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  19841. }
  19842. //送机
  19843. if (info1.IsSelectedAirportdDropOff)
  19844. {
  19845. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  19846. }
  19847. builder.EndTable();
  19848. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  19849. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  19850. for (int i = 0; i < table.Rows.Count; i++)
  19851. {
  19852. var row = table.Rows[i];
  19853. //设置宽度
  19854. row.Cells[0].CellFormat.Width = 20.00;
  19855. row.Cells[1].CellFormat.Width = 30.00;
  19856. row.Cells[2].CellFormat.Width = 50.00;
  19857. if (i != 0)
  19858. {
  19859. //边框设置
  19860. InvertedListFileDownloadSetBorders(row.Cells, 0);
  19861. InvertedListFileDownloadSetBorders(row.Cells, 1);
  19862. InvertedListFileDownloadSetBorders(row.Cells, 2);
  19863. }
  19864. }
  19865. #region 页脚插入图片
  19866. // 创建页脚
  19867. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  19868. doc.FirstSection.HeadersFooters.Add(footer);
  19869. Paragraph para = new Paragraph(doc);
  19870. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  19871. footer.AppendChild(para);
  19872. builder.MoveTo(para);
  19873. string imagePath = "./Images/FMGJ_Log.png";
  19874. builder.InsertImage(imagePath);
  19875. #endregion
  19876. #endregion
  19877. var fileDir = AppSettingsHelper.Get("WordBasePath");
  19878. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  19879. string filePath = fileDir + $@"InvertedList/{fileName}";
  19880. doc.Save(filePath);
  19881. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  19882. return Ok(JsonView(true, "操作成功!", Url));
  19883. }
  19884. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  19885. {
  19886. var fontColor = Color.FromArgb(64, 64, 64);
  19887. builder.InsertCell();
  19888. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  19889. builder.RowFormat.Height = 40;
  19890. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19891. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19892. builder.Font.Name = fontName;
  19893. builder.Font.Size = 8;
  19894. builder.Font.Bold = true;
  19895. builder.Font.Color = fontColor;
  19896. builder.Write(dateTime);
  19897. builder.InsertCell();
  19898. builder.Font.Size = 9;
  19899. builder.Font.Bold = true;
  19900. builder.Font.Color = fontColor;
  19901. builder.Write(content);
  19902. builder.InsertCell();
  19903. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19904. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  19905. builder.Font.Size = 9;
  19906. builder.Font.Bold = false;
  19907. builder.Font.Color = fontColor;
  19908. builder.Write(reamrk);
  19909. builder.EndRow();
  19910. }
  19911. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  19912. {
  19913. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  19914. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  19915. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  19916. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  19917. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  19918. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  19919. }
  19920. #endregion
  19921. #region 会务倒推表
  19922. /// <summary>
  19923. /// 会务倒推表
  19924. /// Init
  19925. /// </summary>
  19926. /// <returns></returns>
  19927. [HttpPost]
  19928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19929. public async Task<IActionResult> InforRetrogressTableInit()
  19930. {
  19931. var groupData = await _groupRepository.PostShareGroupInfos(1);
  19932. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  19933. return Ok(JsonView(false, groupData.Msg));
  19934. }
  19935. /// <summary>
  19936. /// 会务倒推表
  19937. /// ExcelDownload
  19938. /// </summary>
  19939. /// <param name="dto"></param>
  19940. /// <returns></returns>
  19941. [HttpPost]
  19942. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  19943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19944. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  19945. {
  19946. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  19947. var validatorRes = await validator.ValidateAsync(dto);
  19948. if (!validatorRes.IsValid)
  19949. {
  19950. StringBuilder sb = new StringBuilder();
  19951. foreach (var item in validatorRes.Errors)
  19952. {
  19953. sb.AppendLine(item.ErrorMessage);
  19954. }
  19955. return Ok(JsonView(false, sb.ToString()));
  19956. }
  19957. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  19958. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  19959. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  19960. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  19961. #region Excel
  19962. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  19963. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  19964. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  19965. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  19966. var fileNamePrefix = string.Empty;
  19967. if (days >= 30)
  19968. {
  19969. tempPath += $"会务工作倒推进度表(30天).xlsx";
  19970. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  19971. }
  19972. else if (days < 30 && days > 7)
  19973. {
  19974. tempPath += $"会务工作倒推进度表(15天).xlsx";
  19975. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  19976. }
  19977. else if (days <= 7)
  19978. {
  19979. tempPath += $"会务工作倒推进度表(7天).xlsx";
  19980. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  19981. }
  19982. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  19983. fileName = CommonFun.ValidFileName(fileName);
  19984. //载入模板
  19985. WorkbookDesigner designer = new WorkbookDesigner();
  19986. designer.Workbook = new Workbook(tempPath);
  19987. designer.Process();
  19988. if (!Directory.Exists(savePath))
  19989. {
  19990. Directory.CreateDirectory(savePath);
  19991. }
  19992. string serverPath = $"{savePath}{fileName}";
  19993. designer.Workbook.Save(serverPath);
  19994. string rst = $"{servicePath}{ftpPath}{fileName}";
  19995. #endregion
  19996. return Ok(JsonView(new { url = rst }));
  19997. }
  19998. #endregion
  19999. #region 三公签证费用(签证费、代办费)
  20000. /// <summary>
  20001. /// 三公签证费用(签证费、代办费)
  20002. /// List
  20003. /// </summary>
  20004. /// <returns></returns>
  20005. [HttpPost]
  20006. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20007. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  20008. {
  20009. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  20010. if (_view.Code != 0)
  20011. {
  20012. return Ok(JsonView(false, _view.Msg));
  20013. }
  20014. return Ok(JsonView(true, "操作成功!", _view.Data));
  20015. }
  20016. /// <summary>
  20017. /// 三公签证费用(签证费、代办费)
  20018. /// Add Or Update
  20019. /// </summary>
  20020. /// <returns></returns>
  20021. [HttpPost]
  20022. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20023. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  20024. {
  20025. var _view = await _visaFeeInfoRep._Update(_dto);
  20026. if (_view.Code != 0)
  20027. {
  20028. return Ok(JsonView(false, _view.Msg));
  20029. }
  20030. return Ok(JsonView(true, _view.Msg));
  20031. }
  20032. #endregion
  20033. #region 酒店询价
  20034. /// <summary>
  20035. /// 酒店询价
  20036. /// Init
  20037. /// </summary>
  20038. /// <returns></returns>
  20039. [HttpPost]
  20040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20041. public async Task<IActionResult> PostHotelInquiryInit()
  20042. {
  20043. var res = await _hotelInquiryRep._Init();
  20044. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20045. return Ok(JsonView(true, res.Msg, res.Data));
  20046. }
  20047. /// <summary>
  20048. /// 酒店询价
  20049. /// page Item
  20050. /// </summary>
  20051. /// <param name="_dto"></param>
  20052. /// <returns></returns>
  20053. [HttpPost]
  20054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20055. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  20056. {
  20057. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  20058. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20059. var view = res.Data as PageDataViewBase;
  20060. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  20061. }
  20062. /// <summary>
  20063. /// 酒店询价
  20064. /// info
  20065. /// </summary>
  20066. /// <param name="_dto"></param>
  20067. /// <returns></returns>
  20068. [HttpPost]
  20069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20070. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  20071. {
  20072. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  20073. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20074. return Ok(JsonView(true, res.Msg, res.Data));
  20075. }
  20076. /// <summary>
  20077. /// 酒店询价
  20078. /// Add Or Edit
  20079. /// </summary>
  20080. /// <param name="_dto"></param>
  20081. /// <returns></returns>
  20082. [HttpPost]
  20083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20084. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  20085. {
  20086. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  20087. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20088. return Ok(JsonView(true, res.Msg, res.Data));
  20089. }
  20090. /// <summary>
  20091. /// 酒店询价
  20092. /// Del
  20093. /// </summary>
  20094. /// <param name="_dto"></param>
  20095. /// <returns></returns>
  20096. [HttpPost]
  20097. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20098. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  20099. {
  20100. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  20101. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20102. return Ok(JsonView(true, res.Msg, res.Data));
  20103. }
  20104. #endregion
  20105. #region 下载匹配op行程单
  20106. /// <summary>
  20107. /// 匹配op行程单
  20108. /// Init
  20109. /// </summary>
  20110. /// <param name="dto">团组列表请求dto</param>
  20111. /// <returns></returns>
  20112. [HttpPost]
  20113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20114. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  20115. {
  20116. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20117. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20118. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  20119. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  20120. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  20121. .Where(it => it.IsDel == 0)
  20122. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  20123. .OrderByDescending(it => it.VisitStartDate)
  20124. .ToList();
  20125. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  20126. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20127. var diids = groupInfos.Select(it => it.Id).ToList();
  20128. List<string> countrys = new List<string>();
  20129. foreach (var item in country)
  20130. {
  20131. var data = _groupRepository.FormartTeamName(item);
  20132. var dataArray = _groupRepository.GroupSplitCountry(data);
  20133. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20134. }
  20135. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  20136. List<string> areaArray = new List<string>(); //GetGroupCityLine
  20137. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  20138. foreach (var item in areaItem)
  20139. {
  20140. string areaStr = item.Value;
  20141. if (!string.IsNullOrEmpty(areaStr))
  20142. {
  20143. string[] str1 = areaStr.Split("-");
  20144. if (str1.Length > 0)
  20145. {
  20146. areaArray.AddRange(str1);
  20147. }
  20148. }
  20149. }
  20150. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  20151. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  20152. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  20153. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  20154. .ToList();
  20155. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  20156. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  20157. .Where(it => countriesIds.Contains(it.Id))
  20158. .Select(it => new { it.Id, Name = it.Name_CN })
  20159. .ToList();
  20160. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  20161. .Select(it => it.TeamName).ToList();
  20162. stopwatch.Stop();
  20163. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  20164. }
  20165. ///// <summary>
  20166. ///// 匹配op行程单
  20167. ///// Init 查询区域数据
  20168. ///// </summary>
  20169. ///// <param name="dto">团组列表请求dto</param>
  20170. ///// <returns></returns>
  20171. //[HttpPost]
  20172. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20173. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  20174. //{
  20175. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20176. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  20177. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  20178. // if (string.IsNullOrEmpty(countriesDataStr))
  20179. // {
  20180. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  20181. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  20182. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  20183. // }
  20184. // else
  20185. // {
  20186. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  20187. // }
  20188. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  20189. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  20190. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  20191. // List<dynamic> childList = new List<dynamic>();
  20192. // int parentId = dto.CountriesId;
  20193. // if (provinceData.Count > 1)
  20194. // {
  20195. // foreach (var item1 in provinceData)
  20196. // {
  20197. // List<dynamic> childList1 = new List<dynamic>();
  20198. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  20199. // foreach (var item2 in citiesData1)
  20200. // {
  20201. // List<dynamic> childList2 = new List<dynamic>();
  20202. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20203. // foreach (var item3 in countiesData1)
  20204. // {
  20205. // childList2.Add(new
  20206. // {
  20207. // id = item3.Id,
  20208. // parentId = item2.Id,
  20209. // level = "district",
  20210. // name = item3.Name_CN,
  20211. // });
  20212. // }
  20213. // childList1.Add(new
  20214. // {
  20215. // id = item2.Id,
  20216. // parentId = item1.Id,
  20217. // level = "city",
  20218. // name = item2.Name_CN,
  20219. // childList = childList2
  20220. // });
  20221. // }
  20222. // childList.Add(new
  20223. // {
  20224. // id = item1.Id,
  20225. // parentId = parentId,
  20226. // level = "province",
  20227. // name = item1.Name_CN,
  20228. // childList = childList1
  20229. // });
  20230. // }
  20231. // //城市
  20232. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  20233. // foreach (var item2 in citiesData2)
  20234. // {
  20235. // List<dynamic> childList22 = new List<dynamic>();
  20236. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20237. // foreach (var item3 in countiesData1)
  20238. // {
  20239. // childList22.Add(new
  20240. // {
  20241. // id = item3.Id,
  20242. // parentId = item2.Id,
  20243. // level = "district",
  20244. // name = item3.Name_CN,
  20245. // });
  20246. // }
  20247. // childList.Add(new
  20248. // {
  20249. // id = item2.Id,
  20250. // parentId = parentId,
  20251. // level = "city",
  20252. // name = item2.Name_CN,
  20253. // childList = childList22
  20254. // });
  20255. // }
  20256. // }
  20257. // else
  20258. // {
  20259. // foreach (var item2 in citiesData)
  20260. // {
  20261. // string cname = item2.Name_CN;
  20262. // List<dynamic> childList1 = new List<dynamic>();
  20263. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20264. // foreach (var item3 in countiesData1)
  20265. // {
  20266. // childList1.Add(new
  20267. // {
  20268. // Id = item3.Id,
  20269. // parentId = item2.Id,
  20270. // level = "district",
  20271. // name = item3.Name_CN
  20272. // });
  20273. // }
  20274. // childList.Add(new
  20275. // {
  20276. // id = item2.Id,
  20277. // parentId = parentId,
  20278. // level = "city",
  20279. // name = item2.Name_CN,
  20280. // childList = childList1
  20281. // });
  20282. // }
  20283. // }
  20284. // stopwatch.Stop();
  20285. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  20286. //}
  20287. /// <summary>
  20288. /// 匹配op行程单
  20289. /// 接团信息列表 Page
  20290. /// </summary>
  20291. /// <param name="dto">团组列表请求dto</param>
  20292. /// <returns></returns>
  20293. [HttpPost]
  20294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20295. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  20296. {
  20297. var swatch = new Stopwatch();
  20298. swatch.Start();
  20299. #region 参数验证
  20300. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20301. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20302. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20303. #region 页面操作权限验证
  20304. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20305. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  20306. #endregion
  20307. #endregion
  20308. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20309. {
  20310. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  20311. //string sqlWhere = "";
  20312. if (!string.IsNullOrEmpty(dto.Country))
  20313. {
  20314. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  20315. }
  20316. if (!string.IsNullOrEmpty(dto.Area))
  20317. {
  20318. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  20319. }
  20320. if (!string.IsNullOrEmpty(dto.TeamName))
  20321. {
  20322. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  20323. }
  20324. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  20325. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  20326. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  20327. swatch.Stop();
  20328. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  20329. }
  20330. else
  20331. {
  20332. return Ok(JsonView(false, "查询失败"));
  20333. }
  20334. }
  20335. /// <summary>
  20336. /// 匹配op行程单
  20337. /// 行程单下载
  20338. /// </summary>
  20339. /// <param name="dto">团组列表请求dto</param>
  20340. /// <returns></returns>
  20341. [HttpPost]
  20342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20343. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  20344. {
  20345. #region 参数验证
  20346. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20347. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20348. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20349. #region 页面操作权限验证
  20350. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20351. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  20352. #endregion
  20353. #endregion
  20354. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20355. {
  20356. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  20357. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  20358. }
  20359. else
  20360. {
  20361. return Ok(JsonView(false, "下载失败!"));
  20362. }
  20363. }
  20364. #endregion
  20365. #region 国家信息 数据 注释
  20366. //[HttpPost]
  20367. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  20368. //{
  20369. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  20370. // foreach (var item in dto)
  20371. // {
  20372. // infos.Add(new Grp_GroupsTaskAssignment()
  20373. // {
  20374. // DIId = item,
  20375. // CTId = 82,
  20376. // UId = 248,
  20377. // IsEnable = 1,
  20378. // CreateUserId = 233,
  20379. // CreateTime = DateTime.Now,
  20380. // IsDel = 0
  20381. // });
  20382. // infos.Add(new Grp_GroupsTaskAssignment()
  20383. // {
  20384. // DIId = item,
  20385. // CTId = 82,
  20386. // UId = 286,
  20387. // IsEnable = 1,
  20388. // CreateUserId = 233,
  20389. // CreateTime = DateTime.Now,
  20390. // IsDel = 0
  20391. // });
  20392. // }
  20393. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  20394. // return Ok("操作成功");
  20395. //}
  20396. //public class paramJsonDto
  20397. //{
  20398. // public List<CountriesInfo> str { get; set; }
  20399. //}
  20400. //[HttpPost]
  20401. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  20402. //{
  20403. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  20404. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  20405. // List<Sys_Cities> cities = new List<Sys_Cities>();
  20406. // List<Sys_Cities> districts = new List<Sys_Cities>();
  20407. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20408. // _sqlSugar.BeginTran();
  20409. // int countitiesIndex = 0;
  20410. // foreach (var item in dto.str)
  20411. // {
  20412. // dynamic data = item.c;
  20413. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  20414. // if (data != null)
  20415. // {
  20416. // countitiesIndex++;
  20417. // foreach (var item1 in data)
  20418. // {
  20419. // string cnname = item1.cn;
  20420. // string enname = item1.en;
  20421. // Sys_Cities provinceInfo = new Sys_Cities()
  20422. // {
  20423. // CountriesId = countriesId,
  20424. // Name_CN = cnname,
  20425. // Name_EN = enname,
  20426. // ParentId = 0,
  20427. // IsCapital = 1,
  20428. // CreateUserId = 208,
  20429. // CreateTime = DateTime.Now,
  20430. // IsDel = 0
  20431. // };
  20432. // if (item1.lv == "province") //省份
  20433. // {
  20434. // provinceInfo.Level = 1;
  20435. // int provinceId = 0;
  20436. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  20437. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  20438. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20439. // var data1 = item1.c;
  20440. // foreach (var item2 in data1)
  20441. // {
  20442. // if (item2.lv == "city")
  20443. // {
  20444. // string citycnname = item2.cn;
  20445. // string cityenname = item2.en;
  20446. // Sys_Cities cityInfo = new Sys_Cities()
  20447. // {
  20448. // CountriesId = countriesId,
  20449. // ParentId = provinceId,
  20450. // Level = 2,
  20451. // Name_CN = citycnname,
  20452. // Name_EN = cityenname,
  20453. // IsCapital = 1,
  20454. // CreateUserId = 208,
  20455. // CreateTime = DateTime.Now,
  20456. // IsDel = 0
  20457. // };
  20458. // if (item2.c != null)
  20459. // {
  20460. // int cityId = 0;
  20461. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  20462. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20463. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  20464. // foreach (var item3 in item2.c)
  20465. // {
  20466. // if (item3.lv == "district")
  20467. // {
  20468. // var districtInfo = new Sys_Cities()
  20469. // {
  20470. // CountriesId = countriesId,
  20471. // Name_CN = item3.cn,
  20472. // Name_EN = item3.en,
  20473. // Level = 3,
  20474. // ParentId = cityId,
  20475. // IsCapital = 1,
  20476. // CreateUserId = 208,
  20477. // CreateTime = DateTime.Now,
  20478. // IsDel = 0
  20479. // };
  20480. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20481. // //{
  20482. // districts.Add(districtInfo);
  20483. // //}
  20484. // }
  20485. // }
  20486. // }
  20487. // else
  20488. // {
  20489. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  20490. // //{
  20491. // cities.Add(cityInfo);
  20492. // //}
  20493. // }
  20494. // }
  20495. // }
  20496. // }
  20497. // else if (item1.lv == "city")//城市
  20498. // {
  20499. // provinceInfo.Level = 2;
  20500. // if (item1.c != null)
  20501. // {
  20502. // int cityId = 0;
  20503. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  20504. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20505. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20506. // foreach (var item3 in item1.c)
  20507. // {
  20508. // if (item3.lv == "district")
  20509. // {
  20510. // var districtInfo = new Sys_Cities()
  20511. // {
  20512. // CountriesId = countriesId,
  20513. // Name_CN = item3.cn,
  20514. // Name_EN = item3.en,
  20515. // Level = 3,
  20516. // ParentId = cityId,
  20517. // IsCapital = 1,
  20518. // CreateUserId = 208,
  20519. // CreateTime = DateTime.Now,
  20520. // IsDel = 0
  20521. // };
  20522. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20523. // //{
  20524. // districts.Add(districtInfo);
  20525. // //}
  20526. // }
  20527. // }
  20528. // }
  20529. // else
  20530. // {
  20531. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  20532. // //{
  20533. // cities.Add(provinceInfo);
  20534. // //}
  20535. // }
  20536. // }
  20537. // }
  20538. // }
  20539. // }
  20540. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  20541. // cities = cities.Distinct().ToList();
  20542. // districts = districts.Distinct().ToList();
  20543. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  20544. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  20545. // cities.AddRange(districts);
  20546. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  20547. // //_sqlSugar.RollbackTran();
  20548. // _sqlSugar.CommitTran();
  20549. // return Ok(JsonView(false, "操作成功!"));
  20550. //}
  20551. //[HttpPost]
  20552. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  20553. //{
  20554. // List<CountitiesInfo> infos = dto.MyProperty;
  20555. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  20556. // _sqlSugar.BeginTran();
  20557. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20558. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  20559. // foreach (var item in infos)
  20560. // {
  20561. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  20562. // if (countryInfo != null)
  20563. // {
  20564. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  20565. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  20566. // if (cityInfo1 != null)
  20567. // {
  20568. // cityInfo1.IsCapital = 0;
  20569. // cityInfos.Add(cityInfo1);
  20570. // }
  20571. // }
  20572. // }
  20573. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  20574. // .UpdateColumns(it => it.IsCapital)
  20575. // .WhereColumns(it => it.Id)
  20576. // .ExecuteCommand();
  20577. // //_sqlSugar.RollbackTran();
  20578. // _sqlSugar.CommitTran();
  20579. // return Ok(JsonView(false, "操作成功!"));
  20580. //}
  20581. //public class CounrtiesDto
  20582. //{
  20583. // public List<CountitiesInfo> MyProperty { get; set; }
  20584. //}
  20585. //public class CountitiesInfo
  20586. //{
  20587. // /// <summary>
  20588. // /// 圣约翰
  20589. // /// </summary>
  20590. // public string capital_name_chinese { get; set; }
  20591. // /// <summary>
  20592. // ///
  20593. // /// </summary>
  20594. // public string capital_name { get; set; }
  20595. // /// <summary>
  20596. // ///
  20597. // /// </summary>
  20598. // public string country_type { get; set; }
  20599. // /// <summary>
  20600. // /// 安提瓜和巴布达
  20601. // /// </summary>
  20602. // public string country_name_chinese { get; set; }
  20603. // /// <summary>
  20604. // /// 安提瓜和巴布达
  20605. // /// </summary>
  20606. // public string country_name_chinese_short { get; set; }
  20607. // /// <summary>
  20608. // /// 安提瓜和巴布达
  20609. // /// </summary>
  20610. // public string country_name_chinese_UN { get; set; }
  20611. // /// <summary>
  20612. // ///
  20613. // /// </summary>
  20614. // public string country_name_english_abbreviation { get; set; }
  20615. // /// <summary>
  20616. // ///
  20617. // /// </summary>
  20618. // public string country_name_english_formal { get; set; }
  20619. // /// <summary>
  20620. // ///
  20621. // /// </summary>
  20622. // public string country_name_english_UN { get; set; }
  20623. // /// <summary>
  20624. // ///
  20625. // /// </summary>
  20626. // public string continent_name { get; set; }
  20627. // /// <summary>
  20628. // ///
  20629. // /// </summary>
  20630. // public string subregion_name { get; set; }
  20631. // /// <summary>
  20632. // ///
  20633. // /// </summary>
  20634. // public string country_code2 { get; set; }
  20635. // /// <summary>
  20636. // ///
  20637. // /// </summary>
  20638. // public string country_code3 { get; set; }
  20639. // /// <summary>
  20640. // ///
  20641. // /// </summary>
  20642. // public string phone_code { get; set; }
  20643. //}
  20644. //public class CountriesInfo : BasicInfo
  20645. //{
  20646. // public List<CitiesInfo> c { get; set; }
  20647. //}
  20648. //public class CitiesInfo : BasicInfo
  20649. //{
  20650. // public List<AreaInfo> c { get; set; }
  20651. //}
  20652. //public class AreaInfo : BasicInfo
  20653. //{
  20654. // public List<AreaInfo> c { get; set; }
  20655. //}
  20656. //public class BasicInfo
  20657. //{
  20658. // public string code { get; set; }
  20659. // public string cn { get; set; }
  20660. // public string lv { get; set; }
  20661. // public string en { get; set; }
  20662. //}
  20663. #endregion
  20664. #region 查看邀请方
  20665. /// <summary>
  20666. /// 查看邀请方
  20667. /// 邀请方信息 Init
  20668. /// </summary>
  20669. /// <param name="dto"></param>
  20670. /// <returns></returns>
  20671. [HttpPost]
  20672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20673. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  20674. {
  20675. string sqlWhere = string.Empty;
  20676. if (!string.IsNullOrEmpty(dto.Search))
  20677. {
  20678. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  20679. }
  20680. string sql = string.Format($@"Select
  20681. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  20682. Id,
  20683. UnitName
  20684. From Res_InvitationOfficialActivityData
  20685. Where IsDel = 0
  20686. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  20687. RefAsync<int> total = 0;
  20688. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20689. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  20690. }
  20691. /// <summary>
  20692. /// 查看邀请方
  20693. /// 国家信息 Init
  20694. /// </summary>
  20695. /// <param name="dto"></param>
  20696. /// <returns></returns>
  20697. [HttpPost]
  20698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20699. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  20700. {
  20701. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  20702. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20703. var diids = groupInfos.Select(it => it.Id).ToList();
  20704. List<string> countrys = new List<string>();
  20705. foreach (var item in country)
  20706. {
  20707. var data = _groupRepository.FormartTeamName(item);
  20708. var dataArray = _groupRepository.GroupSplitCountry(data);
  20709. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20710. }
  20711. countrys = countrys.Distinct().ToList();
  20712. for (int i = 0; i < countrys.Count; i++)
  20713. {
  20714. string item = countrys[i];
  20715. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  20716. {
  20717. countrys.Remove(item);
  20718. i--;
  20719. }
  20720. }
  20721. RefAsync<int> total = 0;
  20722. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  20723. .Where(it => countrys.Contains(it.Name_CN))
  20724. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20725. .Select(it => new { id = it.Id, name = it.Name_CN })
  20726. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20727. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20728. }
  20729. /// <summary>
  20730. /// 查看邀请方
  20731. /// 城市信息 Init
  20732. /// </summary>
  20733. /// <param name="dto"></param>
  20734. /// <returns></returns>
  20735. [HttpPost]
  20736. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20737. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  20738. {
  20739. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  20740. RefAsync<int> total = 0;
  20741. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  20742. .Where(it => it.CountriesId == dto.CountiesId)
  20743. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20744. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  20745. .Select(it => new { id = it.Id, name = it.Name_CN })
  20746. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20747. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20748. }
  20749. /// <summary>
  20750. /// 查看邀请方
  20751. /// 团组名称 Init
  20752. /// </summary>
  20753. /// <param name="dto"></param>
  20754. /// <returns></returns>
  20755. [HttpPost]
  20756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20757. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  20758. {
  20759. var watch = new Stopwatch();
  20760. watch.Start();
  20761. RefAsync<int> total = 0;
  20762. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  20763. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  20764. .Where((oa, di) => oa.IsDel == 0)
  20765. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  20766. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  20767. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  20768. .Distinct()
  20769. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20770. watch.Stop();
  20771. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  20772. }
  20773. /// <summary>
  20774. /// 查看邀请方
  20775. /// 团组 & 邀请方信息
  20776. /// </summary>
  20777. /// <param name="dto"></param>
  20778. /// <returns></returns>
  20779. [HttpPost]
  20780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20781. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  20782. {
  20783. var watch = new Stopwatch();
  20784. watch.Start();
  20785. RefAsync<int> total = 0;
  20786. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  20787. .AS("Grp_DelegationInfo")
  20788. .Includes(x => x.InvitingInfos)
  20789. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  20790. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  20791. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  20792. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  20793. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  20794. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  20795. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20796. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  20797. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  20798. infos.ForEach(x =>
  20799. {
  20800. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  20801. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  20802. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  20803. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  20804. });
  20805. watch.Stop();
  20806. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  20807. }
  20808. #endregion
  20809. #region 报批行程
  20810. /// <summary>
  20811. /// 报批行程初始化
  20812. /// </summary>
  20813. /// <param name="dto"></param>
  20814. /// <returns></returns>
  20815. [HttpPost]
  20816. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  20817. {
  20818. const int chiNumber = 5;
  20819. var jw = JsonView(false);
  20820. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  20821. var group = groupList.First();
  20822. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  20823. group = groupList.First(x => x.Id == diid);
  20824. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20825. .Where(x => x.DiId == diid && x.IsDel == 0)
  20826. .ToArray();
  20827. var count = 1;
  20828. foreach (var item in blackCodeList)
  20829. {
  20830. if (string.IsNullOrWhiteSpace(item.Title))
  20831. {
  20832. item.Title = "未设置名称数据" + count;
  20833. }
  20834. count++;
  20835. }
  20836. ;
  20837. if (group == null)
  20838. {
  20839. jw.Msg = "暂无团组!";
  20840. return Ok(jw);
  20841. }
  20842. var data = new
  20843. {
  20844. groupList = groupList.Select(x => new
  20845. {
  20846. x.TeamName,
  20847. x.Id
  20848. }),
  20849. content = new ArrayList(),
  20850. groupInfo = new
  20851. {
  20852. group.VisitDays,
  20853. group.TourCode,
  20854. group.VisitPNumber,
  20855. group.TeamName,
  20856. group.Id,
  20857. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  20858. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  20859. group.ClientUnit
  20860. },
  20861. blackCodeList = blackCodeList.Select(x => new
  20862. {
  20863. x.Title,
  20864. x.Id
  20865. }),
  20866. FileTempList = new ArrayList()
  20867. {
  20868. new { Index = 1,FileName = "旧模板" },
  20869. new { Index = 2,FileName = "省外办" },
  20870. new { Index = 3,FileName = "市外办" },
  20871. }
  20872. };
  20873. var resultArr = new ArrayList();
  20874. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  20875. #region 默认不生成行程
  20876. //if (content.Count == 0)
  20877. //{
  20878. // var stay = "-";
  20879. // var cityPath = "-";
  20880. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20881. // .Where(x => x.DiId == diid && x.IsDel == 0)
  20882. // .ToList();
  20883. // //添加城市路径以及住宿地
  20884. // //黑屏代码数据
  20885. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  20886. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  20887. // {
  20888. // jw = JsonView(true, "黑屏代码有误!", data);
  20889. // return Ok(jw);
  20890. // }
  20891. // data = data with
  20892. // {
  20893. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  20894. // {
  20895. // x.Title,
  20896. // x.Id,
  20897. // }).ToArray())
  20898. // };
  20899. // foreach (DataRow row in dtBlack.Rows)
  20900. // {
  20901. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  20902. // {
  20903. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  20904. // return Ok(jw);
  20905. // }
  20906. // }
  20907. // //黑屏代码获取时间区间
  20908. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  20909. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  20910. // _sqlSugar.BeginTran();
  20911. // for (int i = 0; i < timeArr.Count; i++)
  20912. // {
  20913. // stay = "-";
  20914. // cityPath = "-";
  20915. // DateTime NewData = DateTime.Parse(timeArr[i]);
  20916. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  20917. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  20918. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  20919. // if (tbSelect.Length > 0)
  20920. // {
  20921. // List<string> threeCodeStr = new List<string>();
  20922. // foreach (var item in tbSelect)
  20923. // {
  20924. // var threeCode = item["Three"].ToString() ?? "";
  20925. // if (threeCode.Length == 6)
  20926. // {
  20927. // var start = threeCode.Substring(0, 3);
  20928. // var end = threeCode.Substring(3, 3);
  20929. // if (threeCodeStr.Count == 0)
  20930. // {
  20931. // threeCodeStr.Add(start);
  20932. // threeCodeStr.Add(end);
  20933. // }
  20934. // else
  20935. // {
  20936. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  20937. // {
  20938. // threeCodeStr.Add(end);
  20939. // }
  20940. // else
  20941. // {
  20942. // threeCodeStr.Add(start);
  20943. // threeCodeStr.Add(end);
  20944. // }
  20945. // }
  20946. // }
  20947. // }
  20948. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  20949. // var last = threeCodeStr.Last();
  20950. // foreach (var item in threeCodeStr)
  20951. // {
  20952. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  20953. // if (item.Equals(last))
  20954. // {
  20955. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  20956. // }
  20957. // }
  20958. // cityPath = cityPath.Trim('-');
  20959. // }
  20960. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  20961. // appro.Diid = diid ?? -1;
  20962. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  20963. // appro.Id = thisId;
  20964. // appro.CreateUserId = dto.UserId;
  20965. // appro.CreateTime = DateTime.Now;
  20966. // content.Add(appro);
  20967. // }
  20968. // _sqlSugar.CommitTran();
  20969. //}
  20970. #endregion
  20971. foreach (var x in content)
  20972. {
  20973. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  20974. if (chiList.Count < chiNumber)
  20975. {
  20976. for (int i = chiList.Count; i < chiNumber; i++)
  20977. {
  20978. chiList.Add(new Grp_ApprovalTravelDetails());
  20979. }
  20980. }
  20981. resultArr.Add(new
  20982. {
  20983. x.Id,
  20984. x.Date,
  20985. x.Diid,
  20986. chiList = chiList.Select(x1 => new
  20987. {
  20988. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  20989. x1.Details,
  20990. x1.ParentId,
  20991. x1.Id
  20992. })
  20993. });
  20994. }
  20995. data = data with
  20996. {
  20997. content = resultArr,
  20998. };
  20999. jw = JsonView(true, "获取成功!", data);
  21000. return Ok(jw);
  21001. }
  21002. /// <summary>
  21003. /// 报批行程删除
  21004. /// </summary>
  21005. /// <param name="dto"></param>
  21006. /// <returns></returns>
  21007. [HttpPost]
  21008. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  21009. {
  21010. var jw = JsonView(false);
  21011. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21012. if (group == null)
  21013. {
  21014. jw.Msg = "团组参数有误!";
  21015. return Ok(jw);
  21016. }
  21017. try
  21018. {
  21019. _sqlSugar.BeginTran();
  21020. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  21021. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  21022. {
  21023. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21024. DeleteUserId = dto.uesrId,
  21025. IsDel = 1
  21026. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  21027. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  21028. {
  21029. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21030. DeleteUserId = dto.uesrId,
  21031. IsDel = 1
  21032. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  21033. _sqlSugar.CommitTran();
  21034. jw = JsonView(true, "删除成功");
  21035. }
  21036. catch (Exception ex)
  21037. {
  21038. jw = JsonView(false, ex.Message);
  21039. }
  21040. return Ok(jw);
  21041. }
  21042. /// <summary>
  21043. /// 报批行程保存
  21044. /// </summary>
  21045. /// <param name="dto"></param>
  21046. /// <returns></returns>
  21047. [HttpPost]
  21048. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  21049. {
  21050. var jw = JsonView(false);
  21051. var Find = dto.Arr.Find(x => x.id == 0);
  21052. if (Find != null)
  21053. {
  21054. jw.Msg = "生成的ID为0!";
  21055. return Ok(jw);
  21056. }
  21057. foreach (var item in dto.Arr)
  21058. {
  21059. foreach (var chi in item.chiList)
  21060. {
  21061. if (chi.parentId == 0)
  21062. {
  21063. chi.parentId = item.id;
  21064. }
  21065. }
  21066. }
  21067. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  21068. _sqlSugar.BeginTran();
  21069. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  21070. {
  21071. var parentIds = dto.Arr.Select(x => x.id).ToList();
  21072. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  21073. {
  21074. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21075. DeleteUserId = dto.UserId,
  21076. IsDel = 1
  21077. }).ExecuteCommand();
  21078. }
  21079. try
  21080. {
  21081. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  21082. {
  21083. CreateTime = DateTime.Now,
  21084. CreateUserId = dto.UserId,
  21085. Details = x.details,
  21086. ParentId = x.parentId,
  21087. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21088. Remark = "",
  21089. IsDel = 0
  21090. }).ToList()).ExecuteCommand();
  21091. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  21092. {
  21093. Id = x.id,
  21094. Details = x.details,
  21095. ParentId = x.parentId,
  21096. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21097. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  21098. {
  21099. Details = x.Details,
  21100. ParentId = x.ParentId,
  21101. Time = x.Time
  21102. }).ExecuteCommand();
  21103. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  21104. {
  21105. Id = x.id,
  21106. Date = x.date,
  21107. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  21108. {
  21109. Date = x.Date
  21110. }).ExecuteCommand();
  21111. _sqlSugar.CommitTran();
  21112. jw = JsonView(true, "保存成功!");
  21113. }
  21114. catch (Exception ex)
  21115. {
  21116. _sqlSugar.RollbackTran();
  21117. jw = JsonView(false, "保存失败!" + ex.Message);
  21118. }
  21119. return Ok(jw);
  21120. }
  21121. /// <summary>
  21122. /// 报批行程生成
  21123. /// </summary>
  21124. /// <param name="dto"></param>
  21125. /// <returns></returns>
  21126. [HttpPost]
  21127. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  21128. {
  21129. var jw = JsonView(false);
  21130. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21131. if (group == null)
  21132. {
  21133. jw.Msg = "暂无该团组!";
  21134. return Ok(jw);
  21135. }
  21136. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  21137. //黑屏代码数据
  21138. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  21139. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21140. {
  21141. jw.Msg = "黑屏代码有误!";
  21142. return Ok(jw);
  21143. }
  21144. foreach (DataRow row in dtBlack.Rows)
  21145. {
  21146. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21147. {
  21148. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  21149. return Ok(jw);
  21150. }
  21151. }
  21152. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  21153. var resultArr = new ArrayList();
  21154. //if (officialActivitiesArr.Count == 0)
  21155. //{
  21156. // jw.Msg = "暂无公务出访信息!";
  21157. // return Ok(jw);
  21158. //}
  21159. try
  21160. {
  21161. _sqlSugar.BeginTran();
  21162. DeleteApprovalJourney(new
  21163. Domain.Dtos.Groups.DeleteApprovalJourney
  21164. {
  21165. Diid = dto.Diid,
  21166. uesrId = dto.Userid
  21167. });
  21168. var stay = "-";
  21169. var cityPath = "-";
  21170. var arriveCountry = string.Empty;
  21171. //添加城市路径以及住宿地
  21172. //黑屏代码获取时间区间
  21173. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21174. var empty = "【未收入该三字码!请机票同事录入】";
  21175. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21176. #region 配置公务活动时间
  21177. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  21178. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  21179. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  21180. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  21181. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  21182. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21183. {
  21184. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,6,0,0), new List<string>{"9:00-10:30","11:00-12:00","14:00-15:30","16:00-17:00" }),
  21185. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,8,30,0), new List<string>{"11:00-12:00","14:00-15:30","16:00-17:00"}),
  21186. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21187. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  21188. };
  21189. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21190. {
  21191. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,7,0,0), new List<string>{"9:00-10:30","11:00-12:00","14:00-15:30","16:00-17:00" }),
  21192. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,9,0,0), new List<string>{"11:00-12:00","14:00-15:30","16:00-17:00"}),
  21193. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21194. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  21195. };
  21196. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  21197. {
  21198. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,18,0,0), new List<string>{"9:00-10:30","11:00-12:00", "14:00-15:30","16:00-17:00" }),
  21199. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,15,30,0), new List<string>{"9:00-10:30", "11:00-12:00", "14:00-15:00","15:00-16:00"}),
  21200. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  21201. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  21202. };
  21203. #endregion
  21204. var nextDayNum = 0;
  21205. for (int i = 0; i < timeArr.Count; i++)
  21206. {
  21207. stay = "-";
  21208. cityPath = "-";
  21209. var chiarr = new List<Grp_ApprovalTravelDetails>();
  21210. DateTime NewData = DateTime.Parse(timeArr[i]);
  21211. //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();
  21212. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21213. if (nextDayNum > 0)
  21214. {
  21215. nextDayNum--;
  21216. }
  21217. if (tbSelect.Length > 0)
  21218. {
  21219. List<string> threeCodeStr = new List<string>();
  21220. bool isTrade = false;
  21221. string trip = string.Empty;
  21222. foreach (var item in tbSelect)
  21223. {
  21224. if (nextDayNum == 0)
  21225. {
  21226. nextDayNum = Convert.ToInt32(item["Sign"]);
  21227. }
  21228. var airStartTime = item["StartTime"].ToString() ?? "0000";
  21229. var airEndTime = item["EndTime"].ToString() ?? "0000";
  21230. var takeOffTime = DateTime.Parse(timeArr[i]);
  21231. var fallToTime = DateTime.Parse(timeArr[i]);
  21232. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  21233. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  21234. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  21235. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  21236. if (nextDayNum > 0)
  21237. {
  21238. fallToTime = fallToTime.AddDays(nextDayNum);
  21239. }
  21240. trip = string.Empty;
  21241. var start = string.Empty;
  21242. var end = string.Empty;
  21243. var threeCode = item["Three"].ToString() ?? "";
  21244. if (threeCode.Length == 6)
  21245. {
  21246. start = threeCode.Substring(0, 3);
  21247. end = threeCode.Substring(3, 3);
  21248. if (threeCodeStr.Count == 0)
  21249. {
  21250. threeCodeStr.Add(start);
  21251. threeCodeStr.Add(end);
  21252. }
  21253. else
  21254. {
  21255. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21256. {
  21257. threeCodeStr.Add(end);
  21258. }
  21259. else
  21260. {
  21261. threeCodeStr.Add(start);
  21262. threeCodeStr.Add(end);
  21263. }
  21264. }
  21265. }
  21266. //处理机票信息
  21267. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  21268. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  21269. if (start_Object == null)
  21270. {
  21271. start_Object = new Res_ThreeCode()
  21272. {
  21273. AirPort = empty,
  21274. AirPort_En = empty,
  21275. City = empty,
  21276. Country = empty,
  21277. Four = empty,
  21278. Three = empty,
  21279. };
  21280. }
  21281. if (end_Object == null)
  21282. {
  21283. end_Object = new Res_ThreeCode()
  21284. {
  21285. AirPort = empty,
  21286. AirPort_En = empty,
  21287. City = empty,
  21288. Country = empty,
  21289. Four = empty,
  21290. Three = empty,
  21291. };
  21292. }
  21293. //机型判断
  21294. string airModel = item["AirModel"].ToString();
  21295. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  21296. string flightTime = item["FlightTime"].ToString();
  21297. flightTime = ParseBlackTime(flightTime);
  21298. //航班号
  21299. string flightcode = item["Fliagtcode"].ToString();
  21300. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  21301. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  21302. if (aircompany == null)
  21303. {
  21304. aircompany = new Res_AirCompany
  21305. {
  21306. CnName = hsEmpty,
  21307. EnName = hsEmpty,
  21308. ShortCode = hsEmpty,
  21309. };
  21310. }
  21311. //航班前公务安排
  21312. if (tbSelect.First().Equals(item) && i != 0)
  21313. {
  21314. foreach (var takeoff in takeoffTimes)
  21315. {
  21316. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  21317. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  21318. {
  21319. foreach (var addTime in takeoff.Item2)
  21320. {
  21321. chiarr.Add(new Grp_ApprovalTravelDetails
  21322. {
  21323. Time = addTime,
  21324. CreateTime = DateTime.Now,
  21325. CreateUserId = dto.Userid,
  21326. ParentId = 0,
  21327. Details = "公务活动"
  21328. });
  21329. }
  21330. break;
  21331. }
  21332. }
  21333. }
  21334. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  21335. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  21336. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  21337. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  21338. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  21339. if (isTrade)
  21340. {
  21341. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  21342. trip += "(转机不出机场)。";
  21343. }
  21344. //else
  21345. //{
  21346. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  21347. //}
  21348. chiarr.Add(new Grp_ApprovalTravelDetails
  21349. {
  21350. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  21351. CreateTime = DateTime.Now,
  21352. CreateUserId = dto.Userid,
  21353. ParentId = 0,
  21354. Details = trip
  21355. });
  21356. //最后一条到达的时间安排公务
  21357. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  21358. {
  21359. bool isCheckCountry = false;
  21360. if (end_Object.Country != arriveCountry)
  21361. {
  21362. arriveCountry = end_Object.Country;
  21363. isCheckCountry = true;
  21364. }
  21365. if (nextDayNum == 0)
  21366. {
  21367. //需要入境的情况
  21368. if (isCheckCountry)
  21369. {
  21370. foreach (var fallTime in fallTimesCheckCountry)
  21371. {
  21372. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21373. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21374. {
  21375. foreach (var addTime in fallTime.Item2)
  21376. {
  21377. chiarr.Add(new Grp_ApprovalTravelDetails
  21378. {
  21379. Time = addTime,
  21380. CreateTime = DateTime.Now,
  21381. CreateUserId = dto.Userid,
  21382. ParentId = 0,
  21383. Details = "公务活动"
  21384. });
  21385. }
  21386. break;
  21387. }
  21388. }
  21389. }
  21390. else
  21391. {
  21392. foreach (var fallTime in fallTimesNotCheckCountry)
  21393. {
  21394. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21395. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21396. {
  21397. foreach (var addTime in fallTime.Item2)
  21398. {
  21399. chiarr.Add(new Grp_ApprovalTravelDetails
  21400. {
  21401. Time = addTime,
  21402. CreateTime = DateTime.Now,
  21403. CreateUserId = dto.Userid,
  21404. ParentId = 0,
  21405. Details = "公务活动"
  21406. });
  21407. }
  21408. break;
  21409. }
  21410. }
  21411. }
  21412. }
  21413. }
  21414. }
  21415. //添加乘车语句
  21416. //chiarr.Add(new Grp_ApprovalTravelDetails
  21417. //{
  21418. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  21419. // CreateTime = DateTime.Now,
  21420. // CreateUserId = dto.Userid,
  21421. // ParentId = 0,
  21422. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  21423. //});
  21424. //if (i != timeArr.Count - 1)
  21425. //{
  21426. // fallToTime = fallToTime.AddHours(2.5);
  21427. // foreach (var item in Times)
  21428. // {
  21429. // //排列公务时间
  21430. // if (fallToTime.Hour < item.Item1)
  21431. // {
  21432. // chiarr.Add(new Grp_ApprovalTravelDetails
  21433. // {
  21434. // Time = $"{item.Item2} - {item.Item3}",
  21435. // CreateTime = DateTime.Now,
  21436. // CreateUserId = dto.Userid,
  21437. // ParentId = 0,
  21438. // Details = "公务活动"
  21439. // });
  21440. // }
  21441. // }
  21442. //}
  21443. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21444. var last = threeCodeStr.Last();
  21445. foreach (var item in threeCodeStr)
  21446. {
  21447. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21448. if (item.Equals(last))
  21449. {
  21450. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21451. }
  21452. }
  21453. cityPath = cityPath.Trim('-');
  21454. }
  21455. else
  21456. {
  21457. foreach (var item in Times)
  21458. {
  21459. chiarr.Add(new Grp_ApprovalTravelDetails
  21460. {
  21461. Time = $"{item.Item2} - {item.Item3}",
  21462. CreateTime = DateTime.Now,
  21463. CreateUserId = dto.Userid,
  21464. ParentId = 0,
  21465. Details = "公务活动"
  21466. });
  21467. }
  21468. }
  21469. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21470. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21471. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  21472. appro.Diid = dto.Diid;
  21473. appro.CreateUserId = dto.Userid;
  21474. appro.CreateTime = DateTime.Now;
  21475. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21476. appro.Id = thisId;
  21477. //foreach (var item in gwinfo)
  21478. //{
  21479. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  21480. // chi.Details = "拜访" + item.Client;
  21481. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  21482. // {
  21483. // chi.Details += "," + item.ReqSample;
  21484. // }
  21485. // chi.ParentId = thisId;
  21486. // chi.Time = item.Time;
  21487. // chiarr.Add(chi);
  21488. //}
  21489. if (chiarr.Count < 6)
  21490. {
  21491. for (int j = chiarr.Count; j < 6; j++)
  21492. {
  21493. chiarr.Add(new
  21494. Grp_ApprovalTravelDetails());
  21495. }
  21496. }
  21497. resultArr.Add(new
  21498. {
  21499. appro.Id,
  21500. appro.Date,
  21501. appro.Diid,
  21502. chiList = chiarr.Select(x1 => new
  21503. {
  21504. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21505. x1.Details,
  21506. x1.ParentId,
  21507. x1.Id
  21508. })
  21509. });
  21510. }
  21511. _sqlSugar.CommitTran();
  21512. jw = JsonView(true, "生成成功!", resultArr);
  21513. }
  21514. catch (Exception ex)
  21515. {
  21516. jw.Code = 400;
  21517. jw.Msg = "生成失败!" + ex.Message;
  21518. }
  21519. return Ok(jw);
  21520. }
  21521. /// <summary>
  21522. /// 报批行程word导出
  21523. /// </summary>
  21524. /// <param name="dto"></param>
  21525. /// <returns></returns>
  21526. [HttpPost]
  21527. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  21528. {
  21529. var jw = JsonView(false);
  21530. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21531. if (group == null)
  21532. {
  21533. jw.Msg = "暂无该团组!";
  21534. return Ok(jw);
  21535. }
  21536. //模板路径
  21537. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  21538. var fileName = string.Empty;
  21539. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  21540. bool bold = false;
  21541. if (dto.FileIndex == 1)
  21542. {
  21543. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  21544. }
  21545. else if (dto.FileIndex == 2)
  21546. {
  21547. fileName = "省外办-报批.docx";
  21548. bold = false;
  21549. titleFont = "方正黑体简体";
  21550. timeFont = "Times New Roman";
  21551. contentFont = "方正仿宋_GBK";
  21552. }
  21553. else if (dto.FileIndex == 3)
  21554. {
  21555. fileName = "市外办-报批.docx";
  21556. titleFont = "方正黑体简体";
  21557. timeFont = "Times New Roman";
  21558. contentFont = "方正仿宋简体";
  21559. }
  21560. tempPath = tempPath + fileName;
  21561. //载入模板
  21562. Document doc = new Document(tempPath);
  21563. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21564. //获取所填表格的序数
  21565. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21566. Aspose.Words.Tables.Row titleRowClone = null;
  21567. Aspose.Words.Tables.Row CenterRowClone = null;
  21568. int index = 0;
  21569. int indexChi = 0;
  21570. int SetIndex = 0;
  21571. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  21572. //获取数据,放到datatable
  21573. foreach (var item in ApprovalTravelArr)
  21574. {
  21575. if (index > 0)
  21576. {
  21577. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  21578. tableOne.AppendChild(titleRowClone);
  21579. }
  21580. var textTime = item.Date;
  21581. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  21582. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  21583. SetIndex++;
  21584. if (ChiRep.Count > 0)
  21585. {
  21586. foreach (var itemChi in ChiRep)
  21587. {
  21588. var txtTime = itemChi.Time;
  21589. var txtDetail = itemChi.Details;
  21590. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  21591. {
  21592. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  21593. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21594. //indexChi++;
  21595. //SetIndex++;
  21596. break;
  21597. }
  21598. if (indexChi > 0)
  21599. {
  21600. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21601. tableOne.AppendChild(CenterRowClone);
  21602. }
  21603. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  21604. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  21605. indexChi++;
  21606. SetIndex++;
  21607. }
  21608. }
  21609. //else
  21610. //{
  21611. // if (indexChi > 0)
  21612. // {
  21613. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21614. // tableOne.AppendChild(CenterRowClone);
  21615. // }
  21616. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  21617. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21618. // indexChi++;
  21619. // SetIndex++;
  21620. //}
  21621. index++;
  21622. }
  21623. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  21624. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21625. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21626. jw.Code = 200;
  21627. jw.Msg = "";
  21628. return Ok(jw);
  21629. }
  21630. private string ParseBlackTime(string time)
  21631. {
  21632. // 匹配可能只有分钟的情况
  21633. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  21634. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  21635. if (match.Success)
  21636. {
  21637. string hours = match.Groups[1].Value;
  21638. string minutes = match.Groups[2].Value;
  21639. // 如果小时部分为空,则只显示分钟
  21640. if (string.IsNullOrEmpty(hours))
  21641. {
  21642. return $"{minutes}分钟";
  21643. }
  21644. // 如果分钟部分为空,则只显示小时
  21645. else if (string.IsNullOrEmpty(minutes))
  21646. {
  21647. return $"{hours}小时";
  21648. }
  21649. // 否则显示完整格式
  21650. else
  21651. {
  21652. return $"{hours}小时{minutes}分钟";
  21653. }
  21654. }
  21655. else
  21656. {
  21657. return "未知时长";
  21658. }
  21659. }
  21660. private string intToString(int numberVal)
  21661. {
  21662. string numberval = numberVal.ToString();
  21663. Dictionary<char, string> Number = new Dictionary<char, string>();
  21664. Number.Add('1', "一");
  21665. Number.Add('2', "二");
  21666. Number.Add('3', "三");
  21667. Number.Add('4', "四");
  21668. Number.Add('5', "五");
  21669. Number.Add('6', "六");
  21670. Number.Add('7', "七");
  21671. Number.Add('8', "八");
  21672. Number.Add('9', "九");
  21673. string stringNumberVal = string.Empty;
  21674. for (int i = 0; i < numberval.Length; i++)
  21675. {
  21676. if (i == 0)
  21677. {
  21678. stringNumberVal += Number[numberval[i]];
  21679. }
  21680. else if (i >= 1)
  21681. {
  21682. if (numberval[i] == '0')
  21683. {
  21684. stringNumberVal = "十";
  21685. }
  21686. else
  21687. {
  21688. stringNumberVal += "十" + Number[numberval[i]];
  21689. }
  21690. }
  21691. }
  21692. return stringNumberVal;
  21693. }
  21694. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  21695. {
  21696. //获取table中的某个单元格,从0开始
  21697. Cell lshCell = table.Rows[rows].Cells[cells];
  21698. //将单元格中段落移除
  21699. foreach (Paragraph item in lshCell.Paragraphs)
  21700. {
  21701. lshCell.Paragraphs.Remove(item);
  21702. }
  21703. if (val.Contains("\r\n"))
  21704. {
  21705. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  21706. foreach (var item in spArr)
  21707. {
  21708. //新建一个段落
  21709. Paragraph p = new Paragraph(doc);
  21710. var r = new Run(doc, item);
  21711. //设置字体
  21712. if (!string.IsNullOrEmpty(font))
  21713. {
  21714. r.Font.Name = font;
  21715. }
  21716. r.Font.Bold = bold;
  21717. //把设置的值赋给之前新建的段落
  21718. p.AppendChild(r);
  21719. //将此段落加到单元格内
  21720. lshCell.AppendChild(p);
  21721. }
  21722. }
  21723. else
  21724. {
  21725. //新建一个段落
  21726. Paragraph p = new Paragraph(doc);
  21727. var r = new Run(doc, val);
  21728. //设置字体
  21729. if (!string.IsNullOrEmpty(font))
  21730. {
  21731. r.Font.Name = font;
  21732. }
  21733. r.Font.Bold = bold;
  21734. //把设置的值赋给之前新建的段落
  21735. p.AppendChild(r);
  21736. //将此段落加到单元格内
  21737. lshCell.AppendChild(p);
  21738. }
  21739. }
  21740. /// <summary>
  21741. /// 报批行程AI续写
  21742. /// </summary>
  21743. /// <returns></returns>
  21744. [HttpPost]
  21745. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  21746. {
  21747. var jw = JsonView(false);
  21748. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  21749. {
  21750. jw.Msg = "参数有误!";
  21751. return Ok(jw);
  21752. }
  21753. KiMiApiClient kiMi = new KiMiApiClient();
  21754. List<SeedMessages> messages = new List<SeedMessages>() {
  21755. new SeedMessages
  21756. {
  21757. Role = KimiRole.system,
  21758. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  21759. },
  21760. new SeedMessages
  21761. {
  21762. Role = KimiRole.user,
  21763. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  21764. }
  21765. };
  21766. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  21767. string data = kimi_result.Choices[0]?.Message.Content;
  21768. if (string.IsNullOrWhiteSpace(data))
  21769. {
  21770. jw.Data = "Ai续写失败!";
  21771. }
  21772. else
  21773. {
  21774. jw = JsonView(true, "success!", data);
  21775. }
  21776. return Ok(jw);
  21777. }
  21778. #endregion
  21779. #region 团组接待意见调查
  21780. /// <summary>
  21781. /// 团组接待意见调查 - 信息管理
  21782. /// 基础数据(团组)
  21783. /// </summary>
  21784. /// <returns></returns>
  21785. [HttpGet]
  21786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21787. public async Task<IActionResult> OpinionaireInit()
  21788. {
  21789. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  21790. .Select(x => new
  21791. {
  21792. x.Id,
  21793. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  21794. })
  21795. .OrderByDescending(x => x.Id)
  21796. .ToListAsync();
  21797. return Ok(JsonView(groupData, groupData.Count));
  21798. }
  21799. /// <summary>
  21800. /// 团组接待意见调查 - 信息管理
  21801. /// 列表
  21802. /// </summary>
  21803. /// <param name="groupId"></param>
  21804. /// <returns></returns>
  21805. [HttpGet("{groupId}")]
  21806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21807. public async Task<IActionResult> OpinionaireManageList(int groupId)
  21808. {
  21809. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21810. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  21811. .Select(x => new
  21812. {
  21813. x.Id,
  21814. x.TourGuideName,
  21815. x.CityName,
  21816. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  21817. x.CreateTime
  21818. })
  21819. .OrderBy(x => x.Id)
  21820. .ToListAsync();
  21821. return Ok(JsonView(data));
  21822. }
  21823. /// <summary>
  21824. /// 团组接待意见调查 - 信息管理
  21825. /// 保存
  21826. /// </summary>
  21827. /// <param name="dto"></param>
  21828. /// <returns></returns>
  21829. [HttpPost]
  21830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21831. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  21832. {
  21833. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21834. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21835. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21836. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  21837. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  21838. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  21839. _opinionaireRep.BeginTran();
  21840. if (addData != null && addData.Count > 0)
  21841. {
  21842. foreach (var item in addData)
  21843. {
  21844. item.CreateUserId = currUserInfo.UserId;
  21845. item.DiId = dto.DiId;
  21846. }
  21847. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  21848. }
  21849. if (updData != null && updData.Count > 0)
  21850. {
  21851. var upd = await _opinionaireRep._sqlSugar
  21852. .Updateable(updData)
  21853. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  21854. .WhereColumns(x => new { x.Id })
  21855. .ExecuteCommandAsync();
  21856. }
  21857. _opinionaireRep.CommitTran();
  21858. return Ok(JsonView("操作成功!"));
  21859. }
  21860. /// <summary>
  21861. /// 团组接待意见调查 - 信息管理
  21862. /// 删除
  21863. /// </summary>
  21864. /// <param name="id"></param>
  21865. /// <returns></returns>
  21866. [HttpDelete("{id}")]
  21867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21868. public async Task<IActionResult> OpinionaireManageDel(int id)
  21869. {
  21870. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21871. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21872. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  21873. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  21874. if (!del) return Ok(JsonView("操作失败!"));
  21875. return Ok(JsonView("操作成功!"));
  21876. }
  21877. /// <summary>
  21878. /// 团组接待意见调查 - 用户
  21879. /// 列表
  21880. /// </summary>
  21881. /// <param name="diId"></param>
  21882. /// <returns></returns>
  21883. [HttpGet("{diId}")]
  21884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21885. public async Task<IActionResult> OpinionaireUserList(int diId)
  21886. {
  21887. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21888. var sql = string.Format(@"
  21889. SELECT
  21890. o.Id,
  21891. o.DiId,
  21892. di.TeamName AS 'GroupName',
  21893. di.VisitPNumber AS 'PeopleNumber',
  21894. di.ClientName AS 'LeadGroup',
  21895. di.VisitCountry AS 'Travel',
  21896. di.VisitDays AS 'Days',
  21897. o.CityName,
  21898. o.TourGuideName,
  21899. o.Catering,
  21900. o.CateringReason,
  21901. o.Stay,
  21902. o.StayReason,
  21903. o.[Route],
  21904. o.RouteReason,
  21905. o.OfficialActivity,
  21906. o.OfficialActivityReason,
  21907. o.TourGuide,
  21908. o.TourGuideReason,
  21909. o.[Translate],
  21910. o.TranslateReason,
  21911. o.Trip,
  21912. o.TripReason,
  21913. o.ESFileName,
  21914. o.SignatureDate,
  21915. o.Remark
  21916. FROM
  21917. Grp_Opinionaire o
  21918. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  21919. WHERE
  21920. o.IsDel = 0
  21921. AND o.DiId = {0}
  21922. ORDER BY
  21923. o.Id ASC", diId);
  21924. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  21925. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  21926. return Ok(JsonView(data));
  21927. }
  21928. /// <summary>
  21929. /// 团组接待意见调查 - 用户
  21930. /// 保存
  21931. /// </summary>
  21932. /// <param name="dto"></param>
  21933. /// <returns></returns>
  21934. [HttpPost]
  21935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21936. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  21937. {
  21938. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  21939. foreach (var item in dto)
  21940. {
  21941. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  21942. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  21943. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  21944. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  21945. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  21946. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  21947. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  21948. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  21949. }
  21950. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  21951. if (!Directory.Exists(filePathBase))
  21952. {
  21953. Directory.CreateDirectory(filePathBase);
  21954. }
  21955. #region 上传文件
  21956. var filePaths = new List<string>();
  21957. foreach (var item in dto)
  21958. {
  21959. var file = item.File;
  21960. // 将文件保存到指定位置
  21961. var filePath = Path.Combine(filePathBase, file.FileName);
  21962. using (var stream = new FileStream(filePath, FileMode.Create))
  21963. {
  21964. await file.CopyToAsync(stream);
  21965. }
  21966. //验证文件是否上传成功
  21967. if (!System.IO.File.Exists(filePath))
  21968. {
  21969. foreach (var filePathStr in filePaths)
  21970. {
  21971. System.IO.File.Delete(filePathStr);
  21972. }
  21973. return Ok(JsonView(false, "文件上传失败!"));
  21974. }
  21975. item.ESFileName = file.FileName;
  21976. }
  21977. #endregion
  21978. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  21979. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  21980. .UpdateColumns(x => new
  21981. {
  21982. x.Catering,
  21983. x.CateringReason,
  21984. x.Stay,
  21985. x.StayReason,
  21986. x.Route,
  21987. x.RouteReason,
  21988. x.OfficialActivity,
  21989. x.OfficialActivityReason,
  21990. x.TourGuide,
  21991. x.TourGuideReason,
  21992. x.Translate,
  21993. x.TranslateReason,
  21994. x.Trip,
  21995. x.TripReason,
  21996. x.ESFileName,
  21997. x.SignatureDate,
  21998. x.Remark
  21999. })
  22000. .WhereColumns(x => new { x.Id })
  22001. .ExecuteCommandAsync();
  22002. if (upd < 1)
  22003. {
  22004. foreach (var filePathStr in filePaths)
  22005. {
  22006. System.IO.File.Delete(filePathStr);
  22007. }
  22008. return Ok(JsonView(false));
  22009. }
  22010. return Ok(JsonView(true));
  22011. }
  22012. #endregion
  22013. #region 团组餐厅相关信息
  22014. /// <summary>
  22015. /// 团组相关餐厅信息
  22016. /// 基础数据(团组)
  22017. /// </summary>
  22018. /// <returns></returns>
  22019. [HttpGet]
  22020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22021. public async Task<IActionResult> RestaurantInit()
  22022. {
  22023. return Ok(await _restaurantRep.InitAsync());
  22024. }
  22025. /// <summary>
  22026. /// 团组相关餐厅信息
  22027. /// Item
  22028. /// </summary>
  22029. /// <param name="dto"></param>
  22030. /// <returns></returns>
  22031. [HttpPost]
  22032. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22033. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  22034. {
  22035. int portType = dto.PortType,
  22036. groupId = dto.GroupId;
  22037. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22038. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22039. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  22040. }
  22041. /// <summary>
  22042. /// 团组相关餐厅信息
  22043. /// List
  22044. /// </summary>
  22045. /// <param name="dto"></param>
  22046. /// <returns></returns>
  22047. [HttpPost]
  22048. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22049. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  22050. {
  22051. int portType = dto.PortType,
  22052. groupId = dto.GroupId;
  22053. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22054. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22055. var sql = string.Format(@" SELECT
  22056. ri.Id,
  22057. ri.GroupId,
  22058. ri.Date,
  22059. ri.StartTime,
  22060. ri.EndTime,
  22061. CASE WHEN ri.Type = 1 THEN '早餐'
  22062. WHEN ri.Type = 2 THEN '午餐'
  22063. WHEN ri.Type = 3 THEN '晚餐'
  22064. ELSE '其他'
  22065. END AS 'Type',
  22066. ri.Name,
  22067. ri.Address,
  22068. ri.Tel,
  22069. ri.Remark,
  22070. ri.CreateTime,
  22071. u.CnName AS CreateUserName
  22072. FROM
  22073. Grp_RestaurantInfo ri
  22074. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  22075. WHERE
  22076. ri.IsDel = 0
  22077. AND ri.GroupId = {0}
  22078. ORDER BY
  22079. ri.Date ASC
  22080. ", groupId);
  22081. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  22082. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  22083. return Ok(JsonView(infos));
  22084. }
  22085. /// <summary>
  22086. /// 团组相关餐厅信息
  22087. /// Info
  22088. /// </summary>
  22089. /// <param name="dto"></param>
  22090. /// <returns></returns>
  22091. [HttpPost]
  22092. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22093. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  22094. {
  22095. int portType = dto.PortType,
  22096. id = dto.Id;
  22097. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22098. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22099. return Ok(await _restaurantRep.InfoAsync(portType, id));
  22100. }
  22101. /// <summary>
  22102. /// 团组相关餐厅信息
  22103. /// Op
  22104. /// </summary>
  22105. /// <param name="dto"></param>
  22106. /// <returns></returns>
  22107. [HttpPost]
  22108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22109. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  22110. {
  22111. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22112. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22113. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  22114. return Ok(await _restaurantRep.OpAsync(dto));
  22115. }
  22116. /// <summary>
  22117. /// 团组相关餐厅信息
  22118. /// Del
  22119. /// </summary>
  22120. /// <param name="dto"></param>
  22121. /// <returns></returns>
  22122. [HttpPost]
  22123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22124. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  22125. {
  22126. int userId = dto.DeleteUserId;
  22127. var id = dto.Id;
  22128. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22129. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22130. return Ok(await _restaurantRep.DelAsync(dto));
  22131. }
  22132. #endregion
  22133. /// <summary>
  22134. /// 123132123
  22135. /// </summary>
  22136. /// <param name="_dto"></param>
  22137. /// <returns></returns>
  22138. [HttpPost]
  22139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22140. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  22141. {
  22142. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  22143. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  22144. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  22145. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  22146. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  22147. dicDetail.Add(789, 1034);
  22148. dicDetail.Add(790, 1035);
  22149. dicDetail.Add(791, 1036);
  22150. dicDetail.Add(792, 1037);
  22151. dicDetail.Add(793, 1038);
  22152. dicDetail.Add(794, 1039);
  22153. dicDetail.Add(795, 1040);
  22154. dicDetail.Add(796, 1041);
  22155. dicDetail.Add(797, 1042);
  22156. dicDetail.Add(798, 1043);
  22157. dicDetail.Add(801, 1044);
  22158. dicDetail.Add(802, 1045);
  22159. dicDetail.Add(803, 1046);
  22160. Dictionary<int, int> dic = new Dictionary<int, int>();
  22161. dic.Add(806, 1027);
  22162. dic.Add(807, 1028);
  22163. dic.Add(808, 1029);
  22164. dic.Add(809, 1030);
  22165. dic.Add(810, 1031);
  22166. dic.Add(811, 1032);
  22167. dic.Add(812, 1033);
  22168. foreach (var item in list_visa)
  22169. {
  22170. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  22171. temp.Coefficient = item.coefficient;
  22172. DateTime dtCrt;
  22173. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  22174. if (b1)
  22175. {
  22176. temp.CreateTime = dtCrt;
  22177. }
  22178. else
  22179. {
  22180. temp.CreateTime = DateTime.Now;
  22181. }
  22182. temp.CreateUserId = item.Operators;
  22183. temp.DeleteTime = "";
  22184. temp.DeleteUserId = 0;
  22185. temp.DiId = int.Parse(item.DIID);
  22186. temp.FilePath = item.FilePath;
  22187. temp.IsDel = item.IsDel;
  22188. temp.Price = item.Price;
  22189. temp.PriceCount = 1;
  22190. temp.PriceCurrency = item.Currency;
  22191. int detailId = 0;
  22192. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  22193. {
  22194. detailId = dicDetail[item.PriceTypeDetail];
  22195. }
  22196. temp.PriceDetailType = detailId;
  22197. temp.PriceDt = DateTime.Now;
  22198. temp.PriceName = item.PriceName;
  22199. temp.PriceSum = item.Price;
  22200. int tid = 0;
  22201. if (dic.ContainsKey(item.PriceType))
  22202. {
  22203. tid = dic[item.PriceType];
  22204. }
  22205. temp.PriceType = tid;
  22206. temp.Remark = item.Remark;
  22207. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  22208. }
  22209. return Ok(JsonView(true, "操作成功!"));
  22210. }
  22211. [HttpPost]
  22212. public IActionResult TimeTest()
  22213. {
  22214. var jw = JsonView(false, "error");
  22215. _sqlSugar.BeginTran();
  22216. try
  22217. {
  22218. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  22219. .Select(x => new Crm_NewClientData
  22220. {
  22221. Id = x.Id,
  22222. Client = x.Client,
  22223. Contact = x.Contact,
  22224. Location = x.Location,
  22225. })
  22226. .ToList();
  22227. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  22228. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  22229. Stopwatch stopwatch = new Stopwatch();
  22230. // 开始计时
  22231. stopwatch.Start();
  22232. foreach (var item in clientList)
  22233. {
  22234. EncryptionProcessor.DecryptProperties(item);
  22235. }
  22236. stopwatch.Stop();
  22237. jw.Code = 200;
  22238. jw.Data = stopwatch.ElapsedMilliseconds;
  22239. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  22240. }
  22241. catch (Exception ex)
  22242. {
  22243. jw.Code = 400;
  22244. jw.Msg = ex.Message;
  22245. }
  22246. return Ok(jw);
  22247. }
  22248. }
  22249. }