GroupsController.cs 1.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794
  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. /// 团组前期信息H5-URL(员工对应地址)
  370. /// </summary>
  371. /// <param name="name">用户名称</param>
  372. /// <returns></returns>
  373. [HttpGet]
  374. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  375. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  376. {
  377. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  378. .Where(x => x.IsDel == 0)
  379. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  380. .OrderBy(x => x.Id)
  381. .Select(x => new
  382. {
  383. name = x.CnName,
  384. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  385. })
  386. .ToListAsync();
  387. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count()));
  388. }
  389. /// <summary>
  390. /// 团组前期信息 List
  391. /// </summary>
  392. /// <returns></returns>
  393. [HttpPost]
  394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  395. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  396. {
  397. var search = dto.Search;
  398. int[] nameTempIds = new int[] { 1, 12, 28 },
  399. countryTempIds = new int[] { 2, 13, 29 },
  400. daysTempIds = new int[] { 4, 15, 31 },
  401. ppNumTempIds = new int[] { 6 };
  402. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  403. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  404. .Where((opi, u) => opi.IsDel == 0)
  405. .OrderByDescending((opi, u) => opi.CreateTime)
  406. .Select((opi, u) => new GroupOrderPreInfoListView()
  407. {
  408. Id = opi.Id,
  409. Name = opi.Name,
  410. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  411. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  412. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  413. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  414. Operator = u.CnName,
  415. OperationTime = opi.CreateTime
  416. })
  417. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  418. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  419. .ToListAsync();
  420. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  421. int total = list.Count;
  422. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  423. var listPageData1 = listPageData
  424. .Skip((dto.PageIndex - 1) * dto.PageSize)
  425. .Take(dto.PageSize)
  426. .ToList();
  427. var infoIds = listPageData1.Select(x => x.Id).ToList();
  428. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  429. .Where(x => x.IsDel == 0 && x.STid == 109)
  430. .ToArrayAsync();
  431. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  432. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  433. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  434. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  435. .ToListAsync();
  436. foreach (var item in listPageData1)
  437. {
  438. var typeDatas1 = typeDatas.Select(x => new
  439. {
  440. Id = x.Id,
  441. Name = x.Name,
  442. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  443. }).ToArray();
  444. item.VersionDetails = typeDatas1;
  445. }
  446. return Ok(JsonView(listPageData1, listPageData1.Count));
  447. }
  448. /// <summary>
  449. /// 团组前期信息 Init
  450. /// </summary>
  451. /// <returns></returns>
  452. [HttpGet("{userId}")]
  453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  454. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  455. {
  456. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  457. }
  458. /// <summary>
  459. /// 国家数据源
  460. /// </summary>
  461. /// <param name="pageIndex">当前页码</param>
  462. /// <param name="pageSize">每页条数</param>
  463. /// <param name="search">查询条件</param>
  464. /// <returns></returns>
  465. [HttpGet]
  466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  467. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  468. {
  469. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  470. if (pageIndex == 0 && pageSize == 0)
  471. {
  472. //所有数据
  473. return Ok(JsonView(countrys, countrys.Count));
  474. }
  475. //分页
  476. int skip = (pageIndex - 1) * pageSize;
  477. int take = pageSize;
  478. if (!string.IsNullOrEmpty(search))
  479. {
  480. IEnumerable<char> charSequence = search.Select(c => c);
  481. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  482. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  483. return Ok(JsonView(pageData, pageResult1.Count));
  484. }
  485. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  486. return Ok(JsonView(pageResult2, countrys.Count));
  487. }
  488. /// <summary>
  489. /// 城市数据源
  490. /// </summary>
  491. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  492. /// <param name="pageIndex">当前页码</param>
  493. /// <param name="pageSize">每页条数</param>
  494. /// <param name="search">查询条件</param>
  495. /// <returns></returns>
  496. [HttpGet("{countryLabel}")]
  497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  498. public async Task<IActionResult> CityByCountry(
  499. string countryLabel,
  500. [FromQuery] int pageIndex,
  501. [FromQuery] int pageSize,
  502. [FromQuery] string search)
  503. {
  504. countryLabel = HttpUtility.UrlDecode(countryLabel);
  505. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  506. var citys = Array.Empty<string?>();
  507. if (countryList.Any())
  508. {
  509. var cityDatas = await _sqlSugar
  510. .Queryable<Grp_NationalTravelFee>()
  511. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  512. .ToArrayAsync();
  513. foreach (var item in cityDatas)
  514. {
  515. if (item.City.Contains("城市"))
  516. {
  517. item.City = item.Country + "-所有城市";
  518. }
  519. }
  520. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  521. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  522. }
  523. if (pageIndex == 0 && pageSize == 0)
  524. {
  525. //所有数据
  526. return Ok(JsonView(citys, citys?.Length ?? 0));
  527. }
  528. //分页
  529. int skip = (pageIndex - 1) * pageSize;
  530. int take = pageSize;
  531. if (!string.IsNullOrEmpty(search))
  532. {
  533. IEnumerable<char> charSequence = search.Select(c => c);
  534. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  535. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  536. return Ok(JsonView(pageData, pageResult1.Count()));
  537. }
  538. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  539. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  540. }
  541. /// <summary>
  542. /// 团组前期信息 Info
  543. /// </summary>
  544. /// <param name="dto">Id</param>
  545. /// <param name="portType">Id</param>
  546. /// <returns></returns>
  547. [HttpGet("{Id}/{TempId}")]
  548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  549. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto, int portType = 1)
  550. {
  551. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  552. }
  553. /// <summary>
  554. /// 团组前期信息 移动端 Info
  555. /// </summary>
  556. /// <param name="dto">Id</param>
  557. /// <returns></returns>
  558. [HttpGet("{Id}/{TempId}")]
  559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  560. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  561. {
  562. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  563. }
  564. /// <summary>
  565. /// 团组前期信息 Save
  566. /// </summary>
  567. /// <param name="dto">Id</param>
  568. /// <returns></returns>
  569. [HttpPost]
  570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  571. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  572. {
  573. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  574. }
  575. /// <summary>
  576. /// 团组前期信息 Del
  577. /// </summary>
  578. /// <param name="dto">Id</param>
  579. /// <returns></returns>
  580. [HttpPost]
  581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  582. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  583. {
  584. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  585. }
  586. /// <summary>
  587. /// 团组前期信息 文件下载
  588. /// </summary>
  589. /// <param name="dto">Id</param>
  590. /// <returns></returns>
  591. [HttpGet("{Id}/{TempId}")]
  592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  593. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  594. {
  595. int id = dto.Id, tempId = dto.TempId;
  596. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  597. var data = view.Data as GrpOrderPreInfoView;
  598. #region Excel
  599. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  600. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  601. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  602. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  603. var fileNamePrefix = string.Empty;
  604. if (tempId == 1405)
  605. {
  606. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  607. fileNamePrefix = $"{data.Name}_无商邀版";
  608. }
  609. else if (tempId == 1406)
  610. {
  611. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  612. fileNamePrefix = $"{data.Name}_有商邀版";
  613. }
  614. else
  615. {
  616. //tempId == 1404 默认下载
  617. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  618. fileNamePrefix = $"{data.Name}_单接送机";
  619. }
  620. foreach (var item in data.Items)
  621. {
  622. var obj = item.NewValue;
  623. if (obj == null) item.OriginVal = "";
  624. else if (obj.Equals("有") || obj.Equals("无"))
  625. {
  626. item.OriginVal = obj.ToString();
  627. }
  628. else if (obj is object[] objArray)
  629. {
  630. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  631. item.OriginVal = string.Join("、", stringArray);
  632. }
  633. else if (obj is string[] stringArray)
  634. {
  635. item.OriginVal = string.Join("、", stringArray);
  636. }
  637. else if (obj.Equals("-"))
  638. {
  639. item.OriginVal = "";
  640. }
  641. }
  642. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  643. fileName = CommonFun.ValidFileName(fileName);
  644. //载入模板
  645. WorkbookDesigner designer = new WorkbookDesigner();
  646. designer.Workbook = new Workbook(tempPath);
  647. if (tempId == 1406)
  648. {
  649. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  650. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  651. for (int i = 1; i <= view2.Length; i++)
  652. {
  653. view2[i - 1].Index = i;
  654. }
  655. designer.SetDataSource("View1", view1);
  656. designer.SetDataSource("View2", view2);
  657. }
  658. else
  659. {
  660. designer.SetDataSource("View", data.Items);
  661. }
  662. designer.Process();
  663. if (!Directory.Exists(savePath))
  664. {
  665. Directory.CreateDirectory(savePath);
  666. }
  667. string serverPath = $"{savePath}{fileName}";
  668. designer.Workbook.Save(serverPath);
  669. string rst = $"{servicePath}{ftpPath}{fileName}";
  670. #endregion
  671. return Ok(JsonView(new { url = rst }));
  672. }
  673. #endregion
  674. #region 团组基本信息
  675. /// <summary>
  676. /// 接团信息列表
  677. /// </summary>
  678. /// <param name="dto">团组列表请求dto</param>
  679. /// <returns></returns>
  680. [HttpPost]
  681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  682. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  683. {
  684. var groupData = await _groupRepository.GetGroupList(dto);
  685. if (groupData.Code != 0)
  686. {
  687. return Ok(JsonView(false, groupData.Msg));
  688. }
  689. return Ok(JsonView(groupData.Data));
  690. }
  691. /// <summary>
  692. /// 分页查询团组列表
  693. /// </summary>
  694. /// <param name="dto"></param>
  695. /// <returns></returns>
  696. [HttpPost]
  697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  698. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  699. {
  700. var watch = new Stopwatch();
  701. watch.Start();
  702. RefAsync<int> total = 0;
  703. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  704. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  705. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  706. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  707. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  708. .Distinct()
  709. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  710. watch.Stop();
  711. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  712. }
  713. /// <summary>
  714. /// 接团信息列表 Page Init
  715. /// </summary>
  716. /// <returns></returns>
  717. [HttpPost]
  718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  719. public async Task<IActionResult> PostGroupPageListInit()
  720. {
  721. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  722. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  723. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  724. var _view = new
  725. {
  726. depData = depDatas,
  727. rankData = rankDatas
  728. };
  729. return Ok(JsonView(true, "查询成功!", _view));
  730. }
  731. /// <summary>
  732. /// 接团信息列表 Page
  733. /// </summary>
  734. /// <param name="dto">团组列表请求dto</param>
  735. /// <returns></returns>
  736. [HttpPost]
  737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  738. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  739. {
  740. #region 参数验证
  741. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  742. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  743. PageFunAuthViewBase
  744. pageFunAuthView = new PageFunAuthViewBase();
  745. #region 页面操作权限验证
  746. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  747. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  748. #endregion
  749. #endregion
  750. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  751. {
  752. string sqlWhere = string.Empty;
  753. if (dto.IsSure == 0) //未完成
  754. {
  755. sqlWhere += string.Format(@" And IsSure = 0");
  756. }
  757. else if (dto.IsSure == 1) //已完成
  758. {
  759. sqlWhere += string.Format(@" And IsSure = 1");
  760. }
  761. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  762. {
  763. string tj = dto.SearchCriteria;
  764. 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}%')",
  765. tj, tj, tj, tj, tj);
  766. }
  767. if (int.TryParse(dto.Rank, out int rankId))
  768. {
  769. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  770. }
  771. string sqlWhere1 = string.Empty;
  772. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  773. {
  774. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  775. }
  776. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  777. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  778. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  779. JietuanOperator,IsSure,CreateTime,IsBid
  780. From (
  781. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  782. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  783. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  784. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  785. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  786. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  787. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  788. From Grp_DelegationInfo gdi
  789. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  790. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  791. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  792. Where gdi.IsDel = 0 {0}
  793. ) temp {1}", sqlWhere, sqlWhere1);
  794. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  795. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  796. var _view = new
  797. {
  798. PageFuncAuth = pageFunAuthView,
  799. Data = _DelegationList
  800. };
  801. return Ok(JsonView(true, "查询成功!", _view, total));
  802. }
  803. else
  804. {
  805. return Ok(JsonView(false, "查询失败"));
  806. }
  807. }
  808. /// <summary>
  809. /// 团组列表
  810. /// </summary>
  811. /// <returns></returns>
  812. [HttpPost]
  813. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  814. {
  815. #region 参数验证
  816. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  817. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  818. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  819. #region 页面操作权限验证
  820. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  821. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  822. #endregion
  823. #endregion
  824. if (dto.PortType != 1 && dto.PortType != 2)
  825. {
  826. return Ok(JsonView(false, "查询失败!"));
  827. }
  828. string orderbyStr = "order by gdi.CreateTime Desc";
  829. string sqlWhere = string.Empty;
  830. if (dto.IsSure == 0) //未完成
  831. {
  832. sqlWhere += string.Format(@" And IsSure = 0");
  833. }
  834. else if (dto.IsSure == 1) //已完成
  835. {
  836. sqlWhere += string.Format(@" And IsSure = 1");
  837. }
  838. //团组类型
  839. if (dto.TeamDid > 0)
  840. {
  841. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  842. }
  843. //团组名称
  844. if (!string.IsNullOrEmpty(dto.TeamName))
  845. {
  846. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  847. }
  848. //客户名称
  849. if (!string.IsNullOrEmpty(dto.ClientName))
  850. {
  851. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  852. }
  853. //客户单位
  854. if (!string.IsNullOrEmpty(dto.ClientUnit))
  855. {
  856. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  857. }
  858. //出访时间
  859. if (!string.IsNullOrEmpty(dto.visitDataTime))
  860. {
  861. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  862. orderbyStr = "order by gdi.VisitDate";
  863. }
  864. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  865. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  866. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  867. JietuanOperator,IsSure,CreateTime
  868. From (
  869. Select row_number() over({0}) as Row_Number,
  870. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  871. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  872. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  873. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  874. From Grp_DelegationInfo gdi
  875. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  876. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  877. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  878. Where gdi.IsDel = 0 {1}
  879. ) temp ", orderbyStr, sqlWhere);
  880. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  881. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  882. #region 处理所属部门
  883. /*
  884. * 1.sq 和 gyy 等显示 市场部
  885. * 2.王鸽和主管及张总还有管理员号统一国交部
  886. * 2-1. 4 管理员 ,21 张海麟
  887. */
  888. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  889. List<int> userIds1 = new List<int>() { 4, 21 };
  890. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  891. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  892. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  893. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  894. .ToList();
  895. foreach (var item in _DelegationList)
  896. {
  897. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  898. }
  899. #endregion
  900. var _view = new
  901. {
  902. PageFuncAuth = pageFunAuthView,
  903. Data = _DelegationList
  904. };
  905. return Ok(JsonView(true, "查询成功!", _view, total));
  906. }
  907. /// <summary>
  908. /// 接团信息详情
  909. /// </summary>
  910. /// <param name="dto">团组info请求dto</param>
  911. /// <returns></returns>
  912. [HttpPost]
  913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  914. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  915. {
  916. var groupData = await _groupRepository.GetGroupInfo(dto);
  917. if (groupData.Code != 0)
  918. {
  919. return Ok(JsonView(false, groupData.Msg));
  920. }
  921. return Ok(JsonView(groupData.Data));
  922. }
  923. /// <summary>
  924. /// 接团信息 编辑添加
  925. /// 基础信息数据源
  926. /// </summary>
  927. /// <param name="dto"></param>
  928. /// <returns></returns>
  929. [HttpPost]
  930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  931. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  932. {
  933. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  934. if (groupData.Code != 0)
  935. {
  936. return Ok(JsonView(false, groupData.Msg));
  937. }
  938. return Ok(JsonView(groupData.Data));
  939. }
  940. /// <summary>
  941. /// 成本修改团组信息
  942. /// </summary>
  943. /// <param name="dto"></param>
  944. /// <returns></returns>
  945. [HttpPost]
  946. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  947. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  948. {
  949. var jw = JsonView(false, "操作失败");
  950. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  951. if (di == null)
  952. {
  953. jw.Msg = "参数有误!";
  954. return Ok(jw);
  955. }
  956. #region 添加出访起止时间
  957. var startTime = new DateTime();
  958. var endTime = new DateTime();
  959. if (DateTime.TryParse(dto.VisitDate, out startTime))
  960. {
  961. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  962. }
  963. else
  964. {
  965. jw.Msg = "参数有误!";
  966. return Ok(jw);
  967. }
  968. #endregion
  969. di.VisitDate = startTime;
  970. di.VisitPNumber = dto.VisitPNumber;
  971. di.VisitDays = dto.VisitDays;
  972. di.VisitStartDate = startTime;
  973. di.VisitEndDate = endTime;
  974. var count = _sqlSugar.Updateable(di)
  975. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  976. .ExecuteCommand();
  977. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  978. }
  979. /// <summary>
  980. /// 接团信息 编辑添加
  981. /// 省份-城市 基础信息数据源
  982. /// </summary>
  983. /// <param name="dto"></param>
  984. /// <returns></returns>
  985. [HttpPost]
  986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  987. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  988. {
  989. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  990. string search = dto.Search;
  991. var data = await _groupRepository.CityBasicSource();
  992. int total = data.Length;
  993. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  994. .Skip((pageIndex - 1) * pageSize)
  995. .Take(pageSize)
  996. .ToArray();
  997. return Ok(JsonView(data, total));
  998. }
  999. /// <summary>
  1000. /// 接团信息 操作(增改)
  1001. /// </summary>
  1002. /// <param name="dto"></param>
  1003. /// <returns></returns>
  1004. [HttpPost]
  1005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1006. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1007. {
  1008. // 创建 Stopwatch 实例
  1009. Stopwatch stopwatch = Stopwatch.StartNew();
  1010. decimal ffrPrice = 0.00M;
  1011. DateTime? visitDt = null;
  1012. if (dto.Status == 2)
  1013. {
  1014. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1015. if (groupInfo != null)
  1016. {
  1017. ffrPrice = groupInfo.PaymentMoney;
  1018. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1019. }
  1020. }
  1021. var groupData = await _groupRepository.GroupOperation(dto);
  1022. if (groupData.Code != 0)
  1023. {
  1024. return Ok(JsonView(false, groupData.Msg));
  1025. }
  1026. int diId = 0;
  1027. try
  1028. {
  1029. //添加时 默认加入团组汇率
  1030. if (dto.Status == 1) //添加
  1031. {
  1032. diId = groupData.Data;
  1033. //添加默认币种
  1034. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1035. //默认分配权限
  1036. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1037. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1038. var _managerIds = new List<int>() { 22, 32, 21 };
  1039. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1040. if (userIds.Count > 0)
  1041. {
  1042. userIds.Add(208);
  1043. //创建团组管控
  1044. GroupStepForDelegation.CreateWorkStep(diId);
  1045. //发送消息
  1046. string groupName = dto.TeamName;
  1047. string createGroupUser = string.Empty;
  1048. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1049. if (userInfo != null) createGroupUser = userInfo.CnName;
  1050. string title = $"系统通知";
  1051. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1052. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1053. }
  1054. //默认创建倒推表
  1055. await _invertedListRep._Create(dto.UserId, diId);
  1056. }
  1057. else if (dto.Status == 2)
  1058. {
  1059. diId = dto.Id;
  1060. }
  1061. #region 签证人员团组时间通知
  1062. #region 计算出访起止时间
  1063. var startTime = new DateTime();
  1064. var endTime = new DateTime();
  1065. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1066. {
  1067. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1068. }
  1069. #endregion
  1070. #endregion
  1071. #region 团组操作默认添加/修改收款账单
  1072. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1073. {
  1074. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1075. .Where(x => x.IsDel == 0 &&
  1076. x.Diid == diId &&
  1077. x.Remark.Equals("预付款")
  1078. )
  1079. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1080. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1081. .FirstAsync();
  1082. ffrInfo = new Fin_ForeignReceivables()
  1083. {
  1084. Diid = diId,
  1085. PriceName = dto.ClientUnit,
  1086. Price = dto.PaymentMoney,
  1087. Count = 1,
  1088. Unit = $"元",
  1089. ItemSumPrice = dto.PaymentMoney,
  1090. Rate = 1.0000M,
  1091. Currency = 836,
  1092. AddingWay = 0,
  1093. CreateUserId = dto.UserId,
  1094. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1095. Remark = $"预付款"
  1096. };
  1097. if (ffrInfo == null) //Add
  1098. {
  1099. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1100. }
  1101. else //修改
  1102. {
  1103. await _sqlSugar.Updateable(ffrInfo)
  1104. .UpdateColumns(x => new
  1105. {
  1106. x.PriceName,
  1107. x.Price,
  1108. x.ItemSumPrice,
  1109. x.CreateTime,
  1110. x.CreateUserId
  1111. })
  1112. .WhereColumns(x => x.Id)
  1113. .ExecuteCommandAsync();
  1114. }
  1115. }
  1116. #endregion
  1117. if (diId > 0)
  1118. {
  1119. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1120. }
  1121. // 停止计时
  1122. stopwatch.Stop();
  1123. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1124. }
  1125. catch (Exception ex)
  1126. {
  1127. // 停止计时
  1128. stopwatch.Stop();
  1129. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1130. Logs(ex.Message);
  1131. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1132. }
  1133. // 停止计时
  1134. stopwatch.Stop();
  1135. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1136. }
  1137. /// <summary>
  1138. /// 接团流程操作(增改)
  1139. /// 安卓端使用 建团时添加客户名单
  1140. /// </summary>
  1141. /// <param name="dto"></param>
  1142. /// <returns></returns>
  1143. [HttpPost]
  1144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1145. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1146. {
  1147. #region 参数验证
  1148. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1149. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1150. #region 页面操作权限验证
  1151. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1152. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1153. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1154. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1155. #endregion
  1156. #endregion
  1157. try
  1158. {
  1159. //_sqlSugar.BeginTran();
  1160. decimal ffrPrice = 0.00M;
  1161. DateTime? visitDt = null;
  1162. if (dto.Status == 2)
  1163. {
  1164. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1165. if (groupInfo != null)
  1166. {
  1167. ffrPrice = groupInfo.PaymentMoney;
  1168. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1169. }
  1170. }
  1171. var _dto = new GroupOperationDto();
  1172. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1173. var groupData = await _groupRepository.GroupOperation(_dto);
  1174. if (groupData.Code != 0)
  1175. {
  1176. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1177. }
  1178. int diId = 0;
  1179. //添加时 默认加入团组汇率
  1180. if (dto.Status == 1) //添加
  1181. {
  1182. diId = groupData.Data;
  1183. //添加默认币种
  1184. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1185. //默认分配权限
  1186. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1187. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1188. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1189. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1190. if (userIds.Count > 0)
  1191. {
  1192. userIds.Add(208);
  1193. //创建团组管控
  1194. GroupStepForDelegation.CreateWorkStep(diId);
  1195. //发送消息
  1196. string groupName = dto.TeamName;
  1197. string createGroupUser = string.Empty;
  1198. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1199. if (userInfo != null) createGroupUser = userInfo.CnName;
  1200. string title = $"系统通知";
  1201. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1202. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1203. }
  1204. #region 应用推送
  1205. try
  1206. {
  1207. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1208. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1209. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1210. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1211. {
  1212. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1213. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1214. }
  1215. }
  1216. catch (Exception ex)
  1217. {
  1218. }
  1219. #endregion
  1220. //默认创建倒推表
  1221. await _invertedListRep._Create(dto.UserId, diId);
  1222. }
  1223. if (dto.Status == 2)
  1224. {
  1225. diId = dto.Id;
  1226. if (diId == 0)
  1227. {
  1228. //_sqlSugar.RollbackTran();
  1229. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1230. }
  1231. }
  1232. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1233. if (viewData.Code != 0)
  1234. {
  1235. //_sqlSugar.RollbackTran();
  1236. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1237. }
  1238. #region 团组操作默认添加/修改收款账单
  1239. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1240. {
  1241. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1242. .Where(x => x.IsDel == 0 &&
  1243. x.Diid == diId &&
  1244. x.Remark.Equals("预付款")
  1245. )
  1246. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1247. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1248. .FirstAsync();
  1249. ffrInfo = new Fin_ForeignReceivables()
  1250. {
  1251. Diid = diId,
  1252. PriceName = dto.ClientUnit,
  1253. Price = dto.PaymentMoney,
  1254. Count = 1,
  1255. Unit = $"元",
  1256. ItemSumPrice = dto.PaymentMoney,
  1257. Rate = 1.0000M,
  1258. Currency = 836,
  1259. AddingWay = 0,
  1260. CreateUserId = dto.UserId,
  1261. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1262. Remark = $"预付款"
  1263. };
  1264. if (ffrInfo == null) //Add
  1265. {
  1266. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1267. }
  1268. else //修改
  1269. {
  1270. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1271. .UpdateColumns(x => new
  1272. {
  1273. x.PriceName,
  1274. x.Price,
  1275. x.ItemSumPrice,
  1276. x.CreateTime,
  1277. x.CreateUserId
  1278. })
  1279. .WhereColumns(x => x.Id)
  1280. .ExecuteCommandAsync();
  1281. }
  1282. }
  1283. #endregion
  1284. #region 签证人员团组时间通知
  1285. #region 计算出访起止时间
  1286. var startTime = new DateTime();
  1287. var endTime = new DateTime();
  1288. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1289. {
  1290. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1291. }
  1292. #endregion
  1293. if (diId > 0)
  1294. {
  1295. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1296. }
  1297. #endregion
  1298. //_sqlSugar.CommitTran();
  1299. return Ok(JsonView(true, "添加成功"));
  1300. }
  1301. catch (Exception ex)
  1302. {
  1303. _sqlSugar.RollbackTran();
  1304. return Ok(JsonView(false, ex.Message));
  1305. }
  1306. }
  1307. /// <summary>
  1308. /// 接团流程操作(增改)
  1309. /// 安卓端使用 建团时添加客户名单
  1310. /// </summary>
  1311. /// <param name="dto"></param>
  1312. /// <returns></returns>
  1313. [HttpPost]
  1314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1315. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1316. {
  1317. #region 参数验证
  1318. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1319. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1320. #region 页面操作权限验证
  1321. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1322. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1323. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1324. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1325. #endregion
  1326. #endregion
  1327. _sqlSugar.BeginTran();
  1328. decimal ffrPrice = 0.00M;
  1329. DateTime? visitDt = null;
  1330. if (dto.Status == 2)
  1331. {
  1332. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1333. if (groupInfo != null)
  1334. {
  1335. ffrPrice = groupInfo.PaymentMoney;
  1336. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1337. }
  1338. }
  1339. var _dto = new GroupOperationDto();
  1340. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1341. var groupData = await _groupRepository.GroupOperation(_dto);
  1342. if (groupData.Code != 0)
  1343. {
  1344. _sqlSugar.RollbackTran();
  1345. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1346. }
  1347. try
  1348. {
  1349. int diId = 0;
  1350. //添加时 默认加入团组汇率
  1351. if (dto.Status == 1) //添加
  1352. {
  1353. diId = groupData.Data;
  1354. //添加默认币种
  1355. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1356. //默认分配权限
  1357. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1358. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1359. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  1360. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1361. if (userIds.Count > 0)
  1362. {
  1363. userIds.Add(208);
  1364. //创建团组管控
  1365. GroupStepForDelegation.CreateWorkStep(diId);
  1366. //发送消息
  1367. string groupName = dto.TeamName;
  1368. string createGroupUser = string.Empty;
  1369. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1370. if (userInfo != null) createGroupUser = userInfo.CnName;
  1371. string title = $"系统通知";
  1372. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1373. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1374. }
  1375. #region 应用推送
  1376. try
  1377. {
  1378. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1379. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1380. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1381. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1382. {
  1383. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1384. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1385. }
  1386. }
  1387. catch (Exception ex)
  1388. {
  1389. _sqlSugar.CommitTran();
  1390. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1391. }
  1392. #endregion
  1393. //默认创建倒推表
  1394. await _invertedListRep._Create(dto.UserId, diId);
  1395. }
  1396. else if (dto.Status == 2)
  1397. {
  1398. diId = dto.Id;
  1399. if (diId == 0)
  1400. {
  1401. _sqlSugar.RollbackTran();
  1402. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1403. }
  1404. }
  1405. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1406. if (viewData.Code != 0)
  1407. {
  1408. _sqlSugar.RollbackTran();
  1409. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1410. }
  1411. #region 团组操作默认添加/修改收款账单
  1412. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1413. {
  1414. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1415. .Where(x => x.IsDel == 0 &&
  1416. x.Diid == diId &&
  1417. x.Remark.Equals("预付款")
  1418. )
  1419. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1420. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1421. .FirstAsync();
  1422. ffrInfo = new Fin_ForeignReceivables()
  1423. {
  1424. Diid = diId,
  1425. PriceName = dto.ClientUnit,
  1426. Price = dto.PaymentMoney,
  1427. Count = 1,
  1428. Unit = $"元",
  1429. ItemSumPrice = dto.PaymentMoney,
  1430. Rate = 1.0000M,
  1431. Currency = 836,
  1432. AddingWay = 0,
  1433. CreateUserId = dto.UserId,
  1434. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1435. Remark = $"预付款"
  1436. };
  1437. if (ffrInfo == null) //Add
  1438. {
  1439. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1440. }
  1441. else //修改
  1442. {
  1443. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1444. .UpdateColumns(x => new
  1445. {
  1446. x.PriceName,
  1447. x.Price,
  1448. x.ItemSumPrice,
  1449. x.CreateTime,
  1450. x.CreateUserId
  1451. })
  1452. .WhereColumns(x => x.Id)
  1453. .ExecuteCommandAsync();
  1454. }
  1455. }
  1456. #endregion
  1457. #region 签证人员团组时间通知
  1458. #region 计算出访起止时间
  1459. var startTime = new DateTime();
  1460. var endTime = new DateTime();
  1461. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1462. {
  1463. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1464. }
  1465. #endregion
  1466. if (diId > 0)
  1467. {
  1468. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1469. }
  1470. #endregion
  1471. _sqlSugar.CommitTran();
  1472. return Ok(JsonView(true));
  1473. }
  1474. catch (Exception ex)
  1475. {
  1476. _sqlSugar.RollbackTran();
  1477. return Ok(JsonView(false, ex.Message));
  1478. }
  1479. }
  1480. /// <summary>
  1481. /// 接团信息 操作(删除)
  1482. /// </summary>
  1483. /// <param name="dto"></param>
  1484. /// <returns></returns>
  1485. [HttpPost]
  1486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1487. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1488. {
  1489. var diId = dto.Id;
  1490. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1491. #region 删除 验证
  1492. /*
  1493. * 1、收款账单数据:0 条
  1494. * 2、收款退还数据:0 条
  1495. * 3、机票费用数据:0 条
  1496. * 4、签证费用数据:0 条
  1497. * 5、保险费用数据:0 条
  1498. * 6、酒店费用数据:0 条
  1499. * 7、公务出访数据:1 条
  1500. * 8、邀请公务活动费用数据:1 条
  1501. * 9、OP费用数据:5 条
  1502. * 10、其他费用数据:0 条
  1503. * 11、团组日付报销费用数据:0 条
  1504. *
  1505. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1506. */
  1507. //收款账单
  1508. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1509. //收款退还
  1510. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1511. //机票费用
  1512. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1513. //签证费用
  1514. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1515. //保险费用
  1516. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1517. //酒店费用
  1518. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1519. //公务出访
  1520. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1521. //邀请公务活动费用
  1522. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1523. //OP费用
  1524. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1525. //其他费用
  1526. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1527. //团组日付报销费用
  1528. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1529. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1530. if (feeCount > 0)
  1531. {
  1532. var delMsgTips = new StringBuilder();
  1533. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1534. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1535. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1536. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1537. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1538. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1539. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1540. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1541. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1542. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1543. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1544. delMsgTips.AppendLine($"");
  1545. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1546. return Ok(JsonView(false, delMsgTips.ToString()));
  1547. }
  1548. #endregion
  1549. var groupData = await _groupRepository.GroupDel(dto);
  1550. if (groupData.Code != 0)
  1551. {
  1552. return Ok(JsonView(false, groupData.Msg));
  1553. }
  1554. return Ok(JsonView(true));
  1555. }
  1556. /// <summary>
  1557. /// 获取团组销售报价号
  1558. /// 团组添加时 使用
  1559. /// </summary>
  1560. /// <returns></returns>
  1561. [HttpPost]
  1562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1563. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1564. {
  1565. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1566. if (groupData.Code != 0)
  1567. {
  1568. return Ok(JsonView(false, groupData.Msg));
  1569. }
  1570. object salesQuoteNo = new
  1571. {
  1572. SalesQuoteNo = groupData.Data
  1573. };
  1574. return Ok(JsonView(salesQuoteNo));
  1575. }
  1576. /// <summary>
  1577. /// 设置确认出团
  1578. /// </summary>
  1579. /// <param name="dto"></param>
  1580. /// <returns></returns>
  1581. [HttpPost]
  1582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1583. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1584. {
  1585. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1586. if (groupData.Code != 0)
  1587. {
  1588. return Ok(JsonView(false, groupData.Msg));
  1589. }
  1590. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1591. #region OA消息推送
  1592. try
  1593. {
  1594. string groupName = groupInfo.TeamName;
  1595. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1596. string title = $"系统通知";
  1597. string content = $"团组[{groupName}]已确认出团!";
  1598. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1599. }
  1600. catch (Exception ex)
  1601. {
  1602. }
  1603. #endregion
  1604. #region 应用推送
  1605. try
  1606. {
  1607. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1608. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1609. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1610. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1611. {
  1612. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1613. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1614. }
  1615. }
  1616. catch (Exception ex)
  1617. {
  1618. }
  1619. #endregion
  1620. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1621. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1622. }
  1623. /// <summary>
  1624. /// 获取团组名称data And 签证国别Data
  1625. /// </summary>
  1626. /// <param name="dto"></param>
  1627. /// <returns></returns>
  1628. [HttpPost]
  1629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1630. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1631. {
  1632. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1633. if (groupData.Code != 0)
  1634. {
  1635. return Ok(JsonView(false, groupData.Msg));
  1636. }
  1637. return Ok(JsonView(groupData.Data));
  1638. }
  1639. /// <summary>
  1640. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1641. /// </summary>
  1642. /// <returns></returns>
  1643. [HttpPost]
  1644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1645. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1646. {
  1647. try
  1648. {
  1649. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1650. if (groupData.Code != 0)
  1651. {
  1652. return Ok(JsonView(false, groupData.Msg));
  1653. }
  1654. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1655. }
  1656. catch (Exception ex)
  1657. {
  1658. return Ok(JsonView(false, "程序错误!"));
  1659. throw;
  1660. }
  1661. }
  1662. /// <summary>
  1663. /// 团组清单 Excel
  1664. /// </summary>
  1665. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1666. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1667. /// <returns></returns>
  1668. [HttpGet]
  1669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1670. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1671. {
  1672. DateTime _beginDt, _endDt;
  1673. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1674. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1675. if (!beginBool && !endBool)
  1676. {
  1677. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1678. }
  1679. string sql = string.Format(@"
  1680. SELECT
  1681. ROW_NUMBER,
  1682. Id,
  1683. SalesQuoteNo,
  1684. TourCode,
  1685. TeamTypeId,
  1686. TeamType,
  1687. TeamLevId,
  1688. TeamLev,
  1689. TeamName,
  1690. ClientName,
  1691. ClientUnit,
  1692. VisitDate,
  1693. VisitDays,
  1694. VisitPNumber,
  1695. JietuanOperatorId,
  1696. JietuanOperator,
  1697. IsSure,
  1698. CreateUserName,
  1699. IsBid
  1700. FROM
  1701. (
  1702. SELECT
  1703. ROW_NUMBER() OVER(
  1704. ORDER BY
  1705. gdi.VisitDate Desc
  1706. ) AS ROW_NUMBER,
  1707. gdi.Id,
  1708. SalesQuoteNo,
  1709. TourCode,
  1710. ssd.Id TeamTypeId,
  1711. ssd.Name TeamType,
  1712. ssd1.Id TeamLevId,
  1713. ssd1.Name TeamLev,
  1714. TeamName,
  1715. ClientName,
  1716. ClientUnit,
  1717. VisitDate,
  1718. VisitDays,
  1719. VisitPNumber,
  1720. JietuanOperator JietuanOperatorId,
  1721. su.CnName JietuanOperator,
  1722. IsSure,
  1723. gdi.CreateTime,
  1724. su1.CnName As CreateUserName,
  1725. gdi.IsBid
  1726. FROM
  1727. Grp_DelegationInfo gdi
  1728. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1729. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1730. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1731. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1732. WHERE
  1733. gdi.IsDel = 0
  1734. AND gdi.IsBid = 0
  1735. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1736. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1737. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1738. #region 处理所属部门
  1739. /*
  1740. * 1.sq 和 gyy 等显示 市场部
  1741. * 2.王鸽和主管及张总还有管理员号统一国交部
  1742. * 2-1. 4 管理员 ,21 张海麟
  1743. */
  1744. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1745. List<int> userIds1 = new List<int>() { 4, 21 };
  1746. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1747. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1748. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1749. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1750. .ToListAsync();
  1751. var droupIds = groupList.Select(it => it.Id).ToList();
  1752. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1753. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1754. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1755. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1756. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1757. {
  1758. DiId = tcl.DiId,
  1759. LastName = dc.LastName,
  1760. FirstName = dc.FirstName,
  1761. Sex = dc.Sex,
  1762. Birthday = dc.BirthDay,
  1763. Company = cc.CompanyFullName,
  1764. Job = dc.Job,
  1765. CreateTime = tcl.CreateTime,
  1766. })
  1767. .ToList();
  1768. foreach (var item in groupList)
  1769. {
  1770. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1771. string groupFirstName = "";
  1772. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1773. if (currDatas.Any())
  1774. {
  1775. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1776. }
  1777. item.GroupFirst = groupFirstName;
  1778. }
  1779. #endregion
  1780. #region Excel
  1781. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1782. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1783. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1784. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1785. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1786. //载入模板
  1787. WorkbookDesigner designer = new WorkbookDesigner();
  1788. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1789. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1790. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1791. dt.TableName = "GroupList";
  1792. designer.SetDataSource(dt);
  1793. designer.Process();
  1794. if (!Directory.Exists(savePath))
  1795. {
  1796. Directory.CreateDirectory(savePath);
  1797. }
  1798. string serverPath = $"{savePath}{fileName}";
  1799. designer.Workbook.Save(serverPath);
  1800. string rst = $"{servicePath}{ftpPath}{fileName}";
  1801. #endregion
  1802. return Ok(JsonView(true, "操作成功!", rst));
  1803. }
  1804. /// <summary>
  1805. /// 团组合同下载(1.付款80% 2.付全款)
  1806. /// </summary>
  1807. /// <param name="dto"></param>
  1808. /// <returns></returns>
  1809. /// <exception cref="Exception"></exception>
  1810. [HttpPost]
  1811. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  1812. {
  1813. var jw = JsonView(false);
  1814. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1815. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  1816. if (di == null)
  1817. {
  1818. jw.Msg = "团组Id有误!";
  1819. return Ok(jw);
  1820. }
  1821. #region 权限校验
  1822. var allDownFile = new List<int>() { 21 };
  1823. try
  1824. {
  1825. var setting = _sqlSugar.Queryable<Sys_SetData>()
  1826. .First(x => x.Id == 1418 && x.IsDel == 0);
  1827. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  1828. }
  1829. catch (Exception)
  1830. { }
  1831. var guojiaoDownFile = new List<int>() { 330 };
  1832. var shichangDownFile = new List<int>() { 95 };
  1833. if (allDownFile.Contains(dto.UserId))
  1834. {
  1835. }
  1836. else if (guojiaoDownFile.Contains(dto.UserId))
  1837. {
  1838. var guojiaobuDi = new List<int>() { 4, 21 };
  1839. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  1840. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  1841. .Where((d, u) => u.Id == di.JietuanOperator)
  1842. .Select((d, u) => d.DepName)
  1843. .First();
  1844. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  1845. {
  1846. jw.Msg = "暂无下载权限!";
  1847. return Ok(jw);
  1848. }
  1849. }
  1850. else if (shichangDownFile.Contains(dto.UserId))
  1851. {
  1852. var dic = new Dictionary<int, int[]>()
  1853. {
  1854. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  1855. };
  1856. try
  1857. {
  1858. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  1859. if (sqSetting != null)
  1860. {
  1861. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  1862. foreach (var item in result.Keys)
  1863. {
  1864. if (dic.Keys.Contains(item))
  1865. {
  1866. int[] dilatation = new int[dic[item].Length + result[item].Length];
  1867. Array.Copy(dic[item], dilatation, dic[item].Length);
  1868. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  1869. dic[item] = dilatation;
  1870. }
  1871. else
  1872. {
  1873. dic.Add(item, result[item]);
  1874. }
  1875. }
  1876. }
  1877. if (!dic[95].Contains(di.CreateUserId))
  1878. {
  1879. jw.Msg = "暂无下载权限!";
  1880. return Ok(jw);
  1881. }
  1882. }
  1883. catch (Exception)
  1884. { }
  1885. }
  1886. else if (dto.UserId == di.CreateUserId)
  1887. {
  1888. }
  1889. else
  1890. {
  1891. jw.Msg = "暂无下载权限!";
  1892. return Ok(jw);
  1893. }
  1894. #endregion
  1895. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  1896. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  1897. .ToListAsync();
  1898. if (!blackCodeList.Any())
  1899. {
  1900. jw.Msg = "该团无机票行程代码!";
  1901. return Ok(jw);
  1902. }
  1903. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  1904. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  1905. if (groupEnterExitCost == null)
  1906. {
  1907. jw.Msg = "暂无三公费用信息!";
  1908. return Ok(jw);
  1909. }
  1910. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  1911. rateList ??= new List<CurrencyInfo>();
  1912. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  1913. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  1914. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  1915. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  1916. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  1917. .Select((x, a, b) => new
  1918. {
  1919. x.Index,
  1920. itemName = a.Name,
  1921. CurrencyStr = b.Name,
  1922. x.Cost,
  1923. x.SubTotal,
  1924. x.Remark
  1925. })
  1926. .OrderBy((x) => x.Index)
  1927. .ToList();
  1928. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  1929. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  1930. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  1931. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  1932. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  1933. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  1934. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  1935. decimal subJJC = 0.00M,
  1936. subGWC = 0.00M,
  1937. subTDC = 0.00M;
  1938. //经济舱
  1939. if (groupEnterExitCost.SumJJC == 1)
  1940. {
  1941. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  1942. }
  1943. //公务舱
  1944. if (groupEnterExitCost.SumGWC == 1)
  1945. {
  1946. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  1947. }
  1948. //头等舱
  1949. if (groupEnterExitCost.SumTDC == 1)
  1950. {
  1951. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  1952. }
  1953. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  1954. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  1955. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  1956. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  1957. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  1958. .Select((x, s, dc, cc) => new groupClints
  1959. {
  1960. Id = x.Id,
  1961. Name = s.Name,
  1962. IsAccompany = x.IsAccompany,
  1963. CompanyFullName = cc.CompanyFullName
  1964. })
  1965. .ToListAsync();
  1966. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  1967. //获取舱位人数
  1968. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  1969. .GroupBy(x => x.Name)
  1970. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  1971. .ToList();
  1972. string cityPath = string.Empty;
  1973. string startCity = string.Empty;
  1974. string endCity = string.Empty;
  1975. foreach (var item in blackCodeList)
  1976. {
  1977. string city = GeneralMethod.GetGroupCityLine(item, "-");
  1978. cityPath += city + "\r\n";
  1979. if (item.Equals(blackCodeList.First()))
  1980. {
  1981. var sp = city.Split('-');
  1982. startCity = sp[0];
  1983. endCity = sp[sp.Length - 1];
  1984. }
  1985. }
  1986. Dictionary<string, string> bookMarkDic = new Dictionary<string, string>();
  1987. bookMarkDic.Add("ClientUnit", di.ClientUnit);
  1988. bookMarkDic.Add("VisitCountry", di.VisitCountry);
  1989. bookMarkDic.Add("VisitDate", di.VisitDate.ToString("yyyy年MM月dd日"));
  1990. bookMarkDic.Add("VisitPNumber", di.VisitPNumber.ToString());
  1991. bookMarkDic.Add("CityPath", cityPath);
  1992. bookMarkDic.Add("StartCity", startCity);
  1993. bookMarkDic.Add("EndCity", endCity);
  1994. bookMarkDic.Add("StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚");
  1995. Document doc = null;
  1996. var percentage = 0.8M;
  1997. var fileNameadd = "预付";
  1998. if (dto.FileType == 1)
  1999. {
  2000. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2001. }
  2002. else if (dto.FileType == 2)
  2003. {
  2004. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2005. percentage = 1;
  2006. fileNameadd = "全款";
  2007. }
  2008. else
  2009. {
  2010. throw new Exception("FileType有误!");
  2011. }
  2012. DocumentBuilder builder = new DocumentBuilder(doc);
  2013. decimal totalPrice = 0.00M;
  2014. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2015. if (firstTable != null)
  2016. {
  2017. // 遍历表格的行和单元格
  2018. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2019. {
  2020. for (int i = 0; i < row.Cells.Count; i++)
  2021. {
  2022. var cell = row.Cells[i];
  2023. // 读取单元格内容
  2024. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2025. if (cellTextFirst.Contains("舱位"))
  2026. {
  2027. break;
  2028. }
  2029. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2030. {
  2031. if (i == 2)
  2032. {
  2033. if (cellTextFirst == "经济舱")
  2034. {
  2035. // 设置单元格内容
  2036. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2037. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2038. }
  2039. else
  2040. {
  2041. // 设置单元格内容
  2042. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2043. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2044. }
  2045. }
  2046. if (i == 3)
  2047. {
  2048. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2049. if (count != null)
  2050. {
  2051. // 设置单元格内容
  2052. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2053. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2054. }
  2055. }
  2056. if (i == 4)
  2057. {
  2058. var rowPrice = 0.00M;
  2059. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2060. count ??= 0;
  2061. if (cellTextFirst == "经济舱")
  2062. {
  2063. rowPrice = subJJC * (int)count;
  2064. }
  2065. else
  2066. {
  2067. rowPrice = subGWC * (int)count;
  2068. }
  2069. totalPrice += rowPrice;
  2070. // 设置单元格内容
  2071. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2072. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2073. }
  2074. }
  2075. }
  2076. }
  2077. }
  2078. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2079. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2080. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2081. //--合同表格部分
  2082. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2083. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2084. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2085. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2086. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2087. bookMarkDic.Add("CityPath1", cityPath);
  2088. bookMarkDic.Add("CityPath2", cityPath);
  2089. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2090. if (contractTable != null)
  2091. {
  2092. //数据源
  2093. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2094. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2095. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2096. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2097. .Select((it, y, s) => new
  2098. {
  2099. it.Cost,
  2100. it.SubTotal,
  2101. it.Type,
  2102. y.Id,
  2103. y.City,
  2104. s.Name,
  2105. CurrencyCodeCn = s.Remark
  2106. })
  2107. .ToList()
  2108. .Select(x => new
  2109. {
  2110. CurrencyCode = x.Name,
  2111. CityId = x.Id,
  2112. x.City,
  2113. VisitPNumber = di.VisitPNumber,
  2114. x.Type,
  2115. x.Cost,
  2116. x.SubTotal,
  2117. Rate = rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2118. x.CurrencyCodeCn,
  2119. });
  2120. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2121. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2122. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2123. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2124. List<tableSetting> tableSettings = new List<tableSetting>()
  2125. {
  2126. new tableSetting{ Index = 1 , Property = "City"},
  2127. new tableSetting{ Index = 2 , Property = "CurrencyCodeCn"},
  2128. new tableSetting{ Index = 3 , Property = "Cost"},
  2129. new tableSetting{ Index = 4 , Property = "VisitPNumber"},
  2130. //new tableSetting{ Index = 5 , Property = ""},
  2131. //new tableSetting{ Index = 6 , Property = ""},
  2132. new tableSetting{ Index = 7 , Property = "Rate"},
  2133. //new tableSetting{ Index = 8 , Property = ""},
  2134. };
  2135. //1.住宿费
  2136. int cloneRow = 8;
  2137. int startDayPrice = 8; //写入index
  2138. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2139. foreach (var dac in dac1)
  2140. {
  2141. var first = dac.First();
  2142. var dayCount = dac.Count();
  2143. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2144. for (int i = 1; i < row.Cells.Count; i++)
  2145. {
  2146. var cell = row.Cells[i];
  2147. var findProperty = tableSettings.Find(x => x.Index == i);
  2148. if (findProperty != null)
  2149. {
  2150. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2151. // 设置单元格内容
  2152. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2153. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2154. }
  2155. else
  2156. {
  2157. switch (i)
  2158. {
  2159. case 5:
  2160. cell.FirstParagraph.Runs.Clear();
  2161. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2162. break;
  2163. case 6:
  2164. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2165. cell.FirstParagraph.Runs.Clear();
  2166. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2167. break;
  2168. case 8:
  2169. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2170. cell.FirstParagraph.Runs.Clear();
  2171. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2172. ZSPriceSum += xiaojiRMB;
  2173. break;
  2174. default:
  2175. break;
  2176. }
  2177. }
  2178. }
  2179. startDayPrice++;
  2180. if (!dac1.Last().Equals(dac))
  2181. {
  2182. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2183. // 将克隆的行追加到原行后面
  2184. contractTable.Rows.Insert(startDayPrice, newRow);
  2185. }
  2186. else
  2187. {
  2188. cloneRow += dac1.Count() + 1;
  2189. startDayPrice = cloneRow;
  2190. }
  2191. }
  2192. //2.伙食费
  2193. foreach (var dac in dac2)
  2194. {
  2195. var first = dac.First();
  2196. var dayCount = dac.Count();
  2197. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2198. for (int i = 1; i < row.Cells.Count; i++)
  2199. {
  2200. var cell = row.Cells[i];
  2201. var findProperty = tableSettings.Find(x => x.Index == i);
  2202. if (findProperty != null)
  2203. {
  2204. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2205. // 设置单元格内容
  2206. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2207. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2208. }
  2209. else
  2210. {
  2211. switch (i)
  2212. {
  2213. case 5:
  2214. cell.FirstParagraph.Runs.Clear();
  2215. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2216. break;
  2217. case 6:
  2218. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2219. cell.FirstParagraph.Runs.Clear();
  2220. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2221. break;
  2222. case 8:
  2223. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2224. cell.FirstParagraph.Runs.Clear();
  2225. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2226. HSPriceSum += xiaojiRMB;
  2227. break;
  2228. default:
  2229. break;
  2230. }
  2231. }
  2232. }
  2233. startDayPrice++;
  2234. if (!dac2.Last().Equals(dac))
  2235. {
  2236. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2237. // 将克隆的行追加到原行后面
  2238. contractTable.Rows.Insert(startDayPrice, newRow);
  2239. }
  2240. else
  2241. {
  2242. cloneRow += dac2.Count() + 1;
  2243. startDayPrice = cloneRow;
  2244. }
  2245. }
  2246. //3.公杂费
  2247. foreach (var dac in dac3)
  2248. {
  2249. var first = dac.First();
  2250. var dayCount = dac.Count();
  2251. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2252. for (int i = 1; i < row.Cells.Count; i++)
  2253. {
  2254. var cell = row.Cells[i];
  2255. var findProperty = tableSettings.Find(x => x.Index == i);
  2256. if (findProperty != null)
  2257. {
  2258. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2259. // 设置单元格内容
  2260. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2261. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2262. }
  2263. else
  2264. {
  2265. switch (i)
  2266. {
  2267. case 5:
  2268. cell.FirstParagraph.Runs.Clear();
  2269. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2270. break;
  2271. case 6:
  2272. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2273. cell.FirstParagraph.Runs.Clear();
  2274. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2275. break;
  2276. case 8:
  2277. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2278. cell.FirstParagraph.Runs.Clear();
  2279. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2280. GZPriceSum += xiaojiRMB;
  2281. break;
  2282. default:
  2283. break;
  2284. }
  2285. }
  2286. }
  2287. startDayPrice++;
  2288. if (!dac3.Last().Equals(dac))
  2289. {
  2290. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2291. // 将克隆的行追加到原行后面
  2292. contractTable.Rows.Insert(startDayPrice, newRow);
  2293. }
  2294. else
  2295. {
  2296. cloneRow += dac3.Count() + 1;
  2297. startDayPrice = cloneRow;
  2298. }
  2299. }
  2300. //合并单元格
  2301. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2302. {
  2303. var currentRow = contractTable.Rows[i];
  2304. var nextRow = contractTable.Rows[i + 1];
  2305. // 获取当前行和下一行的第一个单元格
  2306. Cell currentCell = currentRow.Cells[0];
  2307. Cell nextCell = nextRow.Cells[0];
  2308. // 检查单元格内容是否一致(去除尾部的换行符)
  2309. string currentText = currentCell.GetText().Trim();
  2310. string nextText = nextCell.GetText().Trim();
  2311. if (currentText == nextText)
  2312. {
  2313. // 如果当前单元格已经被合并,找到合并的起始单元格
  2314. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2315. {
  2316. // 找到合并的起始单元格
  2317. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2318. // 将下一行的单元格设置为合并的后续单元格
  2319. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2320. }
  2321. else
  2322. {
  2323. // 如果当前单元格是合并的起始单元格
  2324. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2325. // 将下一行的单元格设置为合并的后续单元格
  2326. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2327. }
  2328. }
  2329. else
  2330. {
  2331. // 如果内容不一致,重置当前单元格的合并属性
  2332. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2333. {
  2334. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2335. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2336. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2337. }
  2338. else
  2339. {
  2340. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2341. }
  2342. }
  2343. }
  2344. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2345. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2346. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2347. }
  2348. foreach (var bookmarkName in bookMarkDic.Keys)
  2349. {
  2350. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2351. if (bookmark != null)
  2352. {
  2353. if (bookmarkName == "ClientUnit")
  2354. {
  2355. // 移动到书签位置
  2356. builder.MoveTo(bookmark.BookmarkStart);
  2357. // 设置字体样式为下划线
  2358. builder.Font.Underline = Aspose.Words.Underline.Single;
  2359. // 插入书签值
  2360. builder.Write(bookMarkDic[bookmarkName]);
  2361. // 清除字体格式,避免影响后续文本
  2362. builder.Font.ClearFormatting();
  2363. }
  2364. else
  2365. {
  2366. builder.MoveToBookmark(bookmarkName);
  2367. builder.Write(bookMarkDic[bookmarkName]);
  2368. }
  2369. }
  2370. }
  2371. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2372. doc.Save(savePaht);
  2373. jw.Msg = "生成成功!";
  2374. jw.Code = 200;
  2375. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2376. return Ok(jw);
  2377. }
  2378. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2379. {
  2380. int index = rowIndex;
  2381. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2382. {
  2383. index--;
  2384. }
  2385. return index;
  2386. }
  2387. #endregion
  2388. #region 团组&签证
  2389. /// <summary>
  2390. /// 根据团组Id获取签证客户信息List
  2391. /// </summary>
  2392. /// <param name="dto">请求dto</param>
  2393. /// <returns></returns>
  2394. [HttpPost]
  2395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2396. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  2397. {
  2398. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  2399. if (groupData.Code != 0)
  2400. {
  2401. return Ok(JsonView(false, groupData.Msg));
  2402. }
  2403. return Ok(JsonView(groupData.Data));
  2404. }
  2405. /// <summary>
  2406. /// IOS获取团组签证拍照上传进度01(团组列表)
  2407. /// </summary>
  2408. /// <param name="dto">请求dto</param>
  2409. /// <returns></returns>
  2410. [HttpPost]
  2411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2412. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  2413. {
  2414. if (dto == null)
  2415. {
  2416. return Ok(JsonView(false, "参数为空"));
  2417. }
  2418. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  2419. return Ok(JsonView(visaList));
  2420. }
  2421. /// <summary>
  2422. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  2423. /// </summary>
  2424. /// <returns></returns>
  2425. [HttpPost]
  2426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2427. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  2428. {
  2429. if (dto == null)
  2430. {
  2431. return Ok(JsonView(false, "请求错误:"));
  2432. }
  2433. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  2434. return Ok(JsonView(list));
  2435. }
  2436. /// <summary>
  2437. /// IOS获取团组签证拍照上传进度03(相册)
  2438. /// </summary>
  2439. /// <returns></returns>
  2440. [HttpPost]
  2441. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2442. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  2443. {
  2444. if (dto == null)
  2445. {
  2446. return Ok(JsonView(false, "请求错误:"));
  2447. }
  2448. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  2449. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  2450. list.ForEach(s => s.url = url);
  2451. return Ok(JsonView(list));
  2452. }
  2453. /// <summary>
  2454. /// IOS获取团组签证拍照上传进度04(图片上传)
  2455. /// </summary>
  2456. /// <param name="dto"></param>
  2457. /// <returns></returns>
  2458. [HttpPost]
  2459. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2460. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  2461. {
  2462. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  2463. //if (!string.IsNullOrEmpty(result))
  2464. //{
  2465. //}
  2466. //else {
  2467. // return Ok(JsonView(false, "上传失败"));
  2468. //}
  2469. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  2470. int sucNum = 0;
  2471. try
  2472. {
  2473. foreach (var item in dto.base64DataList)
  2474. {
  2475. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  2476. string result = DecodeBase64ToImage(item, imageName);
  2477. if (!string.IsNullOrEmpty(result))
  2478. {
  2479. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  2480. pic.CreateUserId = dto.CreateUserId;
  2481. pic.PicName = imageName;
  2482. pic.PicPath = result;
  2483. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  2484. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  2485. if (insertResult > 0)
  2486. {
  2487. sucNum++;
  2488. }
  2489. }
  2490. }
  2491. }
  2492. catch (Exception ex)
  2493. {
  2494. return Ok(JsonView(false, ex.Message));
  2495. }
  2496. string msg = string.Format(@"成功上传{0}张", sucNum);
  2497. return Ok(JsonView(true, msg));
  2498. }
  2499. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  2500. {
  2501. string filename = "";//声明一个string类型的相对路径
  2502. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  2503. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  2504. try//会有异常抛出,try,catch一下
  2505. {
  2506. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  2507. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  2508. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  2509. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  2510. //文件名称
  2511. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  2512. //上传的文件的路径
  2513. string filePath = "";
  2514. if (!Directory.Exists(fileDir))
  2515. {
  2516. Directory.CreateDirectory(fileDir);
  2517. }
  2518. //上传的文件的路径
  2519. filePath = fileDir + filename;
  2520. //string url = HttpRuntime.AppDomainAppPath.ToString();
  2521. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  2522. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  2523. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  2524. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  2525. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  2526. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  2527. ms.Close();//关闭当前流,并释放所有与之关联的资源
  2528. bitmap.Dispose();
  2529. }
  2530. catch (Exception e)
  2531. {
  2532. string massage = e.Message;
  2533. Logs("IOS图片上传Error:" + massage);
  2534. //filename = e.Message;
  2535. }
  2536. return filename;//返回相对路径
  2537. }
  2538. /// <summary>
  2539. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  2540. /// </summary>
  2541. /// <param name="dto"></param>
  2542. /// <returns></returns>
  2543. [HttpPost]
  2544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2545. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  2546. {
  2547. if (dto == null)
  2548. {
  2549. return Ok(JsonView(false, "请求错误:"));
  2550. }
  2551. string msg = "参数错误";
  2552. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  2553. {
  2554. try
  2555. {
  2556. //_delegationVisaRep.BeginTran();
  2557. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  2558. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  2559. .Where(s => s.Id == dto.visaProgressCustomerId)
  2560. .ExecuteCommandAsync();
  2561. if (updCount > 0 && dto.publishCode == 1)
  2562. {
  2563. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  2564. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  2565. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  2566. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  2567. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  2568. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  2569. if (groupData == null)
  2570. {
  2571. _delegationVisaRep.RollbackTran();
  2572. }
  2573. string title = string.Format(@"[签证进度更新]");
  2574. string content = string.Format(@"测试文本");
  2575. bool rst = await _message.AddMsg(new MessageDto()
  2576. {
  2577. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  2578. IssuerId = dto.publisher,
  2579. Title = title,
  2580. Content = content,
  2581. ReleaseTime = DateTime.Now,
  2582. UIdList = new List<int> {
  2583. 234
  2584. }
  2585. });
  2586. if (rst)
  2587. {
  2588. return Ok(JsonView(true, "发送通知成功"));
  2589. }
  2590. }
  2591. //_delegationVisaRep.CommitTran();
  2592. }
  2593. catch (Exception)
  2594. {
  2595. //_delegationVisaRep.RollbackTran();
  2596. }
  2597. }
  2598. return Ok(JsonView(true, msg));
  2599. }
  2600. #endregion
  2601. #region 团组任务分配
  2602. /// <summary>
  2603. /// 团组任务分配初始化
  2604. /// </summary>
  2605. /// <returns></returns>
  2606. [HttpPost]
  2607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2608. public async Task<IActionResult> GetTaskAssignmen()
  2609. {
  2610. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  2611. if (groupData.Code != 0)
  2612. {
  2613. return Ok(JsonView(false, groupData.Msg));
  2614. }
  2615. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2616. }
  2617. /// <summary>
  2618. /// 团组任务分配查询
  2619. /// </summary>
  2620. /// <param name="dto"></param>
  2621. /// <returns></returns>
  2622. [HttpPost]
  2623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2624. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  2625. {
  2626. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  2627. if (groupData.Code != 0)
  2628. {
  2629. return Ok(JsonView(false, groupData.Msg));
  2630. }
  2631. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2632. }
  2633. /// <summary>
  2634. /// 团组任务分配操作
  2635. /// </summary>
  2636. /// <param name="dto"></param>
  2637. /// <returns></returns>
  2638. [HttpPost]
  2639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2640. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  2641. {
  2642. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  2643. if (groupData.Code != 0)
  2644. {
  2645. return Ok(JsonView(false, groupData.Msg));
  2646. }
  2647. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2648. }
  2649. /// <summary>
  2650. /// 团组任务分配
  2651. /// 批量分配
  2652. /// 查询团组
  2653. /// </summary>
  2654. /// <param name="dto"></param>
  2655. /// <returns></returns>
  2656. [HttpPost]
  2657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2658. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  2659. {
  2660. //参数验证
  2661. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  2662. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  2663. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  2664. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  2665. }
  2666. /// <summary>
  2667. /// 团组任务分配
  2668. /// 批量分配
  2669. /// </summary>
  2670. /// <param name="dto"></param>
  2671. /// <returns></returns>
  2672. [HttpPost]
  2673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2674. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  2675. {
  2676. //参数验证
  2677. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  2678. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  2679. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  2680. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  2681. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  2682. }
  2683. #endregion
  2684. #region 团组费用审核
  2685. /// <summary>
  2686. /// 费用审核
  2687. /// 团组列表 Page
  2688. /// </summary>
  2689. /// <param name="_dto">团组列表请求dto</param>
  2690. /// <returns></returns>
  2691. [HttpPost]
  2692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2693. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  2694. {
  2695. #region 参数验证
  2696. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2697. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2698. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2699. #region 页面操作权限验证
  2700. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2701. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2702. #endregion
  2703. #endregion
  2704. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  2705. {
  2706. string sqlWhere = string.Empty;
  2707. if (_dto.IsSure == 0) //未完成
  2708. {
  2709. sqlWhere += string.Format(@" And IsSure = 0");
  2710. }
  2711. else if (_dto.IsSure == 1) //已完成
  2712. {
  2713. sqlWhere += string.Format(@" And IsSure = 1");
  2714. }
  2715. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  2716. {
  2717. string tj = _dto.SearchCriteria;
  2718. 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}%')",
  2719. tj, tj, tj, tj, tj);
  2720. }
  2721. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  2722. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  2723. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  2724. From (
  2725. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  2726. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  2727. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  2728. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  2729. From Grp_DelegationInfo gdi
  2730. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  2731. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  2732. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  2733. Where gdi.IsDel = 0 {0}
  2734. ) temp ", sqlWhere);
  2735. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  2736. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  2737. var _view = new
  2738. {
  2739. PageFuncAuth = pageFunAuthView,
  2740. Data = _DelegationList
  2741. };
  2742. return Ok(JsonView(true, "查询成功!", _view, total));
  2743. }
  2744. else
  2745. {
  2746. return Ok(JsonView(false, "查询失败"));
  2747. }
  2748. }
  2749. /// <summary>
  2750. /// 获取团组费用审核
  2751. /// </summary>
  2752. /// <param name="_dto"></param>
  2753. /// <returns></returns>
  2754. [HttpPost]
  2755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2756. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  2757. {
  2758. try
  2759. {
  2760. #region 参数验证
  2761. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2762. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2763. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  2764. #region 页面操作权限验证
  2765. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2766. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  2767. #endregion
  2768. #endregion
  2769. var _view = new Grp_CreditCardPaymentView();
  2770. var clientNameList = getSimplClientList(_dto.DiId);
  2771. #region 费用清单
  2772. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  2773. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  2774. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  2775. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  2776. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  2777. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  2778. /*
  2779. * 76://酒店预订
  2780. */
  2781. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2782. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2783. /*
  2784. * 79://车/导游地接
  2785. */
  2786. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2787. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2788. /*
  2789. * 80: //签证
  2790. */
  2791. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2792. /*
  2793. *81: //邀请/公务活动
  2794. */
  2795. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2796. /*
  2797. * 82: //团组客户保险
  2798. */
  2799. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2800. /*
  2801. * Lable = 85 机票预订
  2802. */
  2803. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2804. /*
  2805. * 85 机票预定
  2806. */
  2807. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2808. /*
  2809. * 98 其他款项
  2810. */
  2811. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2812. /*
  2813. * 285:收款退还
  2814. */
  2815. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2816. /*
  2817. * 1015: //超支费用
  2818. */
  2819. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  2820. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  2821. /*
  2822. * 币种信息
  2823. */
  2824. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  2825. /*
  2826. * 车/导游地接 费用类型
  2827. */
  2828. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  2829. /*
  2830. * 车/导游地接 费用类型
  2831. */
  2832. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  2833. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  2834. /*
  2835. * 用户信息
  2836. */
  2837. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  2838. /*
  2839. * 费用模块
  2840. */
  2841. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  2842. string priceModule = string.Empty;
  2843. if (sdPriceName != null)
  2844. {
  2845. priceModule = sdPriceName.Name;
  2846. }
  2847. /*
  2848. * 成本信息
  2849. */
  2850. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  2851. decimal _groupRate = 0.0000M;
  2852. string _groupCurrencyCode = "-";
  2853. if (groupCost != null)
  2854. {
  2855. _groupRate = groupCost.Rate;
  2856. if (int.TryParse(groupCost.Currency, out int _currency))
  2857. {
  2858. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  2859. }
  2860. else _groupCurrencyCode = groupCost.Currency;
  2861. }
  2862. string costContentSql = $"Select * From Grp_GroupCost";
  2863. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  2864. //处理日期为空的天数
  2865. for (int i = 0; i < groupCostDetails.Count; i++)
  2866. if (i != 0)
  2867. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  2868. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  2869. /*
  2870. * 处理详情数据
  2871. */
  2872. foreach (var entity in entityList)
  2873. {
  2874. var _detail = new Grp_CreditCardPaymentDetailView();
  2875. _detail.Id = entity.Id;
  2876. _detail.PriceName = priceModule;
  2877. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  2878. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2879. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  2880. //处理金额
  2881. if (entity.CTable == 1015)
  2882. {
  2883. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  2884. if (czInfo != null)
  2885. {
  2886. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  2887. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  2888. }
  2889. }
  2890. /*
  2891. * 应付款金额
  2892. */
  2893. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  2894. string PaymentCurrency_WaitPay = "Unknown";
  2895. string hotelCurrncyCode = "Unknown";
  2896. string hotelCurrncyName = "Unknown";
  2897. if (sdPaymentCurrency_WaitPay != null)
  2898. {
  2899. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  2900. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  2901. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  2902. if (hotelCurrncyCode.Equals("CNY"))
  2903. {
  2904. entity.DayRate = 1.0000M;
  2905. }
  2906. }
  2907. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2908. /*
  2909. * 此次付款金额
  2910. */
  2911. decimal CurrPayStr = 0.00M,
  2912. OriginalCurrPay = 0.00M;
  2913. if (entity.PayPercentage == 0)
  2914. {
  2915. if (entity.PayThenMoney != 0)
  2916. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  2917. }
  2918. else
  2919. {
  2920. if (entity.PayMoney != 0)
  2921. {
  2922. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  2923. }
  2924. }
  2925. //if (_dto.Label == 79)
  2926. //{
  2927. // string original = string.Empty;
  2928. // if (hotelCurrncyCode.Equals("CNY"))
  2929. // {
  2930. // OriginalCurrPay = CurrPayStr;
  2931. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2932. // }
  2933. // else
  2934. // {
  2935. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2936. // //760 EUR(7600.00 CNY)
  2937. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2938. // }
  2939. //}
  2940. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2941. string original = string.Empty;
  2942. if (hotelCurrncyCode.Equals("CNY"))
  2943. {
  2944. OriginalCurrPay = CurrPayStr;
  2945. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  2946. }
  2947. else
  2948. {
  2949. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  2950. //760 EUR(7600.00 CNY)
  2951. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  2952. }
  2953. /*
  2954. * 剩余尾款
  2955. */
  2956. decimal BalanceStr = 0;
  2957. if (CurrPayStr != 0)
  2958. {
  2959. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  2960. BalanceStr = 0;
  2961. else
  2962. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  2963. }
  2964. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  2965. /*
  2966. * Bus名称
  2967. */
  2968. _detail.BusName = "待增加";
  2969. /*
  2970. *费用所属
  2971. */
  2972. switch (entity.CTable)
  2973. {
  2974. case 76://酒店预订
  2975. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2976. if (hotelReservations != null)
  2977. {
  2978. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  2979. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  2980. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  2981. string roomFeeStr = "", roomFeestr1 = "";
  2982. //是否比较房型价格
  2983. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  2984. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  2985. roomFeeStr += $"<br/>";
  2986. var roomTotal = 0.00M;
  2987. if (hotelReservations.SingleRoomPrice > 0)
  2988. {
  2989. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  2990. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  2991. //__isSingle = true;
  2992. roomTotal += fee;
  2993. }
  2994. if (hotelReservations.DoubleRoomPrice > 0)
  2995. {
  2996. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  2997. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  2998. // __isDouble = true;
  2999. roomTotal += fee;
  3000. }
  3001. if (hotelReservations.SuiteRoomPrice > 0)
  3002. {
  3003. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  3004. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3005. //__isSuite = true;
  3006. roomTotal += fee;
  3007. }
  3008. if (hotelReservations.OtherRoomPrice > 0)
  3009. {
  3010. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  3011. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  3012. //__isOther = true;
  3013. roomTotal += fee;
  3014. }
  3015. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  3016. else roomFeeStr += " 0.00 * 0";
  3017. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  3018. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  3019. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  3020. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  3021. /*
  3022. * 费用类型
  3023. * 1:房费
  3024. * 2:早餐
  3025. * 3:地税
  3026. * 4:城市税
  3027. * </summary>
  3028. */
  3029. //地税
  3030. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  3031. if (governmentRentData != null)
  3032. {
  3033. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  3034. governmentRentFee = governmentRentData.Price;
  3035. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  3036. if (governmentRentCurrData != null)
  3037. {
  3038. governmentRentCode = governmentRentCurrData.Name;
  3039. governmentRentName = $"({governmentRentCurrData.Remark})";
  3040. }
  3041. }
  3042. //城市税
  3043. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  3044. if (cityTaxData != null)
  3045. {
  3046. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  3047. cityTaxFee = cityTaxData.Price;
  3048. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  3049. if (cityTaxCurrData != null)
  3050. {
  3051. cityTaxCode = cityTaxCurrData.Name;
  3052. cityTaxName = $"({cityTaxCurrData.Remark})";
  3053. }
  3054. }
  3055. //酒店早餐
  3056. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  3057. if (breakfastData != null)
  3058. {
  3059. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  3060. breakfastFee = breakfastData.Price;
  3061. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  3062. if (breakfastCurrData != null)
  3063. {
  3064. breakfastCode = breakfastCurrData.Name;
  3065. breakfastName = $"({breakfastCurrData.Remark})";
  3066. }
  3067. }
  3068. //房间费用
  3069. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  3070. if (roomData != null)
  3071. {
  3072. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  3073. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  3074. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  3075. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  3076. roomFee = roomData.Price;
  3077. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  3078. if (roomCurrData != null)
  3079. {
  3080. roomCode = roomCurrData.Name;
  3081. roomName = $"({roomCurrData.Remark})";
  3082. }
  3083. }
  3084. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  3085. string hotelCostStr = "";
  3086. decimal hotelCsotTotal = 0.00M;
  3087. if (groupCost != null)
  3088. {
  3089. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  3090. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  3091. }
  3092. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  3093. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  3094. string hotelCost_day = "";
  3095. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  3096. foreach (var item in hotelCostDetails1)
  3097. {
  3098. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  3099. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  3100. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  3101. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  3102. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  3103. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  3104. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  3105. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  3106. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  3107. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  3108. hotelCost_day += @$"<br/>";
  3109. }
  3110. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  3111. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  3112. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  3113. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  3114. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  3115. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  3116. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  3117. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  3118. $"房间说明: {hotelReservations.Remark} <br/>" +
  3119. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  3120. $"{hotelBreakfastStr}" +
  3121. $"{hotelGovernmentRentStr}" +
  3122. $"{hotelCityTaxStr}";
  3123. _detail.PriceNameContent = hotelReservations.HotelName;
  3124. }
  3125. break;
  3126. case 79://车/导游地接
  3127. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3128. if (touristGuideGroundReservations != null)
  3129. {
  3130. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  3131. {
  3132. _detail.BusName = touristGuideGroundReservations.BusName;
  3133. }
  3134. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  3135. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  3136. //if (isInt)
  3137. //{
  3138. // var cityInfo = cityData.Find(it => it.Id == cityId);
  3139. // if (cityInfo != null)
  3140. // {
  3141. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  3142. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  3143. // if (carFeeItem != null)
  3144. // {
  3145. // nameContent += $@"({carFeeItem.Name})";
  3146. // }
  3147. // _detail.PriceNameContent = nameContent;
  3148. // }
  3149. //}
  3150. //else
  3151. //{
  3152. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  3153. //}
  3154. var touristGuideGroundReservationsContents =
  3155. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  3156. var opContent_sb = new StringBuilder();
  3157. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  3158. opContent_sb.AppendLine(contetTitle);
  3159. foreach (var item in touristGuideGroundReservationsContents)
  3160. {
  3161. string typeName = "Unknown";
  3162. string carCurrencyCode = "Unknown";
  3163. string carCurrencyName = "Unknown";
  3164. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  3165. if (carTypeData != null) typeName = carTypeData.Name;
  3166. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  3167. if (currencyData != null)
  3168. {
  3169. carCurrencyCode = currencyData.Name;
  3170. carCurrencyName = currencyData.Remark;
  3171. }
  3172. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  3173. bool IsCurrencyAgreement = false;
  3174. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  3175. string opCostStr = string.Empty;
  3176. decimal opCostTypePrice = 0.00M;
  3177. #region 处理成本各项费用
  3178. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  3179. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  3180. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  3181. costOPFeeCNY = 0.00M, //团组成本 op费用
  3182. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  3183. if (opCost.Count > 0)
  3184. {
  3185. switch (item.SId)
  3186. {
  3187. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  3188. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  3189. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  3190. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  3191. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  3192. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  3193. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  3194. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  3195. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  3196. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  3197. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  3198. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  3199. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  3200. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  3201. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  3202. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  3203. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  3204. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  3205. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  3206. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  3207. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  3208. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  3209. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  3210. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  3211. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  3212. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  3213. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  3214. }
  3215. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  3216. costOPFeeCNY = opCostTypePrice * _groupRate;
  3217. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  3218. }
  3219. #endregion
  3220. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  3221. aduitOPFeeCNY = item.Price * entity.DayRate;
  3222. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  3223. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  3224. $"{opTypeStr} {opCostStr}<br/>" +
  3225. $"明细:{item.PriceContent ?? "-"}<br/>" +
  3226. $"备注:{item.Remark ?? "-"}<br/><br/>";
  3227. if (entity.IsAuditGM != 3) //状态 != 自动审核
  3228. {
  3229. if (IsCurrencyAgreement)
  3230. {
  3231. if (item.Price > opCostTypePrice)
  3232. {
  3233. opContent_sb.Append("<span style='color:red;'>");
  3234. opContent_sb.Append(opContent);
  3235. opContent_sb.Append("</span>");
  3236. opContent_sb.AppendLine();
  3237. }
  3238. else
  3239. {
  3240. opContent_sb.Append(opContent);
  3241. opContent_sb.AppendLine();
  3242. }
  3243. }
  3244. else
  3245. {
  3246. //验证是否超成本 按付款比例计算
  3247. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  3248. {
  3249. opContent_sb.Append("<span style='color:red;'>");
  3250. opContent_sb.Append(opContent);
  3251. opContent_sb.Append("</span>");
  3252. opContent_sb.AppendLine();
  3253. }
  3254. else
  3255. {
  3256. opContent_sb.Append(opContent);
  3257. opContent_sb.AppendLine();
  3258. }
  3259. }
  3260. }
  3261. else
  3262. {
  3263. opContent_sb.Append(opContent);
  3264. opContent_sb.AppendLine();
  3265. }
  3266. }
  3267. _detail.PriceMsgContent = opContent_sb.ToString();
  3268. }
  3269. break;
  3270. case 80: //签证
  3271. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  3272. if (visaInfo != null)
  3273. {
  3274. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  3275. _detail.PriceNameContent = visaInfo.VisaDescription;
  3276. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  3277. }
  3278. break;
  3279. case 81: //邀请/公务活动
  3280. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  3281. if (_ioa != null)
  3282. {
  3283. string inviteCurrName = "Unknown", //邀请费用币种 Name
  3284. inviteCurrCode = "Unknown", //邀请费用币种 Code
  3285. sendCurrName = "Unknown", //快递费用币种 Name
  3286. sendCurrCode = "Unknown", //快递费用币种 Code
  3287. eventsCurrName = "Unknown", //公务活动费币种 Name
  3288. eventsCurrCode = "Unknown", //公务活动费币种 Code
  3289. translateCurrName = "Unknown", //公务翻译费 Name
  3290. translateCurrCode = "Unknown"; //公务翻译费 Code
  3291. #region 处理费用币种
  3292. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  3293. if (inviteCurrData != null)
  3294. {
  3295. inviteCurrName = inviteCurrData.Remark;
  3296. inviteCurrCode = inviteCurrData.Name;
  3297. }
  3298. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  3299. if (sendCurrData != null)
  3300. {
  3301. sendCurrName = sendCurrData.Remark;
  3302. sendCurrCode = sendCurrData.Name;
  3303. }
  3304. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  3305. if (eventsCurrData != null)
  3306. {
  3307. eventsCurrName = eventsCurrData.Remark;
  3308. eventsCurrCode = eventsCurrData.Name;
  3309. }
  3310. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  3311. if (translateCurrData != null)
  3312. {
  3313. translateCurrName = translateCurrData.Remark;
  3314. translateCurrCode = translateCurrData.Name;
  3315. }
  3316. #endregion
  3317. _detail.PriceNameContent = _ioa.InviterArea;
  3318. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  3319. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  3320. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  3321. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  3322. $@"备注:" + _ioa.Remark + "<br/>";
  3323. }
  3324. break;
  3325. case 82: //团组客户保险
  3326. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  3327. if (customers != null)
  3328. {
  3329. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  3330. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  3331. }
  3332. break;
  3333. case 85: //机票预订
  3334. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  3335. if (jpRes != null)
  3336. {
  3337. string FlightsDescription = jpRes.FlightsDescription;
  3338. string PriceDescription = jpRes.PriceDescription;
  3339. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  3340. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  3341. }
  3342. break;
  3343. case 98://其他款项
  3344. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  3345. if (gdpRes != null)
  3346. {
  3347. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  3348. _detail.PriceNameContent = gdpRes.PriceName;
  3349. }
  3350. break;
  3351. case 285://收款退还
  3352. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  3353. if (refundAndOtherMoney != null)
  3354. {
  3355. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  3356. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  3357. }
  3358. break;
  3359. case 751://酒店早餐
  3360. break;
  3361. case 1015://超支费用
  3362. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  3363. if (groupExtraCost != null)
  3364. {
  3365. _detail.PriceNameContent = groupExtraCost.PriceName;
  3366. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  3367. }
  3368. break;
  3369. default:
  3370. break;
  3371. }
  3372. /*
  3373. * 申请人
  3374. */
  3375. string operatorName = " - ";
  3376. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  3377. if (_opUser != null)
  3378. {
  3379. operatorName = _opUser.CnName;
  3380. }
  3381. _detail.OperatorName = operatorName;
  3382. /*
  3383. * 审核人
  3384. */
  3385. string auditOperatorName = "Unknown";
  3386. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  3387. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  3388. else
  3389. {
  3390. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  3391. if (_adUser != null)
  3392. {
  3393. auditOperatorName = _adUser.CnName;
  3394. }
  3395. }
  3396. _detail.AuditOperatorName = auditOperatorName;
  3397. /*
  3398. * 超预算比例
  3399. */
  3400. string overBudgetStr = "";
  3401. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  3402. else if (entity.ExceedBudget == 0)
  3403. {
  3404. if (entity.CTable == 76 || entity.CTable == 79)
  3405. {
  3406. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  3407. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  3408. }
  3409. else
  3410. {
  3411. overBudgetStr = "未超预算";
  3412. }
  3413. }
  3414. else overBudgetStr = entity.ExceedBudget.ToString("P");
  3415. _detail.OverBudget = overBudgetStr;
  3416. decimal auditFee = 0.00M; //已审核金额 人名币
  3417. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  3418. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  3419. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  3420. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  3421. {
  3422. auditedFeeOriginal = entity.PayMoney;
  3423. auditFee = CurrPayStr;
  3424. }
  3425. else if (entity.IsAuditGM == 0)
  3426. {
  3427. unAuditFeeCNY = CurrPayStr;
  3428. unAuditFeeOriginal = OriginalCurrPay;
  3429. OriginalCurrPay = 0.00M;
  3430. }
  3431. /*
  3432. * 费用总计
  3433. */
  3434. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  3435. {
  3436. CurrencyId = entity.PaymentCurrency,
  3437. CurrencyName = PaymentCurrency_WaitPay,
  3438. AmountPayable = entity.PayMoney,
  3439. ThisPayment = OriginalCurrPay,
  3440. BalancePayment = BalanceStr,
  3441. AuditedFunds = auditFee,
  3442. AuditedFundsOriginal = auditedFeeOriginal,
  3443. UnAuditFundsCNY = unAuditFeeCNY,
  3444. UnAuditFundsOriginal = unAuditFeeOriginal
  3445. });
  3446. _detail.IsAuditGM = entity.IsAuditGM;
  3447. detailList.Add(_detail);
  3448. }
  3449. #endregion
  3450. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  3451. /*
  3452. * 下方描述处理
  3453. */
  3454. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  3455. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  3456. if (ccpCurrencyPrice != null)
  3457. {
  3458. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  3459. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  3460. }
  3461. else
  3462. {
  3463. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  3464. }
  3465. string amountPayableStr = string.Format(@"应付款总金额: ");
  3466. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  3467. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  3468. string auditedFundsStr = string.Format(@"已审费用总额: ");
  3469. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  3470. foreach (var item in nonDuplicat)
  3471. {
  3472. var currencyName = item.CurrencyName;
  3473. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  3474. if (strs.Count > 0)
  3475. {
  3476. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  3477. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  3478. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  3479. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  3480. //单独处理此次付款金额
  3481. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3482. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  3483. //单独处理已审核费用
  3484. //if (item.CurrencyId == 836) //人民币
  3485. //{
  3486. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  3487. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  3488. //}
  3489. //else
  3490. //{
  3491. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  3492. //}
  3493. if (currencyName.Equals("CNY"))
  3494. {
  3495. //已审核费用
  3496. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  3497. //未审核费用
  3498. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  3499. }
  3500. else
  3501. {
  3502. //已审核费用
  3503. 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"));
  3504. //未审核费用
  3505. 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"));
  3506. }
  3507. }
  3508. }
  3509. _view.TotalStr1 = amountPayableStr[..^1];
  3510. _view.TotalStr2 = thisPaymentStr[..^1];
  3511. _view.TotalStr3 = balancePaymentStr[..^1];
  3512. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  3513. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  3514. var _view1 = new
  3515. {
  3516. PageFuncAuth = pageFunAuthView,
  3517. Data = _view
  3518. };
  3519. return Ok(JsonView(_view1));
  3520. }
  3521. catch (Exception ex)
  3522. {
  3523. return Ok(JsonView(false, ex.Message));
  3524. }
  3525. }
  3526. /// <summary>
  3527. /// 费用审核
  3528. /// 修改团组费用审核状态
  3529. /// </summary>
  3530. /// <param name="_dto">参数Json字符串</param>
  3531. /// <returns></returns>
  3532. [HttpPost]
  3533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3534. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  3535. {
  3536. #region 参数验证
  3537. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3538. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3539. #endregion
  3540. #region 页面操作权限验证
  3541. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  3542. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3543. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  3544. #endregion
  3545. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  3546. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  3547. DateTime dtNow = DateTime.Now;
  3548. _groupRepository.BeginTran();
  3549. int rst = 0;
  3550. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  3551. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  3552. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3553. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  3554. List<dynamic> msgDatas = new List<dynamic>();
  3555. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  3556. foreach (var item in idList)
  3557. {
  3558. int CreditId = int.Parse(item);
  3559. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  3560. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  3561. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  3562. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  3563. .Where(s => s.Id == CreditId)
  3564. .ExecuteCommandAsync();
  3565. if (result < 1)
  3566. {
  3567. rst = -1;
  3568. _groupRepository.RollbackTran();
  3569. return Ok(JsonView(false, "操作失败并回滚!"));
  3570. }
  3571. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  3572. if (creditData != null)
  3573. {
  3574. #region 应用通知配置
  3575. try
  3576. {
  3577. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  3578. }
  3579. catch (Exception ex)
  3580. {
  3581. }
  3582. #endregion
  3583. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  3584. string groupNameStr = string.Empty;
  3585. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  3586. if (groupData != null) groupNameStr = groupData.TeamName;
  3587. string creditTypeStr = string.Empty;
  3588. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  3589. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  3590. string creditCurrency = string.Empty;
  3591. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  3592. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  3593. if (creditCurrency.Equals("CNY"))
  3594. {
  3595. creditData.DayRate = 1.0000M;
  3596. }
  3597. if (creditData.PayPercentage == 0.00M)
  3598. {
  3599. creditData.PayPercentage = 100M;
  3600. }
  3601. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  3602. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  3603. string msgContent = "";
  3604. if (creditCurrency.Equals("CNY"))
  3605. {
  3606. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  3607. }
  3608. else
  3609. {
  3610. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  3611. }
  3612. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  3613. }
  3614. }
  3615. if (rst == 0)
  3616. {
  3617. _groupRepository.CommitTran();
  3618. foreach (var item in msgDatas)
  3619. {
  3620. //发送消息
  3621. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  3622. }
  3623. #region 应用推送
  3624. try
  3625. {
  3626. foreach (var ccpId in dic_ccp_user.Keys)
  3627. {
  3628. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  3629. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  3630. }
  3631. }
  3632. catch (Exception)
  3633. {
  3634. }
  3635. #endregion
  3636. return Ok(JsonView(true, "操作成功!"));
  3637. }
  3638. return Ok(JsonView(false, "操作失败!"));
  3639. }
  3640. #endregion
  3641. #region 机票费用录入
  3642. /// <summary>
  3643. /// 机票录入当前登录人可操作团组
  3644. /// </summary>
  3645. /// <param name="dto"></param>
  3646. /// <returns></returns>
  3647. [HttpPost]
  3648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3649. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  3650. {
  3651. try
  3652. {
  3653. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  3654. if (groupData.Code != 0)
  3655. {
  3656. return Ok(JsonView(false, groupData.Msg));
  3657. }
  3658. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3659. }
  3660. catch (Exception ex)
  3661. {
  3662. return Ok(JsonView(false, "程序错误!"));
  3663. throw;
  3664. }
  3665. }
  3666. /// <summary>
  3667. /// 机票费用录入列表
  3668. /// </summary>
  3669. /// <param name="dto"></param>
  3670. /// <returns></returns>
  3671. [HttpPost]
  3672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3673. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  3674. {
  3675. try
  3676. {
  3677. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  3678. if (groupData.Code != 0)
  3679. {
  3680. return Ok(JsonView(false, groupData.Msg));
  3681. }
  3682. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3683. }
  3684. catch (Exception ex)
  3685. {
  3686. return Ok(JsonView(false, ex.Message));
  3687. throw;
  3688. }
  3689. }
  3690. /// <summary>
  3691. /// 根据id查询费用录入信息
  3692. /// </summary>
  3693. /// <param name="dto"></param>
  3694. /// <returns></returns>
  3695. [HttpPost]
  3696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3697. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  3698. {
  3699. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  3700. if (groupData.Code != 0)
  3701. {
  3702. return Ok(JsonView(false, groupData.Msg));
  3703. }
  3704. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3705. }
  3706. /// <summary>
  3707. /// 机票费用录入操作(Status:1.新增,2.修改)
  3708. /// </summary>
  3709. /// <param name="dto"></param>
  3710. /// <returns></returns>
  3711. [HttpPost]
  3712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3713. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  3714. {
  3715. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  3716. if (groupData.Code != 0)
  3717. {
  3718. return Ok(JsonView(false, groupData.Msg));
  3719. }
  3720. #region 应用推送
  3721. try
  3722. {
  3723. var diId = dto.AirTicketResOpData.DiId;
  3724. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3725. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3726. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3727. //自动审核
  3728. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  3729. (bool status,string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  3730. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  3731. $"GroupId:{diId};airId:{dataId};",
  3732. status,
  3733. auditMsg);
  3734. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3735. //2024-10-21 新增LZ UID
  3736. var userIds = new List<int>() { 21 };
  3737. string title = $"系统通知";
  3738. string content = "";
  3739. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3740. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3741. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3742. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3743. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3744. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  3745. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3746. }
  3747. catch (Exception ex)
  3748. {
  3749. }
  3750. #endregion
  3751. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3752. }
  3753. /// <summary>
  3754. /// 机票费用自动审核 AI识别方式
  3755. /// </summary>
  3756. /// <returns></returns>
  3757. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  3758. {
  3759. var ecoTypeIds = new List<int>() {
  3760. 459, //超经舱
  3761. 460, //经济舱
  3762. 1430, //公务舱(实际经济舱)
  3763. 1432, //头等舱(实际经济舱)
  3764. };
  3765. var bizTypeIds = new List<int>() {
  3766. 457, //头等舱
  3767. 458, //公务舱
  3768. 1431, //头等舱(实际公务舱)
  3769. };
  3770. var auditFeeTypeIds = new List<int>() {};
  3771. auditFeeTypeIds.AddRange(ecoTypeIds);
  3772. auditFeeTypeIds.AddRange(bizTypeIds);
  3773. int currModule = 85;
  3774. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  3775. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  3776. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  3777. .Select((x, y) => new
  3778. {
  3779. x.Id,
  3780. CcpId = y.Id,
  3781. x.FlightsDate,
  3782. x.PrePrice,
  3783. x.CType,
  3784. x.ClientNum,
  3785. x.DIId
  3786. })
  3787. .FirstAsync();
  3788. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  3789. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  3790. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  3791. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  3792. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  3793. var groupCostContents = await _sqlSugar
  3794. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  3795. .Where(x => x.IsDel == 0 && x.Diid == diId)
  3796. .ToListAsync();
  3797. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  3798. //处理 成本详细信息日期为空 填装费用信息
  3799. var airFeeLabel = new StringBuilder();
  3800. airFeeLabel.AppendLine("费用成本:");
  3801. for (int i = 0; i < groupCostContents.Count; i++)
  3802. {
  3803. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  3804. {
  3805. int index = i - 1;
  3806. if (index >= 0)
  3807. {
  3808. groupCostContents[i].Date = groupCostContents[index].Date;
  3809. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3810. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3811. }
  3812. }
  3813. else
  3814. {
  3815. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  3816. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  3817. }
  3818. var item = groupCostContents[i];
  3819. airFeeLabel.AppendLine($"{item.Date}");
  3820. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  3821. }
  3822. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  3823. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  3824. //访问Kimi AI 返回价格结果
  3825. var msgs = new List<SeedMessages>()
  3826. {
  3827. new ()
  3828. {
  3829. Role = KimiRole.user,
  3830. Content = airFeeLabel.ToString()
  3831. }
  3832. };
  3833. KiMiApiClient client = new KiMiApiClient();
  3834. var kimiApiResult = await client.SeedMessage(msgs);
  3835. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  3836. string clients = kimiApiResult_JObject["content"].ToString();
  3837. decimal ecoPri_kimiAI = 0.00M,
  3838. bizPri_kimiAI = 0.00M;
  3839. //单个价格: 经济舱价格
  3840. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  3841. //价格文本包含/:/前经济舱价格 /后公务舱价格
  3842. if (clients.Contains('/'))
  3843. {
  3844. var priArray = clients.Split('/');
  3845. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  3846. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  3847. }
  3848. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  3849. var isAutoAudit = false;
  3850. //价格验证处理
  3851. //经济舱
  3852. if (ecoTypeIds.Contains(airInfo.CType))
  3853. {
  3854. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  3855. }
  3856. //公务舱
  3857. else if (bizTypeIds.Contains(airInfo.CType))
  3858. {
  3859. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  3860. }
  3861. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  3862. //是否执行自动审核
  3863. if (isAutoAudit)
  3864. {
  3865. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3866. .SetColumns(x => x.IsAuditGM == 3)
  3867. .SetColumns(x => x.AuditGMOperate == 4)
  3868. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  3869. .Where(x => x.Id == airInfo.CcpId)
  3870. .ExecuteCommandAsync();
  3871. if (auditStatus > 0 ) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  3872. }
  3873. return (false, "当前费用超过成本费用,不可自动审核!");
  3874. }
  3875. /// <summary>
  3876. /// 机票费用录入
  3877. /// 自动审核测试 - AI 识别
  3878. /// </summary>
  3879. /// <param name="groupId"></param>
  3880. /// <param name="Id"></param>
  3881. /// <returns></returns>
  3882. [HttpPost]
  3883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3884. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  3885. {
  3886. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  3887. return Ok(JsonView(status, msg));
  3888. }
  3889. /// <summary>
  3890. /// 根据舱位类型查询接团客户名单信息
  3891. /// </summary>
  3892. /// <param name="dto"></param>
  3893. /// <returns></returns>
  3894. [HttpPost]
  3895. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3896. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  3897. {
  3898. try
  3899. {
  3900. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  3901. if (crm_Groups.Count != 0)
  3902. {
  3903. List<dynamic> Customer = new List<dynamic>();
  3904. foreach (var item in crm_Groups)
  3905. {
  3906. var data = new
  3907. {
  3908. Id = item.Id,
  3909. Pinyin = item.Pinyin,
  3910. Name = item.LastName + item.FirstName
  3911. };
  3912. Customer.Add(data);
  3913. }
  3914. return Ok(JsonView(true, "查询成功!", Customer));
  3915. }
  3916. return Ok(JsonView(true, "暂无数据", crm_Groups));
  3917. }
  3918. catch (Exception ex)
  3919. {
  3920. return Ok(JsonView(false, "程序错误!"));
  3921. throw;
  3922. }
  3923. }
  3924. /// <summary>
  3925. /// 根据团号获取客户信息
  3926. /// </summary>
  3927. /// <param name="dto"></param>
  3928. /// <returns></returns>
  3929. [HttpPost]
  3930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3931. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  3932. {
  3933. var jw = JsonView(false);
  3934. if (dto.DIID < 1)
  3935. {
  3936. jw.Msg += "请输入正确的diid";
  3937. return Ok(jw);
  3938. }
  3939. var arr = getSimplClientList(dto.DIID);
  3940. jw = JsonView(true, "获取成功!", arr);
  3941. return Ok(jw);
  3942. }
  3943. private List<SimplClientInfo> getSimplClientList(int diId)
  3944. {
  3945. 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);
  3946. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  3947. foreach (var item in arr)
  3948. {
  3949. EncryptionProcessor.DecryptProperties(item);
  3950. }
  3951. return arr;
  3952. }
  3953. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  3954. {
  3955. string result = origin;
  3956. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3957. {
  3958. string[] temparr = origin.Split(',');
  3959. string fistrStr = temparr[0];
  3960. int count = temparr.Count();
  3961. int tempId;
  3962. bool success = int.TryParse(fistrStr, out tempId);
  3963. if (success)
  3964. {
  3965. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3966. if (tempInfo != null)
  3967. {
  3968. if (count > 1)
  3969. {
  3970. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  3971. }
  3972. else
  3973. {
  3974. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  3975. }
  3976. }
  3977. }
  3978. }
  3979. return result;
  3980. }
  3981. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  3982. {
  3983. string result = origin;
  3984. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  3985. {
  3986. string[] temparr = origin.Split(',');
  3987. result = "";
  3988. foreach (var item in temparr)
  3989. {
  3990. int tempId;
  3991. bool success = int.TryParse(item, out tempId);
  3992. if (success)
  3993. {
  3994. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  3995. if (tempInfo != null)
  3996. {
  3997. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  3998. }
  3999. }
  4000. }
  4001. }
  4002. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  4003. return result;
  4004. }
  4005. /// <summary>
  4006. /// 机票费用录入,删除
  4007. /// </summary>
  4008. /// <param name="dto"></param>
  4009. /// <returns></returns>
  4010. [HttpPost]
  4011. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4012. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  4013. {
  4014. try
  4015. {
  4016. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4017. if (res)
  4018. {
  4019. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  4020. {
  4021. IsDel = 1,
  4022. DeleteUserId = dto.DeleteUserId,
  4023. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4024. }).ExecuteCommandAsync();
  4025. return Ok(JsonView(true, "删除成功!"));
  4026. }
  4027. return Ok(JsonView(false, "删除失败!"));
  4028. }
  4029. catch (Exception ex)
  4030. {
  4031. return Ok(JsonView(false, "程序错误!"));
  4032. throw;
  4033. }
  4034. }
  4035. /// <summary>
  4036. /// 导出机票录入报表
  4037. /// </summary>
  4038. /// <param name="dto"></param>
  4039. /// <returns></returns>
  4040. [HttpPost]
  4041. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4042. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  4043. {
  4044. try
  4045. {
  4046. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  4047. if (groupData.Code != 0)
  4048. {
  4049. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4050. }
  4051. else
  4052. {
  4053. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  4054. if (AirTicketReservations.Count != 0)
  4055. {
  4056. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  4057. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  4058. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  4059. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  4060. WorkbookDesigner designer = new WorkbookDesigner();
  4061. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  4062. decimal countCost = 0;
  4063. foreach (var item in AirTicketReservations)
  4064. {
  4065. #region 处理客人姓名
  4066. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  4067. item.ClientName = clientNames;
  4068. #endregion
  4069. if (item.BankType == "其他")
  4070. {
  4071. item.BankNo = "--";
  4072. }
  4073. else
  4074. {
  4075. if (!string.IsNullOrEmpty(item.BankType))
  4076. {
  4077. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  4078. }
  4079. }
  4080. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  4081. item.Price = System.Decimal.Round(item.Price, 2);
  4082. countCost += Convert.ToDecimal(item.Price);
  4083. }
  4084. designer.SetDataSource("Export", AirTicketReservations);
  4085. designer.SetDataSource("ExportDiCode", diCode);
  4086. designer.SetDataSource("ExportDiName", diName);
  4087. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  4088. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  4089. designer.Process();
  4090. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  4091. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  4092. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  4093. return Ok(JsonView(true, "成功", url = rst));
  4094. }
  4095. else
  4096. {
  4097. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  4098. }
  4099. }
  4100. }
  4101. catch (Exception ex)
  4102. {
  4103. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  4104. throw;
  4105. }
  4106. }
  4107. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4108. /// <summary>
  4109. /// 行程单导出
  4110. /// </summary>
  4111. /// <param name="dto"></param>
  4112. /// <returns></returns>
  4113. [HttpPost]
  4114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4115. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  4116. {
  4117. try
  4118. {
  4119. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  4120. if (groupData.Code != 0)
  4121. {
  4122. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  4123. }
  4124. else
  4125. {
  4126. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  4127. if (dto.Language == "CN")
  4128. {
  4129. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  4130. DocumentBuilder builder = new DocumentBuilder(doc);
  4131. int tableIndex = 0;//表格索引
  4132. //得到文档中的第一个表格
  4133. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4134. foreach (var item in _AirTicketReservations)
  4135. {
  4136. #region 处理固定数据
  4137. string[] FlightsCode = item.FlightsCode.Split('/');
  4138. if (FlightsCode.Length != 0)
  4139. {
  4140. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4141. if (_AirCompany != null)
  4142. {
  4143. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4144. }
  4145. else
  4146. {
  4147. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4148. }
  4149. }
  4150. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4151. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4152. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4153. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4154. string name = "";
  4155. foreach (string clientName in nameArray)
  4156. {
  4157. if (!name.Contains(clientName))
  4158. {
  4159. name += clientName + ",";
  4160. }
  4161. }
  4162. if (!string.IsNullOrWhiteSpace(name))
  4163. {
  4164. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4165. }
  4166. else
  4167. {
  4168. table.Range.Bookmarks["ClientName"].Text = "--";
  4169. }
  4170. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4171. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4172. table.Range.Bookmarks["JointTicket"].Text = "--";
  4173. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4174. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4175. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4176. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4177. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4178. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4179. #endregion
  4180. #region 循环数据处理
  4181. List<AirInfo> airs = new List<AirInfo>();
  4182. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4183. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4184. for (int i = 0; i < FlightsCode.Length; i++)
  4185. {
  4186. AirInfo air = new AirInfo();
  4187. string[] tempstr = DayArray[i]
  4188. .Replace("\r\n", string.Empty)
  4189. .Replace("\\r\\n", string.Empty)
  4190. .TrimStart().TrimEnd()
  4191. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4192. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4193. string starCity = "";
  4194. if (star_Three != null)
  4195. {
  4196. starCity = star_Three.AirPort;
  4197. }
  4198. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4199. string EndCity = "";
  4200. if (End_Three != null)
  4201. {
  4202. EndCity = End_Three.AirPort;
  4203. }
  4204. air.Destination = starCity + "/" + EndCity;
  4205. air.Flight = FlightsCode[i];
  4206. air.SeatingClass = item.CTypeName;
  4207. string dateTime = tempstr[2];
  4208. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4209. air.FlightDate = DateTemp;
  4210. air.DepartureTime = tempstr[5];
  4211. air.LandingTime = tempstr[6];
  4212. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4213. air.TicketStatus = "--";
  4214. air.Luggage = "--";
  4215. air.DepartureTerminal = "--";
  4216. air.LandingTerminal = "--";
  4217. airs.Add(air);
  4218. }
  4219. int row = 13;
  4220. for (int i = 0; i < airs.Count; i++)
  4221. {
  4222. if (airs.Count > 2)
  4223. {
  4224. for (int j = 0; j < airs.Count - 2; j++)
  4225. {
  4226. var CopyRow = table.Rows[12].Clone(true);
  4227. table.Rows.Add(CopyRow);
  4228. }
  4229. }
  4230. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4231. int index = 0;
  4232. foreach (PropertyInfo property in properties)
  4233. {
  4234. string value = property.GetValue(airs[i]).ToString();
  4235. Cell ishcel0 = table.Rows[row].Cells[index];
  4236. Paragraph p = new Paragraph(doc);
  4237. string s = value;
  4238. p.AppendChild(new Run(doc, s));
  4239. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4240. ishcel0.AppendChild(p);
  4241. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4242. index++;
  4243. }
  4244. row++;
  4245. }
  4246. #endregion
  4247. Paragraph lastParagraph = new Paragraph(doc);
  4248. //第一个表格末尾加段落
  4249. table.ParentNode.InsertAfter(lastParagraph, table);
  4250. //复制第一个表格
  4251. Table cloneTable = (Table)table.Clone(true);
  4252. //在文档末尾段落后面加入复制的表格
  4253. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4254. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4255. {
  4256. int rownewsIndex = 13;
  4257. for (int i = 0; i < 2; i++)
  4258. {
  4259. var CopyRow = table.Rows[12].Clone(true);
  4260. table.Rows.RemoveAt(13);
  4261. table.Rows.Add(CopyRow);
  4262. rownewsIndex++;
  4263. }
  4264. }
  4265. else
  4266. {
  4267. table.Rows.RemoveAt(12);
  4268. }
  4269. cloneTable.Rows.RemoveAt(12);
  4270. }
  4271. if (_AirTicketReservations.Count != 0)
  4272. {
  4273. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4274. if (FlightsCode.Length != 0)
  4275. {
  4276. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4277. if (_AirCompany != null)
  4278. {
  4279. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  4280. }
  4281. else
  4282. {
  4283. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4284. }
  4285. }
  4286. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4287. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4288. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4289. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4290. string name = "";
  4291. foreach (string clientName in nameArray)
  4292. {
  4293. if (!name.Contains(clientName))
  4294. {
  4295. name += clientName + ",";
  4296. }
  4297. }
  4298. if (!string.IsNullOrWhiteSpace(name))
  4299. {
  4300. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  4301. }
  4302. else
  4303. {
  4304. table.Range.Bookmarks["ClientName"].Text = "--";
  4305. }
  4306. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4307. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4308. table.Range.Bookmarks["JointTicket"].Text = "--";
  4309. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4310. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4311. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4312. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4313. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4314. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4315. }
  4316. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4317. //保存合并后的文档
  4318. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  4319. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4320. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4321. return Ok(JsonView(true, "成功!", rst));
  4322. }
  4323. else
  4324. {
  4325. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  4326. DocumentBuilder builder = new DocumentBuilder(doc);
  4327. int tableIndex = 0;//表格索引
  4328. //得到文档中的第一个表格
  4329. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  4330. List<string> texts = new List<string>();
  4331. foreach (var item in _AirTicketReservations)
  4332. {
  4333. string[] FlightsCode = item.FlightsCode.Split('/');
  4334. if (FlightsCode.Length != 0)
  4335. {
  4336. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4337. if (_AirCompany != null)
  4338. {
  4339. if (!transDic.ContainsKey(_AirCompany.CnName))
  4340. {
  4341. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  4342. }
  4343. }
  4344. else
  4345. {
  4346. if (!transDic.ContainsKey("--"))
  4347. {
  4348. transDic.Add("--", "--");
  4349. }
  4350. }
  4351. }
  4352. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4353. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4354. string name = "";
  4355. foreach (string clientName in nameArray)
  4356. {
  4357. name += clientName + ",";
  4358. }
  4359. if (!texts.Contains(name))
  4360. {
  4361. texts.Add(name);
  4362. }
  4363. List<AirInfo> airs = new List<AirInfo>();
  4364. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4365. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4366. for (int i = 0; i < FlightsCode.Length; i++)
  4367. {
  4368. AirInfo air = new AirInfo();
  4369. string[] tempstr = DayArray[i]
  4370. .Replace("\r\n", string.Empty)
  4371. .Replace("\\r\\n", string.Empty)
  4372. .TrimStart().TrimEnd()
  4373. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4374. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4375. if (star_Three != null)
  4376. {
  4377. if (!transDic.ContainsKey(star_Three.AirPort))
  4378. {
  4379. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  4380. }
  4381. }
  4382. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4383. if (End_Three != null)
  4384. {
  4385. if (!transDic.ContainsKey(End_Three.AirPort))
  4386. {
  4387. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  4388. }
  4389. }
  4390. if (!texts.Contains(item.CTypeName))
  4391. {
  4392. texts.Add(item.CTypeName);
  4393. }
  4394. }
  4395. }
  4396. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  4397. if (transData.Count > 0)
  4398. {
  4399. foreach (TranslateResult item in transData)
  4400. {
  4401. if (!transDic.ContainsKey(item.Query))
  4402. {
  4403. transDic.Add(item.Query, item.Translation);
  4404. }
  4405. }
  4406. }
  4407. foreach (var item in _AirTicketReservations)
  4408. {
  4409. #region 处理固定数据
  4410. string[] FlightsCode = item.FlightsCode.Split('/');
  4411. if (FlightsCode.Length != 0)
  4412. {
  4413. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4414. if (_AirCompany != null)
  4415. {
  4416. string str = "--";
  4417. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4418. if (!string.IsNullOrEmpty(translateResult))
  4419. {
  4420. str = translateResult;
  4421. str = _airTicketResRep.Processing(str);
  4422. }
  4423. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4424. }
  4425. else
  4426. {
  4427. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4428. }
  4429. }
  4430. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4431. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4432. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4433. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4434. string names = "";
  4435. foreach (string clientName in nameArray)
  4436. {
  4437. names += clientName + ",";
  4438. }
  4439. if (!string.IsNullOrWhiteSpace(names))
  4440. {
  4441. string str = "--";
  4442. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4443. if (!string.IsNullOrEmpty(translateResult))
  4444. {
  4445. str = translateResult;
  4446. str = _airTicketResRep.Processing(str);
  4447. }
  4448. table.Range.Bookmarks["ClientName"].Text = str;
  4449. }
  4450. else
  4451. {
  4452. table.Range.Bookmarks["ClientName"].Text = "--";
  4453. }
  4454. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4455. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4456. table.Range.Bookmarks["JointTicket"].Text = "--";
  4457. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4458. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4459. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4460. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4461. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4462. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4463. #endregion
  4464. #region 循环数据处理
  4465. List<AirInfo> airs = new List<AirInfo>();
  4466. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  4467. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  4468. for (int i = 0; i < FlightsCode.Length; i++)
  4469. {
  4470. AirInfo air = new AirInfo();
  4471. string[] tempstr = DayArray[i]
  4472. .Replace("\r\n", string.Empty)
  4473. .Replace("\\r\\n", string.Empty)
  4474. .TrimStart().TrimEnd()
  4475. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  4476. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  4477. string starCity = "";
  4478. if (star_Three != null)
  4479. {
  4480. string str2 = "--";
  4481. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  4482. if (!string.IsNullOrEmpty(translateResult2))
  4483. {
  4484. str2 = translateResult2;
  4485. str2 = _airTicketResRep.Processing(str2);
  4486. }
  4487. starCity = str2;
  4488. }
  4489. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  4490. string EndCity = "";
  4491. if (End_Three != null)
  4492. {
  4493. string str1 = "--";
  4494. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  4495. if (!string.IsNullOrEmpty(translateResult1))
  4496. {
  4497. str1 = translateResult1;
  4498. str1 = _airTicketResRep.Processing(str1);
  4499. }
  4500. EndCity = str1;
  4501. }
  4502. air.Destination = starCity + "/" + EndCity;
  4503. air.Flight = FlightsCode[i];
  4504. string str = "--";
  4505. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  4506. if (!string.IsNullOrEmpty(translateResult))
  4507. {
  4508. str = translateResult;
  4509. str = _airTicketResRep.Processing(str);
  4510. }
  4511. air.SeatingClass = str;
  4512. string dateTime = tempstr[2];
  4513. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  4514. air.FlightDate = DateTemp;
  4515. air.DepartureTime = tempstr[5];
  4516. air.LandingTime = tempstr[6];
  4517. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  4518. air.TicketStatus = "--";
  4519. air.Luggage = "--";
  4520. air.DepartureTerminal = "--";
  4521. air.LandingTerminal = "--";
  4522. airs.Add(air);
  4523. }
  4524. int row = 13;
  4525. for (int i = 0; i < airs.Count; i++)
  4526. {
  4527. if (airs.Count > 2)
  4528. {
  4529. for (int j = 0; j < airs.Count - 2; j++)
  4530. {
  4531. var CopyRow = table.Rows[12].Clone(true);
  4532. table.Rows.Add(CopyRow);
  4533. }
  4534. }
  4535. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  4536. int index = 0;
  4537. foreach (PropertyInfo property in properties)
  4538. {
  4539. string value = property.GetValue(airs[i]).ToString();
  4540. Cell ishcel0 = table.Rows[row].Cells[index];
  4541. Paragraph p = new Paragraph(doc);
  4542. string s = value;
  4543. p.AppendChild(new Run(doc, s));
  4544. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  4545. ishcel0.AppendChild(p);
  4546. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  4547. //ishcel0.CellFormat.VerticalAlignment=
  4548. index++;
  4549. }
  4550. row++;
  4551. }
  4552. #endregion
  4553. Paragraph lastParagraph = new Paragraph(doc);
  4554. //第一个表格末尾加段落
  4555. table.ParentNode.InsertAfter(lastParagraph, table);
  4556. //复制第一个表格
  4557. Table cloneTable = (Table)table.Clone(true);
  4558. //在文档末尾段落后面加入复制的表格
  4559. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  4560. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  4561. {
  4562. int rownewsIndex = 13;
  4563. for (int i = 0; i < 2; i++)
  4564. {
  4565. var CopyRow = table.Rows[12].Clone(true);
  4566. table.Rows.RemoveAt(13);
  4567. table.Rows.Add(CopyRow);
  4568. rownewsIndex++;
  4569. }
  4570. }
  4571. else
  4572. {
  4573. table.Rows.RemoveAt(12);
  4574. }
  4575. cloneTable.Rows.RemoveAt(12);
  4576. }
  4577. if (_AirTicketReservations.Count != 0)
  4578. {
  4579. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  4580. if (FlightsCode.Length != 0)
  4581. {
  4582. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  4583. if (_AirCompany != null)
  4584. {
  4585. string str = "--";
  4586. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  4587. if (!string.IsNullOrEmpty(translateResult))
  4588. {
  4589. str = translateResult;
  4590. str = _airTicketResRep.Processing(str);
  4591. }
  4592. table.Range.Bookmarks["AirlineCompany"].Text = str;
  4593. }
  4594. else
  4595. {
  4596. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  4597. }
  4598. }
  4599. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  4600. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  4601. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  4602. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  4603. string names = "";
  4604. foreach (string clientName in nameArray)
  4605. {
  4606. names += clientName + ",";
  4607. }
  4608. if (!string.IsNullOrWhiteSpace(names))
  4609. {
  4610. string str = "--";
  4611. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  4612. if (!string.IsNullOrEmpty(translateResult))
  4613. {
  4614. str = translateResult;
  4615. str = _airTicketResRep.Processing(str);
  4616. }
  4617. table.Range.Bookmarks["ClientName"].Text = str;
  4618. }
  4619. else
  4620. {
  4621. table.Range.Bookmarks["ClientName"].Text = "--";
  4622. }
  4623. table.Range.Bookmarks["TicketNumber"].Text = "--";
  4624. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  4625. table.Range.Bookmarks["JointTicket"].Text = "--";
  4626. table.Range.Bookmarks["TimeIssue"].Text = "--";
  4627. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  4628. table.Range.Bookmarks["NavigationCode"].Text = "--";
  4629. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  4630. table.Range.Bookmarks["AgentPhone"].Text = "--";
  4631. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  4632. }
  4633. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  4634. //保存合并后的文档
  4635. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  4636. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  4637. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  4638. return Ok(JsonView(true, "成功!", rst));
  4639. }
  4640. }
  4641. }
  4642. catch (Exception ex)
  4643. {
  4644. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  4645. throw;
  4646. }
  4647. }
  4648. #endregion
  4649. #region 团组增减款项 --> 其他款项
  4650. /// <summary>
  4651. /// 团组增减款项下拉框绑定
  4652. /// </summary>
  4653. /// <param name="dto"></param>
  4654. /// <returns></returns>
  4655. [HttpPost]
  4656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4657. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  4658. {
  4659. #region 参数验证
  4660. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4661. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  4662. #endregion
  4663. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  4664. }
  4665. /// <summary>
  4666. /// 根据团组Id查询团组增减款项
  4667. /// </summary>
  4668. /// <param name="dto"></param>
  4669. /// <returns></returns>
  4670. [HttpPost]
  4671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4672. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  4673. {
  4674. #region 参数验证
  4675. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4676. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4677. #endregion
  4678. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  4679. }
  4680. /// <summary>
  4681. /// 团组增减款项操作(Status:1.新增,2.修改)
  4682. /// </summary>
  4683. /// <param name="dto"></param>
  4684. /// <returns></returns>
  4685. [HttpPost]
  4686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4687. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  4688. {
  4689. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  4690. if (groupData.Code != 200)
  4691. {
  4692. return Ok(JsonView(false, groupData.Msg));
  4693. }
  4694. #region 应用推送
  4695. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4696. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4697. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4698. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  4699. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  4700. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  4701. //自动审核
  4702. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  4703. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4704. //2024-10-21 新增LZ UID
  4705. var userIds = new List<int>() { 21 };
  4706. string title = $"系统通知";
  4707. string content = "";
  4708. var diId = dto.DiId;
  4709. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4710. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4711. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4712. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4713. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4714. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  4715. #endregion
  4716. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4717. }
  4718. /// <summary>
  4719. /// 团组增减款项操作 删除
  4720. /// </summary>
  4721. /// <param name="dto"></param>
  4722. /// <returns></returns>
  4723. [HttpPost]
  4724. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4725. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  4726. {
  4727. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  4728. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  4729. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  4730. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  4731. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  4732. }
  4733. /// <summary>
  4734. /// 根据团组增减款项Id查询
  4735. /// </summary>
  4736. /// <param name="dto"></param>
  4737. /// <returns></returns>
  4738. [HttpPost]
  4739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4740. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  4741. {
  4742. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  4743. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  4744. }
  4745. /// <summary>
  4746. /// 查询供应商名称
  4747. /// </summary>
  4748. /// <param name="dto"></param>
  4749. /// <returns></returns>
  4750. [HttpPost]
  4751. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  4752. {
  4753. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  4754. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  4755. ?? new List<Grp_DecreasePayments>();
  4756. dbResult = dbResult.Distinct(new
  4757. ProductComparer()).ToList();
  4758. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  4759. {
  4760. x.Id,
  4761. x.SupplierAddress,
  4762. x.SupplierArea,
  4763. x.SupplierContact,
  4764. x.SupplierContactNumber,
  4765. x.SupplierEmail,
  4766. x.SupplierName,
  4767. x.SupplierSocialAccount,
  4768. x.SupplierTypeId,
  4769. }).ToList());
  4770. return Ok(jw);
  4771. }
  4772. /// <summary>
  4773. /// 团组增减款项 OTA匹配
  4774. /// </summary>
  4775. /// <param name="file"></param>
  4776. /// <returns></returns>
  4777. [HttpPost]
  4778. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  4779. {
  4780. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  4781. string fileName = file.FileName;
  4782. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  4783. {
  4784. return Ok(JsonView(false, "请上传Excel文件!"));
  4785. }
  4786. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  4787. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  4788. if (!Directory.Exists(path))
  4789. {
  4790. Directory.CreateDirectory(path);
  4791. }
  4792. var filePath = @$"{path}/{fileName}";
  4793. //保存文件
  4794. using (FileStream fs = System.IO.File.Create(filePath))
  4795. {
  4796. file.CopyTo(fs);
  4797. fs.Flush();
  4798. }
  4799. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  4800. //读取ExcelFile
  4801. DataTable dt = ConvertExcelToDataTable(filePath);
  4802. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  4803. dt.TableName = "TB";
  4804. //修改table列名
  4805. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  4806. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  4807. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  4808. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  4809. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  4810. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  4811. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  4812. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  4813. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  4814. dt.Columns[9].ColumnName = "Quantity"; // 台数
  4815. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  4816. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  4817. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  4818. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  4819. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  4820. var otaOrderNos = new List<string>();
  4821. foreach (DataRow item in dt.Rows)
  4822. {
  4823. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  4824. }
  4825. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  4826. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  4827. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  4828. .Select((dp, di) => new
  4829. {
  4830. dp.PriceName,
  4831. dp.OTAOrderNo,
  4832. dp.FeeTotal,
  4833. di.TeamName,
  4834. })
  4835. .ToListAsync();
  4836. foreach (DataRow item in dt.Rows)
  4837. {
  4838. var otaOrderNo = item["OTAOrderNo"].ToString();
  4839. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  4840. if (oaData == null) continue;
  4841. item["GroupName"] = oaData.TeamName;
  4842. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  4843. }
  4844. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4845. Dictionary<string, object> pairs = new Dictionary<string, object>();
  4846. List<DataTable> datas = new List<DataTable>();
  4847. datas.Add(dt);
  4848. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  4849. return Ok(JsonView(true, "操作成功", new { url = url }));
  4850. }
  4851. #region
  4852. private DataTable ConvertExcelToDataTable(string excelFilePath)
  4853. {
  4854. // 创建Workbook对象
  4855. Workbook workbook = new Workbook(excelFilePath);
  4856. // 获取第一个工作表
  4857. Worksheet worksheet = workbook.Worksheets[0];
  4858. // 将工作表转换为DataTable
  4859. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  4860. return dataTable;
  4861. }
  4862. #endregion
  4863. [HttpGet]
  4864. public IActionResult WorldGamesData()
  4865. {
  4866. var setData = _sqlSugar.Queryable<Sys_SetData>()
  4867. .Where(x => x.IsDel == 0 && x.STid == 117)
  4868. .ToList();
  4869. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  4870. foreach (var item in setData)
  4871. {
  4872. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  4873. {
  4874. Data = new SetDataView
  4875. {
  4876. Id = item.Id,
  4877. Name = item.Name,
  4878. Remark = item.Remark,
  4879. STid = item.STid,
  4880. },
  4881. Child = JsonConvert.DeserializeObject<List<string>>(item.Remark)
  4882. });
  4883. }
  4884. return Ok(JsonView(true, "success", resultArr));
  4885. }
  4886. #endregion
  4887. #region 文件上传、删除
  4888. /// <summary>
  4889. /// region 文件上传 可以带参数
  4890. /// </summary>
  4891. /// <param name="file"></param>
  4892. /// <returns></returns>
  4893. [HttpPost]
  4894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4895. public async Task<IActionResult> UploadProject(IFormFile file)
  4896. {
  4897. //var TypeName = Request.Headers["TypeName"].ToString();
  4898. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  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. // filePath = fileDir + $@"\团组增减款项相关文件";
  4907. // if (!Directory.Exists(filePath))
  4908. // {
  4909. // Directory.CreateDirectory(filePath);
  4910. // }
  4911. // //上传的文件的路径
  4912. // filePath += $@"\{projectFileName}";
  4913. //}
  4914. //else if (TypeName == "B")//B代表商邀相关文件
  4915. //{
  4916. // //上传的文件的路径
  4917. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4918. // if (!Directory.Exists(filePath))
  4919. // {
  4920. // Directory.CreateDirectory(filePath);
  4921. // }
  4922. // //上传的文件的路径
  4923. // filePath = $@"\{projectFileName}";
  4924. //}
  4925. //try
  4926. //{
  4927. // using (FileStream fs = System.IO.File.Create(filePath))
  4928. // {
  4929. // file.CopyTo(fs);
  4930. // fs.Flush();
  4931. // }
  4932. //}
  4933. //catch (Exception ex)
  4934. //{
  4935. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  4936. //}
  4937. //return Ok(JsonView(true, "上传成功!", projectFileName));
  4938. try
  4939. {
  4940. var TypeName = Request.Headers["TypeName"].ToString();
  4941. if (file != null)
  4942. {
  4943. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4944. //文件名称
  4945. string projectFileName = file.FileName;
  4946. //上传的文件的路径
  4947. string filePath = $"{fileDir}/{projectFileName}";
  4948. if (TypeName == "A")//A代表团组增减款项
  4949. {
  4950. if (!Directory.Exists(fileDir))
  4951. {
  4952. Directory.CreateDirectory(fileDir);
  4953. }
  4954. //上传的文件的路径
  4955. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4956. }
  4957. else if (TypeName == "B")//B代表商邀相关文件
  4958. {
  4959. if (!Directory.Exists(fileDir))
  4960. {
  4961. Directory.CreateDirectory(fileDir);
  4962. }
  4963. //上传的文件的路径
  4964. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4965. }
  4966. using (FileStream fs = System.IO.File.Create(filePath))
  4967. {
  4968. file.CopyTo(fs);
  4969. fs.Flush();
  4970. }
  4971. return Ok(JsonView(true, "上传成功!", projectFileName));
  4972. }
  4973. else
  4974. {
  4975. return Ok(JsonView(false, "上传失败!"));
  4976. }
  4977. }
  4978. catch (Exception ex)
  4979. {
  4980. return Ok(JsonView(false, "程序错误!"));
  4981. }
  4982. }
  4983. /// <summary>
  4984. /// 删除指定文件
  4985. /// </summary>
  4986. /// <param name="dto"></param>
  4987. /// <returns></returns>
  4988. [HttpPost]
  4989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4990. public async Task<IActionResult> DelFile(DelFileDto dto)
  4991. {
  4992. try
  4993. {
  4994. var TypeName = Request.Headers["TypeName"].ToString();
  4995. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4996. string filePath = "";
  4997. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4998. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4999. int id = 0;
  5000. if (TypeName == "A")
  5001. {
  5002. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  5003. // 删除该文件
  5004. System.IO.File.Delete(filePath);
  5005. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  5006. .Where(a => a.Id == dto.Id)
  5007. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  5008. .ExecuteCommandAsync();
  5009. }
  5010. else if (TypeName == "B")
  5011. {
  5012. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  5013. // 删除该文件
  5014. System.IO.File.Delete(filePath);
  5015. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  5016. if (info != null)
  5017. {
  5018. string[] files = new string[] { };
  5019. if (!string.IsNullOrEmpty(info.Attachment))
  5020. {
  5021. try
  5022. {
  5023. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  5024. }
  5025. catch (Exception)
  5026. {
  5027. files = new List<string>() { info.Attachment }.ToArray();
  5028. }
  5029. }
  5030. if (files.Length > 0)
  5031. {
  5032. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  5033. string filePath2 = string.Empty;
  5034. if (files1.Length > 0)
  5035. {
  5036. filePath2 = JsonConvert.SerializeObject(files1);
  5037. }
  5038. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5039. .Where(a => a.Id == dto.Id)
  5040. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  5041. .ExecuteCommandAsync();
  5042. }
  5043. }
  5044. }
  5045. if (id != 0)
  5046. {
  5047. return Ok(JsonView(true, "成功!"));
  5048. }
  5049. else
  5050. {
  5051. return Ok(JsonView(false, "失败!"));
  5052. }
  5053. }
  5054. catch (Exception ex)
  5055. {
  5056. return Ok(JsonView(false, "程序错误!"));
  5057. throw;
  5058. }
  5059. }
  5060. /// <summary>
  5061. /// 文件上传多个文件 可以带参数
  5062. /// </summary>
  5063. /// <param name="files"></param>
  5064. /// <returns></returns>
  5065. [HttpPost]
  5066. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5067. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  5068. {
  5069. try
  5070. {
  5071. var TypeName = Request.Headers["TypeName"].ToString();
  5072. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5073. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  5074. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5075. var filePahts = new List<string>();
  5076. foreach (var file in files)
  5077. {
  5078. //文件名称
  5079. string projectFileName = file.FileName;
  5080. //上传的文件的路径
  5081. string filePath = $"{fileDir}/{projectFileName}";
  5082. if (TypeName == "A")//A代表团组增减款项
  5083. {
  5084. if (!Directory.Exists(fileDir))
  5085. {
  5086. Directory.CreateDirectory(fileDir);
  5087. }
  5088. //上传的文件的路径
  5089. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5090. }
  5091. else if (TypeName == "B")//B代表商邀相关文件
  5092. {
  5093. if (!Directory.Exists(fileDir))
  5094. {
  5095. Directory.CreateDirectory(fileDir);
  5096. }
  5097. //上传的文件的路径
  5098. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5099. }
  5100. using (FileStream fs = System.IO.File.Create(filePath))
  5101. {
  5102. file.CopyTo(fs);
  5103. fs.Flush();
  5104. }
  5105. filePahts.Add(projectFileName);
  5106. }
  5107. return Ok(JsonView(true, "上传成功!", filePahts));
  5108. }
  5109. catch (Exception ex)
  5110. {
  5111. return Ok(JsonView(false, "程序错误!"));
  5112. }
  5113. }
  5114. #endregion
  5115. #region 商邀费用录入
  5116. /// <summary>
  5117. /// 根据团组Id查询商邀费用列表
  5118. /// </summary>
  5119. /// <param name="dto"></param>
  5120. /// <returns></returns>
  5121. [HttpPost]
  5122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5123. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  5124. {
  5125. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  5126. if (groupData.Code != 0)
  5127. {
  5128. return Ok(JsonView(false, groupData.Msg));
  5129. }
  5130. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5131. }
  5132. /// <summary>
  5133. /// 商邀费用列表
  5134. /// 下载文件
  5135. /// </summary>
  5136. /// <param name="id"></param>
  5137. /// <returns></returns>
  5138. [HttpGet("{id}")]
  5139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5140. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  5141. {
  5142. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  5143. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  5144. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  5145. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  5146. var filePaths = new List<string>();
  5147. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  5148. try
  5149. {
  5150. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  5151. }
  5152. catch (Exception ex)
  5153. {
  5154. filePaths.Add(info.Attachment);
  5155. }
  5156. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  5157. for (int i = 0; i < filePaths.Count; i++)
  5158. {
  5159. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  5160. }
  5161. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  5162. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  5163. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  5164. {
  5165. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  5166. {
  5167. foreach (string filePath in filePaths)
  5168. {
  5169. if (System.IO.File.Exists(filePath))
  5170. {
  5171. // 获取文件名
  5172. string fileName = Path.GetFileName(filePath);
  5173. // 将文件添加到ZIP归档中
  5174. zipArchive.CreateEntryFromFile(filePath, fileName);
  5175. }
  5176. }
  5177. }
  5178. }
  5179. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5180. }
  5181. /// <summary>
  5182. /// 商邀费用 Info Page 基础数据源
  5183. /// </summary>
  5184. /// <returns></returns>
  5185. [HttpPost]
  5186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5187. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5188. {
  5189. try
  5190. {
  5191. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  5192. if (groupData.Code != 0)
  5193. {
  5194. return Ok(JsonView(false, groupData.Msg));
  5195. }
  5196. return Ok(JsonView(true, "操作成功", groupData.Data));
  5197. }
  5198. catch (Exception ex)
  5199. {
  5200. return Ok(JsonView(false, ex.Message));
  5201. throw;
  5202. }
  5203. }
  5204. /// <summary>
  5205. /// 根据商邀费用ID查询C表和商邀费用数据
  5206. /// </summary>
  5207. /// <param name="dto"></param>
  5208. /// <returns></returns>
  5209. [HttpPost]
  5210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5211. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5212. {
  5213. try
  5214. {
  5215. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5216. if (groupData.Code != 0)
  5217. {
  5218. return Ok(JsonView(false, groupData.Msg));
  5219. }
  5220. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5221. }
  5222. catch (Exception ex)
  5223. {
  5224. return Ok(JsonView(false, ex.Message));
  5225. throw;
  5226. }
  5227. }
  5228. /// <summary>
  5229. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5230. /// </summary>
  5231. /// <param name="dto"></param>
  5232. /// <returns></returns>
  5233. [HttpPost]
  5234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5235. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5236. {
  5237. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5238. if (groupData.Code != 0)
  5239. {
  5240. return Ok(JsonView(false, groupData.Msg));
  5241. }
  5242. #region 应用推送
  5243. try
  5244. {
  5245. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5246. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5247. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5248. //2024-10-21 新增LZ UID
  5249. var userIds = new List<int>() { 21 };
  5250. string title = $"系统通知";
  5251. string content = "";
  5252. var diId = dto.DiId;
  5253. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5254. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5255. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5256. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5257. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5258. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5259. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5260. }
  5261. catch (Exception ex)
  5262. {
  5263. }
  5264. #endregion
  5265. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5266. }
  5267. /// <summary>
  5268. /// 商邀删除
  5269. /// </summary>
  5270. /// <param name="dto"></param>
  5271. /// <returns></returns>
  5272. [HttpPost]
  5273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5274. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5275. {
  5276. try
  5277. {
  5278. _sqlSugar.BeginTran();
  5279. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5280. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5281. {
  5282. IsDel = 1,
  5283. DeleteUserId = dto.DeleteUserId,
  5284. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5285. })
  5286. .Where(it => it.Id == dto.Id)
  5287. .ExecuteCommand();
  5288. if (res1 > 0)
  5289. {
  5290. int _diId = 0;
  5291. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5292. if (_ioaInfo != null)
  5293. {
  5294. _diId = _ioaInfo.DiId;
  5295. }
  5296. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5297. .SetColumns(a => new Grp_CreditCardPayment()
  5298. {
  5299. IsDel = 1,
  5300. DeleteUserId = dto.DeleteUserId,
  5301. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5302. })
  5303. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5304. .ExecuteCommand();
  5305. if (res2 > 0)
  5306. {
  5307. _sqlSugar.CommitTran();
  5308. return Ok(JsonView(true, "删除成功!"));
  5309. }
  5310. }
  5311. _sqlSugar.RollbackTran();
  5312. return Ok(JsonView(false, "删除失败"));
  5313. }
  5314. catch (Exception ex)
  5315. {
  5316. _sqlSugar.RollbackTran();
  5317. return Ok(JsonView(false, ex.Message));
  5318. }
  5319. }
  5320. #endregion
  5321. #region 票据上传
  5322. /// <summary>
  5323. /// 团组模块文件上传
  5324. /// </summary>
  5325. /// <param name="dto"></param>
  5326. /// <returns></returns>
  5327. [HttpPost]
  5328. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5329. {
  5330. var jw = JsonView(false);
  5331. long M = 1024 * 1024;
  5332. if (dto.Files == null || dto.Files.Count == 0)
  5333. {
  5334. jw.Msg = "无文件信息!";
  5335. return Ok(jw);
  5336. }
  5337. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5338. {
  5339. jw.Msg = "文件大小超过20M!";
  5340. return Ok(jw);
  5341. }
  5342. //var nameSp = dto.File.FileName.Split(".");
  5343. //if (nameSp.Length < 2)
  5344. //{
  5345. // jw.Msg = "拓展名称有误!";
  5346. // return Ok(jw);
  5347. //}
  5348. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5349. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5350. //{
  5351. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5352. // return Ok(jw);
  5353. //}
  5354. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5355. if (Ctable == null)
  5356. {
  5357. jw.Msg = "Ctable指向有误!";
  5358. return Ok(jw);
  5359. }
  5360. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5361. if (groupInfo == null)
  5362. {
  5363. jw.Msg = "团组信息不存在!";
  5364. return Ok(jw);
  5365. }
  5366. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5367. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5368. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5369. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5370. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5371. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5372. try
  5373. {
  5374. if (!Directory.Exists(fileBase))
  5375. {
  5376. Directory.CreateDirectory(fileBase);
  5377. }
  5378. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  5379. foreach (var fileStream in dto.Files)
  5380. {
  5381. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5382. Grp_GroupModelFile file = new Grp_GroupModelFile()
  5383. {
  5384. Cid = dto.Cid,
  5385. CreateTime = DateTime.Now,
  5386. CreateUserId = dto.Userid,
  5387. Ctable = dto.Ctable,
  5388. Diid = dto.Diid,
  5389. IsDel = 0,
  5390. FilePath = saveFilePath,
  5391. FileName = fileStream.FileName
  5392. };
  5393. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5394. {
  5395. fileStream.CopyTo(fs);
  5396. fs.Flush();
  5397. }
  5398. saveArr.Add(file);
  5399. }
  5400. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5401. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5402. jw = JsonView(true, "保存成功!", new
  5403. {
  5404. count = addResult,
  5405. filesName = saveArr.Select(x => x.FileName)
  5406. });
  5407. }
  5408. catch (Exception ex)
  5409. {
  5410. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5411. {
  5412. count = 0,
  5413. filesName = new string[0],
  5414. });
  5415. }
  5416. return Ok(jw);
  5417. }
  5418. /// <summary>
  5419. /// 查询各模块已保存文件
  5420. /// </summary>
  5421. /// <param name="dto"></param>
  5422. /// <returns></returns>
  5423. [HttpPost]
  5424. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5425. {
  5426. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5427. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5428. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5429. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5430. {
  5431. expression = Expressionable.Create<Grp_GroupModelFile>()
  5432. .And(x => visaIds.Contains(x.CreateUserId));
  5433. }
  5434. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5435. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5436. .Where(expression.ToExpression())
  5437. .ToList();
  5438. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5439. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5440. {
  5441. x.FileName,
  5442. x.Id,
  5443. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5444. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5445. })));
  5446. }
  5447. /// <summary>
  5448. /// 下载该团组下的所有文件
  5449. /// </summary>
  5450. /// <param name="dto"></param>
  5451. /// <returns></returns>
  5452. [HttpPost]
  5453. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5454. {
  5455. var jw = JsonView(false);
  5456. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5457. if (groupInfo == null)
  5458. {
  5459. jw.Msg = "团组信息不存在!";
  5460. return Ok(jw);
  5461. }
  5462. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5463. var isModule = Convert.ToBoolean(dto.isModule);
  5464. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5465. IOOperatorHelper io = new IOOperatorHelper();
  5466. if (isModule)
  5467. {
  5468. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5469. foreach (var moduleArr in moduleGroup)
  5470. {
  5471. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5472. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5473. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5474. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  5475. foreach (var item in moduleArr)
  5476. {
  5477. if (System.IO.File.Exists(item.FilePath))
  5478. {
  5479. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5480. {
  5481. byte[] bytes = new byte[fileStream.Length];
  5482. fileStream.Read(bytes, 0, bytes.Length);
  5483. fileStream.Close();
  5484. Stream stream = new MemoryStream(bytes);
  5485. chiZips.Add(item.FileName, stream);
  5486. }
  5487. }
  5488. }
  5489. if (chiZips.Count > 0)
  5490. {
  5491. var byts = io.ConvertZipStream(chiZips);
  5492. Stream stream = new MemoryStream(byts);
  5493. Zips.Add(key.Name + "_.zip", stream);
  5494. }
  5495. }
  5496. }
  5497. else
  5498. {
  5499. foreach (var item in dbQuery)
  5500. {
  5501. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5502. {
  5503. byte[] bytes = new byte[fileStream.Length];
  5504. fileStream.Read(bytes, 0, bytes.Length);
  5505. fileStream.Close();
  5506. Stream stream = new MemoryStream(bytes);
  5507. while (Zips.Keys.Contains(item.FileName))
  5508. {
  5509. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5510. }
  5511. Zips.Add(item.FileName, stream);
  5512. }
  5513. }
  5514. }
  5515. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5516. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5517. if (Zips.Count > 0)
  5518. {
  5519. var byts = io.ConvertZipStream(Zips);
  5520. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5521. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5522. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5523. }
  5524. else
  5525. {
  5526. jw.Msg = "暂无生成文件!";
  5527. }
  5528. return Ok(jw);
  5529. }
  5530. /// <summary>
  5531. /// 下载该团组下此模块的所有文件
  5532. /// </summary>
  5533. /// <param name="dto"></param>
  5534. /// <returns></returns>
  5535. [HttpPost]
  5536. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5537. {
  5538. var jw = JsonView(false);
  5539. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5540. if (groupInfo == null)
  5541. {
  5542. jw.Msg = "团组信息不存在!";
  5543. return Ok(jw);
  5544. }
  5545. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5546. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5547. && x.IsDel == 0);
  5548. if (key == null)
  5549. {
  5550. jw.Msg = "Ctable指向错误!";
  5551. return Ok(jw);
  5552. }
  5553. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5554. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5555. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5556. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5557. IOOperatorHelper io = new IOOperatorHelper();
  5558. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5559. foreach (var item in dbQuery)
  5560. {
  5561. if (System.IO.File.Exists(item.FilePath))
  5562. {
  5563. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5564. {
  5565. byte[] bytes = new byte[fileStream.Length];
  5566. fileStream.Read(bytes, 0, bytes.Length);
  5567. fileStream.Close();
  5568. Stream stream = new MemoryStream(bytes);
  5569. while (Zips.Keys.Contains(item.FileName))
  5570. {
  5571. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5572. }
  5573. Zips.Add(item.FileName, stream);
  5574. }
  5575. }
  5576. }
  5577. if (Zips.Count > 0)
  5578. {
  5579. var byts = io.ConvertZipStream(Zips);
  5580. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5581. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5582. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5583. }
  5584. else
  5585. {
  5586. jw.Msg = "暂无生成文件!";
  5587. }
  5588. return Ok(jw);
  5589. }
  5590. /// <summary>
  5591. /// 删除该团组下的指定文件
  5592. /// </summary>
  5593. /// <param name="dto"></param>
  5594. /// <returns></returns>
  5595. [HttpPost]
  5596. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5597. {
  5598. var jw = JsonView(false);
  5599. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5600. if (sing == null)
  5601. {
  5602. jw.Msg = "暂无";
  5603. return Ok(jw);
  5604. }
  5605. if (System.IO.File.Exists(sing.FilePath))
  5606. {
  5607. try
  5608. {
  5609. System.IO.File.Delete(sing.FilePath);
  5610. }
  5611. catch (Exception ex)
  5612. {
  5613. jw.Msg = "删除失败!" + ex.Message;
  5614. return Ok(jw);
  5615. }
  5616. }
  5617. sing.IsDel = 1;
  5618. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5619. sing.DeleteUserId = dto.UserId;
  5620. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5621. jw = JsonView(true, "删除成功!");
  5622. return Ok(jw);
  5623. }
  5624. #endregion
  5625. #region 共享文件上传
  5626. /// <summary>
  5627. /// 共享文件数据初始化
  5628. /// </summary>
  5629. /// <returns></returns>
  5630. [HttpGet]
  5631. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  5632. {
  5633. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  5634. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5635. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5636. .Select(x => x.Id)
  5637. .ToList()
  5638. .Contains(userid);
  5639. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5640. .Where(x => x.STid == 111 && x.IsDel == 0)
  5641. .Select(x => new
  5642. {
  5643. x.Name,
  5644. x.Id,
  5645. }).ToList();
  5646. if (isMarketingDepartment)
  5647. {
  5648. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5649. }
  5650. if (portType == 1)
  5651. {
  5652. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5653. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5654. .Where(x => x.IsDel == 0)
  5655. .OrderByDescending(x => x.VisitDate)
  5656. .Select(x => new
  5657. {
  5658. x.TeamName,
  5659. x.Id,
  5660. x.CityId,
  5661. })
  5662. .ToList()
  5663. .Select(x =>
  5664. {
  5665. var provinceId = x.CityId;
  5666. var isDefualtVal = true;
  5667. if (provinceId > 0)
  5668. {
  5669. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5670. if (parentId != null)
  5671. {
  5672. isDefualtVal = false;
  5673. provinceId = (int)parentId;
  5674. }
  5675. }
  5676. if (isDefualtVal)
  5677. {
  5678. provinceId = 122; //默认四川
  5679. }
  5680. return new
  5681. {
  5682. x.TeamName,
  5683. x.Id,
  5684. provinceId,
  5685. };
  5686. })
  5687. .ToList();
  5688. return Ok(JsonView(true, "SUCCESS!", new
  5689. {
  5690. dropDownType,
  5691. dropDownGroupList,
  5692. isMarketingDepartment
  5693. }));
  5694. }
  5695. else if (portType == 2 || portType == 3)
  5696. {
  5697. return Ok(JsonView(true, "SUCCESS!", new
  5698. {
  5699. dropDownType,
  5700. isMarketingDepartment
  5701. }));
  5702. }
  5703. else
  5704. {
  5705. return Ok(JsonView(false, "portType有误!"));
  5706. }
  5707. }
  5708. /// <summary>
  5709. /// 共享文件上传
  5710. /// </summary>
  5711. /// <param name="dto"></param>
  5712. /// <returns></returns>
  5713. [HttpPost]
  5714. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5715. {
  5716. var isGroup = new List<int> { 1412 };
  5717. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5718. {
  5719. return Ok(JsonView(false, "该文件需要关联团组!"));
  5720. }
  5721. if (dto.Files == null || dto.Files.Count == 0)
  5722. {
  5723. return Ok(JsonView(false, "无文件信息!"));
  5724. }
  5725. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5726. {
  5727. return Ok(JsonView(false, "文件大小超过20M!"));
  5728. }
  5729. if (dto.Userid < 1)
  5730. {
  5731. return Ok(JsonView(false, "请传入有效的Userid!"));
  5732. }
  5733. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5734. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5735. .Select((u, j) => new
  5736. {
  5737. u.CnName,
  5738. UserId = u.Id,
  5739. j.JobName,
  5740. })
  5741. .First();
  5742. if (jobInfo == null)
  5743. {
  5744. return Ok(JsonView(false, "请传入有效的Userid!"));
  5745. }
  5746. List<string> commonFileExtensions = new List<string>
  5747. {
  5748. // 文本文件
  5749. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5750. // 图片文件
  5751. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5752. // 视频文件
  5753. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5754. // 音频文件
  5755. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5756. // 压缩文件
  5757. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5758. // 数据文件
  5759. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5760. };
  5761. try
  5762. {
  5763. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5764. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5765. commonFileExtensions.AddRange(settingExtend);
  5766. }
  5767. catch (Exception)
  5768. { }
  5769. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5770. if (setdata == null)
  5771. {
  5772. return Ok(JsonView(false, "请传入有效的FileType!"));
  5773. }
  5774. List<Grp_GroupShareFile> insertList = new List<Grp_GroupShareFile>();
  5775. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5776. if (!Directory.Exists(winPath))
  5777. {
  5778. Directory.CreateDirectory(winPath);
  5779. }
  5780. foreach (var item in dto.Files)
  5781. {
  5782. var houzui = Path.GetExtension(item.FileName);
  5783. if (!commonFileExtensions.Contains(houzui))
  5784. {
  5785. return Ok(JsonView(false, "未知后缀名称!"));
  5786. }
  5787. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5788. var saveFilePath = winPath + fileName;
  5789. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5790. {
  5791. item.CopyTo(fs);
  5792. fs.Flush();
  5793. }
  5794. var fileDetail = new Grp_GroupShareFile()
  5795. {
  5796. CreateUserId = dto.Userid,
  5797. CreateTime = DateTime.Now,
  5798. UploadJob = jobInfo.JobName,
  5799. FileName = fileName,
  5800. FileType = dto.FileType,
  5801. Diid = dto.Diid,
  5802. FilePath = winPath + fileName,
  5803. };
  5804. insertList.Add(fileDetail);
  5805. }
  5806. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5807. return Ok(JsonView(true, "保存成功!"));
  5808. }
  5809. /// <summary>
  5810. /// 查询共享文件列表
  5811. /// </summary>
  5812. /// <param name="dto"></param>
  5813. /// <returns></returns>
  5814. [HttpPost]
  5815. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5816. {
  5817. var isGroup = new List<int> { 1412 };
  5818. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5819. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5820. .And(x => x.Diid == dto.Diid)
  5821. .And(x => x.FileType == dto.FileType)
  5822. .And(x => x.IsDel == 0)
  5823. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5824. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5825. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5826. int totalCount = 0;
  5827. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5828. .Where(queryExpression.ToExpression())
  5829. .OrderBy(x => x.UploadJob)
  5830. .Select(x => new
  5831. {
  5832. x.Id,
  5833. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5834. x.FileName,
  5835. x.FileType,
  5836. x.CreateTime,
  5837. })
  5838. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5839. return Ok(JsonView(true, "SUCCESS!", new
  5840. {
  5841. FileList = dbQuery,
  5842. dto.PageSize,
  5843. dto.PageIndex,
  5844. totalCount
  5845. }));
  5846. }
  5847. /// <summary>
  5848. /// 删除共享文件模块下的指定文件
  5849. /// </summary>
  5850. /// <param name="dto"></param>
  5851. /// <returns></returns>
  5852. [HttpPost]
  5853. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  5854. {
  5855. var jw = JsonView(false);
  5856. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5857. if (sing == null)
  5858. {
  5859. jw.Msg = "暂无文件信息!";
  5860. return Ok(jw);
  5861. }
  5862. if (sing.CreateUserId != dto.UserId)
  5863. {
  5864. jw.Msg = "只能删除自己上传的文件!";
  5865. return Ok(jw);
  5866. }
  5867. if (System.IO.File.Exists(sing.FilePath))
  5868. {
  5869. try
  5870. {
  5871. System.IO.File.Delete(sing.FilePath);
  5872. }
  5873. catch (Exception ex)
  5874. {
  5875. jw.Msg = "删除失败!" + ex.Message;
  5876. return Ok(jw);
  5877. }
  5878. }
  5879. sing.IsDel = 1;
  5880. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5881. sing.DeleteUserId = dto.UserId;
  5882. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  5883. jw = JsonView(true, "删除成功!");
  5884. return Ok(jw);
  5885. }
  5886. #endregion
  5887. #region 团组英文资料
  5888. /// <summary>
  5889. /// 查询团组英文所有资料
  5890. /// </summary>
  5891. /// <param name="dto"></param>
  5892. /// <returns></returns>
  5893. [HttpPost]
  5894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5895. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  5896. {
  5897. try
  5898. {
  5899. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  5900. if (groupData.Code != 0)
  5901. {
  5902. return Ok(JsonView(false, groupData.Msg));
  5903. }
  5904. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5905. }
  5906. catch (Exception ex)
  5907. {
  5908. return Ok(JsonView(false, "程序错误!"));
  5909. throw;
  5910. }
  5911. }
  5912. /// <summary>
  5913. /// 团组英文资料操作(Status:1.新增,2.修改)
  5914. /// </summary>
  5915. /// <param name="dto"></param>
  5916. /// <returns></returns>
  5917. [HttpPost]
  5918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5919. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  5920. {
  5921. try
  5922. {
  5923. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  5924. if (groupData.Code != 0)
  5925. {
  5926. return Ok(JsonView(false, groupData.Msg));
  5927. }
  5928. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5929. }
  5930. catch (Exception ex)
  5931. {
  5932. return Ok(JsonView(false, "程序错误!"));
  5933. throw;
  5934. }
  5935. }
  5936. /// <summary>
  5937. /// 团组英文资料Id查询数据
  5938. /// </summary>
  5939. /// <param name="dto"></param>
  5940. /// <returns></returns>
  5941. [HttpPost]
  5942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5943. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  5944. {
  5945. try
  5946. {
  5947. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  5948. if (_DelegationEnData != null)
  5949. {
  5950. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  5951. }
  5952. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  5953. }
  5954. catch (Exception ex)
  5955. {
  5956. return Ok(JsonView(false, "程序错误!"));
  5957. throw;
  5958. }
  5959. }
  5960. /// <summary>
  5961. /// 团组英文资料删除
  5962. /// </summary>
  5963. /// <param name="dto"></param>
  5964. /// <returns></returns>
  5965. [HttpPost]
  5966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5967. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  5968. {
  5969. try
  5970. {
  5971. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  5972. if (!res)
  5973. {
  5974. return Ok(JsonView(false, "删除失败"));
  5975. }
  5976. return Ok(JsonView(true, "删除成功!"));
  5977. }
  5978. catch (Exception ex)
  5979. {
  5980. return Ok(JsonView(false, "程序错误!"));
  5981. throw;
  5982. }
  5983. }
  5984. #endregion
  5985. #region 导出邀请函
  5986. /// <summary>
  5987. /// 导出邀请函页面初始化
  5988. /// </summary>
  5989. /// <param name="dto"></param>
  5990. /// <returns></returns>
  5991. [HttpPost]
  5992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5993. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  5994. {
  5995. try
  5996. {
  5997. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  5998. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  5999. if (dto.DiId == 0)
  6000. {
  6001. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  6002. }
  6003. else
  6004. {
  6005. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  6006. }
  6007. return Ok(JsonView(true, "查询成功!", new
  6008. {
  6009. deleClient = crm_Deles,
  6010. delegations = grp_Delegations
  6011. }));
  6012. }
  6013. catch (Exception ex)
  6014. {
  6015. return Ok(JsonView(false, "程序错误!"));
  6016. throw;
  6017. }
  6018. }
  6019. /// <summary>
  6020. /// 导出邀请函
  6021. /// </summary>
  6022. /// <param name="dto"></param>
  6023. /// <returns></returns>
  6024. [HttpPost]
  6025. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6026. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  6027. {
  6028. #region 参数验证
  6029. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  6030. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6031. #endregion
  6032. try
  6033. {
  6034. Dictionary<string, string> transDic = new Dictionary<string, string>();
  6035. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  6036. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  6037. From Grp_TourClientList tcl
  6038. Left Join
  6039. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  6040. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  6041. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  6042. From Crm_DeleClient dc
  6043. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  6044. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  6045. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  6046. Where dc.IsDel = 0) temp
  6047. On temp.DcId =tcl.ClientId
  6048. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  6049. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  6050. List<string> texts = new List<string>();
  6051. if (datas.Count != 0)
  6052. {
  6053. foreach (TourClientListDetailsView item in datas)
  6054. {
  6055. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  6056. {
  6057. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  6058. }
  6059. else
  6060. {
  6061. string name = item.LastName + item.FirstName;
  6062. texts.Add(name);
  6063. }
  6064. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  6065. {
  6066. if (!transDic.ContainsKey(item.Job))
  6067. {
  6068. texts.Add(item.Job);
  6069. }
  6070. }
  6071. if (!string.IsNullOrEmpty(item.CompanyFullName))
  6072. {
  6073. texts.Add(item.CompanyFullName);
  6074. }
  6075. }
  6076. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  6077. if (transData.Count > 0)
  6078. {
  6079. foreach (TranslateResult item in transData)
  6080. {
  6081. if (!transDic.ContainsKey(item.Query))
  6082. {
  6083. transDic.Add(item.Query, item.Translation);
  6084. }
  6085. }
  6086. }
  6087. List<GuestList> list = new List<GuestList>();
  6088. foreach (TourClientListDetailsView dele in datas)
  6089. {
  6090. GuestList guestList = new GuestList();
  6091. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  6092. {
  6093. guestList.Name = dele.Pinyin;
  6094. }
  6095. else
  6096. {
  6097. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  6098. guestList.Name = Name;
  6099. }
  6100. if (dele.Sex == 0)
  6101. {
  6102. guestList.Sex = "Male";
  6103. }
  6104. else if (dele.Sex == 1)
  6105. {
  6106. guestList.Sex = "Female";
  6107. }
  6108. guestList.DOB = dele.BirthDay.Replace('-', '.');
  6109. if (!string.IsNullOrEmpty(dele.Job))
  6110. {
  6111. guestList.Job = dele.Job;
  6112. }
  6113. list.Add(guestList);
  6114. }
  6115. //载入模板
  6116. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  6117. DocumentBuilder builder = new DocumentBuilder(doc);
  6118. //获取word里所有表格
  6119. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6120. //获取所填表格的序数
  6121. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6122. var rowStart = tableOne.Rows[0]; //获取第1行
  6123. //循环赋值
  6124. for (int i = 0; i < list.Count; i++)
  6125. {
  6126. builder.MoveToCell(0, i + 1, 0, 0);
  6127. builder.Write(list[i].Name.ToString());
  6128. builder.MoveToCell(0, i + 1, 1, 0);
  6129. builder.Write(list[i].Sex.ToString());
  6130. builder.MoveToCell(0, i + 1, 2, 0);
  6131. builder.Write(list[i].DOB.ToString());
  6132. builder.MoveToCell(0, i + 1, 3, 0);
  6133. builder.Write(list[i].Job.ToString());
  6134. }
  6135. //删除多余行
  6136. while (tableOne.Rows.Count > list.Count + 1)
  6137. {
  6138. tableOne.Rows.RemoveAt(list.Count + 1);
  6139. }
  6140. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6141. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  6142. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  6143. doc.Save(filePath);
  6144. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  6145. return Ok(JsonView(true, "操作成功!", Url));
  6146. }
  6147. else
  6148. {
  6149. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  6150. }
  6151. }
  6152. catch (Exception ex)
  6153. {
  6154. return Ok(JsonView(false, ex.Message));
  6155. throw;
  6156. }
  6157. }
  6158. #endregion
  6159. #region 团组经理模块 出入境费用
  6160. /// <summary>
  6161. /// 团组模块 - 出入境费用 - 省份基础数据源
  6162. /// </summary>
  6163. /// <returns></returns>
  6164. [HttpGet]
  6165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6166. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  6167. {
  6168. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  6169. }
  6170. /// <summary>
  6171. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6172. /// </summary>
  6173. /// <returns></returns>
  6174. [HttpPost]
  6175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6176. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6177. {
  6178. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6179. var groupNamFirst = groupNameData.FirstOrDefault();
  6180. //SetDataInfoView
  6181. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6182. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6183. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6184. //验证城市归属并给默认值
  6185. int provinceId = 122;
  6186. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6187. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6188. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6189. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6190. return Ok(JsonView(true, "查询成功!", new
  6191. {
  6192. GroupNameData = groupNameData,
  6193. CurrencyData = _CurrencyData,
  6194. WordTypeData = wordTypeData,
  6195. ExcelTypeData = excelTypeData,
  6196. CurrencyInit = _currencyInfos,
  6197. ViewPermissionData = viewPermissionData
  6198. }));
  6199. }
  6200. /// <summary>
  6201. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6202. /// </summary>
  6203. /// <returns></returns>
  6204. [HttpGet("{provinceId}")]
  6205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6206. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6207. {
  6208. //验证城市归属并给默认值
  6209. if (provinceId < 1) provinceId = 122;
  6210. /*
  6211. * 122 四川
  6212. * 108 贵州
  6213. * 103 重庆
  6214. * 132 云南
  6215. */
  6216. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6217. return Ok(JsonView(true, "查询成功!", new
  6218. {
  6219. WordTypeData = wordTypeData,
  6220. ExcelTypeData = excelTypeData,
  6221. }));
  6222. }
  6223. /// <summary>
  6224. /// 团组模块 - 出入境费用
  6225. /// 实时汇率 tips
  6226. /// 签证费用 tips
  6227. /// 机票费用 tips
  6228. /// </summary>
  6229. /// <returns></returns>
  6230. [HttpPost]
  6231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6232. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6233. {
  6234. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6235. //默认币种显示
  6236. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6237. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6238. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6239. return Ok(JsonView(true, "查询成功!", new
  6240. {
  6241. //GroupNameData = groupNameData.Data,
  6242. visaData = visaData.Data,
  6243. airData = airData,
  6244. reteInfos = reteInfos
  6245. }));
  6246. }
  6247. /// <summary>
  6248. /// 团组模块 - 出入境费用 - Info
  6249. /// </summary>
  6250. /// <returns></returns>
  6251. [HttpPost]
  6252. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6254. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6255. {
  6256. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6257. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6258. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6259. }
  6260. /// <summary>
  6261. /// 团组模块 - 出入境费用 - 设置view权限
  6262. /// </summary>
  6263. /// <returns></returns>
  6264. [HttpPost]
  6265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6266. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6267. {
  6268. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6269. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6270. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6271. var permissions = new List<Grp_EnterExitCostPermission>();
  6272. foreach (var userId in dto.UserIds)
  6273. {
  6274. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6275. }
  6276. if (permissions.Any())
  6277. {
  6278. _sqlSugar.BeginTran();
  6279. try
  6280. {
  6281. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6282. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6283. if (result < 1)
  6284. {
  6285. _sqlSugar.RollbackTran();
  6286. return Ok(JsonView(false));
  6287. }
  6288. }
  6289. catch (Exception ex)
  6290. {
  6291. _sqlSugar.RollbackTran();
  6292. return Ok(JsonView(false, ex.Message));
  6293. }
  6294. _sqlSugar.CommitTran();
  6295. return Ok(JsonView(true));
  6296. }
  6297. return Ok(JsonView(false));
  6298. }
  6299. /// <summary>
  6300. /// 团组模块 - 出入境费用 - Add And Update
  6301. /// </summary>
  6302. /// <returns></returns>
  6303. [HttpPost]
  6304. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6306. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6307. {
  6308. try
  6309. {
  6310. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6311. if (dto.DayOtherPriceData.Any())
  6312. {
  6313. var inserList = dto.DayOtherPriceData
  6314. .Where(x => x.Id == 0)
  6315. .Select(x => new Grp_DayOtherPrice
  6316. {
  6317. Cost = x.Cost,
  6318. Id = x.Id,
  6319. CreateTime = DateTime.Now,
  6320. CreateUserId = dto.UserId,
  6321. Currency = x.Currency,
  6322. Diid = x.DiId,
  6323. Index = x.Index,
  6324. IsDel = 0,
  6325. SetDataId = x.SetDataId,
  6326. SubTotal = x.SubTotal,
  6327. Remark = x.Remark
  6328. })
  6329. .ToList();
  6330. var updateList = dto.DayOtherPriceData
  6331. .Where(x => x.Id != 0)
  6332. .Select(x => new Grp_DayOtherPrice
  6333. {
  6334. Cost = x.Cost,
  6335. Id = x.Id,
  6336. CreateTime = DateTime.Now,
  6337. CreateUserId = dto.UserId,
  6338. Currency = x.Currency,
  6339. Diid = x.DiId,
  6340. Index = x.Index,
  6341. IsDel = 0,
  6342. SetDataId = x.SetDataId,
  6343. SubTotal = x.SubTotal,
  6344. Remark = x.Remark
  6345. })
  6346. .ToList();
  6347. //添加
  6348. _sqlSugar.BeginTran();
  6349. if (inserList.Any())
  6350. {
  6351. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6352. }
  6353. if (updateList.Any())
  6354. {
  6355. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6356. }
  6357. _sqlSugar.CommitTran();
  6358. }
  6359. if (data.Code != 0)
  6360. {
  6361. return Ok(JsonView(false, data.Msg));
  6362. }
  6363. //生成默认文件pdf并且通知人员
  6364. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6365. {
  6366. DiId = dto.DiId,
  6367. ExportType = 1,
  6368. SubTypeId = 1005
  6369. }, "pdf");
  6370. //发送通知
  6371. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6372. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6373. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6374. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6375. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6376. //汇率信息记录
  6377. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6378. return Ok(JsonView(true, data.Msg, data.Data));
  6379. }
  6380. catch (Exception ex)
  6381. {
  6382. return Ok(JsonView(false, ex.Message));
  6383. }
  6384. }
  6385. /// <summary>
  6386. /// 团组模块 - 出入境费用 - Confirm 费用
  6387. /// </summary>
  6388. /// <returns></returns>
  6389. [HttpPost]
  6390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6391. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6392. {
  6393. //TODO:测试完毕需把对应的用户ID更改
  6394. //1、数据表添加字段
  6395. //2、更改字段接口()
  6396. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6397. //3、确认成功 给财务发送消息
  6398. if (_view.Code == 200)
  6399. {
  6400. if (dto.Type == 1)
  6401. {
  6402. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6403. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6404. }
  6405. }
  6406. return Ok(_view);
  6407. }
  6408. /// <summary>
  6409. /// 团组模块 - 出入境费用 - File download
  6410. /// </summary>
  6411. /// <param name="dto"></param>
  6412. /// <returns></returns>
  6413. [HttpPost]
  6414. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6415. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6416. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6417. {
  6418. try
  6419. {
  6420. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6421. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6422. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6423. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6424. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6425. 3 团组成员名单 1 团组成员名单", ""));
  6426. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6427. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6428. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6429. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6430. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6431. //数据源
  6432. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6433. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6434. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6435. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6436. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6437. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6438. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6439. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6440. .Select((x, a, b) => new
  6441. {
  6442. x.Index,
  6443. itemName = a.Name,
  6444. CurrencyStr = b.Name,
  6445. x.Cost,
  6446. x.SubTotal,
  6447. x.Remark
  6448. })
  6449. .OrderBy((x) => x.Index)
  6450. .ToList(); //其他款项费用
  6451. var peiceItemCurrencys = new List<string>();
  6452. if (_DayAndCosts.Any())
  6453. {
  6454. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6455. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6456. }
  6457. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6458. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6459. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6460. {
  6461. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6462. }
  6463. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6464. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6465. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6466. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6467. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6468. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6469. .Select((tcl, dc, cc) => new ClientInfo
  6470. {
  6471. LastName = dc.LastName,
  6472. FirstName = dc.FirstName,
  6473. Sex = dc.Sex,
  6474. Birthday = dc.BirthDay,
  6475. Company = cc.CompanyFullName,
  6476. Job = dc.Job
  6477. })
  6478. .ToList();
  6479. foreach (var item in DeleClientList)
  6480. {
  6481. EncryptionProcessor.DecryptProperties(item);
  6482. }
  6483. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6484. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6485. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6486. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6487. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6488. if (dto.ExportType == 1) //明细表
  6489. {
  6490. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6491. {
  6492. //获取模板
  6493. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6494. //载入模板
  6495. Document doc = new Document(tempPath);
  6496. DocumentBuilder builder = new DocumentBuilder(doc);
  6497. //利用键值对存放数据
  6498. Dictionary<string, string> dic = new Dictionary<string, string>();
  6499. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6500. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6501. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6502. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6503. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6504. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6505. //境内费用(其他费用)
  6506. if (_EnterExitCosts.ChoiceOne == 1)
  6507. {
  6508. string row1_1 = "";
  6509. if (_EnterExitCosts.Visa > 0)
  6510. {
  6511. //insidePayTotal += _EnterExitCosts.Visa;
  6512. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6513. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6514. //{
  6515. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6516. //}
  6517. }
  6518. string row1_2 = "";
  6519. if (_EnterExitCosts.YiMiao > 0)
  6520. {
  6521. //insidePayTotal += _EnterExitCosts.YiMiao;
  6522. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6523. }
  6524. if (_EnterExitCosts.HeSuan > 0)
  6525. {
  6526. //insidePayTotal += _EnterExitCosts.HeSuan;
  6527. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6528. }
  6529. if (_EnterExitCosts.Service > 0)
  6530. {
  6531. //insidePayTotal += _EnterExitCosts.Service;
  6532. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6533. }
  6534. string row1_3 = "";
  6535. if (_EnterExitCosts.Safe > 0)
  6536. {
  6537. //insidePayTotal += _EnterExitCosts.Safe;
  6538. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6539. }
  6540. if (_EnterExitCosts.Ticket > 0)
  6541. {
  6542. //insidePayTotal += _EnterExitCosts.Ticket;
  6543. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6544. }
  6545. string row1 = "";
  6546. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6547. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6548. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6549. row1 += $"备注:{_EnterExitCosts.Remark}";
  6550. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6551. dic.Add("Row1Str", row1);
  6552. }
  6553. string airTotalStr = string.Empty,
  6554. airPriceStr = string.Empty;
  6555. //经济舱
  6556. if (_EnterExitCosts.SumJJC == 1)
  6557. {
  6558. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6559. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6560. }
  6561. //公务舱
  6562. if (_EnterExitCosts.SumGWC == 1)
  6563. {
  6564. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6565. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6566. }
  6567. //头等舱
  6568. if (_EnterExitCosts.SumTDC == 1)
  6569. {
  6570. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6571. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6572. }
  6573. //汇率描述
  6574. string rateStr = "";
  6575. if (peiceItemCurrencyInfos.Any())
  6576. {
  6577. rateStr = "\r\n汇率描述:";
  6578. foreach (var item in peiceItemCurrencyInfos)
  6579. {
  6580. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6581. }
  6582. }
  6583. string twoItemRemark = "备注:";
  6584. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6585. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6586. dic.Add("AirTotalStr", airTotalStr);
  6587. dic.Add("AirPriceStr", airPriceStr);
  6588. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6589. dic.Add("TwoItemRemark", twoItemRemark);
  6590. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6591. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6592. int table1Row = 0,
  6593. table2Row = 0,
  6594. table3Row = 0,
  6595. table4Row = 0,
  6596. table5Row = 0;
  6597. //住宿费
  6598. if (_EnterExitCosts.ChoiceThree == 1)
  6599. {
  6600. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6601. table1Row = dac1.Count;
  6602. #region 填充word表格内容
  6603. for (int i = 0; i < dac1.Count; i++)
  6604. {
  6605. Grp_DayAndCost dac = dac1[i];
  6606. if (dac == null) continue;
  6607. builder.MoveToCell(0, i, 0, 0);
  6608. builder.Write("第" + dac.Days.ToString() + "晚:");
  6609. builder.MoveToCell(0, i, 1, 0);
  6610. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6611. //builder.Write(dac.Place == null ? "" : dac.Place);
  6612. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6613. builder.MoveToCell(0, i, 2, 0);
  6614. builder.Write("费用标准:");
  6615. string curr = "";
  6616. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6617. if (currData != null)
  6618. {
  6619. curr = currData.Name;
  6620. }
  6621. builder.MoveToCell(0, i, 3, 0);
  6622. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6623. builder.MoveToCell(0, i, 4, 0);
  6624. builder.Write("费用小计:");
  6625. builder.MoveToCell(0, i, 5, 0);
  6626. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6627. }
  6628. #endregion
  6629. }
  6630. else dic.Add("SubZS", "0.00");
  6631. //删除多余行
  6632. while (table1.Rows.Count > table1Row)
  6633. {
  6634. table1.Rows.RemoveAt(table1Row);
  6635. }
  6636. //伙食费
  6637. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6638. if (_EnterExitCosts.ChoiceFour == 1)
  6639. {
  6640. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6641. table2Row = dac2.Count;
  6642. #region 填充word表格内容
  6643. for (int i = 0; i < dac2.Count; i++)
  6644. {
  6645. Grp_DayAndCost dac = dac2[i];
  6646. if (dac == null) continue;
  6647. builder.MoveToCell(1, i, 0, 0);
  6648. builder.Write("第" + dac.Days.ToString() + "天:");
  6649. builder.MoveToCell(1, i, 1, 0);
  6650. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6651. builder.MoveToCell(1, i, 2, 0);
  6652. builder.Write("费用标准:");
  6653. string curr = "";
  6654. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6655. if (currData != null)
  6656. {
  6657. curr = currData.Name;
  6658. }
  6659. builder.MoveToCell(1, i, 3, 0);
  6660. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6661. builder.MoveToCell(1, i, 4, 0);
  6662. builder.Write("费用小计:");
  6663. builder.MoveToCell(1, i, 5, 0);
  6664. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6665. }
  6666. #endregion
  6667. }
  6668. else dic.Add("SubHS", "0.00");
  6669. //删除多余行
  6670. while (table2.Rows.Count > table2Row)
  6671. {
  6672. table2.Rows.RemoveAt(table2Row);
  6673. }
  6674. //公杂费
  6675. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6676. if (_EnterExitCosts.ChoiceFive == 1)
  6677. {
  6678. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6679. table3Row = dac3.Count;
  6680. #region 填充word表格内容
  6681. for (int i = 0; i < dac3.Count; i++)
  6682. {
  6683. Grp_DayAndCost dac = dac3[i];
  6684. if (dac == null) continue;
  6685. builder.MoveToCell(2, i, 0, 0);
  6686. builder.Write("第" + dac.Days.ToString() + "天:");
  6687. builder.MoveToCell(2, i, 1, 0);
  6688. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6689. builder.MoveToCell(2, 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(2, i, 3, 0);
  6698. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6699. builder.MoveToCell(2, i, 4, 0);
  6700. builder.Write("费用小计:");
  6701. builder.MoveToCell(2, i, 5, 0);
  6702. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6703. }
  6704. //删除多余行
  6705. while (table3.Rows.Count > table3Row)
  6706. {
  6707. table3.Rows.RemoveAt(table3Row);
  6708. }
  6709. #endregion
  6710. }
  6711. else dic.Add("SubGZF", "0.00");
  6712. //删除多余行
  6713. while (table3.Rows.Count > table3Row)
  6714. {
  6715. table3.Rows.RemoveAt(table3Row);
  6716. }
  6717. //培训费
  6718. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6719. if (_EnterExitCosts.ChoiceSix == 1)
  6720. {
  6721. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6722. dic.Add("SubPX", pxStr);
  6723. table4Row = dac4.Count;
  6724. #region 填充word表格内容
  6725. for (int i = 0; i < dac4.Count; i++)
  6726. {
  6727. Grp_DayAndCost dac = dac4[i];
  6728. if (dac == null) continue;
  6729. builder.MoveToCell(3, i, 0, 0);
  6730. builder.Write("第" + dac.Days.ToString() + "天:");
  6731. builder.MoveToCell(3, i, 1, 0);
  6732. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6733. builder.MoveToCell(3, i, 2, 0);
  6734. builder.Write("费用标准:");
  6735. string curr = "";
  6736. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6737. if (currData != null)
  6738. {
  6739. curr = currData.Name;
  6740. }
  6741. builder.MoveToCell(3, i, 3, 0);
  6742. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6743. builder.MoveToCell(3, i, 4, 0);
  6744. builder.Write("费用小计:");
  6745. builder.MoveToCell(3, i, 5, 0);
  6746. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6747. }
  6748. #endregion
  6749. }
  6750. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6751. //删除多余行
  6752. while (table4.Rows.Count > table4Row)
  6753. {
  6754. table4.Rows.RemoveAt(table4Row);
  6755. }
  6756. //其他费用
  6757. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6758. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6759. {
  6760. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6761. dic.Add("titleQi", qtStr);
  6762. table5Row = dac5.Count;
  6763. #region 填充word表格内容
  6764. for (int i = 0; i < dac5.Count; i++)
  6765. {
  6766. var dac = dac5[i];
  6767. if (dac == null) continue;
  6768. builder.MoveToCell(4, i, 0, 0);
  6769. builder.Write("第" + dac.Index.ToString() + "项:");
  6770. builder.MoveToCell(4, i, 1, 0);
  6771. builder.Write(dac.itemName);
  6772. builder.MoveToCell(4, i, 2, 0);
  6773. builder.Write("费用标准:");
  6774. builder.MoveToCell(4, i, 3, 0);
  6775. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6776. builder.MoveToCell(4, i, 4, 0);
  6777. builder.Write("费用小计:");
  6778. builder.MoveToCell(4, i, 5, 0);
  6779. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6780. builder.MoveToCell(4, i, 6, 0);
  6781. builder.Write("备注:");
  6782. builder.MoveToCell(4, i, 7, 0);
  6783. builder.Write(dac.Remark);
  6784. }
  6785. #endregion
  6786. }
  6787. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6788. //删除多余行
  6789. while (table5.Rows.Count > table5Row)
  6790. {
  6791. table5.Rows.RemoveAt(table5Row);
  6792. }
  6793. //加上其他费用
  6794. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6795. decimal subJJC = 0.00M,
  6796. subGWC = 0.00M,
  6797. subTDC = 0.00M;
  6798. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6799. string totalLabel = string.Format("全部费用总计:");
  6800. //经济舱
  6801. if (_EnterExitCosts.SumJJC == 1)
  6802. {
  6803. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6804. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  6805. }
  6806. //公务舱
  6807. if (_EnterExitCosts.SumGWC == 1)
  6808. {
  6809. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6810. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  6811. }
  6812. //头等舱
  6813. if (_EnterExitCosts.SumTDC == 1)
  6814. {
  6815. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6816. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  6817. }
  6818. //TotalLabel
  6819. dic.Add("TotalLabel", totalLabel);
  6820. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6821. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6822. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6823. #region 填充word模板书签内容
  6824. foreach (var key in dic.Keys)
  6825. {
  6826. Bookmark bookmark = doc.Range.Bookmarks[key];
  6827. if (bookmark != null)
  6828. {
  6829. builder.MoveToBookmark(key);
  6830. builder.Write(dic[key]);
  6831. }
  6832. }
  6833. #endregion
  6834. #region 设置页眉
  6835. string userLabel = string.Empty;
  6836. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6837. if (currUserInfo != null)
  6838. {
  6839. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6840. if (userInfo != null)
  6841. {
  6842. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6843. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  6844. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  6845. }
  6846. }
  6847. //设置页脚
  6848. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  6849. #endregion
  6850. //文件名
  6851. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  6852. AsposeHelper.removewatermark_v2180();
  6853. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6854. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6855. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6856. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6857. }
  6858. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6859. {
  6860. //获取模板
  6861. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6862. //载入模板
  6863. Document doc = new Document(tempPath);
  6864. DocumentBuilder builder = new DocumentBuilder(doc);
  6865. Dictionary<string, string> dic = new Dictionary<string, string>();
  6866. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6867. {
  6868. List<string> list = new List<string>();
  6869. try
  6870. {
  6871. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6872. foreach (var item in spilitArr)
  6873. {
  6874. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6875. var depCode = spDotandEmpty[2].Substring(0, 3);
  6876. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6877. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6878. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6879. list.Add(depName);
  6880. list.Add(arrName);
  6881. }
  6882. list = list.Distinct().ToList();
  6883. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6884. }
  6885. catch (Exception)
  6886. {
  6887. dic.Add("ReturnCode", "行程录入不正确!");
  6888. }
  6889. }
  6890. else
  6891. {
  6892. dic.Add("ReturnCode", "未录入行程!");
  6893. }
  6894. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6895. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6896. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6897. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6898. {
  6899. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6900. dic.Add("Day", sp.Days.ToString());
  6901. }
  6902. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6903. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6904. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6905. //dic.Add("Names", Names);
  6906. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6907. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6908. decimal dac1totalPrice = 0.00M;
  6909. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  6910. foreach (var dac in dac1)
  6911. {
  6912. if (dac.SubTotal == 0.00M)
  6913. {
  6914. continue;
  6915. }
  6916. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6917. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6918. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6919. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6920. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6921. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6922. builder.Write(currency);//币种
  6923. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6924. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6925. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6926. builder.Write("");//人数
  6927. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6928. builder.Write("");//天数
  6929. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6930. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6931. builder.MoveToCell(0, accommodationStartIndex, 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, accommodationStartIndex, 8, 0);
  6936. decimal rbmPrice = dac.SubTotal;
  6937. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6938. accommodationStartIndex++;
  6939. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6940. }
  6941. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6942. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  6943. {
  6944. table1.Rows.RemoveAt(i - 1);
  6945. foodandotherStartIndex--;
  6946. }
  6947. if (dac2.Count == dac3.Count)//国家 币种 金额
  6948. {
  6949. for (int i = 0; i < dac2.Count; i++)
  6950. {
  6951. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6952. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6953. }
  6954. }
  6955. decimal dac2totalPrice = 0.00M;
  6956. foreach (var dac in dac2)
  6957. {
  6958. if (dac.SubTotal == 0)
  6959. {
  6960. continue;
  6961. }
  6962. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6963. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6964. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6965. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6966. builder.Write(currency);//币种
  6967. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6968. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6969. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6970. builder.Write("");//人数
  6971. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6972. builder.Write("");//天数
  6973. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6974. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6975. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6976. decimal rate = 0.00M;
  6977. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6978. builder.Write(rate.ToString("#0.0000"));//汇率
  6979. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6980. decimal rbmPrice = dac.SubTotal;
  6981. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6982. foodandotherStartIndex++;
  6983. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6984. }
  6985. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6986. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  6987. {
  6988. table1.Rows.RemoveAt(i - 1);
  6989. }
  6990. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6991. string otherFeeStr = "";
  6992. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  6993. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  6994. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  6995. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6996. foreach (var otherInfo in dac5)
  6997. {
  6998. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6999. }
  7000. #endregion
  7001. if (otherFeeStr.Length > 0)
  7002. {
  7003. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7004. otherFeeStr = $"({otherFeeStr})";
  7005. dic.Add("OtherFeeStr", otherFeeStr);
  7006. }
  7007. //总计
  7008. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7009. //国际旅费
  7010. string outsideAir = string.Empty;
  7011. string allPriceAir = string.Empty;
  7012. if (_EnterExitCosts.SumJJC == 1)
  7013. {
  7014. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7015. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7016. }
  7017. if (_EnterExitCosts.SumGWC == 1)
  7018. {
  7019. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7020. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7021. }
  7022. if (_EnterExitCosts.SumTDC == 1)
  7023. {
  7024. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7025. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7026. }
  7027. dic.Add("InTravelPrice", $"({outsideAir})");
  7028. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7029. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7030. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7031. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7032. foreach (var key in dic.Keys)
  7033. {
  7034. builder.MoveToBookmark(key);
  7035. builder.Write(dic[key]);
  7036. }
  7037. //模板文件名
  7038. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7039. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7040. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7041. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7042. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7043. }
  7044. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7045. {
  7046. //获取模板
  7047. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7048. //载入模板
  7049. WorkbookDesigner designer = new WorkbookDesigner();
  7050. designer.Workbook = new Workbook(tempPath);
  7051. Dictionary<string, string> dic = new Dictionary<string, string>();
  7052. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7053. {
  7054. List<string> list = new List<string>();
  7055. try
  7056. {
  7057. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7058. foreach (var item in spilitArr)
  7059. {
  7060. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7061. var depCode = spDotandEmpty[2].Substring(0, 3);
  7062. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7063. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  7064. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  7065. list.Add(depName);
  7066. list.Add(arrName);
  7067. }
  7068. list = list.Distinct().ToList();
  7069. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7070. }
  7071. catch (Exception)
  7072. {
  7073. dic.Add("ReturnCode", "行程录入不正确!");
  7074. }
  7075. }
  7076. else
  7077. {
  7078. dic.Add("ReturnCode", "未录入行程!");
  7079. }
  7080. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7081. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7082. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7083. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7084. {
  7085. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7086. dic.Add("Day", sp.Days.ToString());
  7087. }
  7088. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7089. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7090. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7091. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  7092. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  7093. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  7094. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  7095. designer.SetDataSource("Name", Names);
  7096. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  7097. designer.SetDataSource("Day", dic["Day"] + "天");
  7098. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  7099. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  7100. int startIndex = 10;
  7101. const int startIndexcopy = 10;
  7102. if (dac2.Count == dac3.Count)//国家 币种 金额
  7103. {
  7104. for (int i = 0; i < dac2.Count; i++)
  7105. {
  7106. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7107. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7108. }
  7109. }
  7110. DataTable dtdac1 = new DataTable();
  7111. List<string> place = new List<string>();
  7112. dtdac1.Columns.AddRange(new DataColumn[] {
  7113. new DataColumn(){ ColumnName = "city"},
  7114. new DataColumn(){ ColumnName = "curr"},
  7115. new DataColumn(){ ColumnName = "criterion"},
  7116. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7117. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7118. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7119. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7120. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7121. });
  7122. DataTable dtdac2 = new DataTable();
  7123. dtdac2.Columns.AddRange(new DataColumn[] {
  7124. new DataColumn(){ ColumnName = "city"},
  7125. new DataColumn(){ ColumnName = "curr"},
  7126. new DataColumn(){ ColumnName = "criterion"},
  7127. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7128. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7129. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7130. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7131. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7132. });
  7133. dtdac1.TableName = "tb1";
  7134. dtdac2.TableName = "tb2";
  7135. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7136. foreach (var item in dac1)
  7137. {
  7138. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7139. if (place.Contains(item.Place))
  7140. {
  7141. continue;
  7142. }
  7143. DataRow row = dtdac1.NewRow();
  7144. row["city"] = item.Place;
  7145. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7146. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7147. row["curr"] = currency;
  7148. row["rate"] = rate.ToString("#0.0000");
  7149. row["criterion"] = item.Cost.ToString("#0.00");
  7150. row["number"] = 1;
  7151. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7152. //row["costRMB"] = rbmPrice;
  7153. dtdac1.Rows.Add(row);
  7154. place.Add(item.Place);
  7155. }
  7156. place = new List<string>();
  7157. foreach (var item in dac2)
  7158. {
  7159. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7160. if (place.Contains(item.Place))
  7161. {
  7162. continue;
  7163. }
  7164. DataRow row = dtdac2.NewRow();
  7165. row["city"] = item.Place;
  7166. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7167. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7168. row["curr"] = currency;
  7169. row["rate"] = rate.ToString("#0.0000");
  7170. row["criterion"] = item.Cost.ToString("#0.00");
  7171. row["number"] = 1;
  7172. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7173. //row["cost"] = item.SubTotal;
  7174. //row["costRMB"] = rbmPrice;
  7175. dtdac2.Rows.Add(row);
  7176. place.Add(item.Place);
  7177. //dac2totalPrice += rbmPrice;
  7178. }
  7179. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7180. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7181. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7182. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7183. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  7184. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  7185. string cell4Str1 = string.Empty;
  7186. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  7187. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  7188. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  7189. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7190. string cellStr = $" 5.其他费用(";
  7191. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7192. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7193. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7194. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7195. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7196. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7197. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7198. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7199. foreach (var otherInfo in dac5)
  7200. {
  7201. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7202. }
  7203. #endregion
  7204. if (cellStr.Length > 8)
  7205. {
  7206. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7207. }
  7208. cellStr += ")";
  7209. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7210. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7211. decimal pxFee = dac4.Sum(it => it.Cost);
  7212. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7213. string celllastStr1 = "";
  7214. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  7215. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  7216. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  7217. celllastStr1 += $",国际旅费 元";
  7218. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  7219. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7220. designer.SetDataSource("cell4Str", cell4Str);
  7221. designer.SetDataSource("cellStr", cellStr);
  7222. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7223. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7224. designer.SetDataSource("celllastStr", celllastStr);
  7225. Workbook wb = designer.Workbook;
  7226. var sheet = wb.Worksheets[0];
  7227. //绑定datatable数据集
  7228. designer.SetDataSource(dtdac1);
  7229. designer.SetDataSource(dtdac2);
  7230. designer.Process();
  7231. var rowStart = dtdac1.Rows.Count;
  7232. while (rowStart > 0)
  7233. {
  7234. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7235. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7236. startIndex++;
  7237. rowStart--;
  7238. }
  7239. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7240. startIndex += 1; //总计行
  7241. rowStart = dtdac2.Rows.Count;
  7242. while (rowStart > 0)
  7243. {
  7244. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7245. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7246. startIndex++;
  7247. rowStart--;
  7248. }
  7249. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7250. wb.CalculateFormula(true);
  7251. //模板文件名
  7252. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7253. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7254. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7255. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7256. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7257. }
  7258. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7259. {
  7260. //获取模板
  7261. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7262. //载入模板
  7263. Document doc = new Document(tempPath);
  7264. DocumentBuilder builder = new DocumentBuilder(doc);
  7265. Dictionary<string, string> dic = new Dictionary<string, string>();
  7266. dic.Add("GroupName", _DelegationInfo.TeamName);
  7267. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7268. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7269. string missionLeaderJob = "";//负责人job
  7270. //int groupNumber = 0; //团人数
  7271. if (DeleClientList.Count > 0)
  7272. {
  7273. missionLeader = DeleClientList[0]?.Name ?? "";
  7274. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7275. }
  7276. dic.Add("MissionLeader", missionLeader); //团负责人
  7277. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7278. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7279. #region MyRegion
  7280. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7281. //{
  7282. // List<string> list = new List<string>();
  7283. // try
  7284. // {
  7285. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7286. // foreach (var item in spilitArr)
  7287. // {
  7288. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7289. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7290. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7291. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7292. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7293. // list.Add(depName);
  7294. // list.Add(arrName);
  7295. // }
  7296. // list = list.Distinct().ToList();
  7297. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7298. // }
  7299. // catch (Exception)
  7300. // {
  7301. // dic.Add("ReturnCode", "行程录入不正确!");
  7302. // }
  7303. //}
  7304. //else
  7305. //{
  7306. // dic.Add("ReturnCode", "未录入行程!");
  7307. //}
  7308. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7309. dic.Add("ReturnCode", string.Join("、", countrys));
  7310. #endregion
  7311. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7312. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7313. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7314. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7315. //{
  7316. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7317. // dic.Add("Day", sp.Days.ToString());
  7318. //}
  7319. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7320. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7321. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7322. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7323. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7324. //培训人员名单
  7325. int cultivateRowIndex = 7;
  7326. foreach (var item in DeleClientList)
  7327. {
  7328. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7329. builder.Write(item.Name);
  7330. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7331. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7332. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7333. string birthDay = "";
  7334. if (item.Birthday != null)
  7335. {
  7336. DateTime dt = Convert.ToDateTime(item.Birthday);
  7337. birthDay = $"{dt.Year}.{dt.Month}";
  7338. }
  7339. builder.Write(birthDay);
  7340. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7341. builder.Write(item.Company);
  7342. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7343. builder.Write(item.Job);
  7344. cultivateRowIndex++;
  7345. }
  7346. //删除多余行
  7347. //cultivateRowIndex -= 2;
  7348. int delRows = 10 + 7 - cultivateRowIndex;
  7349. if (delRows > 0)
  7350. {
  7351. for (int i = 0; i < delRows; i++)
  7352. {
  7353. table1.Rows.RemoveAt(cultivateRowIndex);
  7354. //cultivateRowIndex++;
  7355. }
  7356. }
  7357. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7358. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7359. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7360. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7361. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7362. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7363. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7364. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7365. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7366. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7367. //其他费用
  7368. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7369. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7370. //其他费用合计
  7371. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7372. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7373. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7374. //公务舱合计
  7375. //国际旅费
  7376. //string outsideJJ = "";
  7377. //string allPriceJJ = "";
  7378. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7379. {
  7380. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7381. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7382. }
  7383. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7384. {
  7385. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7386. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7387. }
  7388. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7389. {
  7390. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7391. dic.Add("AirFeeTotal", airFeeTotalStr);
  7392. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7393. dic.Add("FeeTotal", feeTotalStr);
  7394. }
  7395. foreach (var key in dic.Keys)
  7396. {
  7397. builder.MoveToBookmark(key);
  7398. builder.Write(dic[key]);
  7399. }
  7400. //模板文件名
  7401. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7402. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7403. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7404. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7405. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7406. }
  7407. }
  7408. else if (dto.ExportType == 2) //表格
  7409. {
  7410. //利用键值对存放数据
  7411. Dictionary<string, string> dic = new Dictionary<string, string>();
  7412. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7413. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7414. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7415. dic.Add("Day", sp.Days.ToString());
  7416. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7417. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7418. {
  7419. //获取模板
  7420. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7421. //载入模板
  7422. Document doc = new Document(tempPath);
  7423. DocumentBuilder builder = new DocumentBuilder(doc);
  7424. dic.Add("TeamName", _DelegationInfo.TeamName);
  7425. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7426. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7427. string missionLeaderName = "",
  7428. missionLeaderJob = "";
  7429. if (DeleClientList.Count > 0)
  7430. {
  7431. missionLeaderName = DeleClientList[0].Name;
  7432. missionLeaderJob = DeleClientList[0].Job;
  7433. }
  7434. dic.Add("MissionLeaderName", missionLeaderName);
  7435. dic.Add("MissionLeaderJob", missionLeaderJob);
  7436. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7437. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7438. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7439. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7440. int rowCount = 10;//总人数行
  7441. int startRowIndex = 7; //起始行
  7442. for (int i = 0; i < DeleClientList.Count; i++)
  7443. {
  7444. builder.MoveToCell(0, startRowIndex, 0, 0);
  7445. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7446. builder.MoveToCell(0, startRowIndex, 1, 0);
  7447. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7448. builder.Write(sex);//性别
  7449. builder.MoveToCell(0, startRowIndex, 2, 0);
  7450. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7451. builder.MoveToCell(0, startRowIndex, 3, 0);
  7452. builder.Write(DeleClientList[i].Company);//工作单位
  7453. builder.MoveToCell(0, startRowIndex, 4, 0);
  7454. builder.Write(DeleClientList[i].Job);//职务及级别
  7455. builder.MoveToCell(0, startRowIndex, 5, 0);
  7456. builder.Write("");//人员属性
  7457. builder.MoveToCell(0, startRowIndex, 6, 0);
  7458. builder.Write("");//上次出国时间
  7459. startRowIndex++;
  7460. }
  7461. int nullRow = rowCount - DeleClientList.Count;//空行
  7462. for (int i = 0; i < nullRow; i++)
  7463. {
  7464. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7465. }
  7466. foreach (var key in dic.Keys)
  7467. {
  7468. builder.MoveToBookmark(key);
  7469. builder.Write(dic[key]);
  7470. }
  7471. //模板文件名
  7472. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7473. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7474. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7475. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7476. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7477. }
  7478. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7479. {
  7480. //获取模板
  7481. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7482. //载入模板
  7483. Document doc = new Document(tempPath);
  7484. DocumentBuilder builder = new DocumentBuilder(doc);
  7485. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7486. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7487. dic.Add("Names", Names);
  7488. int accommodationRows = 12;
  7489. //int foodandotherRows = 12;
  7490. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7491. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7492. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7493. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7494. int accommodationStartIndex = 6;
  7495. decimal dac1totalPrice = 0.00M;
  7496. foreach (var dac in dac1)
  7497. {
  7498. if (dac.SubTotal == 0)
  7499. {
  7500. continue;
  7501. }
  7502. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7503. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7504. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7505. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7506. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7507. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7508. builder.Write(currency);//币种
  7509. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7510. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7511. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7512. builder.Write("");//人数
  7513. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7514. builder.Write("");//天数
  7515. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7516. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7517. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7518. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7519. builder.Write(rate.ToString("#0.0000"));//汇率
  7520. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7521. decimal rbmPrice = rate * dac.SubTotal;
  7522. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7523. accommodationStartIndex++;
  7524. dac1totalPrice += rbmPrice;
  7525. }
  7526. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7527. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7528. builder.Write("小计");
  7529. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7530. builder.Write(dac1totalPrice.ToString("#0.00"));
  7531. accommodationStartIndex++;
  7532. int nullRow = accommodationRows - dac1.Count;
  7533. //删除空行
  7534. //if (nullRow > 0)
  7535. //{
  7536. // int rowIndex = accommodationStartIndex;
  7537. // for (int i = 0; i < nullRow; i++)
  7538. // {
  7539. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7540. // row.Remove();
  7541. // rowIndex++;
  7542. // }
  7543. //}
  7544. if (dac2.Count == dac3.Count)//国家 币种 金额
  7545. {
  7546. for (int i = 0; i < dac2.Count; i++)
  7547. {
  7548. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7549. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7550. }
  7551. }
  7552. int foodandotherStartIndex = 19;//
  7553. decimal dac2totalPrice = 0.00M;
  7554. foreach (var dac in dac2)
  7555. {
  7556. if (dac.SubTotal == 0)
  7557. {
  7558. continue;
  7559. }
  7560. //foodandotherStartIndex = 12;
  7561. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7562. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7563. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7564. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7565. builder.Write(currency);//币种
  7566. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7567. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7568. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7569. builder.Write("");//人数
  7570. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7571. builder.Write("");//天数
  7572. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7573. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7574. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7575. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7576. builder.Write(rate.ToString("#0.0000"));//汇率
  7577. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7578. decimal rbmPrice = rate * dac.SubTotal;
  7579. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7580. foodandotherStartIndex++;
  7581. dac2totalPrice += rbmPrice;
  7582. }
  7583. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7584. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7585. //删除空行
  7586. //if (dac2.Count < foodandotherRows)
  7587. //{
  7588. // while (table2.Rows.Count > dac2.Count)
  7589. // {
  7590. // table2.Rows.RemoveAt(dac2.Count);
  7591. // }
  7592. //}
  7593. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7594. string otherFeeStr = "";
  7595. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7596. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7597. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7598. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7599. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7600. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7601. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7602. foreach (var otherInfo in dac5)
  7603. {
  7604. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7605. }
  7606. #endregion
  7607. if (otherFeeStr.Length > 0)
  7608. {
  7609. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7610. otherFeeStr = $"({otherFeeStr})";
  7611. dic.Add("OtherFeeStr", otherFeeStr);
  7612. }
  7613. foreach (var key in dic.Keys)
  7614. {
  7615. builder.MoveToBookmark(key);
  7616. builder.Write(dic[key]);
  7617. }
  7618. //模板文件名
  7619. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  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. else if (dto.ExportType == 3)
  7627. {
  7628. if (dto.SubTypeId == 1) //团组成员名单
  7629. {
  7630. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7631. //获取模板
  7632. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7633. //载入模板
  7634. Document doc = new Document(tempPath);
  7635. DocumentBuilder builder = new DocumentBuilder(doc);
  7636. //获取word里所有表格
  7637. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7638. //获取所填表格的序数
  7639. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7640. var rowStart = tableOne.Rows[0]; //获取第1行
  7641. //循环赋值
  7642. for (int i = 0; i < DeleClientList.Count; i++)
  7643. {
  7644. builder.MoveToCell(0, i + 1, 0, 0);
  7645. builder.Write(DeleClientList[i].Name);
  7646. builder.MoveToCell(0, i + 1, 1, 0);
  7647. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7648. builder.Write(sex);
  7649. builder.MoveToCell(0, i + 1, 2, 0);
  7650. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7651. builder.MoveToCell(0, i + 1, 3, 0);
  7652. builder.Write(DeleClientList[i].Company);
  7653. builder.MoveToCell(0, i + 1, 4, 0);
  7654. builder.Write(DeleClientList[i].Job);
  7655. }
  7656. //删除多余行
  7657. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7658. {
  7659. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7660. }
  7661. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7662. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7663. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7664. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7665. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7666. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7667. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7668. }
  7669. }
  7670. return Ok(JsonView(400, "操作失败!", ""));
  7671. }
  7672. catch (Exception ex)
  7673. {
  7674. return Ok(JsonView(400, ex.Message, ""));
  7675. }
  7676. }
  7677. /// <summary>
  7678. /// 获取三公费用标准city
  7679. /// </summary>
  7680. /// <param name="placeData"></param>
  7681. /// <param name="nationalTravelFeeId"></param>
  7682. /// <returns></returns>
  7683. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7684. {
  7685. string _city = string.Empty;
  7686. if (placeData.Count < 1) return _city;
  7687. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7688. if (data == null) return _city;
  7689. string country = data.Country;
  7690. string city = data.City;
  7691. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7692. else _city = city;
  7693. return _city;
  7694. }
  7695. ///// <summary>
  7696. ///// 团组模块 - 出入境费用 - 明细表导出
  7697. ///// </summary>
  7698. ///// <returns></returns>
  7699. //[HttpPost]
  7700. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7701. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7702. //{
  7703. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7704. // if (data.Code != 0)
  7705. // {
  7706. // return Ok(JsonView(false, data.Msg));
  7707. // }
  7708. // return Ok(JsonView(true, data.Msg, data.Data));
  7709. //}
  7710. /// <summary>
  7711. /// 团组模块 - 出入境费用 - 一键清空
  7712. /// </summary>
  7713. /// <returns></returns>
  7714. [HttpPost]
  7715. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7717. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7718. {
  7719. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7720. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7721. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7722. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7723. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7724. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7725. .SetColumns(x => new Grp_DayOtherPrice
  7726. {
  7727. IsDel = 1,
  7728. DeleteUserId = dto.UserId,
  7729. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7730. })
  7731. .ExecuteCommandAsync();
  7732. if (_view.Code == 0)
  7733. {
  7734. return Ok(JsonView(true, "操作成功"));
  7735. }
  7736. return Ok(JsonView(false, "操作失败"));
  7737. }
  7738. /// <summary>
  7739. /// 团组模块 - 出入境费用 - 子项删除
  7740. /// </summary>
  7741. /// <returns></returns>
  7742. [HttpPost]
  7743. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7745. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7746. {
  7747. try
  7748. {
  7749. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7750. if (data.Code != 0)
  7751. {
  7752. return Ok(JsonView(false, data.Msg));
  7753. }
  7754. return Ok(JsonView(true, "操作成功!", data.Data));
  7755. }
  7756. catch (Exception ex)
  7757. {
  7758. return Ok(JsonView(false, ex.Message));
  7759. }
  7760. }
  7761. /// <summary>
  7762. /// 删除三公其他费用
  7763. /// </summary>
  7764. /// <param name="dto"></param>
  7765. /// <returns></returns>
  7766. [HttpPost]
  7767. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7768. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7769. {
  7770. var jw = JsonView(false, "删除失败!");
  7771. var data = new Grp_DayOtherPrice()
  7772. {
  7773. Id = dto.Id,
  7774. IsDel = 1,
  7775. DeleteUserId = dto.DeleteUserId,
  7776. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7777. };
  7778. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7779. if (del > 0)
  7780. {
  7781. jw.Code = 200;
  7782. jw.Msg = "删除成功!";
  7783. }
  7784. return Ok(jw);
  7785. }
  7786. /// <summary>
  7787. /// 团组模块 - 出入境国家费用标准 List
  7788. /// </summary>
  7789. /// <returns></returns>
  7790. [HttpPost]
  7791. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7792. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7793. {
  7794. int provinceId = dto.ProvinceId;
  7795. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7796. var nftData = await _sqlSugar
  7797. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7798. JoinType.Left, ntf.Currency == sd1.Id,
  7799. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7800. JoinType.Left, ntf.ProvinceId == c.Id
  7801. ))
  7802. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7803. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7804. {
  7805. Id = ntf.Id,
  7806. ProvinceId = ntf.ProvinceId,
  7807. ProvinceName = c.Name_CN,
  7808. Continent = ntf.Continent,
  7809. Country = ntf.Country,
  7810. City = ntf.City,
  7811. Currency = ntf.Currency,
  7812. CurrencyCode = sd1.Name,
  7813. CurrencyName = sd1.Remark,
  7814. RoomCost = ntf.RoomCost,
  7815. FoodCost = ntf.FoodCost,
  7816. PublicCost = ntf.PublicCost,
  7817. LastUpdateUserId = ntf.LastUpdateUserId,
  7818. LastUpdateUserName = u.CnName,
  7819. LastUpdateTime = ntf.LastUpdateTime
  7820. })
  7821. .ToListAsync();
  7822. return Ok(JsonView(true, "查询成功!", nftData));
  7823. }
  7824. /// <summary>
  7825. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7826. /// </summary>
  7827. /// <returns></returns>
  7828. [HttpPost]
  7829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7830. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7831. {
  7832. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7833. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7834. List<string> countryData = new List<string>();
  7835. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7836. countryData = countryData.Distinct().ToList();
  7837. List<dynamic> dataSource = new List<dynamic>();
  7838. foreach (var item in countryData)
  7839. {
  7840. var cityData1 = new List<string>();
  7841. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7842. var countryData2 = new
  7843. {
  7844. CountryName = item,
  7845. CityData = cityData1
  7846. };
  7847. if (!dataSource.Contains(countryData2))
  7848. {
  7849. dataSource.Add(countryData2);
  7850. }
  7851. }
  7852. return Ok(JsonView(true, "查询成功!", dataSource));
  7853. }
  7854. /// <summary>
  7855. /// 团组模块 - 出入境国家费用标准 Page List
  7856. /// </summary>
  7857. /// <returns></returns>
  7858. [HttpPost]
  7859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7860. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  7861. {
  7862. int portId = dto.PortType,
  7863. pageIndex = dto.PageIndex,
  7864. pageSize = dto.PageSize;
  7865. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7866. if (pageIndex == 0) pageIndex = 1;
  7867. if (pageSize == 0) pageSize = 10;
  7868. RefAsync<int> total = 0;
  7869. var nationalTravelFeeData = await _sqlSugar
  7870. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  7871. JoinType.Left, ntf.Currency == sd1.Id,
  7872. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7873. JoinType.Left, ntf.ProvinceId == sd2.Id
  7874. ))
  7875. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  7876. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  7877. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  7878. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  7879. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  7880. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  7881. {
  7882. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  7883. Id = ntf.Id,
  7884. ProvinceId = ntf.ProvinceId,
  7885. ProvinceName = sd2.Name_CN,
  7886. Continent = ntf.Continent,
  7887. Country = ntf.Country,
  7888. City = ntf.City,
  7889. Currency = ntf.Currency,
  7890. CurrencyCode = sd1.Name,
  7891. CurrencyName = sd1.Remark,
  7892. RoomCost = ntf.RoomCost,
  7893. FoodCost = ntf.FoodCost,
  7894. PublicCost = ntf.PublicCost,
  7895. LastUpdateUserId = ntf.LastUpdateUserId,
  7896. LastUpdateUserName = u.CnName,
  7897. LastUpdateTime = ntf.LastUpdateTime,
  7898. Remark = ntf.Remark
  7899. })
  7900. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7901. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  7902. }
  7903. /// <summary>
  7904. /// 团组模块 - 出入境国家费用标准 根据城市查询
  7905. /// </summary>
  7906. /// <returns></returns>
  7907. [HttpPost]
  7908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7909. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  7910. {
  7911. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  7912. int portId = dto.PortType;
  7913. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7914. string whereSql = string.Empty;
  7915. if (!string.IsNullOrEmpty(dto.Country))
  7916. {
  7917. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  7918. }
  7919. if (!string.IsNullOrEmpty(dto.City))
  7920. {
  7921. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  7922. }
  7923. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  7924. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  7925. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  7926. From Grp_NationalTravelFee gntf
  7927. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  7928. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  7929. Where gntf.Isdel = 0 {0} ", whereSql);
  7930. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  7931. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  7932. }
  7933. /// <summary>
  7934. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  7935. /// </summary>
  7936. /// <returns></returns>
  7937. [HttpPost]
  7938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7939. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  7940. {
  7941. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  7942. }
  7943. /// <summary>
  7944. /// 团组模块 - 出入境国家费用标准 - Del
  7945. /// </summary>
  7946. /// <returns></returns>
  7947. [HttpPost]
  7948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7949. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  7950. {
  7951. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  7952. {
  7953. Id = dto.Id,
  7954. DeleteUserId = dto.DeleteUserId,
  7955. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7956. IsDel = 1
  7957. };
  7958. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  7959. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  7960. .WhereColumns(it => new { it.Id })
  7961. .ExecuteCommandAsync();
  7962. if (delStatus <= 0)
  7963. {
  7964. return Ok(JsonView(false, "删除失败!"));
  7965. }
  7966. return Ok(JsonView(true, "操作成功!"));
  7967. }
  7968. /// <summary>
  7969. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  7970. /// 注:Get 请求Headers 加 Token
  7971. /// </summary>
  7972. /// <param name="groupId"></param>
  7973. /// <returns></returns>
  7974. [HttpGet("{groupId}")]
  7975. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7976. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  7977. {
  7978. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7979. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  7980. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  7981. data.ForEach(x =>
  7982. {
  7983. x.CreateUserId = _currUserInfo.UserId;
  7984. });
  7985. if (data.Any())
  7986. {
  7987. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  7988. if (add > 0)
  7989. {
  7990. return Ok(JsonView(true, "操作成功!"));
  7991. }
  7992. }
  7993. return Ok(JsonView(false, "未操作!"));
  7994. }
  7995. #endregion
  7996. #region 团组经理模块 出入境费用-草稿
  7997. /// <summary>
  7998. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  7999. /// </summary>
  8000. /// <returns></returns>
  8001. [HttpGet]
  8002. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8003. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  8004. {
  8005. var provData = await _groupRepository.ProvinceBasicSource();
  8006. return Ok(JsonView(true, "查询成功!", provData));
  8007. }
  8008. /// <summary>
  8009. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  8010. /// </summary>
  8011. /// <returns></returns>
  8012. [HttpGet("{provinceId}")]
  8013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8014. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  8015. {
  8016. //验证城市归属并给默认值
  8017. if (provinceId < 1) provinceId = 122;
  8018. /*
  8019. * 122 四川
  8020. * 108 贵州
  8021. * 103 重庆
  8022. * 132 云南
  8023. */
  8024. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  8025. return Ok(JsonView(true, "查询成功!", new
  8026. {
  8027. WordTypeData = wordTypeData,
  8028. ExcelTypeData = excelTypeData,
  8029. }));
  8030. }
  8031. /// <summary>
  8032. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  8033. /// </summary>
  8034. /// <returns></returns>
  8035. [HttpPost]
  8036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8037. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  8038. {
  8039. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8040. .Where(x => x.IsDel == 0)
  8041. .OrderByDescending(x => x.CreateTime)
  8042. .Select(x => new { x.Id, x.DraftName })
  8043. .ToListAsync();
  8044. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8045. //SetDataInfoView
  8046. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  8047. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  8048. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  8049. int provinceId = dto.ProvinceId;
  8050. if (provinceId < 1) provinceId = 122;
  8051. /*
  8052. * 122 四川
  8053. * 108 贵州
  8054. * 103 重庆
  8055. * 132 云南
  8056. */
  8057. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  8058. //默认币种显示
  8059. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  8060. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  8061. return Ok(JsonView(true, "查询成功!", new
  8062. {
  8063. DraftNameDatas = draftNameDatas,
  8064. CurrencyData = _CurrencyData,
  8065. WordTypeData = wordTypeData,
  8066. ExcelTypeData = excelTypeData,
  8067. CurrencyInit = _currencyInfos,
  8068. ViewPermissionData = viewPermissionData
  8069. }));
  8070. }
  8071. /// <summary>
  8072. /// 团组模块 - 出入境费用-草稿
  8073. /// 实时汇率 tips
  8074. /// 机票费用 tips
  8075. /// </summary>
  8076. /// <returns></returns>
  8077. [HttpPost]
  8078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8079. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  8080. {
  8081. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  8082. return Ok(JsonView(true, "查询成功!", new
  8083. {
  8084. //GroupNameData = groupNameData.Data,
  8085. //visaData = visaData.Data,
  8086. //airData = airData.Data,
  8087. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  8088. }));
  8089. }
  8090. /// <summary>
  8091. /// 团组模块 - 出入境费用-草稿
  8092. /// 签证费用 tips
  8093. /// </summary>
  8094. /// <returns></returns>
  8095. [HttpPost]
  8096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8097. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  8098. {
  8099. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  8100. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  8101. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  8102. .Select(x => x.NationalTravelFeeId)
  8103. .Distinct()
  8104. .ToListAsync();
  8105. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8106. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8107. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  8108. .Select(x => x.Country)
  8109. .Distinct()
  8110. .ToArrayAsync();
  8111. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8112. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  8113. return Ok(JsonView(true, "查询成功!", new
  8114. {
  8115. totalAmt = totalAmt,
  8116. remark = remark
  8117. }));
  8118. }
  8119. /// <summary>
  8120. /// 团组模块 - 出入境费用-草稿 - Info
  8121. /// </summary>
  8122. /// <returns></returns>
  8123. [HttpPost]
  8124. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  8125. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8126. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  8127. {
  8128. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  8129. }
  8130. /// <summary>
  8131. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  8132. /// </summary>
  8133. /// <returns></returns>
  8134. [HttpPost]
  8135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8136. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  8137. {
  8138. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8139. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  8140. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8141. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  8142. foreach (var userId in dto.UserIds)
  8143. {
  8144. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  8145. }
  8146. if (permissions.Any())
  8147. {
  8148. _sqlSugar.BeginTran();
  8149. try
  8150. {
  8151. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  8152. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8153. if (result < 1)
  8154. {
  8155. _sqlSugar.RollbackTran();
  8156. return Ok(JsonView(false));
  8157. }
  8158. }
  8159. catch (Exception ex)
  8160. {
  8161. _sqlSugar.RollbackTran();
  8162. return Ok(JsonView(false, ex.Message));
  8163. }
  8164. _sqlSugar.CommitTran();
  8165. return Ok(JsonView(true));
  8166. }
  8167. return Ok(JsonView(false));
  8168. }
  8169. /// <summary>
  8170. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8171. /// </summary>
  8172. /// <returns></returns>
  8173. [HttpPost]
  8174. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8176. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8177. {
  8178. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8179. if (data.Code != 0)
  8180. {
  8181. return Ok(JsonView(false, data.Msg));
  8182. }
  8183. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8184. //汇率信息记录
  8185. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8186. return Ok(JsonView(true, data.Msg, data.Data));
  8187. }
  8188. /// <summary>
  8189. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8190. /// </summary>
  8191. /// <param name="dto"></param>
  8192. /// <returns></returns>
  8193. [HttpPost]
  8194. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8196. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8197. {
  8198. try
  8199. {
  8200. var id = dto.Id;
  8201. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8202. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8203. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8204. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8205. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8206. 3 团组成员名单 1 团组成员名单", ""));
  8207. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8208. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8209. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8210. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8211. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8212. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8213. //数据源
  8214. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8215. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8216. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8217. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8218. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8219. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8220. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8221. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8222. .Select((x, a, b) => new
  8223. {
  8224. x.Index,
  8225. itemName = a.Name,
  8226. CurrencyStr = b.Name,
  8227. x.Cost,
  8228. x.SubTotal,
  8229. x.Remark
  8230. })
  8231. .OrderBy((x) => x.Index)
  8232. .ToList(); //其他款项费用
  8233. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8234. var peiceItemCurrencys = new List<string>();
  8235. if (_DayAndCosts.Any())
  8236. {
  8237. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8238. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8239. }
  8240. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8241. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8242. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8243. {
  8244. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8245. }
  8246. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8247. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8248. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8249. if (dto.ExportType == 1) //明细表
  8250. {
  8251. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8252. {
  8253. //获取模板
  8254. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8255. //载入模板
  8256. Document doc = new Document(tempPath);
  8257. DocumentBuilder builder = new DocumentBuilder(doc);
  8258. //利用键值对存放数据
  8259. Dictionary<string, string> dic = new Dictionary<string, string>();
  8260. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8261. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8262. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8263. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8264. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8265. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8266. //境内费用(其他费用)
  8267. if (_EnterExitCosts.ChoiceOne == 1)
  8268. {
  8269. string row1_1 = "";
  8270. if (_EnterExitCosts.Visa > 0)
  8271. {
  8272. //insidePayTotal += _EnterExitCosts.Visa;
  8273. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8274. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8275. //{
  8276. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8277. //}
  8278. }
  8279. string row1_2 = "";
  8280. if (_EnterExitCosts.YiMiao > 0)
  8281. {
  8282. //insidePayTotal += _EnterExitCosts.YiMiao;
  8283. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8284. }
  8285. if (_EnterExitCosts.HeSuan > 0)
  8286. {
  8287. //insidePayTotal += _EnterExitCosts.HeSuan;
  8288. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8289. }
  8290. if (_EnterExitCosts.Service > 0)
  8291. {
  8292. //insidePayTotal += _EnterExitCosts.Service;
  8293. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8294. }
  8295. string row1_3 = "";
  8296. if (_EnterExitCosts.Safe > 0)
  8297. {
  8298. //insidePayTotal += _EnterExitCosts.Safe;
  8299. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8300. }
  8301. if (_EnterExitCosts.Ticket > 0)
  8302. {
  8303. //insidePayTotal += _EnterExitCosts.Ticket;
  8304. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8305. }
  8306. string row1 = "";
  8307. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8308. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8309. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8310. row1 += $"备注:{_EnterExitCosts.Remark}";
  8311. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8312. dic.Add("Row1Str", row1);
  8313. }
  8314. string airTotalStr = string.Empty,
  8315. airPriceStr = string.Empty;
  8316. //经济舱
  8317. if (_EnterExitCosts.SumJJC == 1)
  8318. {
  8319. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8320. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8321. }
  8322. //公务舱
  8323. if (_EnterExitCosts.SumGWC == 1)
  8324. {
  8325. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8326. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8327. }
  8328. //头等舱
  8329. if (_EnterExitCosts.SumTDC == 1)
  8330. {
  8331. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8332. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8333. }
  8334. //汇率描述
  8335. string rateStr = "";
  8336. if (peiceItemCurrencyInfos.Any())
  8337. {
  8338. rateStr = "\r\n汇率描述:";
  8339. foreach (var item in peiceItemCurrencyInfos)
  8340. {
  8341. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8342. }
  8343. }
  8344. string twoItemRemark = "备注:";
  8345. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8346. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8347. dic.Add("AirTotalStr", airTotalStr);
  8348. dic.Add("AirPriceStr", airPriceStr);
  8349. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8350. dic.Add("TwoItemRemark", twoItemRemark);
  8351. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8352. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8353. int table1Row = 0,
  8354. table2Row = 0,
  8355. table3Row = 0,
  8356. table4Row = 0,
  8357. table5Row = 0;
  8358. //住宿费
  8359. if (_EnterExitCosts.ChoiceThree == 1)
  8360. {
  8361. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8362. table1Row = dac1.Count;
  8363. #region 填充word表格内容
  8364. for (int i = 0; i < dac1.Count; i++)
  8365. {
  8366. var dac = dac1[i];
  8367. if (dac == null) continue;
  8368. builder.MoveToCell(0, i, 0, 0);
  8369. builder.Write("第" + dac.Days.ToString() + "晚:");
  8370. builder.MoveToCell(0, i, 1, 0);
  8371. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8372. //builder.Write(dac.Place == null ? "" : dac.Place);
  8373. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8374. builder.MoveToCell(0, i, 2, 0);
  8375. builder.Write("费用标准:");
  8376. string curr = "";
  8377. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8378. if (currData != null)
  8379. {
  8380. curr = currData.Name;
  8381. }
  8382. builder.MoveToCell(0, i, 3, 0);
  8383. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8384. builder.MoveToCell(0, i, 4, 0);
  8385. builder.Write("费用小计:");
  8386. builder.MoveToCell(0, i, 5, 0);
  8387. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8388. }
  8389. #endregion
  8390. }
  8391. else dic.Add("SubZS", "0.00");
  8392. //删除多余行
  8393. while (table1.Rows.Count > table1Row)
  8394. {
  8395. table1.Rows.RemoveAt(table1Row);
  8396. }
  8397. //伙食费
  8398. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8399. if (_EnterExitCosts.ChoiceFour == 1)
  8400. {
  8401. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8402. table2Row = dac2.Count;
  8403. #region 填充word表格内容
  8404. for (int i = 0; i < dac2.Count; i++)
  8405. {
  8406. var dac = dac2[i];
  8407. if (dac == null) continue;
  8408. builder.MoveToCell(1, i, 0, 0);
  8409. builder.Write("第" + dac.Days.ToString() + "天:");
  8410. builder.MoveToCell(1, i, 1, 0);
  8411. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8412. builder.MoveToCell(1, i, 2, 0);
  8413. builder.Write("费用标准:");
  8414. string curr = "";
  8415. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8416. if (currData != null)
  8417. {
  8418. curr = currData.Name;
  8419. }
  8420. builder.MoveToCell(1, i, 3, 0);
  8421. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8422. builder.MoveToCell(1, i, 4, 0);
  8423. builder.Write("费用小计:");
  8424. builder.MoveToCell(1, i, 5, 0);
  8425. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8426. }
  8427. #endregion
  8428. }
  8429. else dic.Add("SubHS", "0.00");
  8430. //删除多余行
  8431. while (table2.Rows.Count > table2Row)
  8432. {
  8433. table2.Rows.RemoveAt(table2Row);
  8434. }
  8435. //公杂费
  8436. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8437. if (_EnterExitCosts.ChoiceFive == 1)
  8438. {
  8439. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8440. table3Row = dac3.Count;
  8441. #region 填充word表格内容
  8442. for (int i = 0; i < dac3.Count; i++)
  8443. {
  8444. var dac = dac3[i];
  8445. if (dac == null) continue;
  8446. builder.MoveToCell(2, i, 0, 0);
  8447. builder.Write("第" + dac.Days.ToString() + "天:");
  8448. builder.MoveToCell(2, i, 1, 0);
  8449. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8450. builder.MoveToCell(2, 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(2, i, 3, 0);
  8459. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8460. builder.MoveToCell(2, i, 4, 0);
  8461. builder.Write("费用小计:");
  8462. builder.MoveToCell(2, i, 5, 0);
  8463. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8464. }
  8465. //删除多余行
  8466. while (table3.Rows.Count > table3Row)
  8467. {
  8468. table3.Rows.RemoveAt(table3Row);
  8469. }
  8470. #endregion
  8471. }
  8472. else dic.Add("SubGZF", "0.00");
  8473. //删除多余行
  8474. while (table3.Rows.Count > table3Row)
  8475. {
  8476. table3.Rows.RemoveAt(table3Row);
  8477. }
  8478. //培训费
  8479. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8480. if (_EnterExitCosts.ChoiceSix == 1)
  8481. {
  8482. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8483. dic.Add("SubPX", pxStr);
  8484. table4Row = dac4.Count;
  8485. #region 填充word表格内容
  8486. for (int i = 0; i < dac4.Count; i++)
  8487. {
  8488. var dac = dac4[i];
  8489. if (dac == null) continue;
  8490. builder.MoveToCell(3, i, 0, 0);
  8491. builder.Write("第" + dac.Days.ToString() + "天:");
  8492. builder.MoveToCell(3, i, 1, 0);
  8493. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8494. builder.MoveToCell(3, i, 2, 0);
  8495. builder.Write("费用标准:");
  8496. string curr = "";
  8497. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8498. if (currData != null)
  8499. {
  8500. curr = currData.Name;
  8501. }
  8502. builder.MoveToCell(3, i, 3, 0);
  8503. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8504. builder.MoveToCell(3, i, 4, 0);
  8505. builder.Write("费用小计:");
  8506. builder.MoveToCell(3, i, 5, 0);
  8507. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8508. }
  8509. #endregion
  8510. }
  8511. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8512. //删除多余行
  8513. while (table4.Rows.Count > table4Row)
  8514. {
  8515. table4.Rows.RemoveAt(table4Row);
  8516. }
  8517. //其他费用
  8518. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8519. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8520. {
  8521. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8522. dic.Add("titleQi", qtStr);
  8523. table5Row = dac5.Count;
  8524. #region 填充word表格内容
  8525. for (int i = 0; i < dac5.Count; i++)
  8526. {
  8527. var dac = dac5[i];
  8528. if (dac == null) continue;
  8529. builder.MoveToCell(4, i, 0, 0);
  8530. builder.Write("第" + dac.Index.ToString() + "项:");
  8531. builder.MoveToCell(4, i, 1, 0);
  8532. builder.Write(dac.itemName);
  8533. builder.MoveToCell(4, i, 2, 0);
  8534. builder.Write("费用标准:");
  8535. builder.MoveToCell(4, i, 3, 0);
  8536. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8537. builder.MoveToCell(4, i, 4, 0);
  8538. builder.Write("费用小计:");
  8539. builder.MoveToCell(4, i, 5, 0);
  8540. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8541. builder.MoveToCell(4, i, 6, 0);
  8542. builder.Write("备注:");
  8543. builder.MoveToCell(4, i, 7, 0);
  8544. builder.Write(dac.Remark);
  8545. }
  8546. #endregion
  8547. }
  8548. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8549. //删除多余行
  8550. while (table5.Rows.Count > table5Row)
  8551. {
  8552. table5.Rows.RemoveAt(table5Row);
  8553. }
  8554. //加上其他费用
  8555. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8556. decimal subJJC = 0.00M,
  8557. subGWC = 0.00M,
  8558. subTDC = 0.00M;
  8559. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8560. string totalLabel = string.Format("全部费用总计:");
  8561. //经济舱
  8562. if (_EnterExitCosts.SumJJC == 1)
  8563. {
  8564. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8565. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8566. }
  8567. //公务舱
  8568. if (_EnterExitCosts.SumGWC == 1)
  8569. {
  8570. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8571. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8572. }
  8573. //头等舱
  8574. if (_EnterExitCosts.SumTDC == 1)
  8575. {
  8576. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8577. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8578. }
  8579. //TotalLabel
  8580. dic.Add("TotalLabel", totalLabel);
  8581. #region 填充word模板书签内容
  8582. foreach (var key in dic.Keys)
  8583. {
  8584. Bookmark bookmark = doc.Range.Bookmarks[key];
  8585. if (bookmark != null)
  8586. {
  8587. builder.MoveToBookmark(key);
  8588. builder.Write(dic[key]);
  8589. }
  8590. }
  8591. #endregion
  8592. //文件名
  8593. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8594. strFileName = CommonFun.ValidFileName(strFileName);
  8595. AsposeHelper.removewatermark_v2180();
  8596. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8597. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8598. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8599. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8600. }
  8601. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8602. {
  8603. //获取模板
  8604. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8605. //载入模板
  8606. Document doc = new Document(tempPath);
  8607. DocumentBuilder builder = new DocumentBuilder(doc);
  8608. Dictionary<string, string> dic = new Dictionary<string, string>();
  8609. string returnCodeLabel = string.Empty;
  8610. if (nationalTravelFeeData.Any())
  8611. {
  8612. List<string> list = new List<string>();
  8613. foreach (var item in nationalTravelFeeData)
  8614. {
  8615. list.Add($"{item.Country}({item.City})");
  8616. }
  8617. list = list.Distinct().ToList();
  8618. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8619. }
  8620. var countryLabel = string.Empty;
  8621. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8622. if (countryData.Any())
  8623. {
  8624. countryLabel = string.Join("、", countryData);
  8625. }
  8626. dic.Add("ReturnCodeAir", returnCodeLabel);
  8627. dic.Add("VisitStartDate", "-");
  8628. dic.Add("VisitEndDate", "-");
  8629. dic.Add("Day", "-");
  8630. dic.Add("VisitCountry", countryLabel);
  8631. dic.Add("ClientUnit", "-");
  8632. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8633. //dic.Add("Names", Names);
  8634. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8635. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8636. decimal dac1totalPrice = 0.00M;
  8637. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8638. foreach (var dac in dac1)
  8639. {
  8640. if (dac.SubTotal == 0.00M)
  8641. {
  8642. continue;
  8643. }
  8644. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8645. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8646. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8647. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8648. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8649. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8650. builder.Write(currency);//币种
  8651. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8652. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8653. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8654. builder.Write("");//人数
  8655. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8656. builder.Write("");//天数
  8657. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8658. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8659. builder.MoveToCell(0, accommodationStartIndex, 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, accommodationStartIndex, 8, 0);
  8664. decimal rbmPrice = dac.SubTotal;
  8665. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8666. accommodationStartIndex++;
  8667. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8668. }
  8669. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8670. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8671. {
  8672. table1.Rows.RemoveAt(i - 1);
  8673. foodandotherStartIndex--;
  8674. }
  8675. if (dac2.Count == dac3.Count)//国家 币种 金额
  8676. {
  8677. for (int i = 0; i < dac2.Count; i++)
  8678. {
  8679. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8680. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8681. }
  8682. }
  8683. decimal dac2totalPrice = 0.00M;
  8684. foreach (var dac in dac2)
  8685. {
  8686. if (dac.SubTotal == 0)
  8687. {
  8688. continue;
  8689. }
  8690. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8691. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8692. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8693. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8694. builder.Write(currency);//币种
  8695. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8696. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8697. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8698. builder.Write("");//人数
  8699. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8700. builder.Write("");//天数
  8701. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8702. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8703. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8704. decimal rate = 0.00M;
  8705. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8706. builder.Write(rate.ToString("#0.0000"));//汇率
  8707. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8708. decimal rbmPrice = dac.SubTotal;
  8709. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8710. foodandotherStartIndex++;
  8711. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8712. }
  8713. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8714. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8715. {
  8716. table1.Rows.RemoveAt(i - 1);
  8717. }
  8718. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8719. string otherFeeStr = "";
  8720. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8721. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8722. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8723. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8724. foreach (var otherInfo in dac5)
  8725. {
  8726. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8727. }
  8728. #endregion
  8729. if (otherFeeStr.Length > 0)
  8730. {
  8731. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8732. otherFeeStr = $"({otherFeeStr})";
  8733. dic.Add("OtherFeeStr", otherFeeStr);
  8734. }
  8735. //总计
  8736. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8737. //国际旅费
  8738. string outsideAir = string.Empty;
  8739. string allPriceAir = string.Empty;
  8740. if (_EnterExitCosts.SumJJC == 1)
  8741. {
  8742. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8743. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8744. }
  8745. if (_EnterExitCosts.SumGWC == 1)
  8746. {
  8747. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8748. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8749. }
  8750. if (_EnterExitCosts.SumTDC == 1)
  8751. {
  8752. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8753. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8754. }
  8755. dic.Add("InTravelPrice", $"({outsideAir})");
  8756. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8757. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8758. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8759. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8760. foreach (var key in dic.Keys)
  8761. {
  8762. builder.MoveToBookmark(key);
  8763. builder.Write(dic[key]);
  8764. }
  8765. //模板文件名
  8766. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8767. strFileName = CommonFun.ValidFileName(strFileName);
  8768. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8769. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8770. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8771. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8772. }
  8773. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8774. {
  8775. //获取模板
  8776. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8777. //载入模板
  8778. WorkbookDesigner designer = new WorkbookDesigner();
  8779. designer.Workbook = new Workbook(tempPath);
  8780. Dictionary<string, string> dic = new Dictionary<string, string>();
  8781. string returnCodeLabel = string.Empty;
  8782. if (nationalTravelFeeData.Any())
  8783. {
  8784. List<string> list = new List<string>();
  8785. foreach (var item in nationalTravelFeeData)
  8786. {
  8787. list.Add($"{item.Country}({item.City})");
  8788. }
  8789. list = list.Distinct().ToList();
  8790. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8791. }
  8792. var countryLabel = string.Empty;
  8793. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8794. if (countryData.Any())
  8795. {
  8796. countryLabel = string.Join("、", countryData);
  8797. }
  8798. dic.Add("ReturnCodeAir", returnCodeLabel);
  8799. dic.Add("VisitStartDate", "-");
  8800. dic.Add("VisitEndDate", "-");
  8801. dic.Add("Day", "0");
  8802. dic.Add("VisitCountry", countryLabel);
  8803. dic.Add("ClientUnit", "-");
  8804. designer.SetDataSource("ClientUnit", "-");
  8805. designer.SetDataSource("VisitCountry", countryLabel);
  8806. designer.SetDataSource("Group", "-");
  8807. designer.SetDataSource("ClientUnitTitle", "-");
  8808. designer.SetDataSource("Name", "-");
  8809. designer.SetDataSource("VisitStartDate", "-");
  8810. designer.SetDataSource("Day", "0");
  8811. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8812. designer.SetDataSource("ReturnCodeAir", "-");
  8813. int startIndex = 10;
  8814. const int startIndexcopy = 10;
  8815. if (dac2.Count == dac3.Count)//国家 币种 金额
  8816. {
  8817. for (int i = 0; i < dac2.Count; i++)
  8818. {
  8819. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8820. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8821. }
  8822. }
  8823. DataTable dtdac1 = new DataTable();
  8824. List<string> place = new List<string>();
  8825. dtdac1.Columns.AddRange(new DataColumn[] {
  8826. new DataColumn(){ ColumnName = "city"},
  8827. new DataColumn(){ ColumnName = "curr"},
  8828. new DataColumn(){ ColumnName = "criterion"},
  8829. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8830. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8831. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8832. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8833. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8834. });
  8835. DataTable dtdac2 = new DataTable();
  8836. dtdac2.Columns.AddRange(new DataColumn[] {
  8837. new DataColumn(){ ColumnName = "city"},
  8838. new DataColumn(){ ColumnName = "curr"},
  8839. new DataColumn(){ ColumnName = "criterion"},
  8840. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8841. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8842. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8843. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8844. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8845. });
  8846. dtdac1.TableName = "tb1";
  8847. dtdac2.TableName = "tb2";
  8848. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8849. foreach (var item in dac1)
  8850. {
  8851. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8852. if (place.Contains(item.Place))
  8853. {
  8854. continue;
  8855. }
  8856. DataRow row = dtdac1.NewRow();
  8857. row["city"] = item.Place;
  8858. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8859. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8860. row["curr"] = currency;
  8861. row["rate"] = rate.ToString("#0.0000");
  8862. row["criterion"] = item.Cost.ToString("#0.00");
  8863. row["number"] = 1;
  8864. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8865. //row["costRMB"] = rbmPrice;
  8866. dtdac1.Rows.Add(row);
  8867. place.Add(item.Place);
  8868. }
  8869. place = new List<string>();
  8870. foreach (var item in dac2)
  8871. {
  8872. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8873. if (place.Contains(item.Place))
  8874. {
  8875. continue;
  8876. }
  8877. DataRow row = dtdac2.NewRow();
  8878. row["city"] = item.Place;
  8879. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8880. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8881. row["curr"] = currency;
  8882. row["rate"] = rate.ToString("#0.0000");
  8883. row["criterion"] = item.Cost.ToString("#0.00");
  8884. row["number"] = 1;
  8885. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8886. //row["cost"] = item.SubTotal;
  8887. //row["costRMB"] = rbmPrice;
  8888. dtdac2.Rows.Add(row);
  8889. place.Add(item.Place);
  8890. //dac2totalPrice += rbmPrice;
  8891. }
  8892. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8893. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8894. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8895. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8896. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8897. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8898. string cell4Str1 = string.Empty;
  8899. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8900. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8901. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8902. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8903. string cellStr = $" 5.其他费用(";
  8904. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8905. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8906. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8907. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8908. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8909. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8910. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8911. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8912. foreach (var otherInfo in dac5)
  8913. {
  8914. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8915. }
  8916. #endregion
  8917. if (cellStr.Length > 8)
  8918. {
  8919. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8920. }
  8921. cellStr += ")";
  8922. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8923. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8924. decimal pxFee = dac4.Sum(it => it.Cost);
  8925. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8926. string celllastStr1 = "";
  8927. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8928. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8929. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8930. celllastStr1 += $",国际旅费 元";
  8931. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8932. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8933. designer.SetDataSource("cell4Str", cell4Str);
  8934. designer.SetDataSource("cellStr", cellStr);
  8935. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8936. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8937. designer.SetDataSource("celllastStr", celllastStr);
  8938. Workbook wb = designer.Workbook;
  8939. var sheet = wb.Worksheets[0];
  8940. //绑定datatable数据集
  8941. designer.SetDataSource(dtdac1);
  8942. designer.SetDataSource(dtdac2);
  8943. designer.Process();
  8944. var rowStart = dtdac1.Rows.Count;
  8945. while (rowStart > 0)
  8946. {
  8947. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8948. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8949. startIndex++;
  8950. rowStart--;
  8951. }
  8952. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8953. startIndex += 1; //总计行
  8954. rowStart = dtdac2.Rows.Count;
  8955. while (rowStart > 0)
  8956. {
  8957. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8958. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8959. startIndex++;
  8960. rowStart--;
  8961. }
  8962. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8963. wb.CalculateFormula(true);
  8964. //模板文件名
  8965. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8966. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8967. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8968. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8969. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8970. }
  8971. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8972. {
  8973. //获取模板
  8974. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8975. //载入模板
  8976. Document doc = new Document(tempPath);
  8977. DocumentBuilder builder = new DocumentBuilder(doc);
  8978. Dictionary<string, string> dic = new Dictionary<string, string>();
  8979. dic.Add("GroupName", "-");
  8980. dic.Add("ClientUnit", "-");
  8981. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8982. //string missionLeaderJob = "";//负责人job
  8983. //int groupNumber = 0; //团人数
  8984. dic.Add("MissionLeader", "-"); //团负责人
  8985. dic.Add("MissionLeaderJob", "-"); //团负责人job
  8986. dic.Add("GroupNumber", "0"); //团人数
  8987. dic.Add("Day", "0");
  8988. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8989. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8990. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8991. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8992. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8993. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8994. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8995. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8996. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8997. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8998. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8999. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  9000. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  9001. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  9002. //其他费用
  9003. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  9004. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  9005. //其他费用合计
  9006. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  9007. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  9008. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  9009. //公务舱合计
  9010. //国际旅费
  9011. //string outsideJJ = "";
  9012. //string allPriceJJ = "";
  9013. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  9014. {
  9015. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9016. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  9017. }
  9018. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  9019. {
  9020. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  9021. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  9022. }
  9023. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  9024. {
  9025. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  9026. dic.Add("AirFeeTotal", airFeeTotalStr);
  9027. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  9028. dic.Add("FeeTotal", feeTotalStr);
  9029. }
  9030. foreach (var key in dic.Keys)
  9031. {
  9032. builder.MoveToBookmark(key);
  9033. builder.Write(dic[key]);
  9034. }
  9035. //模板文件名
  9036. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  9037. strFileName = CommonFun.ValidFileName(strFileName);
  9038. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9039. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9040. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9041. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9042. }
  9043. }
  9044. else if (dto.ExportType == 2) //表格
  9045. {
  9046. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9047. }
  9048. else if (dto.ExportType == 3)
  9049. {
  9050. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9051. }
  9052. return Ok(JsonView(400, "只可导出明细表!", ""));
  9053. }
  9054. catch (Exception ex)
  9055. {
  9056. return Ok(JsonView(400, ex.Message, ""));
  9057. }
  9058. }
  9059. /// <summary>
  9060. /// 获取三公费用标准city
  9061. /// </summary>
  9062. /// <param name="placeData"></param>
  9063. /// <param name="nationalTravelFeeId"></param>
  9064. /// <returns></returns>
  9065. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9066. {
  9067. string _city = string.Empty;
  9068. if (!placeData.Any()) return _city;
  9069. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9070. if (data == null) return _city;
  9071. string country = data.Country;
  9072. string city = data.City;
  9073. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9074. else _city = city;
  9075. return _city;
  9076. }
  9077. /// <summary>
  9078. /// 团组模块 - 出入境费用-草稿 - 一键清空
  9079. /// </summary>
  9080. /// <returns></returns>
  9081. [HttpPost]
  9082. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9084. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  9085. {
  9086. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9087. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9088. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  9089. if (_view.Code == 0)
  9090. {
  9091. return Ok(JsonView(true, "操作成功"));
  9092. }
  9093. return Ok(JsonView(false, "操作失败"));
  9094. }
  9095. /// <summary>
  9096. /// 团组模块 - 出入境费用-草稿 - 子项删除
  9097. /// </summary>
  9098. /// <returns></returns>
  9099. [HttpPost]
  9100. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9102. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  9103. {
  9104. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  9105. if (data.Code != 0)
  9106. {
  9107. return Ok(JsonView(false, data.Msg));
  9108. }
  9109. return Ok(JsonView(true, "操作成功!", data.Data));
  9110. }
  9111. /// <summary>
  9112. /// 三公其他费用草稿 删除
  9113. /// </summary>
  9114. /// <param name="dto"></param>
  9115. /// <returns></returns>
  9116. [HttpPost]
  9117. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9118. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  9119. {
  9120. var jw = JsonView(false, "删除失败!");
  9121. var data = new Grp_DayOtherPriceDraft()
  9122. {
  9123. Id = dto.Id,
  9124. IsDel = 1,
  9125. DeleteUserId = dto.DeleteUserId,
  9126. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9127. };
  9128. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9129. if (del > 0)
  9130. {
  9131. jw.Code = 200;
  9132. jw.Msg = "删除成功!";
  9133. }
  9134. return Ok(jw);
  9135. }
  9136. /// <summary>
  9137. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  9138. /// </summary>
  9139. /// <returns></returns>
  9140. [HttpPost]
  9141. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  9142. {
  9143. var jw = JsonView(false);
  9144. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  9145. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  9146. jw.Code = StatusCodes.Status200OK;
  9147. jw.Msg = "操作成功!";
  9148. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  9149. return Ok(jw);
  9150. }
  9151. /// <summary>
  9152. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  9153. /// </summary>
  9154. /// <param name="dto"></param>
  9155. /// <returns></returns>
  9156. [HttpPost]
  9157. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  9158. {
  9159. int userId = dto.UserId,
  9160. portId = dto.PortType,
  9161. groupId = dto.GroupId,
  9162. draftId = dto.DraftId;
  9163. _portTypeData.Add(1);
  9164. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9165. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  9166. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  9167. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  9168. _sqlSugar.BeginTran();
  9169. try
  9170. {
  9171. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9172. if (draftDatas == null)
  9173. {
  9174. _sqlSugar.RollbackTran();
  9175. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9176. }
  9177. //验证可覆盖已有数据 两边创建人需为同一人;
  9178. int draftCreateUserId = draftDatas.CreateUserId,
  9179. formalCreateUserId = 0;
  9180. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9181. if (formalData != null)
  9182. {
  9183. formalCreateUserId = formalData.CreateUserId;
  9184. if (draftCreateUserId != formalCreateUserId)
  9185. {
  9186. _sqlSugar.RollbackTran();
  9187. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9188. }
  9189. }
  9190. //默认添加查看、编辑权限(创建人、自己)
  9191. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9192. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9193. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9194. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9195. newExterData.DiId = groupId;
  9196. newExterData.CreateUserId = userId;
  9197. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9198. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9199. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9200. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9201. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9202. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9203. //数据如果存在执行删除
  9204. if (enterExitCostInfo != null)
  9205. {
  9206. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9207. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9208. .Where(x => x.Id == enterExitCostInfo.Id)
  9209. .ExecuteCommand();
  9210. _sqlSugar.Updateable<Grp_DayAndCost>()
  9211. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9212. .Where(x => x.DiId == groupId)
  9213. .ExecuteCommand();
  9214. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9215. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9216. .Where(x => x.Diid == groupId)
  9217. .ExecuteCommand();
  9218. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9219. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9220. .Where(x => x.GroupId == groupId)
  9221. .ExecuteCommand();
  9222. }
  9223. //执行insert
  9224. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9225. if (insertId < 1)
  9226. {
  9227. _sqlSugar.RollbackTran();
  9228. return Ok(JsonView(false, "草稿数据导入失败!"));
  9229. }
  9230. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9231. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9232. #region 默认添加权限
  9233. #endregion
  9234. _sqlSugar.CommitTran();
  9235. //执行操作之后
  9236. //生成默认文件pdf并且通知人员
  9237. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9238. {
  9239. DiId = groupId,
  9240. ExportType = 1,
  9241. SubTypeId = 1005
  9242. }, "pdf");
  9243. //发送通知
  9244. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9245. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9246. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9247. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9248. //汇率信息记录
  9249. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9250. return Ok(JsonView(true));
  9251. }
  9252. catch (Exception ex)
  9253. {
  9254. _sqlSugar.RollbackTran();
  9255. return Ok(JsonView(false, ex.Message));
  9256. }
  9257. }
  9258. #endregion
  9259. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9260. /// <summary>
  9261. /// 获取币种基础数据(含逻辑处理)
  9262. /// </summary>
  9263. /// <returns></returns>
  9264. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9265. {
  9266. return await GeneralMethod.EnterExitCostInitRate();
  9267. }
  9268. /// <summary>
  9269. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9270. /// </summary>
  9271. /// <returns></returns>
  9272. [HttpPost]
  9273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9274. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9275. {
  9276. //验证城市归属并给默认值
  9277. int provinceId = dto.ProvinceId;
  9278. if (provinceId < 1) provinceId = 122;
  9279. var dataSource = await _sqlSugar
  9280. .Queryable<Sys_SetData>()
  9281. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9282. .ToListAsync();
  9283. var fileTypes = new List<EecSetDataInfoView>();
  9284. //三公费用-Word明细类型
  9285. var wordTypeData = dataSource
  9286. .Where(it => it.STid == 72)
  9287. .Select(x => new EecSetDataInfoView
  9288. {
  9289. ParentId = 1,
  9290. Id = x.Id,
  9291. Name = x.Name
  9292. })
  9293. .ToArray();
  9294. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9295. var excelTypeData = dataSource
  9296. .Where(it => it.STid == 73)
  9297. .Select(x => new EecSetDataInfoView
  9298. {
  9299. ParentId = 2,
  9300. Id = x.Id,
  9301. Name = x.Name
  9302. })
  9303. .ToArray();
  9304. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9305. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9306. fileTypes.Add(groupNameList);
  9307. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9308. //默认币种显示
  9309. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9310. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9311. return Ok(JsonView(true, "查询成功!", new
  9312. {
  9313. FileTypeData = fileTypes,
  9314. CurrencyInit = _currencyInfos,
  9315. viewPermissionData = viewPermissionData
  9316. }));
  9317. }
  9318. /// <summary>
  9319. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9320. /// </summary>
  9321. /// <returns></returns>
  9322. [HttpPost]
  9323. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9324. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9325. {
  9326. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9327. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9328. RefAsync<int> total = 0;
  9329. int diId = 0;
  9330. var status = int.TryParse(dto.GroupName, out diId);
  9331. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9332. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9333. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9334. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9335. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9336. .OrderByDescending(x => x.VisitStartDate)
  9337. .Select(x => new EnterExitCostMobileGroupView()
  9338. {
  9339. Id = x.Id,
  9340. GroupName = x.TeamName,
  9341. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9342. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9343. ProvinceId = x.CityId
  9344. })
  9345. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9346. //处理省份Id
  9347. if (data.Any())
  9348. {
  9349. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9350. if (provCityDatas.Any())
  9351. {
  9352. foreach (var item in data)
  9353. {
  9354. var provinceId = item.ProvinceId;
  9355. var isDefualtVal = true;
  9356. if (provinceId > 0)
  9357. {
  9358. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9359. if (parentId != null)
  9360. {
  9361. isDefualtVal = false;
  9362. item.ProvinceId = (int)parentId;
  9363. }
  9364. }
  9365. if (isDefualtVal)
  9366. {
  9367. item.ProvinceId = 122; //默认四川
  9368. }
  9369. }
  9370. }
  9371. }
  9372. //处理是否显示
  9373. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9374. {
  9375. foreach (var item in data)
  9376. {
  9377. item.IsView = true;
  9378. }
  9379. }
  9380. return Ok(JsonView(true, "查询成功!", data, total));
  9381. }
  9382. /// <summary>
  9383. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9384. /// </summary>
  9385. /// <returns></returns>
  9386. [HttpPost]
  9387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9388. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9389. {
  9390. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9391. RefAsync<int> total = 0;
  9392. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9393. .Where(x => x.IsDel == 0 && x.STid == 66)
  9394. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9395. .Select(x => new
  9396. {
  9397. id = x.Id,
  9398. name = x.Name,
  9399. remark = x.Remark,
  9400. })
  9401. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9402. return Ok(JsonView(true, "查询成功!", data, total));
  9403. }
  9404. /// <summary>
  9405. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9406. /// </summary>
  9407. /// <returns></returns>
  9408. [HttpPost]
  9409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9410. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9411. {
  9412. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9413. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9414. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9415. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9416. var groupOtherRateData = groupRateData.TeamRates;
  9417. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9418. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9419. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9420. groupOtherRateData = groupOtherRateData
  9421. .Select(x => new TeamRateDescAddCurrencyIdView
  9422. {
  9423. CurrencyId = x.CurrencyId,
  9424. CurrencyName = x.CurrencyName,
  9425. CurrencyCode = x.CurrencyCode,
  9426. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9427. }).ToList();
  9428. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9429. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9430. }
  9431. /// <summary>
  9432. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9433. /// </summary>
  9434. /// <returns></returns>
  9435. [HttpPost]
  9436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9437. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9438. {
  9439. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9440. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9441. var tipsData = new List<int>() { 1, 2, 3 };
  9442. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9443. if (dto.TipsType == 1)
  9444. {
  9445. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9446. }
  9447. else if (dto.TipsType == 2)
  9448. {
  9449. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9450. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9451. }
  9452. else if (dto.TipsType == 3)
  9453. {
  9454. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9455. return Ok(JsonView(true, "查询成功!", airData));
  9456. }
  9457. return Ok(JsonView(false));
  9458. }
  9459. /// <summary>
  9460. /// 团组模块 - 出入境国家费用标准-移动端 List
  9461. /// </summary>
  9462. /// <returns></returns>
  9463. [HttpPost]
  9464. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9465. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9466. {
  9467. Stopwatch sw = new Stopwatch();
  9468. sw.Start();
  9469. int provinceId = dto.ProvinceId;
  9470. if (provinceId < 1) provinceId = 122; // 默认四川
  9471. RefAsync<int> total = 0;
  9472. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9473. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9474. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9475. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9476. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9477. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9478. .Select((ntf, sd, u, sd1) => new
  9479. {
  9480. Id = ntf.Id,
  9481. Area = $"{ntf.Country}-{ntf.City}",
  9482. Currency = ntf.Currency,
  9483. CurrencyCode = sd.Name,
  9484. CurrencyName = sd.Remark,
  9485. RoomCost = ntf.RoomCost,
  9486. FoodCost = ntf.FoodCost,
  9487. PublicCost = ntf.PublicCost,
  9488. TrainCost = ntf.TrainCost,
  9489. LastUpdateUserId = ntf.LastUpdateUserId,
  9490. LastUpdateUserName = u.CnName,
  9491. LastUpdateTime = ntf.LastUpdateTime
  9492. })
  9493. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9494. sw.Stop();
  9495. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9496. }
  9497. /// <summary>
  9498. /// 团组模块 - 出入境费用-移动端 - Info
  9499. /// </summary>
  9500. /// <returns></returns>
  9501. [HttpPost]
  9502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9503. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9504. {
  9505. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9506. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9507. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9508. return Ok(data);
  9509. }
  9510. /// <summary>
  9511. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9512. /// </summary>
  9513. /// <returns></returns>
  9514. [HttpPost]
  9515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9516. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9517. {
  9518. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9519. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9520. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9521. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9522. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9523. mobileInfo.DiId = dto.DiId;
  9524. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9525. if (eecInfo == null) return Ok(mobileInfo);
  9526. //验证查看权限
  9527. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9528. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9529. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9530. mobileInfo.IsAssignPerm = isSet;
  9531. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9532. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9533. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9534. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9535. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9536. {
  9537. SubId = dac.Id,
  9538. DiId = dac.DiId,
  9539. Type = dac.Type,
  9540. Days = dac.Days,
  9541. NationalTravelFeeId = dac.NationalTravelFeeId,
  9542. Arae = $"{ntf.Country}-{ntf.City}",
  9543. Cost = dac.Cost,
  9544. Currency = dac.Currency,
  9545. CurrencyName = sd.Name,
  9546. SubTotal = dac.SubTotal,
  9547. })
  9548. .ToList();
  9549. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9550. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9551. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9552. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9553. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9554. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9555. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9556. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9557. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9558. //其他款项
  9559. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9560. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9561. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9562. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9563. .OrderBy((dop, sd1, sd2) => dop.Index)
  9564. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9565. {
  9566. SubId = dop.Id,
  9567. DiId = dop.Diid,
  9568. Index = dop.Index,
  9569. SetDataId = dop.SetDataId,
  9570. SetDataName = sd1.Name,
  9571. Cost = dop.Cost,
  9572. Currency = dop.Currency,
  9573. CurrencyName = sd2.Remark,
  9574. SubTotal = dop.SubTotal,
  9575. Remark = dop.Remark,
  9576. })
  9577. .ToArray();
  9578. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9579. return Ok(mobileInfo);
  9580. }
  9581. /// <summary>
  9582. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9583. /// </summary>
  9584. /// <returns></returns>
  9585. [HttpPost]
  9586. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9587. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9588. {
  9589. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9590. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9591. //验证查看权限
  9592. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9593. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9594. var userIds = await _sqlSugar
  9595. .Queryable<Grp_EnterExitCostPermission>()
  9596. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9597. .Select(x => x.UserId)
  9598. .ToArrayAsync();
  9599. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9600. var perUsersView = new List<dynamic>();
  9601. foreach (var item in perUsers)
  9602. {
  9603. bool isView1 = false;
  9604. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9605. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9606. }
  9607. return Ok(JsonView(perUsersView));
  9608. }
  9609. /// <summary>
  9610. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9611. /// </summary>
  9612. /// <returns></returns>
  9613. [HttpPost]
  9614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9615. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9616. {
  9617. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9618. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9619. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9620. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9621. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9622. //验证查看权限
  9623. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9624. //if (!isView) return Ok(JsonView(false, msg));
  9625. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9626. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9627. var subType = dto.SubType;
  9628. if (subType == 1) //1:境内费用
  9629. {
  9630. var oneData = new ChoiceOneMobileSubInfoView()
  9631. {
  9632. Id = eecInfo.Id,
  9633. ChoiceOne = eecInfo.ChoiceOne,
  9634. ChoiceOneTotalCost = eecInfo.InsidePay,
  9635. Visa = eecInfo.Visa,
  9636. VisaRemark = eecInfo.VisaRemark,
  9637. YiMiao = eecInfo.YiMiao,
  9638. HeSuan = eecInfo.HeSuan,
  9639. Service = eecInfo.Service,
  9640. Ticket = eecInfo.Ticket,
  9641. Safe = eecInfo.Safe,
  9642. FirstItemRemark = eecInfo.FirstItemRemark
  9643. };
  9644. return Ok(JsonView(oneData));
  9645. }
  9646. else if (subType == 2) //2:国际旅费
  9647. {
  9648. var twoData = new ChoiceTwoMobileSubInfoView()
  9649. {
  9650. Id = eecInfo.Id,
  9651. ChoiceTwoJJ = eecInfo.SumJJC,
  9652. OutsideJJPay = eecInfo.OutsideJJPay,
  9653. ChoiceTwoGW = eecInfo.SumGWC,
  9654. OutsideGWPay = eecInfo.OutsideGWPay,
  9655. ChoiceTwoTD = eecInfo.SumTDC,
  9656. OutsideTDPay = eecInfo.OutsideTDPay,
  9657. AirJJ = eecInfo.AirJJ,
  9658. AirGW = eecInfo.AirGW,
  9659. AirTD = eecInfo.AirTD,
  9660. CityTranffic = eecInfo.CityTranffic,
  9661. TwoItemRemark = eecInfo.TwoItemRemark
  9662. };
  9663. return Ok(JsonView(twoData));
  9664. }
  9665. else if (subType == 3) //3:住宿费
  9666. {
  9667. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9668. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9669. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9670. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9671. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9672. {
  9673. SubId = dac.Id,
  9674. DiId = dac.DiId,
  9675. Type = dac.Type,
  9676. Days = dac.Days,
  9677. NationalTravelFeeId = dac.NationalTravelFeeId,
  9678. Arae = $"{ntf.Country}-{ntf.City}",
  9679. Cost = dac.Cost,
  9680. Currency = dac.Currency,
  9681. CurrencyName = sd.Name,
  9682. SubTotal = dac.SubTotal,
  9683. })
  9684. .ToArray();
  9685. var data = new ChoiceMobileSubInfo3To6View()
  9686. {
  9687. ParentId = eecInfo.Id,
  9688. Choice = eecInfo.ChoiceThree,
  9689. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9690. Details = dayAndCostDatas
  9691. };
  9692. return Ok(JsonView(data));
  9693. }
  9694. else if (subType == 4) //4:伙食费
  9695. {
  9696. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9697. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9698. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9699. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9700. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9701. {
  9702. SubId = dac.Id,
  9703. DiId = dac.DiId,
  9704. Type = dac.Type,
  9705. Days = dac.Days,
  9706. NationalTravelFeeId = dac.NationalTravelFeeId,
  9707. Arae = $"{ntf.Country}-{ntf.City}",
  9708. Cost = dac.Cost,
  9709. Currency = dac.Currency,
  9710. CurrencyName = sd.Name,
  9711. SubTotal = dac.SubTotal,
  9712. })
  9713. .ToArray();
  9714. var data = new ChoiceMobileSubInfo3To6View()
  9715. {
  9716. ParentId = eecInfo.Id,
  9717. Choice = eecInfo.ChoiceFour,
  9718. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9719. Details = dayAndCostDatas
  9720. };
  9721. return Ok(JsonView(data));
  9722. }
  9723. else if (subType == 5) //5:公杂费
  9724. {
  9725. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9726. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9727. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9728. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9729. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9730. {
  9731. SubId = dac.Id,
  9732. DiId = dac.DiId,
  9733. Type = dac.Type,
  9734. Days = dac.Days,
  9735. NationalTravelFeeId = dac.NationalTravelFeeId,
  9736. Arae = $"{ntf.Country}-{ntf.City}",
  9737. Cost = dac.Cost,
  9738. Currency = dac.Currency,
  9739. CurrencyName = sd.Name,
  9740. SubTotal = dac.SubTotal,
  9741. })
  9742. .ToArray();
  9743. var data = new ChoiceMobileSubInfo3To6View()
  9744. {
  9745. ParentId = eecInfo.Id,
  9746. Choice = eecInfo.ChoiceFive,
  9747. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9748. Details = dayAndCostDatas
  9749. };
  9750. return Ok(JsonView(data));
  9751. }
  9752. else if (subType == 6) //6:培训费
  9753. {
  9754. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9755. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9756. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9757. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9758. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9759. {
  9760. SubId = dac.Id,
  9761. DiId = dac.DiId,
  9762. Type = dac.Type,
  9763. Days = dac.Days,
  9764. NationalTravelFeeId = dac.NationalTravelFeeId,
  9765. Arae = $"{ntf.Country}-{ntf.City}",
  9766. Cost = dac.Cost,
  9767. Currency = dac.Currency,
  9768. CurrencyName = sd.Name,
  9769. SubTotal = dac.SubTotal,
  9770. })
  9771. .ToArray();
  9772. var data = new ChoiceMobileSubInfo3To6View()
  9773. {
  9774. ParentId = eecInfo.Id,
  9775. Choice = eecInfo.ChoiceSix,
  9776. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9777. Details = dayAndCostDatas
  9778. };
  9779. return Ok(JsonView(data));
  9780. }
  9781. else if (subType == 7) //7:其他
  9782. {
  9783. //其他款项
  9784. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9785. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9786. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9787. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9788. .OrderBy((dop, sd1, sd2) => dop.Index)
  9789. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9790. {
  9791. SubId = dop.Id,
  9792. DiId = dop.Diid,
  9793. Index = dop.Index,
  9794. SetDataId = dop.SetDataId,
  9795. SetDataName = sd1.Name,
  9796. Cost = dop.Cost,
  9797. Currency = dop.Currency,
  9798. CurrencyName = sd2.Name,
  9799. SubTotal = dop.SubTotal,
  9800. Remark = dop.Remark,
  9801. })
  9802. .ToArray();
  9803. var data = new ChoiceSevenMobileSubInfoView()
  9804. {
  9805. ParentId = eecInfo.Id,
  9806. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9807. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9808. Details = otherData
  9809. };
  9810. return Ok(JsonView(data));
  9811. }
  9812. return Ok(JsonView(false));
  9813. }
  9814. #region op
  9815. /// <summary>
  9816. /// 移动端更新费用消息通知
  9817. /// </summary>
  9818. /// <param name="diid"></param>
  9819. /// <param name="id"></param>
  9820. /// <param name="currUserId"></param>
  9821. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9822. {
  9823. try
  9824. {
  9825. ////生成默认文件pdf并且通知人员
  9826. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9827. //{
  9828. // DiId = diid,
  9829. // ExportType = 1,
  9830. // SubTypeId = 1005
  9831. //}, "pdf");
  9832. ////发送通知
  9833. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9834. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9835. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9836. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9837. ////汇率信息记录
  9838. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9839. }
  9840. catch (Exception ex)
  9841. {
  9842. //记录日志
  9843. throw;
  9844. }
  9845. }
  9846. /// <summary>
  9847. /// 验证出入境费用数据是否存在
  9848. /// 不存在添加
  9849. /// </summary>
  9850. /// <param name="diId"></param>
  9851. /// <param name="currUserId"></param>
  9852. /// <returns></returns>
  9853. /// <exception cref="CustomException"></exception>
  9854. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9855. {
  9856. var parentId = 0;
  9857. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9858. if (info != null)
  9859. {
  9860. parentId = info.Id;
  9861. }
  9862. else
  9863. {
  9864. var currencys = await EnterExitCostMobileGetCurrencyInit();
  9865. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9866. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9867. parentId = addId;
  9868. }
  9869. return parentId;
  9870. }
  9871. /// <summary>
  9872. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  9873. /// </summary>
  9874. /// <returns></returns>
  9875. [HttpPost]
  9876. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9877. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  9878. {
  9879. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9880. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9881. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9882. //验证编辑权限
  9883. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9884. //if (!isEdit) return Ok(JsonView(false, msg));
  9885. var permissions = new List<Grp_EnterExitCostPermission>();
  9886. foreach (var userId in dto.UserIds)
  9887. {
  9888. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  9889. }
  9890. if (permissions.Any())
  9891. {
  9892. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9893. {
  9894. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9895. }
  9896. _sqlSugar.BeginTran();
  9897. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  9898. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9899. if (result < 1)
  9900. {
  9901. _sqlSugar.RollbackTran();
  9902. return Ok(JsonView(false));
  9903. }
  9904. _sqlSugar.CommitTran();
  9905. return Ok(JsonView(true));
  9906. }
  9907. return Ok(JsonView(false));
  9908. }
  9909. /// <summary>
  9910. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  9911. /// </summary>
  9912. /// <returns></returns>
  9913. [HttpPost]
  9914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9915. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  9916. {
  9917. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9918. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9919. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9920. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9921. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9922. int id = dto.Id;
  9923. if (id <= 0) //add
  9924. {
  9925. //int provinceId = dto.ProvinceId;
  9926. int groupId = dto.DiId;
  9927. //if (provinceId < 1) provinceId = 122;
  9928. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  9929. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  9930. if (add < 1) return Ok(JsonView(false));
  9931. id = add;
  9932. }
  9933. else //update
  9934. {
  9935. ////验证编辑权限
  9936. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9937. //if (!isEdit) return Ok(JsonView(false, msg));
  9938. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  9939. if (upd < 1) return Ok(JsonView(false));
  9940. }
  9941. #region 汇率变更时更改币种相关费用
  9942. var opDayCosts = new List<Grp_DayAndCost>();
  9943. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  9944. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9945. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  9946. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9947. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9948. .Select((dac, sd) => new
  9949. {
  9950. dac.Id,
  9951. dac.DiId,
  9952. CurrencyCode = sd.Name,
  9953. dac.Cost
  9954. })
  9955. .ToList();
  9956. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9957. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9958. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9959. .Select((dop, sd) => new
  9960. {
  9961. dop.Id,
  9962. dop.Diid,
  9963. CurrencyCode = sd.Name,
  9964. dop.Cost
  9965. })
  9966. .ToList();
  9967. if (dayCosts.Count > 0)
  9968. {
  9969. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9970. foreach (var dc in new_dayCosts)
  9971. {
  9972. var thisCurrency = dc.Key.ToUpper();
  9973. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9974. if (thisRate == 0.00M) continue;
  9975. foreach (var dcSub in dc)
  9976. {
  9977. opDayCosts.Add(new Grp_DayAndCost()
  9978. {
  9979. Id = dcSub.Id,
  9980. DiId = dcSub.DiId,
  9981. Cost = dcSub.Cost,
  9982. SubTotal = dcSub.Cost * thisRate,
  9983. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9984. });
  9985. }
  9986. }
  9987. if (opDayCosts.Count > 0)
  9988. {
  9989. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9990. }
  9991. }
  9992. if (dayOtherCosts.Count > 0)
  9993. {
  9994. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9995. foreach (var dc in new_dayOtherCosts)
  9996. {
  9997. var thisCurrency = dc.Key.ToUpper();
  9998. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9999. if (thisRate == 0.00M) continue;
  10000. foreach (var dcSub in dc)
  10001. {
  10002. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  10003. {
  10004. Id = dcSub.Id,
  10005. Diid = dcSub.Diid,
  10006. Cost = dcSub.Cost,
  10007. SubTotal = dcSub.Cost * thisRate,
  10008. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  10009. });
  10010. }
  10011. }
  10012. if (opDayOtherCosts.Count > 0)
  10013. {
  10014. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  10015. }
  10016. }
  10017. #endregion
  10018. //消息通知
  10019. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10020. //汇率信息记录
  10021. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  10022. return Ok(JsonView(new { parentId = id }));
  10023. }
  10024. /// <summary>
  10025. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  10026. /// </summary>
  10027. /// <returns></returns>
  10028. [HttpPost]
  10029. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10030. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  10031. {
  10032. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10033. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10034. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10035. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10036. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  10037. int id = dto.Id;
  10038. if (id <= 0) //add
  10039. {
  10040. checkboxInfo.CreateUserId = dto.CurrUserId;
  10041. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10042. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10043. if (add < 1) return Ok(JsonView(false));
  10044. }
  10045. else //update
  10046. {
  10047. ////验证编辑权限
  10048. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10049. //if (!isEdit) return Ok(JsonView(false, msg));
  10050. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10051. .UpdateColumns(x => new
  10052. {
  10053. x.ChoiceOne,
  10054. x.ChoiceTwo,
  10055. x.SumJJC,
  10056. x.SumGWC,
  10057. x.SumTDC,
  10058. x.ChoiceThree,
  10059. x.ChoiceFour,
  10060. x.ChoiceFive,
  10061. x.ChoiceSix,
  10062. x.OtherExpenses_Checked
  10063. })
  10064. .Where(x => x.Id == id)
  10065. .ExecuteCommandAsync();
  10066. if (upd < 1) return Ok(JsonView(false));
  10067. }
  10068. return Ok(JsonView(new { parentId = id }));
  10069. }
  10070. /// <summary>
  10071. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  10072. /// </summary>
  10073. /// <returns></returns>
  10074. [HttpPost]
  10075. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10076. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  10077. {
  10078. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  10079. // if (provinceId < 1) provinceId = 122;
  10080. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10081. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10082. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10083. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10084. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10085. var checkboxInfo = new Grp_EnterExitCost()
  10086. {
  10087. Id = id,
  10088. //ProvinceId = provinceId,
  10089. DiId = diId,
  10090. CreateUserId = currUserId
  10091. };
  10092. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10093. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10094. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10095. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10096. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10097. if (id <= 0) //add
  10098. {
  10099. checkboxInfo.CreateUserId = dto.CurrUserId;
  10100. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10101. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10102. if (add < 1) return Ok(JsonView(false));
  10103. }
  10104. else //update
  10105. {
  10106. ////验证编辑权限
  10107. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10108. //if (!isEdit) return Ok(JsonView(false, msg));
  10109. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  10110. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10111. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10112. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10113. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10114. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10115. .Where(x => x.Id == id)
  10116. .ExecuteCommandAsync();
  10117. if (upd < 1) return Ok(JsonView(false));
  10118. }
  10119. return Ok(JsonView(new { parentId = id }));
  10120. }
  10121. /// <summary>
  10122. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  10123. /// </summary>
  10124. /// <returns></returns>
  10125. [HttpPost]
  10126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10127. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  10128. {
  10129. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10130. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10131. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10132. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10133. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10134. info.FirstItemRemark = dto.FirstItemRemark;
  10135. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10136. int id = dto.Id;
  10137. if (id <= 0) //add
  10138. {
  10139. info.CreateUserId = dto.CurrUserId;
  10140. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10141. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10142. if (add < 1) return Ok(JsonView(false));
  10143. id = add;
  10144. }
  10145. else //update
  10146. {
  10147. ////验证编辑权限
  10148. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10149. //if (!isEdit) return Ok(JsonView(false, msg));
  10150. var upd = await _sqlSugar.Updateable(info)
  10151. .UpdateColumns(x => new
  10152. {
  10153. x.ChoiceOne,
  10154. x.InsidePay,
  10155. x.VisaRemark,
  10156. x.Visa,
  10157. x.Service,
  10158. x.Safe,
  10159. x.Ticket,
  10160. x.HeSuan,
  10161. x.YiMiao,
  10162. x.FirstItemRemark
  10163. })
  10164. .Where(x => x.Id == id)
  10165. .ExecuteCommandAsync();
  10166. if (upd < 1) return Ok(JsonView(false));
  10167. }
  10168. //消息通知
  10169. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10170. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10171. }
  10172. /// <summary>
  10173. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10174. /// </summary>
  10175. /// <returns></returns>
  10176. [HttpPost]
  10177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10178. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10179. {
  10180. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10181. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10182. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10183. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10184. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10185. info.DiId = dto.DiId;
  10186. //info.ProvinceId = dto.ProvinceId;
  10187. info.OutsideJJPay = dto.OutsideJJPay;
  10188. info.OutsideGWPay = dto.OutsideGWPay;
  10189. info.OutsideTDPay = dto.OutsideTDPay;
  10190. info.AirJJ = dto.AirJJ;
  10191. info.AirGW = dto.AirGW;
  10192. info.AirTD = dto.AirTD;
  10193. info.CityTranffic = dto.CityTranffic;
  10194. info.TwoItemRemark = dto.TwoItemRemark;
  10195. info.SumJJC = dto.ChoiceTwoJJ;
  10196. info.SumGWC = dto.ChoiceTwoGW;
  10197. info.SumTDC = dto.ChoiceTwoTD;
  10198. int id = dto.Id;
  10199. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10200. if (id <= 0) //add
  10201. {
  10202. info.CreateUserId = dto.CurrUserId;
  10203. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10204. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10205. if (addId <= 0) return Ok(JsonView(false));
  10206. id = addId;
  10207. }
  10208. else //update
  10209. {
  10210. ////验证编辑权限
  10211. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10212. //if (!isEdit) return Ok(JsonView(false, msg));
  10213. var upd = await _sqlSugar.Updateable(info)
  10214. .UpdateColumns(x => new
  10215. {
  10216. x.SumJJC,
  10217. x.OutsideJJPay,
  10218. x.SumGWC,
  10219. x.OutsideGWPay,
  10220. x.SumTDC,
  10221. x.OutsideTDPay,
  10222. x.AirJJ,
  10223. x.AirGW,
  10224. x.AirTD,
  10225. x.CityTranffic,
  10226. x.TwoItemRemark
  10227. })
  10228. .Where(x => x.Id == id)
  10229. .ExecuteCommandAsync();
  10230. if (upd < 1) return Ok(JsonView(false));
  10231. }
  10232. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10233. gwcItemTotal = info.AirGW + info.CityTranffic;
  10234. tdcItemTotal = info.AirTD + info.CityTranffic;
  10235. //消息通知
  10236. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10237. return Ok(JsonView(new
  10238. {
  10239. parentId = id,
  10240. choiceTwoJJ = dto.ChoiceTwoJJ,
  10241. jjcItemTotal = jjcItemTotal,
  10242. choiceTwoGW = dto.ChoiceTwoGW,
  10243. gwcItemTotal = gwcItemTotal,
  10244. choiceTwoTD = dto.ChoiceTwoTD,
  10245. tdcItemTotal = tdcItemTotal
  10246. }));
  10247. }
  10248. /// <summary>
  10249. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10250. /// </summary>
  10251. /// <returns></returns>
  10252. [HttpPost]
  10253. [ApiExplorerSettings(IgnoreApi = true)]
  10254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10255. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10256. {
  10257. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10258. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10259. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10260. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10261. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10262. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10263. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10264. var infos = infos1.Select(x => new Grp_DayAndCost
  10265. {
  10266. Id = x.Id,
  10267. DiId = dto.DiId,
  10268. Type = dto.FeeType,
  10269. Days = x.Days,
  10270. NationalTravelFeeId = x.NationalTravelFeeId,
  10271. Cost = x.Cost,
  10272. Currency = x.Currency,
  10273. SubTotal = x.SubTotal,
  10274. CreateUserId = dto.CurrUserId
  10275. })
  10276. .ToList();
  10277. var adds = infos.Where(x => x.Id <= 0).ToList();
  10278. var upds = infos.Where(x => x.Id > 0).ToList();
  10279. if (adds.Count > 0)
  10280. {
  10281. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10282. if (add < 1) return Ok(JsonView(false));
  10283. }
  10284. if (upds.Count > 0)
  10285. {
  10286. var upd = await _sqlSugar.Updateable(adds)
  10287. .UpdateColumns(x => new
  10288. {
  10289. x.Days,
  10290. x.NationalTravelFeeId,
  10291. x.Cost,
  10292. x.Currency,
  10293. x.SubTotal
  10294. })
  10295. .WhereColumns(x => new { x.Id })
  10296. .ExecuteCommandAsync();
  10297. if (upd < 1) return Ok(JsonView(false));
  10298. }
  10299. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10300. //消息通知
  10301. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10302. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10303. return Ok(JsonView(new { itemTotal = itemTotal }));
  10304. }
  10305. /// <summary>
  10306. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10307. /// </summary>
  10308. /// <returns></returns>
  10309. [HttpPost]
  10310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10311. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10312. {
  10313. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10314. int subId = dto.SubId, feeType = dto.FeeType;
  10315. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10316. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10317. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10318. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10319. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10320. subInfo.Id = subId;
  10321. subInfo.DiId = dto.DiId;
  10322. if (feeType == 3) subInfo.Type = 1;
  10323. else if (feeType == 4) subInfo.Type = 2;
  10324. else if (feeType == 5) subInfo.Type = 3;
  10325. else if (feeType == 6) subInfo.Type = 4;
  10326. subInfo.CreateUserId = dto.CurrUserId;
  10327. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10328. if (parentId < 1) return Ok(JsonView(false));
  10329. //子表op
  10330. if (subId < 1)
  10331. {
  10332. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10333. if (subAdd < 1) return Ok(JsonView(false));
  10334. }
  10335. else
  10336. {
  10337. ////验证编辑权限
  10338. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10339. //if (!isEdit) return Ok(JsonView(false, msg));
  10340. var subUpd = await _sqlSugar.Updateable(subInfo)
  10341. .UpdateColumns(x => new
  10342. {
  10343. x.Days,
  10344. x.NationalTravelFeeId,
  10345. x.Cost,
  10346. x.Currency,
  10347. x.SubTotal
  10348. })
  10349. .WhereColumns(x => new { x.Id })
  10350. .ExecuteCommandAsync();
  10351. if (subUpd < 1) return Ok(JsonView(false));
  10352. }
  10353. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10354. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10355. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10356. }
  10357. /// <summary>
  10358. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10359. /// </summary>
  10360. /// <returns></returns>
  10361. [HttpPost]
  10362. [ApiExplorerSettings(IgnoreApi = true)]
  10363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10364. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10365. {
  10366. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10367. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10368. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10369. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10370. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10371. {
  10372. Id = x.Id,
  10373. Diid = dto.DiId,
  10374. SetDataId = x.SetDataId,
  10375. Index = x.Index,
  10376. Cost = x.Cost,
  10377. Currency = x.Currency,
  10378. SubTotal = x.SubTotal,
  10379. CreateUserId = dto.CurrUserId,
  10380. Remark = x.Remark
  10381. }).ToList();
  10382. var adds = infos.Where(x => x.Id <= 0).ToList();
  10383. var upds = infos.Where(x => x.Id > 0).ToList();
  10384. if (adds.Count > 0)
  10385. {
  10386. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10387. if (add < 1) return Ok(JsonView(false));
  10388. }
  10389. if (upds.Count > 0)
  10390. {
  10391. var upd = await _sqlSugar.Updateable(adds)
  10392. .UpdateColumns(x => new
  10393. {
  10394. x.Index,
  10395. x.SetDataId,
  10396. x.Cost,
  10397. x.Currency,
  10398. x.SubTotal,
  10399. x.Remark
  10400. })
  10401. .WhereColumns(x => new { x.Id })
  10402. .ExecuteCommandAsync();
  10403. if (upd < 1) return Ok(JsonView(false));
  10404. }
  10405. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10406. //消息通知
  10407. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10408. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10409. return Ok(JsonView(new { itemTotal = itemTotal }));
  10410. }
  10411. /// <summary>
  10412. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10413. /// </summary>
  10414. /// <returns></returns>
  10415. [HttpPost]
  10416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10417. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10418. {
  10419. int subId = dto.SubId;
  10420. int diId = dto.Diid;
  10421. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10422. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10423. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10424. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10425. subInfo.Id = subId;
  10426. subInfo.Diid = dto.Diid;
  10427. subInfo.CreateUserId = dto.CurrUserId;
  10428. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10429. if (parentId < 1) return Ok(JsonView(false));
  10430. #region 子表op
  10431. if (subId < 1)//add
  10432. {
  10433. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10434. if (subAdd < 1) return Ok(JsonView(false));
  10435. }
  10436. else //upd
  10437. {
  10438. ////验证编辑权限
  10439. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10440. //if (!isEdit) return Ok(JsonView(false, msg));
  10441. var subUpd = await _sqlSugar.Updateable(subInfo)
  10442. .UpdateColumns(x => new
  10443. {
  10444. x.Index,
  10445. x.SetDataId,
  10446. x.Cost,
  10447. x.Currency,
  10448. x.SubTotal,
  10449. x.Remark
  10450. })
  10451. .WhereColumns(x => new { x.Id })
  10452. .ExecuteCommandAsync();
  10453. if (subUpd < 1) return Ok(JsonView(false));
  10454. }
  10455. #endregion
  10456. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10457. //消息通知
  10458. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10459. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10460. }
  10461. /// <summary>
  10462. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10463. /// </summary>
  10464. /// <returns></returns>
  10465. [HttpPost]
  10466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10467. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10468. {
  10469. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10470. if (data.Code != 0)
  10471. {
  10472. return Ok(JsonView(false, data.Msg));
  10473. }
  10474. return Ok(JsonView(true, "操作成功!", data.Data));
  10475. }
  10476. /// <summary>
  10477. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10478. /// </summary>
  10479. /// <param name="dto"></param>
  10480. /// <returns></returns>
  10481. [HttpPost]
  10482. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10483. {
  10484. var data = new Grp_DayOtherPrice()
  10485. {
  10486. Id = dto.Id,
  10487. IsDel = 1,
  10488. DeleteUserId = dto.DeleteUserId,
  10489. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10490. };
  10491. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10492. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10493. return Ok(JsonView(false, "删除失败!"));
  10494. }
  10495. #endregion
  10496. #endregion
  10497. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10498. /// <summary>
  10499. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10500. /// </summary>
  10501. /// <returns></returns>
  10502. [HttpGet]
  10503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10504. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10505. {
  10506. var provData = await _groupRepository.ProvinceBasicSource();
  10507. return Ok(JsonView(true, "查询成功!", provData));
  10508. }
  10509. /// <summary>
  10510. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10511. /// </summary>
  10512. /// <returns></returns>
  10513. [HttpPost]
  10514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10515. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10516. {
  10517. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10518. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10519. RefAsync<int> total = 0;
  10520. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10521. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10522. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10523. .Select(x => new
  10524. {
  10525. Id = x.Id,
  10526. DraftName = x.DraftName,
  10527. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10528. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10529. .Any()
  10530. })
  10531. .OrderByDescending(x => x.Id)
  10532. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10533. return Ok(JsonView(true, "查询成功!", data, total));
  10534. }
  10535. /// <summary>
  10536. /// 出入境费用-草稿 移动端
  10537. /// 获取币种基础数据(含逻辑处理)
  10538. /// </summary>
  10539. /// <returns></returns>
  10540. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10541. {
  10542. return await GeneralMethod.EnterExitCostInitRate();
  10543. }
  10544. /// <summary>
  10545. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10546. /// </summary>
  10547. /// <returns></returns>
  10548. [HttpPost]
  10549. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10550. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10551. {
  10552. //验证城市归属并给默认值
  10553. int provinceId = dto.ProvinceId;
  10554. if (provinceId < 1) provinceId = 122;
  10555. var dataSource = await _sqlSugar
  10556. .Queryable<Sys_SetData>()
  10557. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10558. .ToListAsync();
  10559. //三公费用-Word明细类型
  10560. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10561. .Select(x => new SetDataInfoView
  10562. {
  10563. Id = x.Id,
  10564. Name = x.Name,
  10565. Remark = x.Remark
  10566. })
  10567. .ToList();
  10568. //三公费用-Excel明细类型
  10569. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10570. .Select(x => new SetDataInfoView
  10571. {
  10572. Id = x.Id,
  10573. Name = x.Name,
  10574. Remark = x.Remark
  10575. })
  10576. .ToList();
  10577. //默认币种显示
  10578. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10579. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10580. return Ok(JsonView(true, "查询成功!", new
  10581. {
  10582. WordTypeData = wordTypeData,
  10583. ExcelTypeData = excelTypeData,
  10584. CurrencyInit = _currencyInfos,
  10585. viewPermissionData = viewPermissionData
  10586. }));
  10587. }
  10588. /// <summary>
  10589. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10590. /// </summary>
  10591. /// <returns></returns>
  10592. [HttpPost]
  10593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10594. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10595. {
  10596. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10597. RefAsync<int> total = 0;
  10598. int diId = 0;
  10599. var status = int.TryParse(dto.GroupName, out diId);
  10600. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10601. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10602. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10603. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10604. .OrderByDescending(x => x.VisitStartDate)
  10605. .Select(x => new
  10606. {
  10607. Id = x.Id,
  10608. GroupName = x.TeamName
  10609. })
  10610. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10611. return Ok(JsonView(true, "查询成功!", data, total));
  10612. }
  10613. /// <summary>
  10614. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10615. /// </summary>
  10616. /// <returns></returns>
  10617. [HttpPost]
  10618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10619. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10620. {
  10621. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10622. RefAsync<int> total = 0;
  10623. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10624. .Where(x => x.IsDel == 0 && x.STid == 66)
  10625. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10626. .Select(x => new
  10627. {
  10628. id = x.Id,
  10629. name = x.Name,
  10630. remark = x.Remark,
  10631. })
  10632. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10633. return Ok(JsonView(true, "查询成功!", data, total));
  10634. }
  10635. /// <summary>
  10636. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10637. /// </summary>
  10638. /// <returns></returns>
  10639. [HttpPost]
  10640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10641. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10642. {
  10643. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10644. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10645. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10646. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10647. var groupOtherRateData = groupRateData.TeamRates;
  10648. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10649. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10650. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10651. groupOtherRateData = groupOtherRateData
  10652. .Select(x => new TeamRateDescAddCurrencyIdView
  10653. {
  10654. CurrencyId = x.CurrencyId,
  10655. CurrencyName = x.CurrencyName,
  10656. CurrencyCode = x.CurrencyCode,
  10657. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10658. }).ToList();
  10659. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10660. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10661. }
  10662. /// <summary>
  10663. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10664. /// </summary>
  10665. /// <returns></returns>
  10666. [HttpPost]
  10667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10668. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10669. {
  10670. int portType = dto.PortType;
  10671. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10672. var tipsData = new List<int>() { 1, 2, 3 };
  10673. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10674. if (dto.TipsType == 1)
  10675. {
  10676. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10677. }
  10678. else if (dto.TipsType == 2)
  10679. {
  10680. if (portType == 2)
  10681. {
  10682. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10683. }
  10684. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10685. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10686. .Select(x => x.NationalTravelFeeId)
  10687. .Distinct()
  10688. .ToListAsync();
  10689. if (portType == 2)
  10690. {
  10691. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10692. }
  10693. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10694. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10695. .Select(x => x.Country)
  10696. .Distinct()
  10697. .ToArrayAsync();
  10698. if (portType == 2)
  10699. {
  10700. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10701. }
  10702. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10703. return Ok(JsonView(true, "查询成功!", new
  10704. {
  10705. totalAmt = totalAmt,
  10706. remark = remark
  10707. }));
  10708. }
  10709. else if (dto.TipsType == 3)
  10710. {
  10711. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10712. }
  10713. return Ok(JsonView(false));
  10714. }
  10715. /// <summary>
  10716. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10717. /// </summary>
  10718. /// <returns></returns>
  10719. [HttpPost]
  10720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10721. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10722. {
  10723. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10724. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10725. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10726. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10727. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10728. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10729. var info = new Grp_EnterExitCostDraft()
  10730. {
  10731. ProvinceId = dto.ProvinceId,
  10732. DraftName = dto.DraftName,
  10733. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10734. CreateUserId = dto.CurrUserId
  10735. };
  10736. _sqlSugar.BeginTran();
  10737. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10738. if (draftId < 1)
  10739. {
  10740. _sqlSugar.RollbackTran();
  10741. return Ok(JsonView(false, "草稿创建失败!"));
  10742. }
  10743. //添加默认权限
  10744. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10745. _sqlSugar.CommitTran();
  10746. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10747. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10748. mobileInfo.Id = draftId;
  10749. mobileInfo.DraftName = dto.DraftName;
  10750. mobileInfo.Currencys = rateInfos;
  10751. mobileInfo.IsAssignPerm = assignPerm;
  10752. return Ok(JsonView(mobileInfo));
  10753. }
  10754. /// <summary>
  10755. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10756. /// </summary>
  10757. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10758. /// <summary>
  10759. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10760. /// </summary>
  10761. /// <returns></returns>
  10762. [HttpPost]
  10763. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10764. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10765. {
  10766. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10767. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10768. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10769. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10770. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10771. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10772. //验证查看编辑权限
  10773. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10774. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10775. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10776. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10777. mobileInfo.IsAssignPerm = assignPerm;
  10778. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10779. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10780. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10781. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10782. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10783. {
  10784. ParentId = dac.ParentId,
  10785. SubId = dac.Id,
  10786. Type = dac.Type,
  10787. Days = dac.Days,
  10788. NationalTravelFeeId = dac.NationalTravelFeeId,
  10789. Arae = $"{ntf.Country}-{ntf.City}",
  10790. Cost = dac.Cost,
  10791. Currency = dac.Currency,
  10792. CurrencyName = sd.Name,
  10793. SubTotal = dac.SubTotal,
  10794. })
  10795. .ToList();
  10796. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10797. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10798. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10799. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10800. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10801. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10802. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10803. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10804. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10805. //其他款项
  10806. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10807. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10808. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10809. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10810. .OrderBy((dop, sd1, sd2) => dop.Index)
  10811. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10812. {
  10813. ParentId = dop.ParentId,
  10814. SubId = dop.Id,
  10815. Index = dop.Index,
  10816. SetDataId = dop.SetDataId,
  10817. SetDataName = sd1.Name,
  10818. Cost = dop.Cost,
  10819. Currency = dop.Currency,
  10820. CurrencyName = sd2.Remark,
  10821. SubTotal = dop.SubTotal,
  10822. Remark = dop.Remark,
  10823. })
  10824. .ToArray();
  10825. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10826. return Ok(mobileInfo);
  10827. }
  10828. /// <summary>
  10829. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10830. /// </summary>
  10831. /// <returns></returns>
  10832. [HttpPost]
  10833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10834. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10835. {
  10836. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10837. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10838. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10839. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10840. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10841. //验证查看编辑权限
  10842. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10843. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10844. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10845. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10846. var subType = dto.SubType;
  10847. if (subType == 1) //1:境内费用
  10848. {
  10849. var oneData = new ChoiceOneMobileSubInfoView()
  10850. {
  10851. Id = eecInfo.Id,
  10852. ChoiceOne = eecInfo.ChoiceOne,
  10853. ChoiceOneTotalCost = eecInfo.InsidePay,
  10854. Visa = eecInfo.Visa,
  10855. VisaRemark = eecInfo.VisaRemark,
  10856. YiMiao = eecInfo.YiMiao,
  10857. HeSuan = eecInfo.HeSuan,
  10858. Service = eecInfo.Service,
  10859. Ticket = eecInfo.Ticket,
  10860. Safe = eecInfo.Safe,
  10861. FirstItemRemark = eecInfo.FirstItemRemark
  10862. };
  10863. return Ok(JsonView(oneData));
  10864. }
  10865. else if (subType == 2) //2:国际旅费
  10866. {
  10867. var twoData = new ChoiceTwoMobileSubInfoView()
  10868. {
  10869. Id = eecInfo.Id,
  10870. ChoiceTwoJJ = eecInfo.SumJJC,
  10871. OutsideJJPay = eecInfo.OutsideJJPay,
  10872. ChoiceTwoGW = eecInfo.SumGWC,
  10873. OutsideGWPay = eecInfo.OutsideGWPay,
  10874. ChoiceTwoTD = eecInfo.SumTDC,
  10875. OutsideTDPay = eecInfo.OutsideTDPay,
  10876. AirJJ = eecInfo.AirJJ,
  10877. AirGW = eecInfo.AirGW,
  10878. AirTD = eecInfo.AirTD,
  10879. CityTranffic = eecInfo.CityTranffic,
  10880. TwoItemRemark = eecInfo.TwoItemRemark
  10881. };
  10882. return Ok(JsonView(twoData));
  10883. }
  10884. else if (subType == 3) //3:住宿费
  10885. {
  10886. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10887. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10888. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10889. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  10890. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10891. {
  10892. ParentId = dac.ParentId,
  10893. SubId = dac.Id,
  10894. Type = dac.Type,
  10895. Days = dac.Days,
  10896. NationalTravelFeeId = dac.NationalTravelFeeId,
  10897. Arae = $"{ntf.Country}-{ntf.City}",
  10898. Cost = dac.Cost,
  10899. Currency = dac.Currency,
  10900. CurrencyName = sd.Name,
  10901. SubTotal = dac.SubTotal,
  10902. })
  10903. .ToArray();
  10904. var data = new ChoiceDraftMobileSubInfo3To6View()
  10905. {
  10906. ParentId = eecInfo.Id,
  10907. Choice = eecInfo.ChoiceThree,
  10908. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10909. Details = dayAndCostDatas
  10910. };
  10911. return Ok(JsonView(data));
  10912. }
  10913. else if (subType == 4) //4:伙食费
  10914. {
  10915. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10916. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10917. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10918. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  10919. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10920. {
  10921. ParentId = dac.ParentId,
  10922. SubId = dac.Id,
  10923. Type = dac.Type,
  10924. Days = dac.Days,
  10925. NationalTravelFeeId = dac.NationalTravelFeeId,
  10926. Arae = $"{ntf.Country}-{ntf.City}",
  10927. Cost = dac.Cost,
  10928. Currency = dac.Currency,
  10929. CurrencyName = sd.Name,
  10930. SubTotal = dac.SubTotal,
  10931. })
  10932. .ToArray();
  10933. var data = new ChoiceDraftMobileSubInfo3To6View()
  10934. {
  10935. ParentId = eecInfo.Id,
  10936. Choice = eecInfo.ChoiceFour,
  10937. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10938. Details = dayAndCostDatas
  10939. };
  10940. return Ok(JsonView(data));
  10941. }
  10942. else if (subType == 5) //5:公杂费
  10943. {
  10944. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10945. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10946. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10947. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  10948. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10949. {
  10950. ParentId = dac.ParentId,
  10951. SubId = dac.Id,
  10952. Type = dac.Type,
  10953. Days = dac.Days,
  10954. NationalTravelFeeId = dac.NationalTravelFeeId,
  10955. Arae = $"{ntf.Country}-{ntf.City}",
  10956. Cost = dac.Cost,
  10957. Currency = dac.Currency,
  10958. CurrencyName = sd.Name,
  10959. SubTotal = dac.SubTotal,
  10960. })
  10961. .ToArray();
  10962. var data = new ChoiceDraftMobileSubInfo3To6View()
  10963. {
  10964. ParentId = eecInfo.Id,
  10965. Choice = eecInfo.ChoiceFive,
  10966. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10967. Details = dayAndCostDatas
  10968. };
  10969. return Ok(JsonView(data));
  10970. }
  10971. else if (subType == 6) //6:培训费
  10972. {
  10973. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10974. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10975. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10976. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  10977. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10978. {
  10979. ParentId = dac.ParentId,
  10980. SubId = dac.Id,
  10981. Type = dac.Type,
  10982. Days = dac.Days,
  10983. NationalTravelFeeId = dac.NationalTravelFeeId,
  10984. Arae = $"{ntf.Country}-{ntf.City}",
  10985. Cost = dac.Cost,
  10986. Currency = dac.Currency,
  10987. CurrencyName = sd.Name,
  10988. SubTotal = dac.SubTotal,
  10989. })
  10990. .ToArray();
  10991. var data = new ChoiceDraftMobileSubInfo3To6View()
  10992. {
  10993. ParentId = eecInfo.Id,
  10994. Choice = eecInfo.ChoiceSix,
  10995. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10996. Details = dayAndCostDatas
  10997. };
  10998. return Ok(JsonView(data));
  10999. }
  11000. else if (subType == 7) //7:其他
  11001. {
  11002. //其他款项
  11003. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11004. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11005. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11006. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11007. .OrderBy((dop, sd1, sd2) => dop.Index)
  11008. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  11009. {
  11010. ParentId = dop.ParentId,
  11011. SubId = dop.Id,
  11012. Index = dop.Index,
  11013. SetDataId = dop.SetDataId,
  11014. SetDataName = sd1.Name,
  11015. Cost = dop.Cost,
  11016. Currency = dop.Currency,
  11017. CurrencyName = sd2.Name,
  11018. SubTotal = dop.SubTotal,
  11019. Remark = dop.Remark,
  11020. })
  11021. .ToArray();
  11022. var data = new ChoiceSevenDraftMobileSubInfoView()
  11023. {
  11024. ParentId = eecInfo.Id,
  11025. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11026. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11027. Details = otherData
  11028. };
  11029. return Ok(JsonView(data));
  11030. }
  11031. return Ok(JsonView(false));
  11032. }
  11033. #region op
  11034. /// <summary>
  11035. /// 移动端更新费用消息通知
  11036. /// </summary>
  11037. /// <param name="draftId"></param>
  11038. /// <param name="id"></param>
  11039. /// <param name="currUserId"></param>
  11040. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  11041. {
  11042. try
  11043. {
  11044. ////生成默认文件pdf并且通知人员
  11045. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11046. //{
  11047. // DiId = draftId,
  11048. // ExportType = 1,
  11049. // SubTypeId = 1005
  11050. //}, "pdf");
  11051. ////发送通知
  11052. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11053. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11054. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11055. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  11056. ////汇率信息记录
  11057. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11058. }
  11059. catch (Exception ex)
  11060. {
  11061. //记录日志
  11062. throw;
  11063. }
  11064. }
  11065. /// <summary>
  11066. /// 验证出入境费用数据是否存在
  11067. /// 不存在添加
  11068. /// </summary>
  11069. /// <param name="draftId"></param>
  11070. /// <param name="currUserId"></param>
  11071. /// <returns></returns>
  11072. /// <exception cref="CustomException"></exception>
  11073. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  11074. {
  11075. var parentId = 0;
  11076. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11077. if (info != null) parentId = info.Id;
  11078. else
  11079. {
  11080. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  11081. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11082. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11083. parentId = addId;
  11084. }
  11085. return parentId;
  11086. }
  11087. /// <summary>
  11088. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  11089. /// </summary>
  11090. /// <returns></returns>
  11091. [HttpPost]
  11092. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11093. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  11094. {
  11095. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11096. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11097. //验证查看权限
  11098. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11099. if (!isView) return Ok(JsonView(false, _viewPermStr));
  11100. var userIds = await _sqlSugar
  11101. .Queryable<Grp_EnterExitCostDraftPermission>()
  11102. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  11103. .Select(x => x.UserId)
  11104. .ToArrayAsync();
  11105. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11106. var perUsersView = new List<dynamic>();
  11107. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  11108. var viewPermissionData = new List<PermissionViewUserview>();
  11109. if (feeBasePerm.Any())
  11110. {
  11111. foreach (var item in feeBasePerm)
  11112. {
  11113. if (item.Users.Any())
  11114. {
  11115. viewPermissionData.AddRange(item.Users);
  11116. }
  11117. }
  11118. }
  11119. foreach (var item in perUsers)
  11120. {
  11121. bool isView1 = false;
  11122. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11123. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  11124. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11125. }
  11126. return Ok(JsonView(perUsersView));
  11127. }
  11128. /// <summary>
  11129. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  11130. /// </summary>
  11131. /// <returns></returns>
  11132. [HttpPost]
  11133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11134. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  11135. {
  11136. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11137. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11138. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11139. //验证查看编辑权限
  11140. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11141. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11142. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  11143. foreach (var userId in dto.UserIds)
  11144. {
  11145. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11146. }
  11147. if (permissions.Any())
  11148. {
  11149. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11150. {
  11151. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11152. }
  11153. _sqlSugar.BeginTran();
  11154. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11155. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11156. if (result < 1)
  11157. {
  11158. _sqlSugar.RollbackTran();
  11159. return Ok(JsonView(false));
  11160. }
  11161. _sqlSugar.CommitTran();
  11162. return Ok(JsonView(true));
  11163. }
  11164. return Ok(JsonView(false));
  11165. }
  11166. /// <summary>
  11167. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  11168. /// </summary>
  11169. /// <returns></returns>
  11170. [HttpPost]
  11171. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11172. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11173. {
  11174. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11175. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11176. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11177. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11178. int id = dto.DraftId;
  11179. if (id <= 0) //add
  11180. {
  11181. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11182. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11183. if (add < 1) return Ok(JsonView(false));
  11184. id = add;
  11185. }
  11186. else //update
  11187. {
  11188. //验证查看编辑权限
  11189. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11190. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11191. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11192. if (upd < 1) return Ok(JsonView(false));
  11193. }
  11194. return Ok(JsonView(new { parentId = id }));
  11195. }
  11196. /// <summary>
  11197. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11198. /// </summary>
  11199. /// <returns></returns>
  11200. [HttpPost]
  11201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11202. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11203. {
  11204. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11205. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11206. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11207. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11208. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11209. int id = dto.DraftId;
  11210. if (id <= 0) //add
  11211. {
  11212. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11213. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11214. if (add < 1) return Ok(JsonView(false));
  11215. id = add;
  11216. }
  11217. else //update
  11218. {
  11219. //验证查看编辑权限
  11220. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11221. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11222. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11223. if (upd < 1) return Ok(JsonView(false));
  11224. }
  11225. #region 汇率变更时更改币种相关费用
  11226. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11227. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11228. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11229. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11230. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11231. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11232. .Select((dac, sd) => new
  11233. {
  11234. dac.Id,
  11235. dac.ParentId,
  11236. CurrencyCode = sd.Name,
  11237. dac.Cost
  11238. })
  11239. .ToList();
  11240. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11241. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11242. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11243. .Select((dop, sd) => new
  11244. {
  11245. dop.Id,
  11246. dop.ParentId,
  11247. CurrencyCode = sd.Name,
  11248. dop.Cost
  11249. })
  11250. .ToList();
  11251. if (dayCosts.Count > 0)
  11252. {
  11253. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11254. foreach (var dc in new_dayCosts)
  11255. {
  11256. var thisCurrency = dc.Key.ToUpper();
  11257. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11258. if (thisRate == 0.00M) continue;
  11259. foreach (var dcSub in dc)
  11260. {
  11261. opDayCosts.Add(new Grp_DayAndCostDraft()
  11262. {
  11263. Id = dcSub.Id,
  11264. ParentId = dcSub.ParentId,
  11265. Cost = dcSub.Cost,
  11266. SubTotal = dcSub.Cost * thisRate,
  11267. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11268. });
  11269. }
  11270. }
  11271. if (opDayCosts.Count > 0)
  11272. {
  11273. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11274. }
  11275. }
  11276. if (dayOtherCosts.Count > 0)
  11277. {
  11278. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11279. foreach (var dc in new_dayOtherCosts)
  11280. {
  11281. var thisCurrency = dc.Key.ToUpper();
  11282. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11283. if (thisRate == 0.00M) continue;
  11284. foreach (var dcSub in dc)
  11285. {
  11286. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11287. {
  11288. Id = dcSub.Id,
  11289. ParentId = dcSub.ParentId,
  11290. Cost = dcSub.Cost,
  11291. SubTotal = dcSub.Cost * thisRate,
  11292. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11293. });
  11294. }
  11295. }
  11296. if (opDayOtherCosts.Count > 0)
  11297. {
  11298. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11299. }
  11300. }
  11301. #endregion
  11302. ////消息通知
  11303. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11304. ////汇率信息记录
  11305. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11306. return Ok(JsonView(new { parentId = id }));
  11307. }
  11308. /// <summary>
  11309. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11310. /// </summary>
  11311. /// <returns></returns>
  11312. [HttpPost]
  11313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11314. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11315. {
  11316. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11317. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11318. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11319. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11320. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11321. int id = dto.DraftId;
  11322. if (id <= 0) //add
  11323. {
  11324. checkboxInfo.ProvinceId = dto.ProvinceId;
  11325. checkboxInfo.CreateUserId = dto.CurrUserId;
  11326. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11327. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11328. if (add < 1) return Ok(JsonView(false));
  11329. }
  11330. else //update
  11331. {
  11332. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11333. .UpdateColumns(x => new
  11334. {
  11335. x.ChoiceOne,
  11336. x.ChoiceTwo,
  11337. x.SumJJC,
  11338. x.SumGWC,
  11339. x.SumTDC,
  11340. x.ChoiceThree,
  11341. x.ChoiceFour,
  11342. x.ChoiceFive,
  11343. x.ChoiceSix,
  11344. x.OtherExpenses_Checked
  11345. })
  11346. .Where(x => x.Id == id)
  11347. .ExecuteCommandAsync();
  11348. if (upd < 1) return Ok(JsonView(false));
  11349. }
  11350. return Ok(JsonView(new { parentId = id }));
  11351. }
  11352. /// <summary>
  11353. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11354. /// </summary>
  11355. /// <returns></returns>
  11356. [HttpPost]
  11357. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11358. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11359. {
  11360. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11361. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11362. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11363. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11364. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11365. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11366. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11367. var checkboxInfo = new Grp_EnterExitCostDraft()
  11368. {
  11369. Id = draftId,
  11370. ProvinceId = dto.ProvinceId,
  11371. CreateUserId = currUserId
  11372. };
  11373. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11374. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11375. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11376. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11377. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11378. if (draftId <= 0) //add
  11379. {
  11380. checkboxInfo.CreateUserId = dto.CurrUserId;
  11381. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11382. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11383. if (add < 1) return Ok(JsonView(false));
  11384. }
  11385. else //update
  11386. {
  11387. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11388. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11389. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11390. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11391. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11392. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11393. .Where(x => x.Id == draftId)
  11394. .ExecuteCommandAsync();
  11395. if (upd < 1) return Ok(JsonView(false));
  11396. }
  11397. return Ok(JsonView(new { parentId = draftId }));
  11398. }
  11399. /// <summary>
  11400. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11401. /// </summary>
  11402. /// <returns></returns>
  11403. [HttpPost]
  11404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11405. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11406. {
  11407. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11408. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11409. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11410. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11411. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11412. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11413. info.ProvinceId = dto.ProvinceId;
  11414. info.FirstItemRemark = dto.FirstItemRemark;
  11415. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11416. if (id <= 0) //add
  11417. {
  11418. info.CreateUserId = dto.CurrUserId;
  11419. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11420. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11421. if (add < 1) return Ok(JsonView(false));
  11422. id = add;
  11423. }
  11424. else //update
  11425. {
  11426. var upd = await _sqlSugar.Updateable(info)
  11427. .UpdateColumns(x => new
  11428. {
  11429. x.ChoiceOne,
  11430. x.InsidePay,
  11431. x.VisaRemark,
  11432. x.Visa,
  11433. x.Service,
  11434. x.Safe,
  11435. x.Ticket,
  11436. x.HeSuan,
  11437. x.YiMiao,
  11438. x.FirstItemRemark
  11439. })
  11440. .Where(x => x.Id == id)
  11441. .ExecuteCommandAsync();
  11442. if (upd < 1) return Ok(JsonView(false));
  11443. }
  11444. ////消息通知
  11445. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11446. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11447. }
  11448. /// <summary>
  11449. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11450. /// </summary>
  11451. /// <returns></returns>
  11452. [HttpPost]
  11453. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11454. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11455. {
  11456. int id = dto.DraftId;
  11457. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11458. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11459. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11460. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11461. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11462. info.ProvinceId = dto.ProvinceId;
  11463. info.OutsideJJPay = dto.OutsideJJPay;
  11464. info.OutsideGWPay = dto.OutsideGWPay;
  11465. info.OutsideTDPay = dto.OutsideTDPay;
  11466. info.AirJJ = dto.AirJJ;
  11467. info.AirGW = dto.AirGW;
  11468. info.AirTD = dto.AirTD;
  11469. info.CityTranffic = dto.CityTranffic;
  11470. info.TwoItemRemark = dto.TwoItemRemark;
  11471. info.SumJJC = dto.ChoiceTwoJJ;
  11472. info.SumGWC = dto.ChoiceTwoGW;
  11473. info.SumTDC = dto.ChoiceTwoTD;
  11474. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11475. if (id <= 0) //add
  11476. {
  11477. info.CreateUserId = dto.CurrUserId;
  11478. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11479. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11480. if (addId <= 0) return Ok(JsonView(false));
  11481. id = addId;
  11482. }
  11483. else //update
  11484. {
  11485. var upd = await _sqlSugar.Updateable(info)
  11486. .UpdateColumns(x => new
  11487. {
  11488. x.SumJJC,
  11489. x.OutsideJJPay,
  11490. x.SumGWC,
  11491. x.OutsideGWPay,
  11492. x.SumTDC,
  11493. x.OutsideTDPay,
  11494. x.AirJJ,
  11495. x.AirGW,
  11496. x.AirTD,
  11497. x.CityTranffic,
  11498. x.TwoItemRemark
  11499. })
  11500. .Where(x => x.Id == id)
  11501. .ExecuteCommandAsync();
  11502. if (upd < 1) return Ok(JsonView(false));
  11503. }
  11504. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11505. gwcItemTotal = info.AirGW + info.CityTranffic;
  11506. tdcItemTotal = info.AirTD + info.CityTranffic;
  11507. ////消息通知
  11508. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11509. return Ok(JsonView(new
  11510. {
  11511. parentId = id,
  11512. choiceTwoJJ = dto.ChoiceTwoJJ,
  11513. jjcItemTotal = jjcItemTotal,
  11514. choiceTwoGW = dto.ChoiceTwoGW,
  11515. gwcItemTotal = gwcItemTotal,
  11516. choiceTwoTD = dto.ChoiceTwoTD,
  11517. tdcItemTotal = tdcItemTotal
  11518. }));
  11519. }
  11520. /// <summary>
  11521. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11522. /// </summary>
  11523. /// <returns></returns>
  11524. [HttpPost]
  11525. [ApiExplorerSettings(IgnoreApi = true)]
  11526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11527. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11528. {
  11529. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11530. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11531. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11532. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11533. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11534. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11535. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11536. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11537. {
  11538. Id = x.Id,
  11539. ParentId = dto.DraftId,
  11540. Type = dto.FeeType,
  11541. Days = x.Days,
  11542. NationalTravelFeeId = x.NationalTravelFeeId,
  11543. Cost = x.Cost,
  11544. Currency = x.Currency,
  11545. SubTotal = x.SubTotal,
  11546. CreateUserId = dto.CurrUserId
  11547. })
  11548. .ToList();
  11549. var adds = infos.Where(x => x.Id <= 0).ToList();
  11550. var upds = infos.Where(x => x.Id > 0).ToList();
  11551. if (adds.Count > 0)
  11552. {
  11553. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11554. if (add < 1) return Ok(JsonView(false));
  11555. }
  11556. if (upds.Count > 0)
  11557. {
  11558. var upd = await _sqlSugar.Updateable(adds)
  11559. .UpdateColumns(x => new
  11560. {
  11561. x.Days,
  11562. x.NationalTravelFeeId,
  11563. x.Cost,
  11564. x.Currency,
  11565. x.SubTotal
  11566. })
  11567. .WhereColumns(x => new { x.Id })
  11568. .ExecuteCommandAsync();
  11569. if (upd < 1) return Ok(JsonView(false));
  11570. }
  11571. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11572. ////消息通知
  11573. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11574. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11575. return Ok(JsonView(new { itemTotal = itemTotal }));
  11576. }
  11577. /// <summary>
  11578. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11579. /// </summary>
  11580. /// <returns></returns>
  11581. [HttpPost]
  11582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11583. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11584. {
  11585. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11586. int subId = dto.SubId, feeType = dto.FeeType;
  11587. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11588. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11589. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11590. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11591. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11592. subInfo.Id = subId;
  11593. subInfo.ParentId = dto.DraftId;
  11594. if (feeType == 3) subInfo.Type = 1;
  11595. else if (feeType == 4) subInfo.Type = 2;
  11596. else if (feeType == 5) subInfo.Type = 3;
  11597. else if (feeType == 6) subInfo.Type = 4;
  11598. subInfo.CreateUserId = dto.CurrUserId;
  11599. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11600. if (parentId < 1) return Ok(JsonView(false));
  11601. //子表op
  11602. if (subId < 1)
  11603. {
  11604. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11605. if (subAdd < 1) return Ok(JsonView(false));
  11606. }
  11607. else
  11608. {
  11609. var subUpd = await _sqlSugar.Updateable(subInfo)
  11610. .UpdateColumns(x => new
  11611. {
  11612. x.Days,
  11613. x.NationalTravelFeeId,
  11614. x.Cost,
  11615. x.Currency,
  11616. x.SubTotal
  11617. })
  11618. .WhereColumns(x => new { x.Id })
  11619. .ExecuteCommandAsync();
  11620. if (subUpd < 1) return Ok(JsonView(false));
  11621. }
  11622. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11623. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11624. }
  11625. /// <summary>
  11626. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11627. /// </summary>
  11628. /// <returns></returns>
  11629. [HttpPost]
  11630. [ApiExplorerSettings(IgnoreApi = true)]
  11631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11632. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11633. {
  11634. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11635. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11636. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11637. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11638. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11639. {
  11640. Id = x.Id,
  11641. ParentId = dto.DraftId,
  11642. SetDataId = x.SetDataId,
  11643. Index = x.Index,
  11644. Cost = x.Cost,
  11645. Currency = x.Currency,
  11646. SubTotal = x.SubTotal,
  11647. CreateUserId = dto.CurrUserId,
  11648. Remark = x.Remark
  11649. }).ToList();
  11650. var adds = infos.Where(x => x.Id <= 0).ToList();
  11651. var upds = infos.Where(x => x.Id > 0).ToList();
  11652. if (adds.Count > 0)
  11653. {
  11654. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11655. if (add < 1) return Ok(JsonView(false));
  11656. }
  11657. if (upds.Count > 0)
  11658. {
  11659. var upd = await _sqlSugar.Updateable(adds)
  11660. .UpdateColumns(x => new
  11661. {
  11662. x.Index,
  11663. x.SetDataId,
  11664. x.Cost,
  11665. x.Currency,
  11666. x.SubTotal,
  11667. x.Remark
  11668. })
  11669. .WhereColumns(x => new { x.Id })
  11670. .ExecuteCommandAsync();
  11671. if (upd < 1) return Ok(JsonView(false));
  11672. }
  11673. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11674. //消息通知
  11675. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11676. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11677. return Ok(JsonView(new { itemTotal = itemTotal }));
  11678. }
  11679. /// <summary>
  11680. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11681. /// </summary>
  11682. /// <returns></returns>
  11683. [HttpPost]
  11684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11685. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11686. {
  11687. int subId = dto.SubId, id = dto.DraftId;
  11688. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11689. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11690. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11691. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11692. subInfo.Id = subId;
  11693. subInfo.ParentId = id;
  11694. subInfo.CreateUserId = dto.CurrUserId;
  11695. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11696. if (parentId < 1) return Ok(JsonView(false));
  11697. #region 子表op
  11698. if (subId < 1)//add
  11699. {
  11700. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11701. if (subAdd < 1) return Ok(JsonView(false));
  11702. }
  11703. else //upd
  11704. {
  11705. var subUpd = await _sqlSugar.Updateable(subInfo)
  11706. .UpdateColumns(x => new
  11707. {
  11708. x.Index,
  11709. x.SetDataId,
  11710. x.Cost,
  11711. x.Currency,
  11712. x.SubTotal,
  11713. x.Remark
  11714. })
  11715. .WhereColumns(x => new { x.Id })
  11716. .ExecuteCommandAsync();
  11717. if (subUpd < 1) return Ok(JsonView(false));
  11718. }
  11719. #endregion
  11720. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11721. ////消息通知
  11722. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11723. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11724. }
  11725. /// <summary>
  11726. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11727. /// </summary>
  11728. /// <returns></returns>
  11729. [HttpPost]
  11730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11731. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11732. {
  11733. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11734. if (data.Code != 0)
  11735. {
  11736. return Ok(JsonView(false, data.Msg));
  11737. }
  11738. return Ok(JsonView(true, "操作成功!", data.Data));
  11739. }
  11740. /// <summary>
  11741. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11742. /// </summary>
  11743. /// <param name="dto"></param>
  11744. /// <returns></returns>
  11745. [HttpPost]
  11746. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11747. {
  11748. var data = new Grp_DayOtherPriceDraft()
  11749. {
  11750. Id = dto.Id,
  11751. IsDel = 1,
  11752. DeleteUserId = dto.DeleteUserId,
  11753. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11754. };
  11755. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11756. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11757. return Ok(JsonView(false, "删除失败!"));
  11758. }
  11759. #endregion
  11760. #endregion
  11761. #region 团组经理模块 出入境费用报价表
  11762. /// <summary>
  11763. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11764. /// </summary>
  11765. /// <returns></returns>
  11766. [HttpPost]
  11767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11768. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11769. {
  11770. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11771. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11772. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11773. initRates.Insert(0, cnyInfo);
  11774. liveRates.Insert(0, cnyInfo);
  11775. return Ok(JsonView(true, "查询成功!", new
  11776. {
  11777. InitRates = initRates,
  11778. LiveRates = liveRates
  11779. }));
  11780. }
  11781. /// <summary>
  11782. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11783. /// </summary>
  11784. /// <returns></returns>
  11785. [HttpPost]
  11786. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11787. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  11788. {
  11789. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11790. }
  11791. /// <summary>
  11792. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11793. /// </summary>
  11794. /// <returns></returns>
  11795. [HttpPost]
  11796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11797. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  11798. {
  11799. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11800. }
  11801. /// <summary>
  11802. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11803. /// </summary>
  11804. /// <returns></returns>
  11805. [HttpPost]
  11806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11807. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11808. {
  11809. int groupId = dto.DiId,
  11810. currUserId = dto.CurrUserId;
  11811. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11812. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11813. //验证报价数据是否存在
  11814. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  11815. if (isNull != null)
  11816. {
  11817. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  11818. if (!info1.Rates.Any())
  11819. {
  11820. var rates = await GeneralMethod.EnterExitCostInitRate();
  11821. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11822. info1.Rates = rates.ToArray();
  11823. }
  11824. return Ok(JsonView(info1));
  11825. }
  11826. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  11827. result.GroupId = groupId;
  11828. //处理报价名称
  11829. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11830. if (groupInfo != null)
  11831. {
  11832. var visitCountry = groupInfo.VisitCountry;
  11833. if (!string.IsNullOrEmpty(visitCountry))
  11834. {
  11835. string quoteName = string.Empty;
  11836. if (visitCountry.Contains("|"))
  11837. {
  11838. var countrys = visitCountry.Split("|");
  11839. quoteName = string.Join("、", countrys);
  11840. }
  11841. else quoteName = visitCountry;
  11842. quoteName += $"团组报价表";
  11843. result.Name = quoteName;
  11844. }
  11845. }
  11846. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  11847. if (info.Code != StatusCodes.Status200OK)
  11848. {
  11849. if (!result.Rates.Any())
  11850. {
  11851. var rates = await GeneralMethod.EnterExitCostInitRate();
  11852. result.Rates = rates.ToArray();
  11853. }
  11854. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  11855. }
  11856. var infoView = info.Data as EnterExitCostInfoView;
  11857. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  11858. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  11859. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  11860. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11861. var eecRates = infoView.Currencys;
  11862. //默认添加人名币
  11863. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  11864. {
  11865. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11866. }
  11867. //处理团组人数
  11868. int pplNum = 1;
  11869. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  11870. var views = new List<QuoteSubItemInfo>();
  11871. #region 数据填充
  11872. var intTravelCosts = new List<QuoteSubItemInfo>();
  11873. #region 机票费用 1354
  11874. int intTravelIndex = 1;
  11875. if (infoView.SumJJC == 1)
  11876. {
  11877. intTravelCosts.Add(new QuoteSubItemInfo
  11878. {
  11879. ItemId = 1354,
  11880. Index = intTravelIndex,
  11881. FeeName = "经济舱",
  11882. UnitPrice = infoView.AirJJ,
  11883. Currency = "CNY",
  11884. Quantity = 1,
  11885. PplNum = 1,
  11886. TotalAmt = infoView.AirJJ,
  11887. Remark = "",
  11888. });
  11889. intTravelIndex++;
  11890. }
  11891. if (infoView.SumGWC == 1)
  11892. {
  11893. intTravelCosts.Add(new QuoteSubItemInfo
  11894. {
  11895. ItemId = 1354,
  11896. Index = intTravelIndex,
  11897. FeeName = "公务舱",
  11898. UnitPrice = infoView.AirGW,
  11899. Currency = "CNY",
  11900. Quantity = 1,
  11901. PplNum = 1,
  11902. TotalAmt = infoView.AirGW,
  11903. Remark = "",
  11904. });
  11905. intTravelIndex++;
  11906. }
  11907. if (infoView.SumTDC == 1)
  11908. {
  11909. intTravelCosts.Add(new QuoteSubItemInfo
  11910. {
  11911. ItemId = 1354,
  11912. Index = intTravelIndex,
  11913. FeeName = "头等舱",
  11914. UnitPrice = infoView.AirTD,
  11915. Currency = "CNY",
  11916. Quantity = 1,
  11917. PplNum = 1,
  11918. TotalAmt = infoView.AirTD,
  11919. Remark = "",
  11920. });
  11921. intTravelIndex++;
  11922. }
  11923. intTravelCosts.Add(new QuoteSubItemInfo
  11924. {
  11925. ItemId = 1354,
  11926. Index = intTravelIndex,
  11927. FeeName = "城市间交通费用",
  11928. UnitPrice = infoView.CityTranffic,
  11929. Currency = "CNY",
  11930. Quantity = 1,
  11931. PplNum = pplNum,
  11932. TotalAmt = infoView.CityTranffic * pplNum,
  11933. Remark = "",
  11934. });
  11935. views.AddRange(intTravelCosts);
  11936. #endregion
  11937. var accomCosts = new List<QuoteSubItemInfo>();
  11938. #region 住宿费 1355
  11939. if (infoView.QuarterageData.Any())
  11940. {
  11941. int accomIndex = 1;
  11942. int accomItemTypeId = 1355;
  11943. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  11944. foreach (var item in groupData)
  11945. {
  11946. string feeName = string.Empty;
  11947. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11948. if (countryInfo != null)
  11949. {
  11950. feeName = countryInfo.Country;
  11951. var city = countryInfo.City;
  11952. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11953. {
  11954. feeName += $"-{city}";
  11955. }
  11956. }
  11957. var hotelInfo = item.FirstOrDefault();
  11958. if (hotelInfo == null) continue;
  11959. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  11960. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11961. int quantity = item.ToList().Count;
  11962. accomCosts.Add(new QuoteSubItemInfo
  11963. {
  11964. ItemId = accomItemTypeId,
  11965. Index = accomIndex,
  11966. FeeName = feeName,
  11967. UnitPrice = hotelInfo.Cost,
  11968. Currency = thisCurrency,
  11969. Quantity = quantity,
  11970. PplNum = pplNum,
  11971. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  11972. Remark = "",
  11973. });
  11974. accomIndex++;
  11975. }
  11976. views.AddRange(accomCosts);
  11977. }
  11978. #endregion
  11979. var mealCosts = new List<QuoteSubItemInfo>();
  11980. #region 餐饮费 1356
  11981. if (infoView.BoardWagesData.Any())
  11982. {
  11983. var mealIndex = 1;
  11984. int mealItemTypeId = 1356;
  11985. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  11986. foreach (var item in groupData)
  11987. {
  11988. string feeName = string.Empty;
  11989. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11990. if (countryInfo != null)
  11991. {
  11992. feeName = countryInfo.Country;
  11993. var city = countryInfo.City;
  11994. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11995. {
  11996. feeName += $"-{city}";
  11997. }
  11998. }
  11999. var mealInfo = item.FirstOrDefault();
  12000. if (mealInfo == null) continue;
  12001. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  12002. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12003. int quantity = item.ToList().Count;
  12004. mealCosts.Add(new QuoteSubItemInfo
  12005. {
  12006. ItemId = mealItemTypeId,
  12007. Index = mealIndex,
  12008. FeeName = feeName,
  12009. UnitPrice = mealInfo.Cost,
  12010. Currency = thisCurrency,
  12011. Quantity = quantity,
  12012. PplNum = pplNum,
  12013. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  12014. Remark = "",
  12015. });
  12016. mealIndex++;
  12017. }
  12018. views.AddRange(mealCosts);
  12019. }
  12020. #endregion
  12021. var miscCosts = new List<QuoteSubItemInfo>();
  12022. #region 公杂费 1364
  12023. if (infoView.MiscellaneousFeeData.Any())
  12024. {
  12025. var miscIndex = 1;
  12026. int miscItemTypeId = 1364;
  12027. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  12028. foreach (var item in groupData)
  12029. {
  12030. string feeName = string.Empty;
  12031. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12032. if (countryInfo != null)
  12033. {
  12034. feeName = countryInfo.Country;
  12035. var city = countryInfo.City;
  12036. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12037. {
  12038. feeName += $"-{city}";
  12039. }
  12040. }
  12041. var miscInfo = item.FirstOrDefault();
  12042. if (miscInfo == null) continue;
  12043. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  12044. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12045. int quantity = item.ToList().Count;
  12046. miscCosts.Add(new QuoteSubItemInfo
  12047. {
  12048. ItemId = miscItemTypeId,
  12049. Index = miscIndex,
  12050. FeeName = feeName,
  12051. UnitPrice = miscInfo.Cost,
  12052. Currency = thisCurrency,
  12053. Quantity = quantity,
  12054. PplNum = pplNum,
  12055. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  12056. Remark = "",
  12057. });
  12058. miscIndex++;
  12059. }
  12060. views.AddRange(miscCosts);
  12061. }
  12062. #endregion
  12063. #region 签证+保险 1362
  12064. int visaInsIndex = 1;
  12065. int visaInsItemTypeId = 1362;
  12066. if (infoView.Visa > 0)
  12067. {
  12068. views.Add(new QuoteSubItemInfo()
  12069. {
  12070. ItemId = visaInsItemTypeId,
  12071. Index = visaInsIndex,
  12072. FeeName = $"签证",
  12073. UnitPrice = infoView.Visa,
  12074. Currency = $"CNY",
  12075. Quantity = 1,
  12076. PplNum = pplNum,
  12077. TotalAmt = infoView.Visa * pplNum,
  12078. Remark = "",
  12079. });
  12080. visaInsIndex++;
  12081. }
  12082. if (infoView.Safe > 0)
  12083. {
  12084. views.Add(new QuoteSubItemInfo()
  12085. {
  12086. ItemId = visaInsItemTypeId,
  12087. Index = visaInsIndex,
  12088. FeeName = $"保险",
  12089. UnitPrice = infoView.Safe,
  12090. Currency = $"CNY",
  12091. Quantity = 1,
  12092. PplNum = pplNum,
  12093. TotalAmt = infoView.Safe * pplNum,
  12094. Remark = "",
  12095. });
  12096. }
  12097. #endregion
  12098. #region 服务费 1363
  12099. int serviceFeeIndex = 1;
  12100. int serviceFeeItemTypeId = 1363;
  12101. if (infoView.Service > 0)
  12102. {
  12103. views.Add(new QuoteSubItemInfo()
  12104. {
  12105. ItemId = serviceFeeItemTypeId,
  12106. Index = serviceFeeIndex,
  12107. FeeName = $"服务费",
  12108. UnitPrice = infoView.Service,
  12109. Currency = $"CNY",
  12110. Quantity = 1,
  12111. PplNum = pplNum,
  12112. TotalAmt = infoView.Service * pplNum,
  12113. Remark = "",
  12114. });
  12115. }
  12116. #endregion
  12117. #endregion
  12118. if (result.FeeItems.Any())
  12119. {
  12120. result.FeeItems.Select(x =>
  12121. {
  12122. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  12123. if (feeInfos.Any()) x.Infos = feeInfos;
  12124. return x;
  12125. }
  12126. ).OrderBy(x => x.Index)
  12127. .ToList();
  12128. if (!result.Rates.Any())
  12129. {
  12130. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  12131. else
  12132. {
  12133. var rates = await GeneralMethod.EnterExitCostInitRate();
  12134. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12135. result.Rates = rates.ToArray();
  12136. }
  12137. }
  12138. }
  12139. return Ok(JsonView(result));
  12140. }
  12141. /// <summary>
  12142. /// 团组模块 - 出入境费用报价表 - Info
  12143. /// </summary>
  12144. /// <returns></returns>
  12145. [HttpPost]
  12146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12147. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  12148. {
  12149. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  12150. if (!info.Rates.Any())
  12151. {
  12152. var rates = await GeneralMethod.EnterExitCostInitRate();
  12153. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12154. info.Rates = rates.ToArray();
  12155. }
  12156. return Ok(JsonView(info));
  12157. }
  12158. /// <summary>
  12159. /// 团组模块 - 出入境费用报价表 - OP
  12160. /// </summary>
  12161. /// <returns></returns>
  12162. [HttpPost]
  12163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12164. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  12165. {
  12166. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  12167. }
  12168. /// <summary>
  12169. /// 团组模块 - 出入境费用报价表 - 删除 项
  12170. /// </summary>
  12171. /// <returns></returns>
  12172. [HttpPost]
  12173. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12174. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12175. {
  12176. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12177. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12178. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12179. }
  12180. /// <summary>
  12181. /// 团组模块 - 出入境费用报价表 - 导出
  12182. /// </summary>
  12183. /// <returns></returns>
  12184. [HttpPost]
  12185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12186. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12187. {
  12188. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12189. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12190. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12191. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12192. var rates = info.Rates;
  12193. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12194. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12195. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12196. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12197. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12198. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12199. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12200. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12201. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12202. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12203. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12204. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12205. //获取模板
  12206. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12207. var designer = new WorkbookDesigner();
  12208. designer.Workbook = new Workbook(tempPath);
  12209. designer.SetDataSource("QuoteName", info.Name);
  12210. designer.SetDataSource("CompanyTitle", "公司名称");
  12211. designer.SetDataSource("CompanyLabel", "");
  12212. #region 国际旅费
  12213. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12214. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12215. {
  12216. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12217. StringBuilder label = new StringBuilder();
  12218. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12219. if (infos.Any())
  12220. {
  12221. label.Append(infos.Sum(x => x.PplNum));
  12222. label.Append("人全程机票:");
  12223. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12224. label.AppendLine("元");
  12225. }
  12226. foreach (var item in intTravelCosts.Infos)
  12227. {
  12228. label.Append(item.FeeName);
  12229. label.Append(":");
  12230. label.Append(item.UnitPrice.TruncDecimals(2));
  12231. label.Append("元/人*");
  12232. label.Append(item.PplNum);
  12233. label.AppendLine("人");
  12234. }
  12235. if (label.HasValue())
  12236. {
  12237. label.Append("\r\n以上小计:");
  12238. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12239. label.Append("元");
  12240. }
  12241. designer.SetDataSource("IntTravelLabel", label.ToString());
  12242. }
  12243. #endregion
  12244. #region 住宿费
  12245. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12246. if (accomCosts != null && accomCosts.Infos.Any())
  12247. {
  12248. string currencyName = string.Empty,
  12249. countryName = string.Empty;
  12250. decimal rate = 1.0000M;
  12251. StringBuilder label = new StringBuilder();
  12252. label.AppendLine("全程五星酒店,每人1间房");
  12253. foreach (var item in accomCosts.Infos)
  12254. {
  12255. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12256. string name = string.Empty, thisCountryName = string.Empty;
  12257. if (item.FeeName.Contains("-"))
  12258. {
  12259. var feeName = item.FeeName.Split('-');
  12260. thisCountryName = feeName[0];
  12261. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12262. name = feeName[1];
  12263. }
  12264. else name = item.FeeName;
  12265. string thisFeeName = string.Empty;
  12266. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12267. else thisFeeName = $"\r\n{name}:";
  12268. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12269. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12270. rate = rateInfo?.Rate ?? 1.0000M;
  12271. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12272. label.AppendLine(subLabel);
  12273. }
  12274. if (label.HasValue())
  12275. {
  12276. //以上小计:52440元(美金汇率:7.5 )
  12277. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12278. label.AppendLine(subLabel);
  12279. }
  12280. designer.SetDataSource("AccomLabel", label.ToString());
  12281. }
  12282. #endregion
  12283. #region 餐饮费
  12284. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12285. if (mealCosts != null && mealCosts.Infos.Any())
  12286. {
  12287. string currencyName = string.Empty;
  12288. decimal rate = 1.0000M;
  12289. StringBuilder label = new StringBuilder();
  12290. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12291. foreach (var item in mealCosts.Infos)
  12292. {
  12293. string name = string.Empty;
  12294. if (item.FeeName.Contains("-"))
  12295. {
  12296. var feeName = item.FeeName.Split('-');
  12297. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12298. }
  12299. else name = $"\r\n{item.FeeName}:";
  12300. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12301. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12302. rate = rateInfo?.Rate ?? 1.0000M;
  12303. label.Append(name);
  12304. label.Append(item.UnitPrice.TruncDecimals(2));
  12305. label.Append(currencyName);
  12306. label.Append("/天*");
  12307. label.Append(item.Quantity.ToString("#0"));
  12308. label.Append("*");
  12309. label.Append(item.PplNum);
  12310. label.Append("人\r\n");
  12311. }
  12312. if (label.HasValue())
  12313. {
  12314. label.Append("\r\n以上小计:");
  12315. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12316. label.Append("元\r\n(");
  12317. label.Append("汇率:");
  12318. label.Append(rate.TruncDecimals(4));
  12319. label.Append(")");
  12320. }
  12321. designer.SetDataSource("MealLabel", label.ToString());
  12322. }
  12323. #endregion
  12324. #region 车辆安排
  12325. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12326. if (vehArranges != null && vehArranges.Infos.Any())
  12327. {
  12328. string currencyName = string.Empty;
  12329. //decimal rate = 1.0000M;
  12330. StringBuilder label = new StringBuilder();
  12331. foreach (var item in vehArranges.Infos)
  12332. {
  12333. label.AppendLine();
  12334. label.AppendLine();
  12335. label.Append(item.FeeName);
  12336. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12337. }
  12338. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12339. }
  12340. #endregion
  12341. #region 邀请函发放对象
  12342. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12343. designer.SetDataSource("InviteToContent", "");
  12344. #endregion
  12345. #region 邀请函费
  12346. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12347. StringBuilder is_label = new StringBuilder();
  12348. if (inviteCosts != null && inviteCosts.Infos.Any())
  12349. {
  12350. string currencyName = string.Empty;
  12351. decimal rate = 1.0000M;
  12352. foreach (var item in inviteCosts.Infos)
  12353. {
  12354. //乌兹别克斯坦:2000美金
  12355. currencyName = item.Currency;
  12356. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12357. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12358. is_label.AppendLine(label);
  12359. }
  12360. if (is_label.HasValue())
  12361. {
  12362. //以上小计:28500元(美金汇率:7.5)
  12363. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12364. is_label.AppendLine(label);
  12365. }
  12366. }
  12367. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12368. #endregion
  12369. #region 邀请函发放时间
  12370. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12371. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12372. #endregion
  12373. #region 公务活动(含翻译)
  12374. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12375. StringBuilder oa_label = new StringBuilder();
  12376. if (officialActs != null && officialActs.Infos.Any())
  12377. {
  12378. string currencyName = string.Empty;
  12379. decimal rate = 1.0000M;
  12380. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12381. foreach (var item in officialActs.Infos)
  12382. {
  12383. //乌兹别克斯坦:1000美金/场
  12384. currencyName = item.Currency;
  12385. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12386. string label_remark = string.Empty;
  12387. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12388. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12389. }
  12390. label_content += "*总费用中未含超出公务活动价格";
  12391. //8场公务活动(以上小计:60000元)
  12392. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12393. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12394. oa_label.AppendLine(label_title);
  12395. oa_label.AppendLine(label_content);
  12396. }
  12397. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12398. #endregion
  12399. #region 签证+保险
  12400. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12401. StringBuilder vi_label = new StringBuilder();
  12402. if (visaIns != null && visaIns.Infos.Any())
  12403. {
  12404. foreach (var item in visaIns.Infos)
  12405. {
  12406. //签证:500元/人
  12407. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12408. vi_label.AppendLine(label);
  12409. }
  12410. if (vi_label.HasValue())
  12411. {
  12412. //以上小计:6000元
  12413. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12414. vi_label.AppendLine(label);
  12415. }
  12416. }
  12417. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12418. #endregion
  12419. #region 服务费
  12420. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12421. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12422. #endregion
  12423. #region 公杂费
  12424. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12425. StringBuilder pm_label = new StringBuilder();
  12426. if (pubMiscs != null && pubMiscs.Infos.Any())
  12427. {
  12428. string currencyName = string.Empty,
  12429. countryName = string.Empty;
  12430. decimal rate = 1.0000M;
  12431. foreach (var item in pubMiscs.Infos)
  12432. {
  12433. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12434. string name = string.Empty, thisCountryName = string.Empty;
  12435. if (item.FeeName.Contains("-"))
  12436. {
  12437. var feeName = item.FeeName.Split('-');
  12438. thisCountryName = feeName[0];
  12439. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12440. name = feeName[1];
  12441. }
  12442. else name = item.FeeName;
  12443. string thisFeeName = string.Empty;
  12444. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12445. else thisFeeName = $"\r\n{name}:";
  12446. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12447. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12448. rate = rateInfo?.Rate ?? 1.0000M;
  12449. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12450. pm_label.AppendLine(label);
  12451. }
  12452. if (pm_label.HasValue())
  12453. {
  12454. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12455. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12456. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12457. pm_label.AppendLine(string.Format("部分发放成员"));
  12458. }
  12459. }
  12460. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12461. #endregion
  12462. #region 税费
  12463. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12464. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12465. #endregion
  12466. #region 合计(单位:元)
  12467. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12468. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12469. #endregion
  12470. #region 汇率 Remark
  12471. var rate_label = new StringBuilder();
  12472. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12473. foreach (var item in rateGroups)
  12474. {
  12475. //美元汇率按\r\n1:7.5
  12476. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12477. rate_label.AppendLine(label);
  12478. }
  12479. designer.SetDataSource("RateLabel", rate_label.ToString());
  12480. #endregion
  12481. designer.Process();
  12482. //文件名
  12483. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12484. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12485. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12486. return Ok(JsonView(true, "成功", url));
  12487. }
  12488. #endregion
  12489. #region 签证费用录入
  12490. /// <summary>
  12491. /// 根据diid查询签证费用列表
  12492. /// </summary>
  12493. /// <param name="dto"></param>
  12494. /// <returns></returns>
  12495. [HttpPost]
  12496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12497. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12498. {
  12499. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12500. if (groupData.Code != 0)
  12501. {
  12502. return Ok(JsonView(false, groupData.Msg));
  12503. }
  12504. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12505. }
  12506. /// <summary>
  12507. /// 根据签证费用Id查询单条数据及c表数据
  12508. /// </summary>
  12509. /// <param name="dto"></param>
  12510. /// <returns></returns>
  12511. [HttpPost]
  12512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12513. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12514. {
  12515. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12516. if (groupData.Code != 0)
  12517. {
  12518. return Ok(JsonView(false, groupData.Msg));
  12519. }
  12520. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12521. }
  12522. /// <summary>
  12523. /// 签证费用删除
  12524. /// </summary>
  12525. /// <param name="dto"></param>
  12526. /// <returns></returns>
  12527. [HttpPost]
  12528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12529. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12530. {
  12531. _sqlSugar.BeginTran();
  12532. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12533. if (!res)
  12534. {
  12535. _sqlSugar.RollbackTran();
  12536. return Ok(JsonView(false, "删除失败"));
  12537. }
  12538. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12539. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12540. .SetColumns(a => new Grp_CreditCardPayment()
  12541. {
  12542. IsDel = 1,
  12543. DeleteUserId = dto.DeleteUserId,
  12544. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12545. })
  12546. .ExecuteCommand();
  12547. if (resSub < 1)
  12548. {
  12549. _sqlSugar.RollbackTran();
  12550. return Ok(JsonView(false, "删除失败"));
  12551. }
  12552. _sqlSugar.CommitTran();
  12553. return Ok(JsonView(true, "删除成功!"));
  12554. }
  12555. /// <summary>
  12556. /// 签证费用录入下拉框初始化
  12557. /// </summary>
  12558. /// <returns></returns>
  12559. [HttpPost]
  12560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12561. public async Task<IActionResult> VisaPriceAddSelect()
  12562. {
  12563. //支付方式
  12564. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12565. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12566. //币种
  12567. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12568. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12569. //乘客类型
  12570. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12571. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12572. //卡类型
  12573. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12574. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12575. //代办费类型
  12576. var agencyFeeTypeData = new List<dynamic>() {
  12577. new { id = 0 , Text = "未选择" },
  12578. new { id = 1 , Text = "小公务" },
  12579. new { id = 2 , Text = "大公务" },
  12580. };
  12581. //签证费用标准国家Data
  12582. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12583. var data = new
  12584. {
  12585. Payment = _Payment,
  12586. CurrencyList = _CurrencyList,
  12587. PassengerType = _PassengerType,
  12588. BankCard = _BankCard,
  12589. AgencyFeeType = agencyFeeTypeData,
  12590. CountryFeeData = visaCountryFeeData
  12591. };
  12592. return Ok(JsonView(true, "查询成功!", data));
  12593. }
  12594. /// <summary>
  12595. /// 签证费用录入操作(Status:1.新增,2.修改)
  12596. /// </summary>
  12597. /// <param name="dto"></param>
  12598. /// <returns></returns>
  12599. [HttpPost]
  12600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12601. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12602. {
  12603. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12604. if (groupData.Code != 0)
  12605. {
  12606. return Ok(JsonView(false, groupData.Msg));
  12607. }
  12608. #region 应用推送
  12609. try
  12610. {
  12611. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12612. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12613. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12614. //2024-10-21 新增LZ UID
  12615. var userIds = new List<int>() { 21 };
  12616. string title = $"系统通知";
  12617. string content = "";
  12618. var diId = dto.DiId;
  12619. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12620. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12621. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12622. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12623. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12624. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12625. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12626. }
  12627. catch (Exception ex)
  12628. {
  12629. }
  12630. #endregion
  12631. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12632. }
  12633. #endregion
  12634. #region 签证提成录入
  12635. /// <summary>
  12636. /// 签证提成录入
  12637. /// 基础数据
  12638. /// </summary>
  12639. /// <returns></returns>
  12640. [HttpGet]
  12641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12642. public async Task<IActionResult> VisaCommissionInit()
  12643. {
  12644. return Ok(await _visaCommissionRep.Init());
  12645. }
  12646. /// <summary>
  12647. /// 签证提成录入
  12648. /// Item
  12649. /// </summary>
  12650. /// <param name="_dto"></param>
  12651. /// <returns></returns>
  12652. [HttpPost]
  12653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12654. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12655. {
  12656. var validator = new VisaCommissionItemDtoValidator();
  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.Item(_dto));
  12668. }
  12669. /// <summary>
  12670. /// 签证提成录入
  12671. /// Save
  12672. /// </summary>
  12673. /// <param name="_dto"></param>
  12674. /// <returns></returns>
  12675. [HttpPost]
  12676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12677. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12678. {
  12679. //参数验证
  12680. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12681. foreach (var item in _dto.Items)
  12682. {
  12683. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12684. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12685. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12686. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12687. }
  12688. return Ok(await _visaCommissionRep.Save(_dto));
  12689. }
  12690. /// <summary>
  12691. /// 签证提成录入
  12692. /// Create
  12693. /// </summary>
  12694. /// <param name="_dto"></param>
  12695. /// <returns></returns>
  12696. [HttpPost]
  12697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12698. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12699. {
  12700. var validator = new VisaCommissionCreateDtoValidator();
  12701. var validatorRes = await validator.ValidateAsync(_dto);
  12702. if (!validatorRes.IsValid)
  12703. {
  12704. StringBuilder sb = new StringBuilder();
  12705. foreach (var item in validatorRes.Errors)
  12706. {
  12707. sb.AppendLine(item.ErrorMessage);
  12708. }
  12709. return Ok(JsonView(false, sb.ToString()));
  12710. }
  12711. return Ok(await _visaCommissionRep.Create(_dto));
  12712. }
  12713. /// <summary>
  12714. /// 签证提成录入
  12715. /// Put(编辑)
  12716. /// </summary>
  12717. /// <param name="id"></param>
  12718. /// <param name="_dto"></param>
  12719. /// <returns></returns>
  12720. [HttpPut]
  12721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12722. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12723. {
  12724. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12725. var validator = new VisaCommissionCreateDtoValidator();
  12726. var validatorRes = await validator.ValidateAsync(_dto);
  12727. if (!validatorRes.IsValid)
  12728. {
  12729. StringBuilder sb = new StringBuilder();
  12730. foreach (var item in validatorRes.Errors)
  12731. {
  12732. sb.AppendLine(item.ErrorMessage);
  12733. }
  12734. return Ok(JsonView(false, sb.ToString()));
  12735. }
  12736. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12737. }
  12738. /// <summary>
  12739. /// 签证提成录入
  12740. /// Del
  12741. /// </summary>
  12742. /// <param name="id"></param>
  12743. /// <param name="currUserId"></param>
  12744. /// <returns></returns>
  12745. [HttpPost]
  12746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12747. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12748. {
  12749. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12750. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12751. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12752. }
  12753. #endregion
  12754. #region op费用录入
  12755. /// <summary>
  12756. /// 根据diid查询op费用列表
  12757. /// </summary>
  12758. /// <param name="dto"></param>
  12759. /// <returns></returns>
  12760. [HttpPost]
  12761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12762. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12763. {
  12764. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12765. if (groupData.Code != 0)
  12766. {
  12767. return Ok(JsonView(false, groupData.Msg));
  12768. }
  12769. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12770. }
  12771. /// <summary>
  12772. /// 根据op费用Id查询单条数据及c表数据
  12773. /// </summary>
  12774. /// <param name="dto"></param>
  12775. /// <returns></returns>
  12776. [HttpPost]
  12777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12778. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12779. {
  12780. try
  12781. {
  12782. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12783. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12784. var data = new
  12785. {
  12786. CarTouristGuideGround = _groupData,
  12787. CreditCardPayment = _creditCardPayment
  12788. };
  12789. return Ok(JsonView(true, "查询成功!", data));
  12790. }
  12791. catch (Exception ex)
  12792. {
  12793. return Ok(JsonView(false, "程序错误!"));
  12794. }
  12795. }
  12796. /// <summary>
  12797. /// op费用删除
  12798. /// </summary>
  12799. /// <param name="dto"></param>
  12800. /// <returns></returns>
  12801. [HttpPost]
  12802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12803. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12804. {
  12805. try
  12806. {
  12807. _sqlSugar.BeginTran();
  12808. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12809. if (!res)
  12810. {
  12811. return Ok(JsonView(false, "删除失败"));
  12812. }
  12813. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12814. {
  12815. IsDel = 1,
  12816. DeleteUserId = dto.DeleteUserId,
  12817. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12818. }).ExecuteCommandAsync();
  12819. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12820. {
  12821. IsDel = 1,
  12822. DeleteUserId = dto.DeleteUserId,
  12823. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12824. }).ExecuteCommandAsync();
  12825. #region 删除超支相关数据
  12826. //删除导入的超支数据
  12827. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12828. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12829. {
  12830. IsDel = 1,
  12831. DeleteUserId = dto.DeleteUserId,
  12832. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12833. }).ExecuteCommand();
  12834. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12835. {
  12836. IsDel = 1,
  12837. DeleteUserId = dto.DeleteUserId,
  12838. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12839. }).ExecuteCommand();
  12840. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12841. {
  12842. IsDel = 1,
  12843. DeleteUserId = dto.DeleteUserId,
  12844. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12845. }).ExecuteCommand();
  12846. #endregion
  12847. _sqlSugar.CommitTran();
  12848. return Ok(JsonView(true, "删除成功!"));
  12849. }
  12850. catch (Exception ex)
  12851. {
  12852. _sqlSugar.RollbackTran();
  12853. return Ok(JsonView(false, "程序错误!" + ex.Message));
  12854. }
  12855. }
  12856. /// <summary>
  12857. /// op费用录入操作(Status:1.新增,2.修改)
  12858. /// </summary>
  12859. /// <param name="dto"></param>
  12860. /// <returns></returns>
  12861. [HttpPost]
  12862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12863. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  12864. {
  12865. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  12866. if (groupData.Code != 0)
  12867. {
  12868. return Ok(JsonView(false, groupData.Msg));
  12869. }
  12870. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12871. }
  12872. /// <summary>
  12873. /// 填写费用详细页面初始化绑定
  12874. /// </summary>
  12875. /// <param name="dto"></param>
  12876. /// <returns></returns>
  12877. [HttpPost]
  12878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12879. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  12880. {
  12881. try
  12882. {
  12883. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  12884. if (groupData.Code != 0)
  12885. {
  12886. return Ok(JsonView(false, groupData.Msg));
  12887. }
  12888. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12889. }
  12890. catch (Exception ex)
  12891. {
  12892. return Ok(JsonView(false, ex.Message));
  12893. }
  12894. }
  12895. /// <summary>
  12896. /// 根据op费用Id查询详细数据
  12897. /// </summary>
  12898. /// <param name="dto"></param>
  12899. /// <returns></returns>
  12900. [HttpPost]
  12901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12902. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  12903. {
  12904. try
  12905. {
  12906. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  12907. if (groupData.Code != 0)
  12908. {
  12909. return Ok(JsonView(false, groupData.Msg));
  12910. }
  12911. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12912. }
  12913. catch (Exception ex)
  12914. {
  12915. return Ok(JsonView(false, ex.Message));
  12916. }
  12917. }
  12918. /// <summary>
  12919. /// OP费用录入填写详情
  12920. /// </summary>
  12921. /// <param name="dto"></param>
  12922. /// <returns></returns>
  12923. [HttpPost]
  12924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12925. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  12926. {
  12927. try
  12928. {
  12929. #region 参数校验
  12930. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  12931. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  12932. if (di == null) return Ok(JsonView(false, "团组错误!"));
  12933. #endregion
  12934. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  12935. if (groupData.Code != 0)
  12936. {
  12937. return Ok(JsonView(false, groupData.Msg));
  12938. }
  12939. //自动审核
  12940. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  12941. #region 应用推送
  12942. try
  12943. {
  12944. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12945. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12946. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12947. //2024-10-21 新增LZ UID
  12948. var userIds = new List<int>() { 21 };
  12949. string title = $"系统通知";
  12950. var diId = dto.DiId;
  12951. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12952. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12953. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  12954. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12955. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  12956. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12957. }
  12958. catch (Exception ex)
  12959. {
  12960. }
  12961. #endregion
  12962. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12963. }
  12964. catch (Exception ex)
  12965. {
  12966. return Ok(JsonView(false, ex.Message));
  12967. }
  12968. }
  12969. /// <summary>
  12970. /// 获取三公详细所有城市
  12971. /// </summary>
  12972. /// <returns></returns>
  12973. [HttpGet]
  12974. public IActionResult OpCarCityResult()
  12975. {
  12976. var jw = JsonView(false);
  12977. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  12978. {
  12979. x.Id,
  12980. x.Country,
  12981. x.City,
  12982. }).ToList();
  12983. if (data.Count > 0)
  12984. {
  12985. jw = JsonView(true, "获取成功!", data);
  12986. }
  12987. else
  12988. {
  12989. jw.Msg = "城市数据为空!";
  12990. jw.Data = new string[0];
  12991. }
  12992. return Ok(jw);
  12993. }
  12994. /// <summary>
  12995. /// 导出地接费用明细
  12996. /// </summary>
  12997. /// <param name="dto"></param>
  12998. /// <returns></returns>
  12999. [HttpPost]
  13000. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  13001. {
  13002. var jw = JsonView(false);
  13003. if (dto.Diid < 1)
  13004. {
  13005. jw.Msg = "请输入正确的diid!";
  13006. return Ok(jw);
  13007. }
  13008. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  13009. if (group == null)
  13010. {
  13011. jw.Msg = "未找到团组信息!";
  13012. return Ok(jw);
  13013. }
  13014. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  13015. if (localGuideArr.Count == 0)
  13016. {
  13017. jw.Msg = "该团组暂无地接信息!";
  13018. return Ok(jw);
  13019. }
  13020. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  13021. var overspendSoure = new Dictionary<int, int>
  13022. {
  13023. { 91, 982 }, //车
  13024. { 92 , 1059} ,//导游
  13025. { 994 , 1073}, //翻译
  13026. { 988 , 1074 }, //早餐
  13027. { 93 , 1075 }, //午餐
  13028. { 989 , 1076 }, //晚餐
  13029. };
  13030. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  13031. foreach (var groupArr in localGroup)
  13032. {
  13033. var keyValue = groupArr.Key;
  13034. if (int.TryParse(keyValue, out int cityid))
  13035. {
  13036. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  13037. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  13038. }
  13039. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  13040. foreach (var item in groupArr)
  13041. {
  13042. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  13043. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  13044. new Grp_CarTouristGuideGroundReservationsContentExtend
  13045. {
  13046. Count = a.Count,
  13047. CreateTime = a.CreateTime,
  13048. CreateUserId = a.CreateUserId,
  13049. CTGGRId = a.CTGGRId,
  13050. Currency = a.Currency,
  13051. DatePrice = a.DatePrice,
  13052. DeleteTime = a.DeleteTime,
  13053. DeleteUserId = a.DeleteUserId,
  13054. DiId = a.DiId,
  13055. Id = a.Id,
  13056. IsDel = a.IsDel,
  13057. Price = a.Price,
  13058. PriceContent = a.PriceContent,
  13059. Remark = a.Remark,
  13060. SId = a.SId,
  13061. SidName = b.Name,
  13062. Units = a.Units,
  13063. }
  13064. ).ToList();
  13065. if (content.Count > 0)
  13066. {
  13067. contentArr.Add(content);
  13068. }
  13069. }
  13070. //open excel
  13071. //set excel
  13072. //save excel
  13073. try
  13074. {
  13075. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  13076. IWorkbook workbook;
  13077. if (Path.GetExtension(filePath).ToLower() == ".xls")
  13078. {
  13079. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13080. }
  13081. else
  13082. {
  13083. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13084. }
  13085. ISheet sheet = workbook.GetSheetAt(0);
  13086. var rowStartIndex = 2;
  13087. var clounmCount = 10;
  13088. var initStyleRow = sheet.GetRow(2);
  13089. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  13090. //var overspendArrDetail =
  13091. var existsId = new List<CarCompare>();
  13092. var lastElem = arr.Last();
  13093. var thisSid = -1;
  13094. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  13095. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  13096. {
  13097. Name = "未知币种!",
  13098. Remark = "未知币种!",
  13099. };
  13100. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  13101. Action cloneRowFn = () =>
  13102. {
  13103. rowStartIndex++;
  13104. var cloneRow = sheet.CreateRow(rowStartIndex);
  13105. // 复制样式
  13106. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  13107. {
  13108. ICell sourceCell = initStyleRow.GetCell(i);
  13109. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  13110. // 确保单元格存在样式
  13111. if (sourceCell.CellStyle != null)
  13112. {
  13113. targetCell.CellStyle = sourceCell.CellStyle;
  13114. }
  13115. }
  13116. };
  13117. var mergeRow = () =>
  13118. {
  13119. for (int i = 2; i < sheet.LastRowNum; i++)
  13120. {
  13121. var row = sheet.GetRow(i);
  13122. var cellFirst = row.GetCell(0);
  13123. var thisIndex = i + 1;
  13124. while (thisIndex < sheet.LastRowNum)
  13125. {
  13126. var nextRow = sheet.GetRow(thisIndex);
  13127. var nextCellFirst = nextRow.GetCell(0);
  13128. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  13129. {
  13130. thisIndex++;
  13131. }
  13132. else
  13133. {
  13134. break;
  13135. }
  13136. }
  13137. thisIndex--;
  13138. if (thisIndex != i)
  13139. {
  13140. //合并row
  13141. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  13142. i, // 起始行索引(0-based)
  13143. thisIndex, // 结束行索引(0-based)
  13144. 0, // 起始列索引(0-based)
  13145. 0 // 结束列索引(0-based)
  13146. );
  13147. sheet.AddMergedRegion(cellRangeAddress);
  13148. i = thisIndex;
  13149. }
  13150. }
  13151. };
  13152. var chaoshiNumber = 0;
  13153. var totalNumber = 0.00M;
  13154. string lastStr = "";
  13155. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  13156. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  13157. {
  13158. b.IsAuditGM,
  13159. x.Id,
  13160. x.Area,
  13161. b.PayPercentage,
  13162. b.PayMoney,
  13163. }).ToList();
  13164. string yesPayment = "", noPayment = "";
  13165. foreach (var item in queryCarArrByCityAndDiid)
  13166. {
  13167. if (item.IsAuditGM == 1)
  13168. {
  13169. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13170. }
  13171. else
  13172. {
  13173. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13174. }
  13175. }
  13176. lastStr = yesPayment + noPayment;
  13177. foreach (var item in arr)
  13178. {
  13179. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  13180. {
  13181. if (thisSid != item.SId)
  13182. {
  13183. if (thisSid == -1)
  13184. {
  13185. thisSid = item.SId;
  13186. }
  13187. else
  13188. {
  13189. //合并小计行
  13190. //创建合并区域的实例
  13191. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  13192. rowStartIndex, // 起始行索引(0-based)
  13193. rowStartIndex, // 结束行索引(0-based)
  13194. 0, // 起始列索引(0-based)
  13195. 3 // 结束列索引(0-based)
  13196. );
  13197. sheet.AddMergedRegion(cellRangeAddress);
  13198. var CellStyle = workbook.CreateCellStyle();
  13199. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13200. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13201. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13202. for (int i = 0; i <= clounmCount; i++)
  13203. {
  13204. if (i > 6)
  13205. {
  13206. var CellStyle1 = workbook.CreateCellStyle();
  13207. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13208. IFont Font = workbook.CreateFont(); // 创建字体
  13209. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13210. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13211. CellStyle1.SetFont(Font);
  13212. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13213. }
  13214. else
  13215. {
  13216. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13217. }
  13218. }
  13219. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13220. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13221. //超时合计
  13222. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13223. //超时数
  13224. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13225. //超时合计费用
  13226. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13227. thisSid = item.SId;
  13228. cloneRowFn();
  13229. chaoshiNumber = 0;
  13230. totalNumber = 0;
  13231. }
  13232. }
  13233. IRow row = sheet.GetRow(rowStartIndex);
  13234. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13235. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  13236. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13237. if (isOpenOverspendSoure)
  13238. {
  13239. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13240. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13241. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13242. }
  13243. for (int i = 0; i <= clounmCount; i++)
  13244. {
  13245. var cell = row.GetCell(i);
  13246. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13247. if (cell == null)
  13248. {
  13249. cell = row.CreateCell(i);
  13250. }
  13251. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13252. fontRed.CloneStyleFrom(cell.CellStyle);
  13253. IFont Font = workbook.CreateFont(); // 创建字体
  13254. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13255. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13256. fontRed.SetFont(Font);
  13257. byte[] rgb = new byte[3] { 255, 242, 204 };
  13258. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13259. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13260. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13261. if (workbook is XSSFWorkbook)
  13262. {
  13263. BackgroundColor255_242_204.FillForegroundColor = 0;
  13264. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13265. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13266. }
  13267. else
  13268. {
  13269. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13270. }
  13271. if (i == 1 || i > 6)
  13272. {
  13273. if (i > 6)
  13274. {
  13275. fontRed.FillForegroundColor = 0;
  13276. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13277. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13278. }
  13279. cell.CellStyle = fontRed;
  13280. }
  13281. if (i > 2 && i < 7)
  13282. {
  13283. cell.CellStyle = BackgroundColor255_242_204;
  13284. }
  13285. cell.SetCellValue(setCellValue); //写入单元格
  13286. }
  13287. if (overspendSoure.ContainsKey(thisSid))
  13288. {
  13289. var overspendId = overspendSoure[thisSid];
  13290. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13291. }
  13292. cloneRowFn();
  13293. existsId.Add(new CarCompare
  13294. {
  13295. DataPrice = item.DatePrice.ObjToDate(),
  13296. Sid = item.SId
  13297. });
  13298. }
  13299. if (item.Equals(lastElem))
  13300. {
  13301. //合并小计行
  13302. //创建合并区域的实例
  13303. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  13304. rowStartIndex, // 起始行索引(0-based)
  13305. rowStartIndex, // 结束行索引(0-based)
  13306. 0, // 起始列索引(0-based)
  13307. 3 // 结束列索引(0-based)
  13308. );
  13309. sheet.AddMergedRegion(cellRangeAddress);
  13310. var CellStyle = workbook.CreateCellStyle();
  13311. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13312. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13313. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13314. for (int i = 0; i <= clounmCount; i++)
  13315. {
  13316. if (i > 6)
  13317. {
  13318. var CellStyle1 = workbook.CreateCellStyle();
  13319. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13320. IFont Font = workbook.CreateFont(); // 创建字体
  13321. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13322. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13323. CellStyle1.SetFont(Font);
  13324. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13325. }
  13326. else
  13327. {
  13328. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13329. }
  13330. }
  13331. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13332. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13333. //超时合计
  13334. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13335. //超时数
  13336. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13337. //超时合计费用
  13338. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13339. cloneRowFn();
  13340. // 创建合并区域的实例
  13341. cellRangeAddress = new CellRangeAddress(
  13342. rowStartIndex, // 起始行索引(0-based)
  13343. rowStartIndex, // 结束行索引(0-based)
  13344. 0, // 起始列索引(0-based)
  13345. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13346. );
  13347. // 添加合并区域
  13348. sheet.AddMergedRegion(cellRangeAddress);
  13349. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13350. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13351. }
  13352. }
  13353. mergeRow();
  13354. // 保存修改后的Excel文件到新文件
  13355. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13356. // new FileStream(newFilePath, FileMode.CreateNew)
  13357. using (var stream = new MemoryStream())
  13358. {
  13359. workbook.Write(stream, true);
  13360. stream.Flush();
  13361. stream.Seek(0, SeekOrigin.Begin);
  13362. MemoryStream memoryStream = new MemoryStream();
  13363. stream.CopyTo(memoryStream);
  13364. memoryStream.Seek(0, SeekOrigin.Begin);
  13365. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13366. }
  13367. workbook.Close();
  13368. workbook.Dispose();
  13369. }
  13370. catch (Exception ex)
  13371. {
  13372. jw.Msg = "出现异常!" + ex.Message;
  13373. return Ok(jw);
  13374. }
  13375. }
  13376. if (Zips.Count > 0)
  13377. {
  13378. IOOperatorHelper io = new IOOperatorHelper();
  13379. var byts = io.ConvertZipStream(Zips);
  13380. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13381. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13382. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13383. }
  13384. else
  13385. {
  13386. jw.Msg = "暂无生成文件!";
  13387. }
  13388. return Ok(jw);
  13389. }
  13390. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13391. {
  13392. string outStr = string.Empty;
  13393. switch (i)
  13394. {
  13395. case 0:
  13396. outStr = arr[0].SidName;
  13397. break;
  13398. case 1:
  13399. outStr = arr[0].DataPriceStr;
  13400. break;
  13401. case 2:
  13402. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13403. break;
  13404. case 4:
  13405. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13406. break;
  13407. case 7:
  13408. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13409. {
  13410. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13411. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13412. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13413. }
  13414. break;
  13415. case 8:
  13416. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13417. {
  13418. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13419. }
  13420. break;
  13421. case 9:
  13422. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13423. {
  13424. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13425. }
  13426. break;
  13427. case 10:
  13428. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13429. {
  13430. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13431. }
  13432. break;
  13433. }
  13434. return outStr;
  13435. }
  13436. #region OP行程单
  13437. /// <summary>
  13438. /// OP行程单初始化
  13439. /// </summary>
  13440. /// <param name="dto"></param>
  13441. /// <returns></returns>
  13442. [HttpPost]
  13443. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13444. {
  13445. var jw = JsonView(false);
  13446. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13447. var group = groupList.First();
  13448. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13449. if (group == null)
  13450. {
  13451. jw.Msg = "暂无团组!";
  13452. return Ok(jw);
  13453. }
  13454. group = groupList.Find(x => x.Id == diid);
  13455. if (group == null)
  13456. {
  13457. jw.Msg = "请输入正确的团组ID!";
  13458. return Ok(jw);
  13459. }
  13460. string city = string.Empty;
  13461. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13462. if (blackCode.Count > 0)
  13463. {
  13464. var black = blackCode.First();
  13465. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  13466. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13467. if (blackSp.Length > 0)
  13468. {
  13469. try
  13470. {
  13471. var cityArrCode = new List<string>(20);
  13472. foreach (var item in blackSp)
  13473. {
  13474. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13475. var IndexSelect = itemSp[2];
  13476. var cityArrCodeLength = cityArrCode.Count - 1;
  13477. var startCity = IndexSelect.Substring(0, 3);
  13478. if (cityArrCodeLength > 0)
  13479. {
  13480. var arrEndCity = cityArrCode[cityArrCodeLength];
  13481. if (arrEndCity != startCity)
  13482. {
  13483. cityArrCode.Add(startCity.ToUpper());
  13484. }
  13485. }
  13486. else
  13487. {
  13488. cityArrCode.Add(startCity.ToUpper());
  13489. }
  13490. var endCity = IndexSelect.Substring(3, 3);
  13491. cityArrCode.Add(endCity.ToUpper());
  13492. }
  13493. var cityThree = string.Empty;
  13494. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13495. cityThree = cityThree.TrimEnd(',');
  13496. if (string.IsNullOrWhiteSpace(cityThree))
  13497. {
  13498. throw new
  13499. Exception("error");
  13500. }
  13501. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13502. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13503. foreach (var item in cityArrCode)
  13504. {
  13505. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13506. if (find != null)
  13507. {
  13508. city += find.City + "/";
  13509. }
  13510. else
  13511. {
  13512. city += item + "三字码未收入/";
  13513. }
  13514. }
  13515. city = city.TrimEnd('/');
  13516. }
  13517. catch (Exception e)
  13518. {
  13519. city = "黑屏代码格式不正确!";
  13520. }
  13521. }
  13522. }
  13523. else
  13524. {
  13525. city = "未录入黑屏代码";
  13526. }
  13527. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13528. {
  13529. Date = x.Date,
  13530. Days = x.Days,
  13531. Diffgroup = x.Diffgroup,
  13532. Diid = x.Diid,
  13533. Traffic_First = x.Traffic_First,
  13534. Traffic_Second = x.Traffic_Second,
  13535. Trip = x.Trip,
  13536. WeekDay = x.WeekDay,
  13537. Id = x.Id
  13538. }).ToList();
  13539. jw.Data = new
  13540. {
  13541. groupList = groupList.Select(x => new
  13542. {
  13543. x.Id,
  13544. x.TeamName,
  13545. x.TourCode
  13546. }).ToList(),
  13547. groupInfo = new
  13548. {
  13549. group.VisitDays,
  13550. group.TourCode,
  13551. group.VisitPNumber,
  13552. group.TeamName,
  13553. city
  13554. },
  13555. OpTravelList
  13556. };
  13557. jw.Code = 200;
  13558. jw.Msg = "操作成功!";
  13559. return Ok(jw);
  13560. }
  13561. /// <summary>
  13562. /// 删除团组行程单
  13563. /// </summary>
  13564. /// <returns></returns>
  13565. [HttpPost]
  13566. public IActionResult DelTravel(DelOpTravelDto dto)
  13567. {
  13568. var jw = JsonView(false);
  13569. if (dto.UserId <= 0 || dto.Diid <= 0)
  13570. {
  13571. jw.Msg = "请输入正确的参数!";
  13572. return Ok(jw);
  13573. }
  13574. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13575. .SetColumns(x => new Grp_TravelList
  13576. {
  13577. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13578. DeleteUserId = dto.UserId,
  13579. IsDel = 1,
  13580. }).ExecuteCommand();
  13581. jw = JsonView(true);
  13582. return Ok(jw);
  13583. }
  13584. /// <summary>
  13585. /// 行程单保存
  13586. /// </summary>
  13587. /// <returns></returns>
  13588. [HttpPost]
  13589. public IActionResult TravelSave(TravelSaveDto dto)
  13590. {
  13591. var jw = JsonView(false);
  13592. if (dto.Arr.Count > 0)
  13593. {
  13594. try
  13595. {
  13596. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13597. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13598. .ToList();
  13599. _sqlSugar.BeginTran();
  13600. foreach (var item in dto.Arr)
  13601. {
  13602. if (item.Id == 0)
  13603. {
  13604. throw new Exception("请传入正确的Id");
  13605. }
  13606. //比较上一次的差异
  13607. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13608. if (findTravel != null)
  13609. {
  13610. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13611. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13612. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13613. }
  13614. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13615. .SetColumns(x => new Grp_TravelList
  13616. {
  13617. Trip = item.Trip
  13618. }).ExecuteCommand();
  13619. }
  13620. _sqlSugar.CommitTran();
  13621. jw = JsonView(true);
  13622. }
  13623. catch (Exception ex)
  13624. {
  13625. _sqlSugar.RollbackTran();
  13626. jw.Msg = "程序异常!" + ex.Message;
  13627. }
  13628. }
  13629. else
  13630. {
  13631. jw.Msg = "请传入正确的参数!";
  13632. }
  13633. return Ok(jw);
  13634. }
  13635. private string CheckStr(string original, string changed)
  13636. {
  13637. // 创建diff_match_patch对象
  13638. var dmp = new diff_match_patch();
  13639. // 计算差异
  13640. List<Diff> diffs = dmp.diff_main(original, changed);
  13641. // 清理和合并差异
  13642. dmp.diff_cleanupSemantic(diffs);
  13643. // 使用StringBuilder构建最终的字符串
  13644. StringBuilder finalString = new StringBuilder();
  13645. // 输出差异结果,并构建变动后的字符串
  13646. foreach (Diff diff in diffs)
  13647. {
  13648. switch (diff.operation)
  13649. {
  13650. case Operation.EQUAL:
  13651. // 相等的部分,直接添加到最终字符串
  13652. finalString.Append(diff.text);
  13653. break;
  13654. case Operation.INSERT:
  13655. // 插入的部分,添加标记并添加到最终字符串
  13656. finalString.Append("[++]" + diff.text + "[++]");
  13657. break;
  13658. case Operation.DELETE:
  13659. // 删除的部分,不添加到最终字符串
  13660. //finalString.Append("[++]" + diff.text + "[++]");
  13661. break;
  13662. }
  13663. }
  13664. // 输出变动后的字符串
  13665. return finalString.ToString();
  13666. }
  13667. private class tagContent
  13668. {
  13669. public DateTime Date { get; set; }
  13670. public string StartTag { get; set; }
  13671. public string EndTag { get; set; }
  13672. public string Content { get; set; }
  13673. public static int tagLength { get { return 3; } }
  13674. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13675. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13676. public bool IsFinally { get; set; }
  13677. }
  13678. private List<string> ExtractContentBetweenTags(string input, string tag)
  13679. {
  13680. List<string> results = new List<string>();
  13681. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13682. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13683. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13684. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13685. string[] strValueArr = new string[1];
  13686. foreach (System.Text.RegularExpressions.Match match in matches)
  13687. {
  13688. var strValue = match.Groups[1].Value;
  13689. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13690. }
  13691. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13692. return results;
  13693. }
  13694. /// <summary>
  13695. /// 导出行程单
  13696. /// </summary>
  13697. /// <param name="dto"></param>
  13698. /// <returns></returns>
  13699. [HttpPost]
  13700. public IActionResult ExportTravel(ExportTravelDto dto)
  13701. {
  13702. var jw = JsonView(false);
  13703. jw.Data = "";
  13704. int diid = 0;
  13705. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13706. if (Find == null)
  13707. {
  13708. jw.Msg = "请选择正确的团组!";
  13709. return Ok(jw);
  13710. }
  13711. else
  13712. {
  13713. diid = Find.Id;
  13714. }
  13715. //数据源
  13716. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  13717. DataTable dtBlack = null;
  13718. try
  13719. {
  13720. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13721. }
  13722. catch (Exception)
  13723. {
  13724. jw.Msg = "机票黑屏代码有误!";
  13725. return Ok(jw);
  13726. }
  13727. string CityStr = string.Empty;
  13728. if (dtBlack.Rows.Count == 0)
  13729. {
  13730. jw.Msg = "机票黑屏代码有误!";
  13731. return Ok(jw);
  13732. }
  13733. else
  13734. {
  13735. foreach (DataRow row in dtBlack.Rows)
  13736. {
  13737. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13738. {
  13739. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13740. return Ok(jw);
  13741. }
  13742. }
  13743. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13744. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13745. }
  13746. // 指定的文字
  13747. var targetTextDic = new Dictionary<string, List<string>>();
  13748. //创建数据源Table
  13749. DataTable dtSource = new DataTable();
  13750. dtSource.Columns.Add("Days", typeof(string));
  13751. dtSource.Columns.Add("Date", typeof(string));
  13752. dtSource.Columns.Add("Week", typeof(string));
  13753. dtSource.Columns.Add("Traffic", typeof(string));
  13754. dtSource.Columns.Add("Trip", typeof(string));
  13755. //获取数据,放到datatable
  13756. foreach (var item in _travelList)
  13757. {
  13758. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13759. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13760. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13761. .Replace("[++]", string.Empty);
  13762. DataRow dr = dtSource.NewRow();
  13763. dr["Days"] = item.Days;
  13764. dr["Date"] = item.Date;
  13765. dr["Week"] = item.WeekDay;
  13766. dr["Traffic"] = item.Traffic_First
  13767. + "\r\n"
  13768. + item.Traffic_Second;
  13769. dr["Trip"] = item.Trip;
  13770. dtSource.Rows.Add(dr);
  13771. }
  13772. Dictionary<string, string> dic = new Dictionary<string, string>();
  13773. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  13774. dic.Add("City", CityStr);
  13775. dic.Add("Days", Find.VisitDays.ToString());
  13776. dic.Add("DeleCode", Find.TourCode);
  13777. dic.Add("Pnum", Find.VisitPNumber.ToString());
  13778. //模板路径
  13779. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13780. //载入模板
  13781. Document doc = null;
  13782. DocumentBuilder builder = null;
  13783. try
  13784. {
  13785. //载入模板
  13786. doc = new Document(tempPath);
  13787. builder = new DocumentBuilder(doc);
  13788. }
  13789. catch (Exception)
  13790. {
  13791. jw.Msg = "模板位置不存在!";
  13792. return Ok(jw);
  13793. }
  13794. foreach (var key in dic.Keys)
  13795. {
  13796. Bookmark bookmark = doc.Range.Bookmarks[key];
  13797. if (bookmark != null)
  13798. {
  13799. builder.MoveToBookmark(key);
  13800. builder.Write(dic[key]);
  13801. }
  13802. }
  13803. //获取word里所有表格
  13804. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13805. //获取所填表格的序数
  13806. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13807. try
  13808. {
  13809. //循环赋值
  13810. for (int i = 0; i < dtSource.Rows.Count; i++)
  13811. {
  13812. builder.MoveToCell(0, i + 1, 0, 0);
  13813. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13814. builder.MoveToCell(0, i + 1, 1, 0);
  13815. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13816. builder.MoveToCell(0, i + 1, 2, 0);
  13817. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13818. var trip = dtSource.Rows[i]["Trip"].ToString();
  13819. builder.MoveToCell(0, i + 1, 3, 0);
  13820. builder.Write(trip);
  13821. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13822. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13823. // 获取特定索引的段落
  13824. Paragraph paragraph = (Paragraph)paragraphs[0];
  13825. Run run = paragraph.Runs[0];
  13826. Aspose.Words.Font font = run.Font;
  13827. font.Name = "黑体";
  13828. //设置双休红色
  13829. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13830. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13831. paragraph = (Paragraph)paragraphs[1];
  13832. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13833. {
  13834. run = paragraph.Runs[0];
  13835. font = run.Font;
  13836. font.Color = Color.Red;
  13837. }
  13838. }
  13839. }
  13840. catch (Exception ex)
  13841. {
  13842. }
  13843. //删除多余行
  13844. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  13845. {
  13846. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  13847. }
  13848. var targetTextList = new List<string>();
  13849. // 遍历文档中的表格
  13850. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13851. {
  13852. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13853. {
  13854. var cellIndex = 0;
  13855. foreach (Cell cell in row.Cells)
  13856. {
  13857. if (cellIndex == 1 && row.Cells.Count == 4)
  13858. {
  13859. foreach (var target in targetTextDic.Keys)
  13860. {
  13861. if (cell.GetText().Contains(target))
  13862. {
  13863. targetTextList = targetTextDic[target];
  13864. break;
  13865. }
  13866. }
  13867. }
  13868. // 遍历单元格中的所有段落
  13869. foreach (Paragraph paragraph in cell.Paragraphs)
  13870. {
  13871. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  13872. List<Run> runs = new List<Run>();
  13873. foreach (Run run in paragraph.Runs)
  13874. {
  13875. runs.Add(run);
  13876. }
  13877. foreach (Run run in runs)
  13878. {
  13879. foreach (var targetText in targetTextList)
  13880. {
  13881. // 检查文字是否包含指定文字
  13882. if (run.Text.Contains(targetText))
  13883. {
  13884. // 将包含的部分设置为红色
  13885. HighlightText(run, targetText, Color.Red);
  13886. }
  13887. }
  13888. }
  13889. }
  13890. cellIndex++;
  13891. }
  13892. }
  13893. }
  13894. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  13895. if (!Directory.Exists(savePath))
  13896. {
  13897. try
  13898. {
  13899. Directory.CreateDirectory(savePath);
  13900. }
  13901. catch
  13902. {
  13903. }
  13904. }
  13905. string path = savePath + Find.TeamName + "出访日程";
  13906. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  13907. try
  13908. {
  13909. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  13910. string postfix = ".docx";
  13911. if (dto.IsPDF == 1)
  13912. {
  13913. saveFormat = Aspose.Words.SaveFormat.Pdf;
  13914. postfix = ".pdf";
  13915. }
  13916. doc.Save(path + postfix, saveFormat);
  13917. jw = JsonView(true, "导出成功", ftpPath + postfix);
  13918. }
  13919. catch (Exception)
  13920. {
  13921. jw = JsonView(false);
  13922. }
  13923. return Ok(jw);
  13924. }
  13925. /// <summary>
  13926. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  13927. /// </summary>
  13928. /// <param name="num"></param>
  13929. /// <returns></returns>
  13930. string GetNum(string num)
  13931. {
  13932. string str = "";
  13933. switch (num)
  13934. {
  13935. case "1":
  13936. str = "一";
  13937. break;
  13938. case "2":
  13939. str = "二";
  13940. break;
  13941. case "3":
  13942. str = "三";
  13943. break;
  13944. case "4":
  13945. str = "四";
  13946. break;
  13947. case "5":
  13948. str = "五";
  13949. break;
  13950. case "6":
  13951. str = "六";
  13952. break;
  13953. case "7":
  13954. str = "七";
  13955. break;
  13956. case "8":
  13957. str = "八";
  13958. break;
  13959. case "9":
  13960. str = "九";
  13961. break;
  13962. case "10":
  13963. str = "十";
  13964. break;
  13965. case "11":
  13966. str = "十一";
  13967. break;
  13968. case "12":
  13969. str = "十二";
  13970. break;
  13971. case "一":
  13972. str = "1";
  13973. break;
  13974. case "二":
  13975. str = "2";
  13976. break;
  13977. case "三":
  13978. str = "3";
  13979. break;
  13980. case "四":
  13981. str = "4";
  13982. break;
  13983. case "五":
  13984. str = "5";
  13985. break;
  13986. case "六":
  13987. str = "6";
  13988. break;
  13989. case "七":
  13990. str = "7";
  13991. break;
  13992. case "八":
  13993. str = "8";
  13994. break;
  13995. case "九":
  13996. str = "9";
  13997. break;
  13998. case "十":
  13999. str = "10";
  14000. break;
  14001. case "十一":
  14002. str = "11";
  14003. break;
  14004. case "十二":
  14005. str = "12";
  14006. break;
  14007. }
  14008. return str;
  14009. }
  14010. // 高亮包含指定文字的部分
  14011. void HighlightText(Run run, string targetText, Color color)
  14012. {
  14013. string text = run.Text;
  14014. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  14015. if (startIndex >= 0)
  14016. {
  14017. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  14018. // 前部分
  14019. if (startIndex > 0)
  14020. {
  14021. Run beforeRun = (Run)run.Clone(true);
  14022. beforeRun.Text = text.Substring(0, startIndex);
  14023. parentParagraph.InsertBefore(beforeRun, run);
  14024. }
  14025. // 匹配部分
  14026. Run matchRun = (Run)run.Clone(true);
  14027. matchRun.Text = text.Substring(startIndex, targetText.Length);
  14028. matchRun.Font.Color = color;
  14029. parentParagraph.InsertBefore(matchRun, run);
  14030. // 后部分
  14031. if (startIndex + targetText.Length < text.Length)
  14032. {
  14033. Run afterRun = (Run)run.Clone(true);
  14034. afterRun.Text = text.Substring(startIndex + targetText.Length);
  14035. parentParagraph.InsertBefore(afterRun, run);
  14036. }
  14037. // 删除原始Run
  14038. run.Remove();
  14039. }
  14040. }
  14041. #endregion
  14042. #endregion
  14043. #region 团组成本
  14044. /// <summary>
  14045. /// 团组成本数据初始化
  14046. /// </summary>
  14047. /// <param name="dto"></param>
  14048. /// <returns></returns>
  14049. [HttpPost]
  14050. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  14051. {
  14052. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14053. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14054. WHEN COUNT(*) >= 0 THEN 'True'
  14055. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14056. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14057. ").ToList(); //团组列表
  14058. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  14059. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  14060. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  14061. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  14062. if (groupinfoValue != null)
  14063. {
  14064. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  14065. var spArr = new string[1] { countryArr };
  14066. if (countryArr.Contains("|"))
  14067. {
  14068. spArr = countryArr.Split("|");
  14069. }
  14070. else if (countryArr.Contains("、"))
  14071. {
  14072. spArr = countryArr.Split("、");
  14073. }
  14074. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  14075. {
  14076. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  14077. if (dbQueryCountry != null)
  14078. {
  14079. visaCountryInfoArr.Add(dbQueryCountry);
  14080. }
  14081. }
  14082. }
  14083. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  14084. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  14085. #region 屏蔽黑屏代码生成
  14086. //var create = _GroupCostRepository.
  14087. // CreateGroupCostByBlackCode(dto.Diid);
  14088. //if (groupCost.Count == 0 && create.Code == 0)
  14089. //{
  14090. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  14091. //}
  14092. #endregion
  14093. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  14094. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  14095. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  14096. groupCostMap = groupCostMap.Select(x =>
  14097. {
  14098. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  14099. {
  14100. x.Date = dataForamt.ToString("yyyy-MM-dd");
  14101. }
  14102. return x;
  14103. }).ToList();
  14104. //GroupCostParameter.Add(new
  14105. // Grp_GroupCostParameter());
  14106. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  14107. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  14108. return Ok(JsonView(new
  14109. {
  14110. groupList,
  14111. groupInfo,
  14112. groupChecks,
  14113. groupCost = groupCostMap,
  14114. hotelNumber,
  14115. GroupCostParameter = GroupCostParameterMap,
  14116. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  14117. {
  14118. x.VisaCountry,
  14119. x.VisaPrice,
  14120. x.Id,
  14121. }).ToList(),
  14122. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  14123. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  14124. hotelIsTrue = hotelIsTrue,
  14125. }));
  14126. }
  14127. /// <summary>
  14128. /// 团组成本信息保存
  14129. /// </summary>
  14130. /// <param name="dto"></param>
  14131. /// <returns></returns>
  14132. [HttpPost]
  14133. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  14134. {
  14135. if (dto.Diid <= 0 || dto.Userid <= 0)
  14136. {
  14137. return Ok(JsonView(false));
  14138. }
  14139. JsonView jw = null;
  14140. bool isTrue = false;
  14141. #region 复制团组成本
  14142. //if (dto.Diid == 2581)
  14143. //{
  14144. // dto.Diid = 2599;
  14145. // dto.CheckBoxs.ForEach(x =>
  14146. // {
  14147. // x.Diid = 2599;
  14148. // });
  14149. // dto.GroupCosts.ForEach(x =>
  14150. // {
  14151. // x.Diid = 2599;
  14152. // });
  14153. // dto.CostTypeHotelNumbers.ForEach(x =>
  14154. // {
  14155. // x.Diid = 2599;
  14156. // });
  14157. // dto.GroupCostParameters.ForEach(x =>
  14158. // {
  14159. // x.DiId = 2599;
  14160. // });
  14161. //}
  14162. #endregion
  14163. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14164. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14165. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14166. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14167. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14168. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14169. try
  14170. {
  14171. _sqlSugar.BeginTran();
  14172. isTrue = await _GroupCostRepository.
  14173. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14174. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14175. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14176. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14177. _sqlSugar.CommitTran();
  14178. jw = JsonView(true, "保存成功!", isTrue);
  14179. }
  14180. catch (Exception)
  14181. {
  14182. _sqlSugar.RollbackTran();
  14183. jw = JsonView(false);
  14184. }
  14185. return Ok(jw);
  14186. }
  14187. /// <summary>
  14188. /// 复制团组成本信息
  14189. /// </summary>
  14190. /// <param name="dto"></param>
  14191. /// <returns></returns>
  14192. [HttpPost]
  14193. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14194. {
  14195. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14196. {
  14197. return Ok(JsonView(false, "参数有误!"));
  14198. }
  14199. #region 复制团组成本
  14200. dto.Diid = dto.ToGroupId;
  14201. dto.CheckBoxs.ForEach(x =>
  14202. {
  14203. x.Diid = dto.ToGroupId;
  14204. });
  14205. dto.GroupCosts.ForEach(x =>
  14206. {
  14207. x.Diid = dto.ToGroupId;
  14208. });
  14209. dto.CostTypeHotelNumbers.ForEach(x =>
  14210. {
  14211. x.Diid = dto.ToGroupId;
  14212. });
  14213. dto.GroupCostParameters.ForEach(x =>
  14214. {
  14215. x.DiId = dto.ToGroupId;
  14216. });
  14217. #endregion
  14218. JsonView jw = null;
  14219. bool isTrue = false;
  14220. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14221. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14222. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14223. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14224. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14225. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14226. try
  14227. {
  14228. _sqlSugar.BeginTran();
  14229. isTrue = await _GroupCostRepository.
  14230. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14231. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14232. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14233. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14234. _sqlSugar.CommitTran();
  14235. jw = JsonView(true, "保存成功!", isTrue);
  14236. }
  14237. catch (Exception)
  14238. {
  14239. _sqlSugar.RollbackTran();
  14240. jw = JsonView(false);
  14241. }
  14242. return Ok(jw);
  14243. }
  14244. /// <summary>
  14245. /// 司兼导数据
  14246. /// </summary>
  14247. /// <param name="dto"></param>
  14248. /// <returns></returns>
  14249. [HttpPost]
  14250. public IActionResult GetCarGuides(CarGuidesDto dto)
  14251. {
  14252. JsonView jw = null;
  14253. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14254. jw = JsonView(true, "获取成功!", Data);
  14255. return Ok(jw);
  14256. }
  14257. /// <summary>
  14258. /// 导游数据
  14259. /// </summary>
  14260. /// <param name="dto"></param>
  14261. /// <returns></returns>
  14262. [HttpPost]
  14263. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14264. {
  14265. JsonView jw = null;
  14266. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14267. // 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
  14268. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14269. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14270. jw = JsonView(true, "获取成功!", Data);
  14271. return Ok(jw);
  14272. }
  14273. /// <summary>
  14274. /// 成本车数据
  14275. /// </summary>
  14276. /// <param name="dto"></param>
  14277. /// <returns></returns>
  14278. [HttpPost]
  14279. public IActionResult GetCarInfo(CarGuidesDto dto)
  14280. {
  14281. JsonView jw = null;
  14282. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14283. jw = JsonView(true, "获取成功!", Data);
  14284. return Ok(jw);
  14285. }
  14286. /// <summary>
  14287. /// 景点数据
  14288. /// </summary>
  14289. /// <param name="dto"></param>
  14290. /// <returns></returns>
  14291. [HttpPost]
  14292. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14293. {
  14294. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14295. return Ok(JsonView(true, "获取成功!", Data));
  14296. }
  14297. /// <summary>
  14298. /// 成本通知
  14299. /// </summary>
  14300. /// <param name="dto"></param>
  14301. /// <returns></returns>
  14302. [HttpPost]
  14303. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14304. {
  14305. if (dto.Diid < 0)
  14306. {
  14307. return Ok(JsonView(false));
  14308. }
  14309. JsonView jw = null;
  14310. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14311. if (GroupCostParameter != null)
  14312. {
  14313. int IsShare = 0;
  14314. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14315. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14316. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14317. string msg = string.Empty;
  14318. if (isTrue)
  14319. {
  14320. if (IsShare == 0)
  14321. {
  14322. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14323. }
  14324. else
  14325. {
  14326. #region 企微通知对应岗位用户
  14327. try
  14328. {
  14329. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14330. }
  14331. catch (Exception ex)
  14332. {
  14333. }
  14334. #endregion
  14335. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14336. }
  14337. jw = JsonView(isTrue, msg, new { IsShare });
  14338. }
  14339. else
  14340. {
  14341. msg = "修改失败!";
  14342. jw = JsonView(isTrue, msg);
  14343. }
  14344. }
  14345. else
  14346. {
  14347. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14348. }
  14349. return Ok(jw);
  14350. }
  14351. /// <summary>
  14352. /// 导出报价单
  14353. /// </summary>
  14354. /// <param name="dto"></param>
  14355. /// <returns></returns>
  14356. [HttpPost]
  14357. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14358. {
  14359. if (dto.Diid == 0)
  14360. {
  14361. return Ok(JsonView(false, "请传递团组id"));
  14362. }
  14363. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14364. if (deleInfo.Code != 0)
  14365. {
  14366. return Ok(JsonView(false, "团组信息查询失败!"));
  14367. }
  14368. var di = deleInfo.Data as DelegationInfoWebView;
  14369. if (di != null)
  14370. {
  14371. di.TeamName = di.TeamName.Replace("|", "、");
  14372. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14373. //文件名
  14374. string strFileName = di.TeamName + "-收款账单.doc";
  14375. //获取模板
  14376. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14377. //载入模板
  14378. Document doc = new Document(tmppath);
  14379. decimal TotalPrice = 0.00M;
  14380. string itemStr = string.Empty;
  14381. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14382. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14383. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14384. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14385. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14386. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14387. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14388. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14389. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14390. foreach (var cost in groupCostType)
  14391. {
  14392. var List = cost.ToList();
  14393. if (cost.Key == "A")
  14394. {
  14395. foreach (var ListItem in List)
  14396. {
  14397. if (ListItem.number > 0)
  14398. {
  14399. if (ListItem.code.Contains("TBR"))
  14400. {
  14401. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14402. }
  14403. else
  14404. {
  14405. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14406. }
  14407. TotalPrice += (ListItem.number * ListItem.price);
  14408. }
  14409. }
  14410. }
  14411. else
  14412. {
  14413. itemStr = itemStr.Insert(0, "A段\r\n");
  14414. itemStr += "B段\r\n";
  14415. foreach (var ListItem in List)
  14416. {
  14417. if (ListItem.number > 0)
  14418. {
  14419. if (ListItem.code.Contains("TBR"))
  14420. {
  14421. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14422. }
  14423. else
  14424. {
  14425. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14426. }
  14427. TotalPrice += (ListItem.number * ListItem.price);
  14428. }
  14429. }
  14430. }
  14431. }
  14432. #region 替换Word模板书签内容
  14433. Dictionary<string, string> marks = new Dictionary<string, string>();
  14434. marks.Add("To", di.ClientUnit);//付款方
  14435. marks.Add("ToTel", di.TellPhone);//付款方电话
  14436. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14437. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14438. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14439. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14440. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14441. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14442. marks.Add("PayItemContent", itemStr);//详细信息
  14443. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14444. #endregion
  14445. ////注
  14446. //if (doc.Range.Bookmarks["Attention"] != null)
  14447. //{
  14448. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14449. // mark.Text = frList[0].Attention;
  14450. //}
  14451. foreach (var item in marks.Keys)
  14452. {
  14453. if (doc.Range.Bookmarks[item] != null)
  14454. {
  14455. Bookmark mark = doc.Range.Bookmarks[item];
  14456. mark.Text = marks[item];
  14457. }
  14458. }
  14459. byte[] bytes = null;
  14460. using (MemoryStream stream = new MemoryStream())
  14461. {
  14462. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14463. bytes = stream.ToArray();
  14464. }
  14465. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14466. return Ok(JsonView(true, "", new
  14467. {
  14468. Data = bytes,
  14469. strFileName,
  14470. }));
  14471. }
  14472. else
  14473. {
  14474. return Ok(JsonView(false, "团组信息不存在!"));
  14475. }
  14476. }
  14477. /// <summary>
  14478. /// 导出团组成本
  14479. /// </summary>
  14480. /// <param name="dto"></param>
  14481. /// <returns></returns>
  14482. [HttpPost]
  14483. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14484. {
  14485. var jw = JsonView(false);
  14486. if (dto.Diid == 0)
  14487. {
  14488. return Ok(JsonView(false, "请传递团组id"));
  14489. }
  14490. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14491. if (deleInfo.Code != 0)
  14492. {
  14493. return Ok(JsonView(false, "团组信息查询失败!"));
  14494. }
  14495. var di = deleInfo.Data as DelegationInfoWebView;
  14496. if (di == null)
  14497. {
  14498. return Ok(JsonView(false, "团组信息查询失败!"));
  14499. }
  14500. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14501. WorkbookDesigner designer = new WorkbookDesigner();
  14502. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14503. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14504. for (int i = 0; i < List_GC.Count; i++)
  14505. {
  14506. GroupCost_Excel gc = new GroupCost_Excel();
  14507. gc.Id = List_GC[i].Id;
  14508. gc.Diid = List_GC[i].Diid.ToString();
  14509. gc.DAY = List_GC[i].DAY;
  14510. string week = "";
  14511. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14512. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14513. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14514. gc.ITIN = List_GC[i].ITIN;
  14515. gc.CarType = List_GC[i].CarType;
  14516. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  14517. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  14518. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  14519. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  14520. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  14521. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  14522. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  14523. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  14524. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  14525. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  14526. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  14527. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  14528. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14529. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14530. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  14531. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  14532. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  14533. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  14534. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  14535. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  14536. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  14537. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  14538. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  14539. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  14540. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  14541. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  14542. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  14543. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  14544. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  14545. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  14546. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  14547. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  14548. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  14549. List_GC1.Add(gc);
  14550. }
  14551. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  14552. dt.TableName = "TB";
  14553. //报表标题等不用dt的值
  14554. designer.SetDataSource("TeamName", dto.title.TeamName);
  14555. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  14556. designer.SetDataSource("Tax", dto.title.Tax);
  14557. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  14558. designer.SetDataSource("Currency", dto.title.Currency);
  14559. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  14560. designer.SetDataSource("Rate", dto.title.Rate);
  14561. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  14562. var Aparams = hotels.Find(x => x.Type == "Default");
  14563. if (Aparams == null)
  14564. {
  14565. return Ok(jw);
  14566. }
  14567. //酒店数量
  14568. var txtSGRNumber = Aparams.SGR.ToString();
  14569. var txtTBRNumber = Aparams.TBR.ToString();
  14570. var txtJSESNumber = Aparams.JSES.ToString();
  14571. var txtSUITENumbe = Aparams.SUITE.ToString();
  14572. if (dto.costType == "B")
  14573. {
  14574. Aparams = hotels.Find(x => x.Type == "A");
  14575. var Bparams = hotels.Find(x => x.Type == "B");
  14576. if (Aparams == null || Bparams == null)
  14577. {
  14578. return Ok(jw);
  14579. }
  14580. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  14581. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  14582. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  14583. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  14584. }
  14585. designer.SetDataSource("SGRNumber", txtSGRNumber);
  14586. designer.SetDataSource("TBRNumber", txtTBRNumber);
  14587. designer.SetDataSource("JSESNumber", txtJSESNumber);
  14588. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  14589. var ws = designer.Workbook.Worksheets[0];
  14590. int Row = List_GC.Count;
  14591. int startIndex = 11;
  14592. int HideRows = 0;
  14593. List<int> hideRowsList = new List<int>();
  14594. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14595. #region A段left数据
  14596. var left = dto.leftInfo.Find(x => x.Type == "A");
  14597. if (left == null)
  14598. {
  14599. return Ok(jw);
  14600. }
  14601. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14602. if (leftBindData != null)
  14603. {
  14604. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14605. designer.SetDataSource("VisaRS", leftBindData.rs);
  14606. designer.SetDataSource("VisaXS", leftBindData.xs);
  14607. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14608. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14609. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14610. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14611. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14612. }
  14613. else
  14614. {
  14615. hideRowsList.Add(Row + startIndex + HideRows);
  14616. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14617. }
  14618. HideRows += 2;
  14619. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14620. if (leftBindData != null)
  14621. {
  14622. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14623. designer.SetDataSource("BXRS", leftBindData.rs);
  14624. designer.SetDataSource("BXXS", leftBindData.xs);
  14625. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14626. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14627. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14628. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14629. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14630. }
  14631. else
  14632. {
  14633. hideRowsList.Add(Row + startIndex + HideRows);
  14634. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14635. }
  14636. HideRows += 2;
  14637. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14638. if (leftBindData != null)
  14639. {
  14640. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14641. designer.SetDataSource("HSRS", leftBindData.rs);
  14642. designer.SetDataSource("HSXS", leftBindData.xs);
  14643. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14644. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14645. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14646. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14647. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14648. }
  14649. else
  14650. {
  14651. hideRowsList.Add(Row + startIndex + HideRows);
  14652. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14653. }
  14654. HideRows += 2;
  14655. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14656. if (leftBindData != null)
  14657. {
  14658. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14659. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14660. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14661. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14662. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14663. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14664. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14665. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14666. }
  14667. else
  14668. {
  14669. hideRowsList.Add(Row + startIndex + HideRows);
  14670. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14671. }
  14672. HideRows += 2;
  14673. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14674. if (leftBindData != null)
  14675. {
  14676. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14677. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14678. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14679. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14680. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14681. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14682. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14683. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14684. }
  14685. else
  14686. {
  14687. hideRowsList.Add(Row + startIndex + HideRows);
  14688. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14689. }
  14690. HideRows += 2;
  14691. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14692. if (leftBindData != null)
  14693. {
  14694. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14695. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14696. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14697. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14698. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14699. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14700. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14701. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14702. }
  14703. else
  14704. {
  14705. hideRowsList.Add(Row + startIndex + HideRows);
  14706. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14707. }
  14708. HideRows += 2;
  14709. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14710. if (leftBindData != null)
  14711. {
  14712. ////TBR
  14713. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14714. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14715. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14716. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14717. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14718. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14719. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14720. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14721. }
  14722. else
  14723. {
  14724. hideRowsList.Add(Row + startIndex + HideRows);
  14725. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14726. }
  14727. HideRows += 2;
  14728. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14729. if (leftBindData != null)
  14730. {
  14731. ////SGR
  14732. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  14733. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  14734. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  14735. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14736. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14737. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14738. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14739. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14740. }
  14741. else
  14742. {
  14743. hideRowsList.Add(Row + startIndex + HideRows);
  14744. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14745. }
  14746. HideRows += 2;
  14747. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14748. if (leftBindData != null)
  14749. {
  14750. ////JS/ES
  14751. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  14752. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  14753. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  14754. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14755. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14756. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14757. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14758. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14759. }
  14760. else
  14761. {
  14762. hideRowsList.Add(Row + startIndex + HideRows);
  14763. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14764. }
  14765. HideRows += 2;
  14766. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14767. if (leftBindData != null)
  14768. {
  14769. ////SUITE
  14770. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  14771. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  14772. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  14773. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14774. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14775. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14776. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14777. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14778. }
  14779. else
  14780. {
  14781. hideRowsList.Add(Row + startIndex + HideRows);
  14782. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14783. }
  14784. HideRows += 2;
  14785. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14786. if (leftBindData != null)
  14787. {
  14788. designer.SetDataSource("DJDRCB", leftBindData.cb);
  14789. designer.SetDataSource("DJRS", leftBindData.rs);
  14790. designer.SetDataSource("DJXS", leftBindData.xs);
  14791. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14792. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14793. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14794. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14795. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14796. }
  14797. else
  14798. {
  14799. hideRowsList.Add(Row + startIndex + HideRows);
  14800. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14801. }
  14802. HideRows += 2;
  14803. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14804. if (leftBindData != null)
  14805. {
  14806. designer.SetDataSource("HCPCB", leftBindData.cb);
  14807. designer.SetDataSource("HCPRS", leftBindData.rs);
  14808. designer.SetDataSource("HCPXS", leftBindData.xs);
  14809. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14810. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14811. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14812. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14813. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14814. }
  14815. else
  14816. {
  14817. hideRowsList.Add(Row + startIndex + HideRows);
  14818. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14819. }
  14820. HideRows += 2;
  14821. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14822. if (leftBindData != null)
  14823. {
  14824. designer.SetDataSource("CPCB", leftBindData.cb);
  14825. designer.SetDataSource("CPRS", leftBindData.rs);
  14826. designer.SetDataSource("CPXS", leftBindData.xs);
  14827. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14828. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14829. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14830. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14831. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14832. }
  14833. else
  14834. {
  14835. hideRowsList.Add(Row + startIndex + HideRows);
  14836. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14837. }
  14838. HideRows += 2;
  14839. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14840. if (leftBindData != null)
  14841. {
  14842. designer.SetDataSource("GWDRCD", leftBindData.cb);
  14843. designer.SetDataSource("GWRS", leftBindData.rs);
  14844. designer.SetDataSource("GWXS", leftBindData.xs);
  14845. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14846. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14847. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14848. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14849. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14850. }
  14851. else
  14852. {
  14853. hideRowsList.Add(Row + startIndex + HideRows);
  14854. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14855. }
  14856. HideRows += 2;
  14857. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14858. if (leftBindData != null)
  14859. {
  14860. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  14861. designer.SetDataSource("LYJRS", leftBindData.rs);
  14862. designer.SetDataSource("LYJXS", leftBindData.xs);
  14863. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14864. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14865. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14866. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14867. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14868. }
  14869. else
  14870. {
  14871. hideRowsList.Add(Row + startIndex + HideRows);
  14872. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14873. }
  14874. #endregion
  14875. #region A段Right信息
  14876. var right = dto.rightInfo.Find(x => x.Type == "A");
  14877. if (right == null)
  14878. {
  14879. return Ok(jw);
  14880. }
  14881. HideRows += 4;
  14882. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14883. if (rightBindData != null)
  14884. {
  14885. //经济舱 + 双人间 TBR
  14886. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  14887. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  14888. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14889. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  14890. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14891. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14892. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14893. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14894. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14895. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14896. }
  14897. else
  14898. {
  14899. hideRowsList.Add(Row + startIndex + HideRows);
  14900. }
  14901. HideRows += 2;
  14902. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14903. if (rightBindData != null)
  14904. {
  14905. //经济舱 + 单人间 SGR
  14906. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  14907. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  14908. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14909. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  14910. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14911. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14912. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14913. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14914. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14915. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14916. }
  14917. else
  14918. {
  14919. hideRowsList.Add(Row + startIndex + HideRows);
  14920. }
  14921. HideRows += 2;
  14922. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14923. if (rightBindData != null)
  14924. {
  14925. //公务舱 + 单人间 SGR
  14926. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  14927. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  14928. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14929. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  14930. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14931. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14932. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14933. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14934. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14935. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14936. }
  14937. else
  14938. {
  14939. hideRowsList.Add(Row + startIndex + HideRows);
  14940. }
  14941. HideRows += 2;
  14942. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14943. if (rightBindData != null)
  14944. {
  14945. //公务舱 + 小套房 JSES
  14946. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  14947. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  14948. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14949. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  14950. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14951. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14952. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14953. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14954. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14955. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14956. }
  14957. else
  14958. {
  14959. hideRowsList.Add(Row + startIndex + HideRows);
  14960. }
  14961. HideRows += 2;
  14962. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14963. if (rightBindData != null)
  14964. {
  14965. //公务舱 + 小套房 JSES
  14966. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  14967. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  14968. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14969. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  14970. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14971. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14972. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14973. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14974. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14975. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14976. }
  14977. else
  14978. {
  14979. hideRowsList.Add(Row + startIndex + HideRows);
  14980. }
  14981. HideRows += 2;
  14982. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14983. if (rightBindData != null)
  14984. {
  14985. //经济舱 + 大套房
  14986. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  14987. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  14988. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14989. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  14990. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14991. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14992. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14993. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14994. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14995. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14996. }
  14997. else
  14998. {
  14999. hideRowsList.Add(Row + startIndex + HideRows);
  15000. }
  15001. HideRows += 2;
  15002. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15003. if (rightBindData != null)
  15004. {
  15005. //头等舱 + 小套房 JSES
  15006. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  15007. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  15008. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15009. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  15010. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15011. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15012. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15013. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15014. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15015. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15016. }
  15017. else
  15018. {
  15019. hideRowsList.Add(Row + startIndex + HideRows);
  15020. }
  15021. HideRows += 2;
  15022. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15023. if (rightBindData != null)
  15024. {
  15025. //头等舱 + 大套房
  15026. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  15027. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  15028. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15029. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  15030. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15031. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15032. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15033. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15034. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15035. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15036. }
  15037. else
  15038. {
  15039. hideRowsList.Add(Row + startIndex + HideRows);
  15040. }
  15041. #endregion
  15042. #region B段标题清空
  15043. designer.SetDataSource("CostBDRCB", "");
  15044. designer.SetDataSource("CostBRS", "");
  15045. designer.SetDataSource("CostBXS", "");
  15046. designer.SetDataSource("CostBZCB", "");
  15047. designer.SetDataSource("CostBDRBJ", "");
  15048. designer.SetDataSource("CostBZBJ", "");
  15049. designer.SetDataSource("CostBDRLR", "");
  15050. designer.SetDataSource("CostBZLR", "");
  15051. designer.SetDataSource("CostBDRCBOM", "");
  15052. designer.SetDataSource("CostBRSOM", "");
  15053. designer.SetDataSource("CostBZCBOM", "");
  15054. designer.SetDataSource("CostBDRBJOM", "");
  15055. designer.SetDataSource("CostBZBJOM", "");
  15056. designer.SetDataSource("CostBDRLROM", "");
  15057. designer.SetDataSource("CostBZLROM", "");
  15058. #endregion
  15059. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  15060. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  15061. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  15062. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  15063. designer.SetDataSource("DJName", "地接(CNY)");
  15064. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  15065. designer.SetDataSource("CPName", "地接-船票(CNY)");
  15066. designer.SetDataSource("GWName", "公务(CNY)");
  15067. designer.SetDataSource("YQHName", "邀请函(CNY)");
  15068. designer.SetDataSource("LYJName", "零用金(CNY)");
  15069. designer.SetDataSource("HSName", "核酸检测(CNY)");
  15070. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  15071. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  15072. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  15073. designer.SetDataSource("BXName", "保险(CNY)");
  15074. designer.SetDataSource("VisaName", "签证(CNY)");
  15075. #region B段基本数据
  15076. if (dto.costType == "B")
  15077. {
  15078. left = dto.leftInfo.Find(x => x.Type == "B");
  15079. if (left == null)
  15080. {
  15081. return Ok(jw);
  15082. }
  15083. #region B段left数据
  15084. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15085. if (leftBindData != null)
  15086. {
  15087. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  15088. designer.SetDataSource("BHSRS", leftBindData.rs);
  15089. designer.SetDataSource("BHSXS", leftBindData.xs);
  15090. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15091. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15092. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15093. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15094. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15095. }
  15096. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15097. if (leftBindData != null)
  15098. {
  15099. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  15100. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  15101. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  15102. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15103. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15104. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15105. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15106. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15107. }
  15108. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15109. if (leftBindData != null)
  15110. {
  15111. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  15112. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  15113. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  15114. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15115. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15116. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15117. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15118. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15119. }
  15120. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15121. if (leftBindData != null)
  15122. {
  15123. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  15124. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  15125. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  15126. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15127. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15128. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15129. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15130. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15131. }
  15132. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15133. if (leftBindData != null)
  15134. {
  15135. designer.SetDataSource("BHCPCB", leftBindData.cb);
  15136. designer.SetDataSource("BHCPRS", leftBindData.rs);
  15137. designer.SetDataSource("BHCPXS", leftBindData.xs);
  15138. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15139. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15140. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15141. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15142. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15143. }
  15144. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15145. if (leftBindData != null)
  15146. {
  15147. designer.SetDataSource("BCPCB", leftBindData.cb);
  15148. designer.SetDataSource("BCPRS", leftBindData.rs);
  15149. designer.SetDataSource("BCPXS", leftBindData.xs);
  15150. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15151. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15152. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15153. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15154. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15155. }
  15156. //TBR
  15157. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15158. if (leftBindData != null)
  15159. {
  15160. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  15161. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  15162. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  15163. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15164. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15165. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15166. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15167. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15168. }
  15169. //SGR
  15170. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15171. if (leftBindData != null)
  15172. {
  15173. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15174. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15175. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15176. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15177. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15178. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15179. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15180. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15181. }
  15182. //JS/ES
  15183. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15184. if (leftBindData != null)
  15185. {
  15186. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15187. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15188. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15189. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15190. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15191. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15192. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15193. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15194. }
  15195. //SUITE
  15196. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15197. if (leftBindData != null)
  15198. {
  15199. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15200. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15201. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15202. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15203. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15204. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15205. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15206. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15207. }
  15208. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15209. if (leftBindData != null)
  15210. {
  15211. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15212. designer.SetDataSource("BDJRS", leftBindData.rs);
  15213. designer.SetDataSource("BDJXS", leftBindData.xs);
  15214. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15215. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15216. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15217. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15218. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15219. }
  15220. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15221. if (leftBindData != null)
  15222. {
  15223. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15224. designer.SetDataSource("BGWRS", leftBindData.rs);
  15225. designer.SetDataSource("BGWXS", leftBindData.xs);
  15226. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15227. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15228. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15229. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15230. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15231. }
  15232. #region 优化方案
  15233. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15234. //excelBind.Add("零用金", new {
  15235. //cb="",
  15236. //rs="",
  15237. //xs ="",
  15238. //zcb = "",
  15239. //});
  15240. #endregion
  15241. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15242. if (leftBindData != null)
  15243. {
  15244. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15245. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15246. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15247. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15248. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15249. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15250. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15251. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15252. }
  15253. #endregion
  15254. #region B段Right信息
  15255. right = dto.rightInfo.Find(x => x.Type == "B");
  15256. if (right == null)
  15257. {
  15258. return Ok(jw);
  15259. }
  15260. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15261. if (rightBindData != null)
  15262. {
  15263. //经济舱 + 双人间 TBR
  15264. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15265. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15266. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15267. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15268. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15269. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15270. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15271. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15272. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15273. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15274. }
  15275. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15276. if (rightBindData != null)
  15277. {
  15278. //经济舱 + 单人间 SGR
  15279. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15280. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15281. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15282. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15283. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15284. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15285. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15286. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15287. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15288. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15289. }
  15290. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15291. if (rightBindData != null)
  15292. {
  15293. //公务舱 + 单人间 SGR
  15294. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15295. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15296. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15297. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15298. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15299. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15300. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15301. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15302. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15303. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15304. }
  15305. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15306. if (rightBindData != null)
  15307. {
  15308. //公务舱 + 小套房 JSES
  15309. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15310. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15311. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15312. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15313. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15314. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15315. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15316. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15317. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15318. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15319. }
  15320. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15321. if (rightBindData != null)
  15322. {
  15323. //公务舱 + 小套房 JSES
  15324. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15325. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15326. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15327. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15328. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15329. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15330. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15331. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15332. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15333. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15334. }
  15335. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15336. if (rightBindData != null)
  15337. {
  15338. //经济舱 + 大套房
  15339. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15340. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15341. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15342. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15343. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15344. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15345. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15346. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15347. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15348. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15349. }
  15350. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15351. if (rightBindData != null)
  15352. {
  15353. //头等舱 + 小套房 JSES
  15354. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15355. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15356. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15357. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15358. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15359. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15360. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15361. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15362. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15363. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15364. }
  15365. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15366. if (rightBindData != null)
  15367. {
  15368. //头等舱 + 大套房
  15369. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15370. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15371. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15372. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15373. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15374. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15375. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15376. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15377. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15378. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15379. }
  15380. #endregion
  15381. #region 标题
  15382. designer.SetDataSource("CostBDRCB", "单人成本");
  15383. designer.SetDataSource("CostBRS", "人数");
  15384. designer.SetDataSource("CostBXS", "系数");
  15385. designer.SetDataSource("CostBZCB", "总成本");
  15386. designer.SetDataSource("CostBDRBJ", "单人报价");
  15387. designer.SetDataSource("CostBZBJ", "总报价");
  15388. designer.SetDataSource("CostBDRLR", "单人利润");
  15389. designer.SetDataSource("CostBZLR", "总利润");
  15390. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15391. designer.SetDataSource("CostBRSOM", "人数");
  15392. designer.SetDataSource("CostBZCBOM", "总成本");
  15393. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15394. designer.SetDataSource("CostBZBJOM", "总报价");
  15395. designer.SetDataSource("CostBDRLROM", "单人利润");
  15396. designer.SetDataSource("CostBZLROM", "总利润");
  15397. #endregion
  15398. }
  15399. #endregion
  15400. designer.SetDataSource("TzZCB2", TzZCB2);
  15401. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15402. designer.SetDataSource("TzZLR2", TzZLR2);
  15403. string[] dataSourceKeys = new string[]
  15404. {
  15405. "VF",
  15406. "TGS",
  15407. "TGOF",
  15408. "TGM",
  15409. "TGA",
  15410. "TGTF",
  15411. "TGEF",
  15412. "CFM",
  15413. "CFOF",
  15414. "B",
  15415. "L",
  15416. "D",
  15417. "TBR",
  15418. "SGR",
  15419. "JSES",
  15420. "Suite",
  15421. "TV",
  15422. "1L",
  15423. "IF",
  15424. "EF",
  15425. "BRF",
  15426. "TE",
  15427. "TGT",
  15428. "DRVT",
  15429. "PC",
  15430. "TLF",
  15431. "ECT"
  15432. };
  15433. foreach (var item in dataSourceKeys)
  15434. {
  15435. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  15436. if (find != null)
  15437. {
  15438. designer.SetDataSource(item, find.text);
  15439. }
  15440. else
  15441. {
  15442. designer.SetDataSource(item, 0);
  15443. }
  15444. }
  15445. designer.SetDataSource(dt);
  15446. //根据数据源处理生成报表内容
  15447. designer.Process();
  15448. designer.Workbook.Worksheets[0].Name = "清单";
  15449. Worksheet sheet = designer.Workbook.Worksheets[0];
  15450. foreach (var Rowindex in hideRowsList)
  15451. {
  15452. ws.Cells.HideRows(Rowindex, 2);
  15453. }
  15454. byte[] bytes = null;
  15455. string strFileName = di.TeamName + "-团组-成本.xls";
  15456. using (MemoryStream stream = new MemoryStream())
  15457. {
  15458. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  15459. bytes = stream.ToArray();
  15460. }
  15461. return Ok(JsonView(true, "", new
  15462. {
  15463. Data = bytes,
  15464. strFileName,
  15465. }));
  15466. }
  15467. /// <summary>
  15468. /// 导出客户报表
  15469. /// </summary>
  15470. /// <returns></returns>
  15471. [HttpPost]
  15472. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  15473. {
  15474. var jw = JsonView(false);
  15475. if (dto.Diid == 0)
  15476. {
  15477. return Ok(JsonView(false, "请传递团组id"));
  15478. }
  15479. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15480. if (deleInfo.Code != 0)
  15481. {
  15482. return Ok(JsonView(false, "团组信息查询失败!"));
  15483. }
  15484. var di = deleInfo.Data as DelegationInfoWebView;
  15485. if (di == null)
  15486. {
  15487. return Ok(JsonView(false, "团组信息查询失败!"));
  15488. }
  15489. //文件名
  15490. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  15491. //获取模板
  15492. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  15493. //载入模板
  15494. Document doc = new Document(tmppath);
  15495. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  15496. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  15497. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  15498. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  15499. var AParameter = ParameterList.Find(x => x.CostType == "A");
  15500. var BParameter = ParameterList.Find(x => x.CostType == "B");
  15501. if (AParameter == null)
  15502. {
  15503. return Ok(JsonView(false, "系数不存在!"));
  15504. }
  15505. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  15506. , TzAirDesc, TzZCost;
  15507. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  15508. = TzAirDesc = TzZCost = string.Empty;
  15509. TzNumber = AParameter.CostTypenumber.ToString();
  15510. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  15511. CarGuides1 = dto.CarGuides1;
  15512. Meal = dto.Meal;
  15513. SubsidizedMeals = dto.SubsidizedMeals;
  15514. NightRepair = dto.NightRepair;
  15515. AttractionsTickets = dto.AttractionsTickets;
  15516. MiscellaneousFees = dto.MiscellaneousFees;
  15517. ATip = dto.ATip;
  15518. TzHotelDesc = "";
  15519. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  15520. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  15521. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  15522. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  15523. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  15524. TzAirDesc = "";
  15525. TzZCost = dto.TzZCost;
  15526. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  15527. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  15528. var index = 1;
  15529. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  15530. foreach (var item in TzHotelDescArr)
  15531. {
  15532. if (AinfoArr != null)
  15533. {
  15534. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15535. if (Ainfo != null)
  15536. {
  15537. if (int.Parse(Ainfo.rs) <= 0)
  15538. {
  15539. continue;
  15540. }
  15541. var hotelText = string.Empty;
  15542. switch (item)
  15543. {
  15544. case "SGR":
  15545. hotelText = "单人间";
  15546. break;
  15547. case "JSES":
  15548. hotelText = "小套房";
  15549. break;
  15550. case "SUITE":
  15551. hotelText = "套房";
  15552. break;
  15553. case "TBR":
  15554. hotelText = "双人间";
  15555. break;
  15556. }
  15557. if (item != "TBR")
  15558. {
  15559. 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";
  15560. }
  15561. else
  15562. {
  15563. 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";
  15564. }
  15565. index++;
  15566. }
  15567. }
  15568. }
  15569. index = 1;
  15570. foreach (var item in TzAirDescArr)
  15571. {
  15572. if (AinfoArr != null)
  15573. {
  15574. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15575. if (Ainfo != null)
  15576. {
  15577. if (int.Parse(Ainfo.rs) <= 0)
  15578. {
  15579. continue;
  15580. }
  15581. 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";
  15582. index++;
  15583. }
  15584. }
  15585. }
  15586. if (dto.costType == "B")
  15587. {
  15588. if (BParameter == null)
  15589. {
  15590. return Ok(JsonView(false, "B段系数不存在!"));
  15591. }
  15592. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  15593. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  15594. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  15595. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  15596. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15597. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15598. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15599. foreach (var item in TzHotelDescArr)
  15600. {
  15601. if (AinfoArr != null)
  15602. {
  15603. TzHotelDesc += "B段信息 \r\n";
  15604. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15605. if (Ainfo != null)
  15606. {
  15607. if (int.Parse(Ainfo.rs) <= 0)
  15608. {
  15609. continue;
  15610. }
  15611. var hotelText = string.Empty;
  15612. switch (item)
  15613. {
  15614. case "SGR":
  15615. hotelText = "单人间";
  15616. break;
  15617. case "JSES":
  15618. hotelText = "小套房";
  15619. break;
  15620. case "SUITE":
  15621. hotelText = "套房";
  15622. break;
  15623. case "TBR":
  15624. hotelText = "双人间";
  15625. break;
  15626. }
  15627. if (item != "TBR")
  15628. {
  15629. 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";
  15630. }
  15631. else
  15632. {
  15633. 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";
  15634. }
  15635. index++;
  15636. }
  15637. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15638. }
  15639. }
  15640. index = 1;
  15641. foreach (var item in TzAirDescArr)
  15642. {
  15643. if (AinfoArr != null)
  15644. {
  15645. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15646. if (Ainfo != null)
  15647. {
  15648. if (int.Parse(Ainfo.rs) <= 0)
  15649. {
  15650. continue;
  15651. }
  15652. 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";
  15653. index++;
  15654. }
  15655. }
  15656. }
  15657. }
  15658. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15659. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15660. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15661. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15662. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15663. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15664. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15665. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15666. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15667. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15668. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15669. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15670. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15671. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15672. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15673. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15674. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15675. DickeyValue.Add("TzZCost", TzZCost);
  15676. foreach (var key in DickeyValue.Keys)
  15677. {
  15678. if (doc.Range.Bookmarks[key] != null)
  15679. {
  15680. Bookmark mark = doc.Range.Bookmarks[key];
  15681. mark.Text = DickeyValue[key];
  15682. }
  15683. }
  15684. byte[] bytes = null;
  15685. string strFileName = di.TeamName + "-客户报价.doc";
  15686. using (MemoryStream stream = new MemoryStream())
  15687. {
  15688. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15689. bytes = stream.ToArray();
  15690. }
  15691. return Ok(JsonView(true, "", new
  15692. {
  15693. Data = bytes,
  15694. strFileName,
  15695. }));
  15696. }
  15697. /// <summary>
  15698. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15699. /// </summary>
  15700. /// <param name="dto"></param>
  15701. /// <returns></returns>
  15702. [HttpPost]
  15703. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15704. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  15705. {
  15706. try
  15707. {
  15708. #region 参数验证
  15709. if (dto.DiId < 0)
  15710. {
  15711. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  15712. }
  15713. List<int> cTableIds = new List<int>() {
  15714. 76 ,//酒店预订
  15715. 77 ,//行程
  15716. 79 ,//车/导游地接
  15717. 80 ,//签证
  15718. 81 ,//邀请/公务活
  15719. 82 ,//团组客户保险
  15720. 85 ,//机票预订
  15721. 98 ,//其他款项
  15722. 285 ,//收款退还
  15723. 751 ,//酒店早餐
  15724. 1015 // 超支费用
  15725. };
  15726. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  15727. {
  15728. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  15729. }
  15730. #endregion
  15731. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  15732. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  15733. if (_GroupCostParameters.Count <= 0)
  15734. {
  15735. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  15736. }
  15737. if (_GroupCostParameters[0].IsShare == 0)
  15738. {
  15739. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  15740. }
  15741. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15742. //处理date为空问题
  15743. if (_GroupCosts.Count > 0)
  15744. {
  15745. for (int i = 0; i < _GroupCosts.Count; i++)
  15746. {
  15747. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  15748. {
  15749. if (i > 0)
  15750. {
  15751. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  15752. }
  15753. }
  15754. }
  15755. }
  15756. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  15757. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  15758. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  15759. string currCode = "";
  15760. #region currCode 验证
  15761. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  15762. if (isInt)
  15763. {
  15764. var currData = currDatas.Find(it => it.Id == intCurrency);
  15765. if (currData != null)
  15766. {
  15767. currCode = currData.Name;
  15768. }
  15769. }
  15770. else
  15771. {
  15772. currCode = _GroupCostParameters[0].Currency.Trim();
  15773. }
  15774. #endregion
  15775. //op,酒店单段模式存储
  15776. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  15777. {
  15778. CurrencyCode = currCode,
  15779. Rate = _GroupCostParameters[0].Rate,
  15780. CostType = _GroupCostParameters[0].CostType,
  15781. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  15782. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  15783. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  15784. };
  15785. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  15786. if (_GroupCostParameters.Count == 2)
  15787. {
  15788. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  15789. }
  15790. foreach (var item in _GroupCostParameters)
  15791. {
  15792. decimal _rate = 1;
  15793. decimal _rate1 = item.Rate;
  15794. decimal _scale = 1;
  15795. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  15796. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  15797. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  15798. //if (userInfo != null)
  15799. //{
  15800. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  15801. // {
  15802. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  15803. // {
  15804. // _scale = 1.00M;
  15805. // }
  15806. // }
  15807. //}
  15808. #endregion
  15809. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  15810. {
  15811. CurrencyCode = currCode,
  15812. Rate = _rate1,
  15813. CostType = item.CostType,
  15814. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  15815. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  15816. CostTypeNumber = item.CostTypenumber
  15817. };
  15818. if (_GroupCostParameters.Count > 1)
  15819. {
  15820. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  15821. }
  15822. else
  15823. {
  15824. modulePromptInfo.CostTypeNumber = item.LYJRS;
  15825. }
  15826. if (dto.CTable == 79)//
  15827. {
  15828. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  15829. modulePromptInfo.TotalCost = item.DJCB;
  15830. }
  15831. List<string> costTypes = new List<string>() { "A", "B" };
  15832. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  15833. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  15834. if (_GroupCostsDuplicates.Count() == 1)
  15835. {
  15836. _GroupCostsTypeData = _GroupCosts;
  15837. }
  15838. else
  15839. {
  15840. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  15841. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  15842. }
  15843. /*
  15844. * 76 酒店预订
  15845. * 77 行程
  15846. * 79 车/导游地接
  15847. * 80 签证
  15848. * 81 邀请/公务活动
  15849. * 82 团组客户保险
  15850. * 85 机票预订
  15851. * 98 其他款项
  15852. * 285 收款退还
  15853. * 751 酒店早餐
  15854. * 1015 超支费用
  15855. */
  15856. switch (dto.CTable)
  15857. {
  15858. case 76: // 酒店预订
  15859. _ModuleSubPromptInfo.AddRange(
  15860. _GroupCostsTypeData.Select(it => new
  15861. {
  15862. it.DAY,
  15863. it.Date,
  15864. it.ACCON,
  15865. it.ITIN,
  15866. it.SGR,
  15867. it.TBR,
  15868. it.JS_ES,
  15869. it.Suite
  15870. })
  15871. );
  15872. break;
  15873. case 79: // 车/导游地接
  15874. _ModuleSubPromptInfo.AddRange(
  15875. _GroupCostsTypeData.Select(it => new
  15876. {
  15877. Date = it.Date, //日期
  15878. CarFee = it.CarCost * _rate * _scale, //车费用
  15879. CarType = it.CarType, //车型
  15880. DriverFee = it.CFS * _rate * _scale, //司机工资
  15881. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  15882. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  15883. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  15884. GuideFee = it.TGS * _rate * _scale, //导游费用
  15885. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  15886. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  15887. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  15888. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  15889. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  15890. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  15891. Breakfast = it.B * _rate * _scale, //早餐费
  15892. Lunch = it.L * _rate * _scale, //午餐费
  15893. Dinner = it.D * _rate * _scale, //晚餐费
  15894. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  15895. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  15896. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  15897. TicketFee = it.EF * _rate * _scale, //门票费
  15898. TicketRemark = it.EFR, //门票费描述
  15899. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  15900. TravelSupplies = it.TE * _rate * _scale, //出行物资
  15901. SpentCash = it.PC * _rate * _scale, //零用金
  15902. LeadersFee = it.TLF * _rate * _scale, //领队费
  15903. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  15904. })
  15905. );
  15906. break;
  15907. case 85: // 机票
  15908. List<dynamic> datas = new List<dynamic>();
  15909. datas.Add(
  15910. new
  15911. {
  15912. AirType = "经济舱",
  15913. AirNum = item.JJCRS,
  15914. AirDRCB = item.JJCCB,
  15915. AirZCB = (item.JJCRS * item.JJCCB)
  15916. }
  15917. );
  15918. datas.Add(
  15919. new
  15920. {
  15921. AirType = "公务舱",
  15922. AirNum = item.GWCRS,
  15923. AirDRCB = item.GWCCB,
  15924. AirZCB = (item.GWCRS * item.GWCCB)
  15925. }
  15926. );
  15927. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15928. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  15929. modulePromptInfo.Data = new
  15930. {
  15931. airFeeData = datas,
  15932. airInitData = initDatas
  15933. };
  15934. _ModulePromptInfos.Add(modulePromptInfo);
  15935. break;
  15936. default:
  15937. break;
  15938. }
  15939. }
  15940. if (dto.CTable != 85)
  15941. {
  15942. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  15943. _ModulePromptInfos.Add(_ModulePromptInfo);
  15944. }
  15945. _view.ModulePromptInfos = _ModulePromptInfos;
  15946. return Ok(JsonView(true, "操作成功!", _view));
  15947. }
  15948. catch (Exception ex)
  15949. {
  15950. return Ok(JsonView(false, ex.Message));
  15951. }
  15952. }
  15953. /// <summary>
  15954. /// 根据黑屏代码重新生成行程
  15955. /// </summary>
  15956. /// <param name="dto"></param>
  15957. /// <returns></returns>
  15958. [HttpPost]
  15959. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  15960. {
  15961. var jw = JsonView(false, "Error");
  15962. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  15963. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  15964. .Select(x => new
  15965. {
  15966. x.Id,
  15967. x.Title
  15968. })
  15969. .ToList();
  15970. if (Create.Any())
  15971. {
  15972. jw.Msg = "获取成功!";
  15973. jw.Code = 200;
  15974. jw.Data = new
  15975. {
  15976. BlackCodeListSelect = Create,
  15977. blackCodeIsTrue = true
  15978. };
  15979. }
  15980. else
  15981. {
  15982. jw.Code = 400;
  15983. jw.Data = new
  15984. {
  15985. BlackCodeListSelect = Create,
  15986. blackCodeIsTrue = false,
  15987. };
  15988. }
  15989. return Ok(jw);
  15990. }
  15991. /// <summary>
  15992. /// 根据黑屏代码Id重新生成行程
  15993. /// </summary>
  15994. /// <param name="dto"></param>
  15995. /// <returns></returns>
  15996. [HttpPost]
  15997. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  15998. {
  15999. var jw = JsonView(false, "Error");
  16000. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  16001. if (result.Code == 0)
  16002. {
  16003. jw.Msg = "获取成功!";
  16004. jw.Code = 200;
  16005. jw.Data = new
  16006. {
  16007. groupCost = result.Data,
  16008. blackCodeIsTrue = true
  16009. };
  16010. }
  16011. else
  16012. {
  16013. jw.Code = 400;
  16014. jw.Data = new
  16015. {
  16016. groupCost = result.Data,
  16017. blackCodeIsTrue = false,
  16018. };
  16019. }
  16020. return Ok(jw);
  16021. }
  16022. /// <summary>
  16023. /// 成本获取OP历史车费用
  16024. /// </summary>
  16025. /// <param name="dto"></param>
  16026. /// <returns></returns>
  16027. [HttpPost]
  16028. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  16029. {
  16030. var jw = JsonView(false);
  16031. try
  16032. {
  16033. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  16034. //获取现有所有车的数据
  16035. if (!dto.Param.IsNullOrWhiteSpace())
  16036. {
  16037. string sql = $@"
  16038. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  16039. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  16040. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  16041. 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
  16042. AND gctggr.ServiceEndTime is not NULL
  16043. ORDER by gctggrc.id DESC
  16044. ";
  16045. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  16046. var numeberResult = await Task.Run(() =>
  16047. {
  16048. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  16049. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  16050. return numberArr;
  16051. });
  16052. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  16053. foreach (var item in numeberResult)
  16054. {
  16055. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  16056. {
  16057. Country = "数据异常!",
  16058. City = string.Empty,
  16059. };
  16060. item.Area = find.Country + " " + find.City;
  16061. }
  16062. dbResult.AddRange(numeberResult);
  16063. if (dto.Param.Contains("、"))
  16064. {
  16065. var sp = dto.Param.Split("、");
  16066. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16067. .Where(x =>
  16068. {
  16069. return System.Array.Exists(sp, e =>
  16070. {
  16071. bool where = false;
  16072. if (x.Area != null)
  16073. {
  16074. where = x.Area.Contains(e);
  16075. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16076. {
  16077. return false;
  16078. }
  16079. }
  16080. if (x.PriceName != null && !where)
  16081. {
  16082. where = x.PriceName.Contains(e);
  16083. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16084. {
  16085. return false;
  16086. }
  16087. }
  16088. return where;
  16089. });
  16090. }).ToList();
  16091. }
  16092. else
  16093. {
  16094. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16095. .Where(x =>
  16096. {
  16097. bool where = false;
  16098. if (x.Area != null)
  16099. {
  16100. where = x.Area.Contains(dto.Param);
  16101. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16102. {
  16103. return false;
  16104. }
  16105. }
  16106. if (x.PriceName != null && !where)
  16107. {
  16108. where = x.PriceName.Contains(dto.Param);
  16109. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16110. {
  16111. return false;
  16112. }
  16113. }
  16114. return where;
  16115. }
  16116. )
  16117. .ToList();
  16118. }
  16119. }
  16120. var view = dbResult.Select(x =>
  16121. {
  16122. decimal dp = 0.00M;
  16123. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  16124. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  16125. if (string.IsNullOrWhiteSpace(x.DatePrice))
  16126. {
  16127. if (startB && endB)
  16128. {
  16129. var timesp = endD.Subtract(startD);
  16130. if ((timesp.Days + 1) != 0)
  16131. {
  16132. dp = x.Price / (timesp.Days + 1);
  16133. }
  16134. }
  16135. }
  16136. else
  16137. {
  16138. dp = x.Price;
  16139. }
  16140. return new
  16141. {
  16142. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  16143. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  16144. x.Area,
  16145. x.id,
  16146. price = x.Price.ToString("F2"),
  16147. x.PriceName,
  16148. x.PriceContent,
  16149. x.TeamName,
  16150. x.DatePrice,
  16151. dayPrice = dp.ToString("F2"),
  16152. };
  16153. }).OrderByDescending(x => x.id).ToList();
  16154. jw = JsonView(true, "获取成功!", view);
  16155. }
  16156. catch (Exception e)
  16157. {
  16158. jw = JsonView(false, e.Message);
  16159. }
  16160. return Ok(jw);
  16161. }
  16162. [HttpPost]
  16163. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  16164. {
  16165. var jw = JsonView(true);
  16166. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  16167. if (string.IsNullOrWhiteSpace(dto.Keyword))
  16168. {
  16169. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16170. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16171. WHEN COUNT(*) >= 0 THEN 'True'
  16172. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16173. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16174. ")
  16175. .ToList();
  16176. }
  16177. else
  16178. {
  16179. string likeKey = string.Empty;
  16180. foreach (var item in dto.Keyword)
  16181. {
  16182. likeKey += "%" + item;
  16183. }
  16184. likeKey += "%";
  16185. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16186. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16187. WHEN COUNT(*) >= 0 THEN 'True'
  16188. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16189. Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16190. ")
  16191. .ToList();
  16192. }
  16193. if (matches.Any())
  16194. {
  16195. jw.Data = matches;
  16196. }
  16197. else
  16198. {
  16199. jw.Code = 201;
  16200. jw.Msg = "empty list";
  16201. jw.Data = new List<string>(1);
  16202. }
  16203. return Ok(jw);
  16204. }
  16205. /// <summary>
  16206. /// 报价Word下载
  16207. /// </summary>
  16208. /// <param name="dto"></param>
  16209. /// <returns></returns>
  16210. [HttpPost]
  16211. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16212. {
  16213. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16214. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16215. if (di == null)
  16216. {
  16217. return Ok(JsonView(false, "团组不存在!"));
  16218. }
  16219. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16220. if (mainPrice == null || mainPrice.IsShare == 0)
  16221. {
  16222. return Ok(JsonView(false, "团组成本不存在!"));
  16223. }
  16224. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16225. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16226. if (costTypeHotelNumbers == null)
  16227. {
  16228. return Ok(JsonView(false, "团组成本不存在!"));
  16229. }
  16230. //文件名
  16231. string strFileName = di.TeamName + "-收款账单.doc";
  16232. //获取模板
  16233. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16234. //载入模板
  16235. Document doc = new Document(tmppath);
  16236. decimal allPrice = 0.00M;
  16237. string itemStr = string.Empty;
  16238. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16239. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16240. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16241. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16242. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16243. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16244. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16245. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16246. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16247. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16248. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16249. {
  16250. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16251. ("BXRS", "BXCB", "BXXS", "bx"),
  16252. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16253. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16254. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16255. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16256. ("CPRS", "CPCB", "CPXS", "cp"),
  16257. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16258. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16259. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16260. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16261. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16262. ("DJRS", "DJCB", "DJXS", "dj"),
  16263. ("GWRS", "GWCB", "GWXS", "gw"),
  16264. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16265. };
  16266. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16267. var rightSum = 0.00M;
  16268. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16269. {
  16270. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16271. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16272. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16273. if (prefix == "tbr")
  16274. {
  16275. rsValue *= 2;
  16276. cbValue /= 2;
  16277. }
  16278. if (OtherCostPropertyBJ.Contains(prefix))
  16279. {
  16280. rightSum += cbValue * xsValue;
  16281. }
  16282. }
  16283. var hotelRooms = new Dictionary<string, int>
  16284. {
  16285. { "SGR", costTypeHotelNumbers.SGR },
  16286. { "TBR", costTypeHotelNumbers.TBR },
  16287. { "JSES", costTypeHotelNumbers.JSES },
  16288. { "SUITE", costTypeHotelNumbers.SUITE }
  16289. };
  16290. var flights = new Dictionary<string, int>
  16291. {
  16292. { "经济舱", mainPrice.JJCRS },
  16293. { "公务舱", mainPrice.GWCRS },
  16294. { "头等舱", mainPrice.TDCRS }
  16295. };
  16296. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16297. {
  16298. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16299. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16300. { "头等舱", new[] { "SUITE", "JSES" } }
  16301. };
  16302. var result = new Dictionary<string, int>();
  16303. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16304. foreach (var flight in flights.Keys)
  16305. {
  16306. // 获取当前舱位的匹配规则
  16307. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16308. {
  16309. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16310. }
  16311. }
  16312. #region right计算
  16313. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16314. {
  16315. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16316. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16317. airHotelPriceList.Add(new
  16318. AirHotelPrice
  16319. {
  16320. Name = "经济舱TBR",
  16321. Price = rightSum + air + hotel,
  16322. Count = result["经济舱TBR"] * 2
  16323. });
  16324. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16325. }
  16326. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16327. {
  16328. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16329. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16330. airHotelPriceList.Add(new
  16331. AirHotelPrice
  16332. {
  16333. Name = "经济舱SGR",
  16334. Price = rightSum + air + hotel,
  16335. Count = result["经济舱SGR"]
  16336. });
  16337. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16338. }
  16339. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16340. {
  16341. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16342. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16343. airHotelPriceList.Add(new
  16344. AirHotelPrice
  16345. {
  16346. Name = "公务舱SGR",
  16347. Price = rightSum + air + hotel,
  16348. Count = result["公务舱SGR"]
  16349. });
  16350. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16351. }
  16352. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16353. {
  16354. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16355. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16356. airHotelPriceList.Add(new
  16357. AirHotelPrice
  16358. {
  16359. Name = "公务舱JSES",
  16360. Price = rightSum + air + hotel,
  16361. Count = result["公务舱JSES"]
  16362. });
  16363. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16364. }
  16365. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16366. {
  16367. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16368. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16369. airHotelPriceList.Add(new
  16370. AirHotelPrice
  16371. {
  16372. Name = "公务舱SUITE",
  16373. Price = rightSum + air + hotel,
  16374. Count = result["公务舱SUITE"]
  16375. });
  16376. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16377. }
  16378. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16379. {
  16380. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16381. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16382. airHotelPriceList.Add(new
  16383. AirHotelPrice
  16384. {
  16385. Name = "经济舱SUITE",
  16386. Price = rightSum + air + hotel,
  16387. Count = result["经济舱SUITE"]
  16388. });
  16389. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16390. }
  16391. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16392. {
  16393. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16394. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16395. airHotelPriceList.Add(new
  16396. AirHotelPrice
  16397. {
  16398. Name = "头等舱JSES",
  16399. Price = rightSum + air + hotel,
  16400. Count = result["头等舱JSES"]
  16401. });
  16402. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16403. }
  16404. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16405. {
  16406. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16407. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16408. airHotelPriceList.Add(new
  16409. AirHotelPrice
  16410. {
  16411. Name = "头等舱SUITE",
  16412. Price = rightSum + air + hotel,
  16413. Count = result["头等舱SUITE"]
  16414. });
  16415. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16416. }
  16417. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16418. {
  16419. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16420. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16421. airHotelPriceList.Add(new
  16422. AirHotelPrice
  16423. {
  16424. Name = "经济舱JSES",
  16425. Price = rightSum + air + hotel,
  16426. Count = result["经济舱JSES"]
  16427. });
  16428. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16429. }
  16430. #endregion
  16431. foreach (var item in airSouer.Keys)
  16432. {
  16433. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  16434. if (find != null && find.Count > 0)
  16435. {
  16436. if (item.Contains("TBR"))
  16437. {
  16438. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16439. }
  16440. else
  16441. {
  16442. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16443. }
  16444. }
  16445. }
  16446. #region 替换Word模板书签内容
  16447. Dictionary<string, string> marks = new Dictionary<string, string>();
  16448. marks.Add("To", di.ClientUnit);//付款方
  16449. marks.Add("ToTel", di.TellPhone);//付款方电话
  16450. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  16451. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  16452. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  16453. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  16454. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  16455. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16456. marks.Add("PayItemContent", itemStr);//详细信息
  16457. marks.Add("Total", allPrice.ToString("F2"));//合计
  16458. #endregion
  16459. foreach (var item in marks.Keys)
  16460. {
  16461. if (doc.Range.Bookmarks[item] != null)
  16462. {
  16463. Bookmark mark = doc.Range.Bookmarks[item];
  16464. mark.Text = marks[item];
  16465. }
  16466. }
  16467. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  16468. doc.Save(savePaht);
  16469. var jw = new JsonView();
  16470. jw.Msg = "生成成功!";
  16471. jw.Code = 200;
  16472. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  16473. return Ok(jw);
  16474. }
  16475. /// <summary>
  16476. /// 详细报价费用Excel下载
  16477. /// </summary>
  16478. /// <param name="dto"></param>
  16479. /// <returns></returns>
  16480. [HttpPost]
  16481. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  16482. {
  16483. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16484. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16485. if (di == null)
  16486. {
  16487. return Ok(JsonView(false, "团组不存在!"));
  16488. }
  16489. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16490. if (mainPrice == null || mainPrice.IsShare == 0)
  16491. {
  16492. return Ok(JsonView(false, "团组成本不存在!"));
  16493. }
  16494. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16495. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16496. if (costTypeHotelNumbers == null)
  16497. {
  16498. return Ok(JsonView(false, "团组成本不存在!"));
  16499. }
  16500. WorkbookDesigner designer = new WorkbookDesigner();
  16501. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  16502. List<int> hideRowsList = new List<int>();
  16503. int conterStartIndex = 3;
  16504. int rowIndex = conterStartIndex;
  16505. designer.SetDataSource("GroupName", di.TeamName);
  16506. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16507. {
  16508. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16509. ("BXRS", "BXCB", "BXXS", "bx"),
  16510. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16511. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16512. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  16513. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  16514. ("CPRS", "CPCB", "CPXS", "cp") ,
  16515. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  16516. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  16517. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  16518. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16519. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16520. ("DJRS", "DJCB", "DJXS", "dj") ,
  16521. ("GWRS", "GWCB", "GWXS", "gw") ,
  16522. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16523. };
  16524. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16525. var rightSum = 0.00M;
  16526. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16527. {
  16528. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16529. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16530. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16531. if (prefix == "tbr")
  16532. {
  16533. rsValue *= 2;
  16534. cbValue /= 2;
  16535. }
  16536. if (OtherCostPropertyBJ.Contains(prefix))
  16537. {
  16538. rightSum += cbValue * xsValue;
  16539. }
  16540. if (rsValue == 0)
  16541. {
  16542. hideRowsList.Add(rowIndex);
  16543. }
  16544. else
  16545. {
  16546. designer.SetDataSource($"{prefix}rs", rsValue);
  16547. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  16548. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  16549. }
  16550. rowIndex += 2;
  16551. }
  16552. var hotelRooms = new Dictionary<string, int>
  16553. {
  16554. { "SGR", costTypeHotelNumbers.SGR },
  16555. { "TBR", costTypeHotelNumbers.TBR },
  16556. { "JSES", costTypeHotelNumbers.JSES },
  16557. { "SUITE", costTypeHotelNumbers.SUITE }
  16558. };
  16559. var flights = new Dictionary<string, int>
  16560. {
  16561. { "经济舱", mainPrice.JJCRS },
  16562. { "公务舱", mainPrice.GWCRS },
  16563. { "头等舱", mainPrice.TDCRS }
  16564. };
  16565. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16566. {
  16567. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16568. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16569. { "头等舱", new[] { "SUITE", "JSES" } }
  16570. };
  16571. var result = new Dictionary<string, int>();
  16572. foreach (var flight in flights.Keys)
  16573. {
  16574. // 获取当前舱位的匹配规则
  16575. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16576. {
  16577. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16578. }
  16579. }
  16580. var allPrice = 0.00M;
  16581. #region right计算
  16582. int airRowIndex = 35;
  16583. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16584. {
  16585. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16586. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16587. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  16588. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  16589. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  16590. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16591. }
  16592. else
  16593. {
  16594. hideRowsList.Add(airRowIndex);
  16595. }
  16596. airRowIndex += 2;
  16597. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16598. {
  16599. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16600. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16601. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  16602. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  16603. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  16604. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16605. }
  16606. else
  16607. {
  16608. hideRowsList.Add(airRowIndex);
  16609. }
  16610. airRowIndex += 2;
  16611. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16612. {
  16613. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16614. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16615. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  16616. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  16617. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  16618. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16619. }
  16620. else
  16621. {
  16622. hideRowsList.Add(airRowIndex);
  16623. }
  16624. airRowIndex += 2;
  16625. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16626. {
  16627. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16628. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16629. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  16630. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  16631. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  16632. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16633. }
  16634. else
  16635. {
  16636. hideRowsList.Add(airRowIndex);
  16637. }
  16638. airRowIndex += 2;
  16639. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16640. {
  16641. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16642. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16643. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  16644. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  16645. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  16646. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16647. }
  16648. else
  16649. {
  16650. hideRowsList.Add(airRowIndex);
  16651. }
  16652. airRowIndex += 2;
  16653. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16654. {
  16655. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16656. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16657. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  16658. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  16659. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  16660. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16661. }
  16662. else
  16663. {
  16664. hideRowsList.Add(airRowIndex);
  16665. }
  16666. airRowIndex += 2;
  16667. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16668. {
  16669. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16670. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16671. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  16672. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  16673. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  16674. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16675. }
  16676. else
  16677. {
  16678. hideRowsList.Add(airRowIndex);
  16679. }
  16680. airRowIndex += 2;
  16681. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16682. {
  16683. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16684. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16685. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  16686. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  16687. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  16688. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16689. }
  16690. else
  16691. {
  16692. hideRowsList.Add(airRowIndex);
  16693. }
  16694. airRowIndex += 2;
  16695. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16696. {
  16697. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16698. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16699. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  16700. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  16701. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  16702. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16703. }
  16704. else
  16705. {
  16706. hideRowsList.Add(airRowIndex);
  16707. }
  16708. #endregion
  16709. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  16710. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  16711. var ws = designer.Workbook.Worksheets[0];
  16712. foreach (var Rowindex in hideRowsList)
  16713. {
  16714. ws.Cells.HideRows(Rowindex, 2);
  16715. }
  16716. designer.Process();
  16717. designer.Workbook.Save(savePaht);
  16718. return Ok(JsonView(true, "生成成功!", new
  16719. {
  16720. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  16721. }));
  16722. }
  16723. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  16724. {
  16725. foreach (var roomType in roomTypes)
  16726. {
  16727. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  16728. {
  16729. hotelRooms[roomType]--;
  16730. flights[flightType]--;
  16731. if (roomType == "TBR")
  16732. {
  16733. flights[flightType]--; // 双人间在减少1
  16734. }
  16735. string key = flightType + roomType;
  16736. if (result.Keys.Contains(key))
  16737. {
  16738. result[key]++;
  16739. }
  16740. else
  16741. {
  16742. result.Add(key, 1);
  16743. }
  16744. }
  16745. }
  16746. }
  16747. private class AirHotelPrice
  16748. {
  16749. public string Name { get; set; }
  16750. public decimal Price { get; set; }
  16751. public int Count { get; set; }
  16752. }
  16753. #endregion
  16754. #region 酒店预订 New 2023-12-28 17:45
  16755. /// <summary>
  16756. /// 酒店预订
  16757. /// 酒店费用列表 根据团组Id查询
  16758. /// </summary>
  16759. /// <param name="_dto"></param>
  16760. /// <returns></returns>
  16761. [HttpPost]
  16762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16763. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  16764. {
  16765. #region 参数验证
  16766. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16767. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16768. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16769. #region 团组操作权限验证 76 酒店预定模块
  16770. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16771. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16772. #endregion
  16773. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16774. #region 页面操作权限验证
  16775. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16776. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16777. #endregion
  16778. #endregion
  16779. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  16780. }
  16781. /// <summary>
  16782. /// 酒店预订
  16783. /// 基础数据
  16784. /// </summary>
  16785. /// <param name="_dto"></param>
  16786. /// <returns></returns>
  16787. [HttpPost]
  16788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16789. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  16790. {
  16791. #region 参数验证
  16792. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16793. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16794. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16795. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16796. #region 页面操作权限验证
  16797. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16798. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16799. #endregion
  16800. #region 团组操作权限验证 76 酒店预定模块
  16801. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16802. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16803. #endregion
  16804. #endregion
  16805. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  16806. }
  16807. /// <summary>
  16808. /// 酒店预订
  16809. /// 创建 入住卷号码
  16810. /// </summary>
  16811. /// <param name="_dto"></param>
  16812. /// <returns></returns>
  16813. [HttpPost]
  16814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16815. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  16816. {
  16817. #region 参数验证
  16818. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16819. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16820. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16821. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16822. #region 页面操作权限验证
  16823. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16824. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16825. #endregion
  16826. #region 团组操作权限验证 76 酒店预定模块
  16827. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16828. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16829. #endregion
  16830. #endregion
  16831. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  16832. if (data.Code != 0)
  16833. {
  16834. return Ok(JsonView(false, data.Msg));
  16835. }
  16836. return Ok(JsonView(true, data.Msg, data.Data));
  16837. }
  16838. /// <summary>
  16839. /// 酒店预订
  16840. /// 详情
  16841. /// </summary>
  16842. /// <param name="_dto"></param>
  16843. /// <returns></returns>
  16844. [HttpPost]
  16845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16846. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  16847. {
  16848. #region 参数验证
  16849. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  16850. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16851. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  16852. #region 团组操作权限验证 76 酒店预定模块
  16853. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16854. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16855. #endregion
  16856. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16857. #region 页面操作权限验证
  16858. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16859. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16860. #endregion
  16861. #endregion
  16862. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  16863. }
  16864. /// <summary>
  16865. /// 酒店预订
  16866. /// Add Or Edit
  16867. /// </summary>
  16868. /// <param name="_dto"></param>
  16869. /// <returns></returns>
  16870. [HttpPost]
  16871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16872. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  16873. {
  16874. #region 参数验证
  16875. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16876. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16877. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16878. #region 团组操作权限验证 76 酒店预定模块
  16879. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16880. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16881. #endregion
  16882. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16883. #region 页面操作权限验证
  16884. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16885. if (_dto.Id == 0) // Add
  16886. {
  16887. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16888. }
  16889. else if (_dto.Id > 1) // Edit
  16890. {
  16891. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16892. }
  16893. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  16894. #endregion
  16895. #endregion
  16896. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  16897. if (_view.Code != 200)
  16898. {
  16899. return Ok(_view);
  16900. }
  16901. #region 成本无酒店价格数据进入超支
  16902. _sqlSugar.BeginTran();
  16903. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  16904. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  16905. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  16906. for (int i = 0; i < groupCost.Count; i++)
  16907. {
  16908. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  16909. {
  16910. groupCost[i].Date = groupCost[i - 1].Date;
  16911. }
  16912. }
  16913. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  16914. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  16915. List<Fin_GroupExtraCostDto_OP>();
  16916. if (start_Bool && end_Bool)
  16917. {
  16918. while (start_Time < end_Time)
  16919. {
  16920. foreach (var item in groupCost_Grp)
  16921. {
  16922. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  16923. {
  16924. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  16925. {
  16926. extraCostList.Add(new
  16927. Fin_GroupExtraCostDto_OP
  16928. {
  16929. Area = _dto.AreaId,
  16930. coefficient = 1.5M,
  16931. createUser = _dto.UserId,
  16932. currency = _dto.CardPriceCurrency,
  16933. diId = _dto.DiId,
  16934. ManagerConfirm = 0,
  16935. SupervisorConfirm = 0,
  16936. SYsupervisorConfirm = 0,
  16937. editType = 1,
  16938. PortType = 1,
  16939. price = _dto.CardPrice,
  16940. PriceCount = 1,
  16941. priceType = 1027,
  16942. priceDetailType = 1044,
  16943. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  16944. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  16945. });
  16946. }
  16947. }
  16948. }
  16949. start_Time = start_Time.AddDays(1);
  16950. }
  16951. }
  16952. if (extraCostList.Any())
  16953. {
  16954. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  16955. }
  16956. _sqlSugar.CommitTran();
  16957. #endregion
  16958. #region 应用推送
  16959. try
  16960. {
  16961. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  16962. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  16963. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  16964. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  16965. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  16966. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  16967. var diId = _dto.DiId;
  16968. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16969. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16970. #region 操作记录
  16971. var opInfo = new Crm_TableOperationRecord()
  16972. {
  16973. TableName = "Grp_HotelReservations",
  16974. PortType = _dto.PortType,
  16975. DataId = hotelId,
  16976. CreateUserId = _dto.UserId
  16977. };
  16978. //var opStatus = OperationEnum.NoOperation;
  16979. if (_dto.Id < 1) //添加操作
  16980. {
  16981. opInfo.OperationItem = OperationEnum.Add;
  16982. }
  16983. else if (_dto.Id > 0)
  16984. {
  16985. opInfo.OperationItem = OperationEnum.Edit;
  16986. }
  16987. string opRemark = string.Empty;
  16988. if (ccpInfo != null)
  16989. {
  16990. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  16991. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  16992. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  16993. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  16994. }
  16995. opInfo.Remark = opRemark;
  16996. await _tableorRep.AddAsync(opInfo);
  16997. #endregion
  16998. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  16999. //2024-10-21 新增LZ UID
  17000. var userIds = new List<int>() { 21 };
  17001. string title = $"费用审核";
  17002. string content = "";
  17003. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17004. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17005. try
  17006. {
  17007. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  17008. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  17009. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  17010. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  17011. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  17012. }
  17013. catch (Exception ex)
  17014. {
  17015. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  17016. }
  17017. }
  17018. catch (Exception ex)
  17019. {
  17020. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  17021. }
  17022. try
  17023. {
  17024. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17025. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17026. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17027. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17028. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17029. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17030. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17031. //自动审核
  17032. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  17033. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  17034. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  17035. //2024-10-21 新增LZ UID
  17036. var userIds = new List<int>() { 21 };
  17037. string title = $"系统通知";
  17038. var diId = _dto.DiId;
  17039. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17040. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17041. string content = "";
  17042. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17043. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17044. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17045. }
  17046. catch (Exception ex)
  17047. {
  17048. }
  17049. #endregion
  17050. return Ok(_view);
  17051. }
  17052. /// <summary>
  17053. /// 酒店自动审核测试
  17054. /// Add Or Edit
  17055. /// </summary>
  17056. /// <param name="diid"></param>
  17057. /// <param name="dataId"></param>
  17058. /// <returns></returns>
  17059. [HttpPost]
  17060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17061. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  17062. {
  17063. #region 应用推送
  17064. try
  17065. {
  17066. //自动审核
  17067. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  17068. }
  17069. catch (Exception ex)
  17070. {
  17071. return Ok(JsonView(false, "操作失败"));
  17072. }
  17073. #endregion
  17074. return Ok(JsonView(false, "操作成功"));
  17075. }
  17076. /// <summary>
  17077. /// 酒店预订
  17078. /// Del
  17079. /// </summary>
  17080. /// <param name="_dto"></param>
  17081. /// <returns></returns>
  17082. [HttpPost]
  17083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17084. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  17085. {
  17086. #region 参数验证
  17087. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17088. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17089. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17090. #region 团组操作权限验证 76 酒店预定模块
  17091. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17092. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17093. #endregion
  17094. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17095. #region 页面操作权限验证
  17096. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17097. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  17098. #endregion
  17099. #endregion
  17100. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  17101. #region 操作记录
  17102. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  17103. {
  17104. TableName = "Grp_HotelReservations",
  17105. PortType = _dto.PortType,
  17106. OperationItem = OperationEnum.Del,
  17107. DataId = _dto.Id,
  17108. CreateUserId = _dto.UserId
  17109. });
  17110. #endregion
  17111. return Ok(data);
  17112. }
  17113. /// <summary>
  17114. /// 酒店预订
  17115. /// 生成VOUCHER
  17116. /// 2024.05.06 之前版本
  17117. /// </summary>
  17118. /// <param name="_dto"></param>
  17119. /// <returns></returns>
  17120. [HttpPost]
  17121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17122. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  17123. {
  17124. try
  17125. {
  17126. #region 参数验证
  17127. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17128. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17129. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17130. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  17131. #region 团组操作权限验证 76 酒店预定模块
  17132. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17133. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17134. #endregion
  17135. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17136. #region 页面操作权限验证
  17137. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17138. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17139. #endregion
  17140. #endregion
  17141. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  17142. //判断数据是否完整
  17143. if (hr != null)
  17144. {
  17145. if (!string.IsNullOrEmpty(hr.DetermineNo))
  17146. {
  17147. string strFileName = "HotelStatement/";
  17148. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17149. if (dele != null)
  17150. strFileName += dele.TourCode;
  17151. //载入模板
  17152. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  17153. Document doc = new Document(sss);
  17154. DocumentBuilder builder = new DocumentBuilder(doc);
  17155. #region 替换Word模板书签内容
  17156. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  17157. //入住卷预定号码
  17158. if (doc.Range.Bookmarks["VNO"] != null)
  17159. {
  17160. Bookmark mark = doc.Range.Bookmarks["VNO"];
  17161. mark.Text = hr.CheckNumber;
  17162. }
  17163. //酒店时间
  17164. if (doc.Range.Bookmarks["Date"] != null)
  17165. {
  17166. Bookmark mark = doc.Range.Bookmarks["Date"];
  17167. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17168. }
  17169. //团号
  17170. if (doc.Range.Bookmarks["TNo"] != null)
  17171. {
  17172. Bookmark mark = doc.Range.Bookmarks["TNo"];
  17173. mark.Text = dele.TourCode;
  17174. }
  17175. //预定号码
  17176. if (doc.Range.Bookmarks["BookingId"] != null)
  17177. {
  17178. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  17179. mark.Text = hr.ReservationsNo;
  17180. }
  17181. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  17182. {
  17183. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  17184. mark.Text = hr.DetermineNo;
  17185. }
  17186. //酒店城市
  17187. if (doc.Range.Bookmarks["City"] != null)
  17188. {
  17189. Bookmark mark = doc.Range.Bookmarks["City"];
  17190. mark.Text = hr.City;
  17191. }
  17192. //酒店名称
  17193. if (doc.Range.Bookmarks["HName"] != null)
  17194. {
  17195. Bookmark mark = doc.Range.Bookmarks["HName"];
  17196. mark.Text = hr.HotelName;
  17197. }
  17198. //酒店地址
  17199. if (doc.Range.Bookmarks["Address"] != null)
  17200. {
  17201. Bookmark mark = doc.Range.Bookmarks["Address"];
  17202. mark.Text = hr.HotelAddress;
  17203. }
  17204. //酒店电话
  17205. if (doc.Range.Bookmarks["Tel"] != null)
  17206. {
  17207. Bookmark mark = doc.Range.Bookmarks["Tel"];
  17208. mark.Text = hr.HotelTel;
  17209. }
  17210. //酒店传真
  17211. if (doc.Range.Bookmarks["Fax"] != null)
  17212. {
  17213. Bookmark mark = doc.Range.Bookmarks["Fax"];
  17214. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  17215. {
  17216. mark.Text = hr.HotelFax;
  17217. }
  17218. }
  17219. //入住时间
  17220. if (doc.Range.Bookmarks["CIn"] != null)
  17221. {
  17222. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17223. Bookmark mark = doc.Range.Bookmarks["CIn"];
  17224. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  17225. }
  17226. //退房时间
  17227. if (doc.Range.Bookmarks["COut"] != null)
  17228. {
  17229. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17230. Bookmark mark = doc.Range.Bookmarks["COut"];
  17231. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17232. }
  17233. //客户名称
  17234. if (doc.Range.Bookmarks["GName"] != null)
  17235. {
  17236. string guestName = "";
  17237. string[] clients = new string[] { };
  17238. if (hr.GuestName.Contains(","))
  17239. {
  17240. clients = hr.GuestName.Split(",");
  17241. }
  17242. else
  17243. {
  17244. clients = new string[] { hr.GuestName };
  17245. }
  17246. List<int> clientIds_int = new List<int>();
  17247. if (clients.Length > 0)
  17248. {
  17249. foreach (var item in clients)
  17250. {
  17251. if (item.IsNumeric())
  17252. {
  17253. clientIds_int.Add(int.Parse(item));
  17254. }
  17255. }
  17256. }
  17257. if (clientIds_int.Count > 0)
  17258. {
  17259. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  17260. foreach (var client in _clientDatas)
  17261. {
  17262. //男
  17263. if (client.Sex == 0) guestName += $"Mr.";
  17264. //女
  17265. else if (client.Sex == 1) guestName += $"Ms.";
  17266. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  17267. {
  17268. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  17269. }
  17270. //guestName += $"{client.Pinyin},";
  17271. }
  17272. if (guestName.Length > 0)
  17273. {
  17274. guestName = guestName.Substring(0, guestName.Length - 1);
  17275. }
  17276. }
  17277. else
  17278. {
  17279. guestName = hr.GuestName;
  17280. }
  17281. Bookmark mark = doc.Range.Bookmarks["GName"];
  17282. mark.Text = guestName;
  17283. }
  17284. //房间介绍
  17285. if (doc.Range.Bookmarks["ROOM"] != null)
  17286. {
  17287. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  17288. mark.Text = hr.RoomExplanation;
  17289. }
  17290. //报价描述
  17291. if (doc.Range.Bookmarks["NOTE"] != null)
  17292. {
  17293. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  17294. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  17295. if (ss != null)
  17296. mark.Text = ss.Name;
  17297. }
  17298. //入住时间
  17299. if (doc.Range.Bookmarks["CheckIn"] != null)
  17300. {
  17301. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17302. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  17303. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17304. }
  17305. //退房时间
  17306. if (doc.Range.Bookmarks["CheckOut"] != null)
  17307. {
  17308. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17309. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  17310. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17311. }
  17312. //日期
  17313. if (doc.Range.Bookmarks["DT"] != null)
  17314. {
  17315. Bookmark mark = doc.Range.Bookmarks["DT"];
  17316. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17317. }
  17318. //名称
  17319. if (doc.Range.Bookmarks["VName"] != null)
  17320. {
  17321. Bookmark mark = doc.Range.Bookmarks["VName"];
  17322. mark.Text = hr.HotelName;
  17323. }
  17324. //号码
  17325. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  17326. {
  17327. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  17328. mark.Text = hr.CheckNumber;
  17329. }
  17330. #endregion
  17331. strFileName += "VOUCHER.doc";
  17332. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17333. doc.Save(fileDir);
  17334. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17335. return Ok(JsonView(true, "操作成功!", Url));
  17336. }
  17337. else
  17338. {
  17339. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  17340. }
  17341. }
  17342. else
  17343. {
  17344. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  17345. }
  17346. }
  17347. catch (Exception ex)
  17348. {
  17349. return Ok(JsonView(false, ex.Message));
  17350. }
  17351. }
  17352. /// <summary>
  17353. /// 酒店预订
  17354. /// 生成VOUCHER
  17355. /// 2024.05.06 之后版本
  17356. /// </summary>
  17357. /// <param name="_dto"></param>
  17358. /// <returns></returns>
  17359. [HttpPost]
  17360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17361. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  17362. {
  17363. #region 参数验证
  17364. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17365. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17366. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17367. #region 团组操作权限验证 76 酒店预定模块
  17368. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17369. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17370. #endregion
  17371. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17372. #region 页面操作权限验证
  17373. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17374. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17375. #endregion
  17376. #endregion
  17377. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  17378. //判断数据是否完整
  17379. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17380. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17381. string strFileName = "HotelStatement/";
  17382. string guestNames = ""; //格式Mr.xxx Ms.xxx
  17383. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  17384. #region 数据处理
  17385. List<int> guestIds = new List<int>();
  17386. //int index = 0;
  17387. foreach (var item in hrDtas)
  17388. {
  17389. if (item.GuestName.Contains(","))
  17390. {
  17391. string[] guestIdArr = item.GuestName.Split(',');
  17392. foreach (var guestIdStr in guestIdArr)
  17393. {
  17394. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  17395. if (guestBool)
  17396. {
  17397. guestIds.Add(guestId);
  17398. }
  17399. }
  17400. }
  17401. else guestNames += item.GuestName;
  17402. var voucherInfo = new HotelVoucherInfoView()
  17403. {
  17404. HotelName = item.HotelName,
  17405. CheckInDate = item.CheckInDate,
  17406. CheckOutDate = item.CheckOutDate,
  17407. ConfirmationNumber = item.DetermineNo.Trim(),
  17408. RoomType = item.RoomExplanation
  17409. };
  17410. vouchers.Add(voucherInfo);
  17411. }
  17412. if (guestIds.Count > 0)
  17413. {
  17414. guestIds = guestIds.Distinct().ToList();
  17415. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  17416. if (guestDatas.Count > 0)
  17417. {
  17418. guestNames = "";
  17419. foreach (var guest in guestDatas)
  17420. {
  17421. string guestName = "";
  17422. if (guest.Sex == 0) guestName += @"MR.";
  17423. else if (guest.Sex == 1) guestName += @"MS.";
  17424. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17425. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17426. guestNames += @$"{guestName.Trim()}、";
  17427. }
  17428. if (guestNames.Length > 0)
  17429. {
  17430. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17431. }
  17432. }
  17433. }
  17434. #endregion
  17435. //载入模板
  17436. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  17437. Document doc = new Document(sss);
  17438. DocumentBuilder builder = new DocumentBuilder(doc);
  17439. if (doc.Range.Bookmarks["GuestName"] != null)
  17440. {
  17441. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  17442. mark.Text = guestNames;
  17443. }
  17444. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17445. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  17446. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  17447. for (int i = 1; i <= vouchers.Count; i++)
  17448. {
  17449. HotelVoucherInfoView hviv = vouchers[i - 1];
  17450. builder.MoveToCell(0, i, 0, 0);
  17451. builder.Write(hviv.HotelName);
  17452. builder.MoveToCell(0, i, 1, 0);
  17453. builder.Write(hviv.CheckInDate);
  17454. builder.MoveToCell(0, i, 2, 0);
  17455. builder.Write(hviv.CheckOutDate);
  17456. builder.MoveToCell(0, i, 3, 0);
  17457. builder.Write(hviv.RoomType);
  17458. builder.MoveToCell(0, i, 4, 0);
  17459. builder.Write(hviv.ConfirmationNumber);
  17460. }
  17461. //删除多余行
  17462. int currRowIndex = vouchers.Count + 1;
  17463. int delRows = 21 - currRowIndex;
  17464. if (delRows > 0)
  17465. {
  17466. for (int i = 0; i < delRows; i++)
  17467. {
  17468. table.Rows.RemoveAt(currRowIndex);
  17469. //cultivateRowIndex++;
  17470. }
  17471. }
  17472. strFileName += "VOUCHER.docx";
  17473. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17474. doc.Save(fileDir);
  17475. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17476. return Ok(JsonView(true, "操作成功!", Url));
  17477. }
  17478. /// <summary>
  17479. /// 酒店预订
  17480. /// 生成VOUCHER 批量生成
  17481. /// New
  17482. /// </summary>
  17483. /// <param name="_dto"></param>
  17484. /// <returns></returns>
  17485. [HttpPost]
  17486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17487. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  17488. {
  17489. #region 参数验证
  17490. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17491. if (_dto.PageId < 1) _dto.PageId = 28;
  17492. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17493. #region 团组操作权限验证 76 酒店预定模块
  17494. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17495. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17496. #endregion
  17497. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17498. #region 页面操作权限验证
  17499. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17500. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17501. #endregion
  17502. #endregion
  17503. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  17504. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  17505. .OrderBy(x => x.CheckInDate)
  17506. .ToListAsync();
  17507. //判断数据是否完整
  17508. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17509. string strFileName = "HotelStatement/";
  17510. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17511. if (dele != null)
  17512. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  17513. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  17514. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  17515. .Where(it => it.IsDel == 0)
  17516. .ToListAsync();
  17517. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  17518. for (int i = 0; i < hrDtas.Count; i++)
  17519. {
  17520. string guestNames = string.Empty;
  17521. List<int> guestIds = new List<int>();
  17522. var item = hrDtas[i];
  17523. //处理客户姓名
  17524. if (item.GuestName.Contains(","))
  17525. {
  17526. string[] guestIdArr = item.GuestName.Split(',');
  17527. foreach (var guestIdStr in guestIdArr)
  17528. if (int.TryParse(guestIdStr, out int guestId))
  17529. guestIds.Add(guestId);
  17530. }
  17531. else
  17532. {
  17533. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  17534. if (guestIdBool)
  17535. {
  17536. guestIds.Add(guestId);
  17537. }
  17538. //NaN
  17539. if (item.GuestName.Contains("NaN"))
  17540. {
  17541. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  17542. }
  17543. }
  17544. if (guestIds.Count > 0)
  17545. {
  17546. guestIds = guestIds.Distinct().ToList();
  17547. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  17548. if (guestDatas1.Count > 0)
  17549. {
  17550. guestNames = "";
  17551. foreach (var guest in guestDatas1)
  17552. {
  17553. string guestName = "";
  17554. if (guest.Sex == 0) guestName += @"MR.";
  17555. else if (guest.Sex == 1) guestName += @"MS.";
  17556. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17557. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17558. guestNames += @$"{guestName.Trim()}、";
  17559. }
  17560. if (guestNames.Length > 0)
  17561. {
  17562. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17563. }
  17564. }
  17565. }
  17566. //if (!string.IsNullOrEmpty(guestNames))
  17567. //{
  17568. hrDtas[i].GuestName = guestNames;
  17569. //}
  17570. }
  17571. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  17572. Document doc = new Document();
  17573. DocumentBuilder builder = new DocumentBuilder(doc);
  17574. try
  17575. {
  17576. builder.MoveToDocumentStart();
  17577. foreach (var item in hrDtas)
  17578. {
  17579. //标题
  17580. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17581. builder.ParagraphFormat.LineSpacing = 1;
  17582. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17583. builder.ParagraphFormat.Style.Font.Size = 9;
  17584. builder.ParagraphFormat.Style.Font.Bold = true;
  17585. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17586. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  17587. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17588. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17589. builder.ParagraphFormat.LineSpacing = 1;
  17590. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17591. builder.ParagraphFormat.Style.Font.Size = 9;
  17592. builder.ParagraphFormat.Style.Font.Bold = true;
  17593. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  17594. builder.StartTable();
  17595. // 设置边框颜色
  17596. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  17597. //设置边框样式
  17598. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  17599. //表格
  17600. #region 第一行
  17601. builder.InsertCell();
  17602. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17603. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17604. //builder.CellFormat.AllowAutoFit = false;
  17605. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17606. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17607. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17608. builder.CellFormat.WrapText = true; //自动换行
  17609. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17610. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  17611. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17612. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17613. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17614. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17615. builder.Write("TOUR NO:");
  17616. builder.InsertCell();
  17617. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17618. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17619. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17620. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17621. builder.ParagraphFormat.Style.Font.Bold = false;
  17622. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17623. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17624. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17625. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17626. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17627. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17628. builder.Write($"{dele?.TourCode ?? "-"}");
  17629. builder.InsertCell();
  17630. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17631. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17632. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17633. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17634. builder.ParagraphFormat.Style.Font.Bold = false;
  17635. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17636. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17637. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17638. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17639. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17640. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17641. builder.Write($"CITY:");
  17642. builder.InsertCell();
  17643. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17644. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17645. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17646. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17647. builder.ParagraphFormat.Style.Font.Bold = false;
  17648. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17649. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17650. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17651. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17652. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17653. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17654. builder.Write($"{item.City}");
  17655. builder.EndRow();
  17656. #endregion
  17657. #region 第二行
  17658. builder.InsertCell();
  17659. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17660. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17661. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17662. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17663. builder.ParagraphFormat.Style.Font.Bold = false;
  17664. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17665. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17666. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17667. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17668. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17669. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17670. builder.Write("CONFIRMATION NO:");
  17671. builder.InsertCell();
  17672. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17673. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17674. builder.ParagraphFormat.Style.Font.Size = 8;
  17675. builder.ParagraphFormat.Style.Font.Bold = false;
  17676. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17677. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17678. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17679. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17680. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17681. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17682. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17683. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17684. builder.Write($"{item.DetermineNo}");
  17685. builder.InsertCell();
  17686. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17687. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17688. builder.InsertCell();
  17689. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17690. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17691. builder.EndRow();
  17692. #endregion
  17693. #region 第三行
  17694. builder.InsertCell();
  17695. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17696. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17697. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17698. builder.ParagraphFormat.Style.Font.Bold = false;
  17699. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17700. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17701. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17702. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17703. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17704. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17705. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17706. builder.Write($"HOTEL NAME:");
  17707. builder.InsertCell();
  17708. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17709. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17710. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17711. builder.ParagraphFormat.Style.Font.Bold = false;
  17712. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17713. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17714. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17715. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17716. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17717. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17718. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17719. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17720. builder.Write($"{item.HotelName}");
  17721. builder.InsertCell();
  17722. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17723. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17724. builder.InsertCell();
  17725. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17726. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17727. builder.EndRow();
  17728. #endregion
  17729. #region 第四行
  17730. builder.InsertCell();
  17731. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17732. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17733. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17734. builder.ParagraphFormat.Style.Font.Bold = false;
  17735. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17736. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17737. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17738. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17739. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17740. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17741. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17742. builder.Write($"HOTEL ADDRESS:");
  17743. builder.InsertCell();
  17744. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17745. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17746. builder.ParagraphFormat.Style.Font.Size = 8;
  17747. builder.ParagraphFormat.Style.Font.Bold = false;
  17748. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17749. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17750. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17751. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17752. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17753. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17754. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17755. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17756. builder.Write($"{item.HotelAddress}");
  17757. builder.InsertCell();
  17758. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17759. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17760. builder.InsertCell();
  17761. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17762. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17763. builder.EndRow();
  17764. #endregion
  17765. #region 第五行
  17766. builder.InsertCell();
  17767. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17768. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17769. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17770. builder.ParagraphFormat.Style.Font.Bold = false;
  17771. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17772. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17773. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17774. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17775. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17776. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17777. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17778. builder.Write("TEL:");
  17779. builder.InsertCell();
  17780. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17781. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17782. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17783. builder.ParagraphFormat.Style.Font.Bold = false;
  17784. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17785. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17786. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17787. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17788. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17789. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17790. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17791. builder.Write($"{item.HotelTel}");
  17792. builder.InsertCell();
  17793. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17794. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17795. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17796. builder.ParagraphFormat.Style.Font.Bold = false;
  17797. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17798. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17799. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17800. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17801. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17802. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17803. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17804. builder.Write($"FAX:");
  17805. builder.InsertCell();
  17806. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  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.Left;//对齐
  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($"{item.HotelFax}");
  17818. builder.EndRow();
  17819. #endregion
  17820. #region 第六行
  17821. builder.InsertCell();
  17822. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17823. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17824. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17825. builder.ParagraphFormat.Style.Font.Bold = false;
  17826. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17827. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17828. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17829. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17830. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17831. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17832. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17833. builder.Write("CHECK IN:");
  17834. builder.InsertCell();
  17835. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17836. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17837. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17838. builder.ParagraphFormat.Style.Font.Bold = false;
  17839. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17840. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17841. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17842. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17843. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17844. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17845. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17846. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  17847. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17848. builder.Write($"{checkInStr}");
  17849. builder.InsertCell();
  17850. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17851. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17852. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17853. builder.ParagraphFormat.Style.Font.Bold = false;
  17854. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17855. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17856. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  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.Write($"CHECK OUT:");
  17862. builder.InsertCell();
  17863. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17864. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17865. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17866. builder.ParagraphFormat.Style.Font.Bold = false;
  17867. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17868. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17869. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17870. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17871. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17872. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17873. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17874. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  17875. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  17876. builder.Write($"{checkOutStr}");
  17877. builder.EndRow();
  17878. #endregion
  17879. #region 第七行
  17880. builder.InsertCell();
  17881. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17882. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17883. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17884. builder.ParagraphFormat.Style.Font.Bold = false;
  17885. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17886. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17887. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17888. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17889. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17890. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17891. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17892. builder.Write($"GUEST NAME:");
  17893. builder.InsertCell();
  17894. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17895. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17896. builder.ParagraphFormat.Style.Font.Size = 8;
  17897. builder.ParagraphFormat.Style.Font.Bold = false;
  17898. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17899. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17900. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17901. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17902. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17903. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17904. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17905. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17906. builder.Write($"{item.GuestName.Trim()}");
  17907. builder.InsertCell();
  17908. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17909. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17910. builder.InsertCell();
  17911. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17912. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17913. builder.EndRow();
  17914. #endregion
  17915. #region 第八行
  17916. builder.InsertCell();
  17917. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17918. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17919. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17920. builder.ParagraphFormat.Style.Font.Bold = false;
  17921. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17922. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17923. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17924. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17925. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17926. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17927. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17928. builder.Write($"ROOM TYPE:");
  17929. builder.InsertCell();
  17930. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17931. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17932. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17933. builder.ParagraphFormat.Style.Font.Bold = false;
  17934. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17935. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17936. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17937. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17938. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17939. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17940. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17941. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17942. builder.Write($"{item.RoomExplanation}");
  17943. builder.InsertCell();
  17944. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17945. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17946. builder.InsertCell();
  17947. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17948. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17949. builder.EndRow();
  17950. #endregion
  17951. #region 第九行
  17952. builder.InsertCell();
  17953. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17954. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17955. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17956. builder.ParagraphFormat.Style.Font.Bold = false;
  17957. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17958. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17959. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17960. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17961. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17962. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17963. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17964. builder.Write($"NOTE:");
  17965. builder.InsertCell();
  17966. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17967. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17968. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17969. builder.ParagraphFormat.Style.Font.Bold = false;
  17970. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17971. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17972. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17973. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17974. 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.");
  17975. builder.InsertCell();
  17976. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17977. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17978. builder.InsertCell();
  17979. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17980. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17981. builder.EndRow();
  17982. #endregion
  17983. builder.EndTable();
  17984. //换行
  17985. builder.Writeln("");
  17986. builder.Writeln("");
  17987. }
  17988. #region 获取文档中的所有表格 设置文字自适应
  17989. // 获取文档中的所有表格。
  17990. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  17991. {
  17992. // 遍历表格中的所有行。
  17993. foreach (Aspose.Words.Tables.Row row in table.Rows)
  17994. {
  17995. foreach (Cell cell in row.Cells)
  17996. {
  17997. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  17998. cellFormat.Width = 0;
  17999. }
  18000. }
  18001. }
  18002. #endregion
  18003. #region 设置页眉
  18004. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  18005. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  18006. if (System.IO.File.Exists(voucherHeaderPath))
  18007. {
  18008. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  18009. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  18010. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  18011. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  18012. // 调整图片位置
  18013. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  18014. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  18015. shape.Top = 50; // 将图片距离页眉上边缘的距离
  18016. shape.Left = 0; // 将图片距离页面左边缘的距离
  18017. shape.Width = 81; // 设置图片宽度
  18018. shape.Height = 36; // 设置图片高度
  18019. }
  18020. //靠右
  18021. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  18022. //// 设置页脚上下边距
  18023. //builder.PageSetup.HeaderDistance = 42;
  18024. // 添加页眉线
  18025. Aspose.Words.Border borderHeader = null;
  18026. try
  18027. {
  18028. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  18029. }
  18030. catch (Exception e)
  18031. {
  18032. // TODO Auto-generated catch block
  18033. //e.printStackTrace();
  18034. }
  18035. borderHeader.Shadow = true;
  18036. borderHeader.DistanceFromText = 2;
  18037. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  18038. #endregion
  18039. }
  18040. catch (Exception ex)
  18041. {
  18042. }
  18043. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18044. doc.Save(fileDir);
  18045. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18046. return Ok(JsonView(true, "操作成功!", Url));
  18047. }
  18048. /// <summary>
  18049. /// 酒店预订
  18050. /// 生成 预定成本 Excel
  18051. /// </summary>
  18052. /// <param name="_dto"></param>
  18053. /// <returns></returns>
  18054. [HttpPost]
  18055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18056. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  18057. {
  18058. #region 参数验证
  18059. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  18060. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  18061. if (!vadalitorRes.IsValid)
  18062. {
  18063. var errors = new StringBuilder();
  18064. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  18065. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  18066. }
  18067. #region 团组操作权限验证 76 酒店预定模块
  18068. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18069. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18070. #endregion
  18071. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18072. #region 页面操作权限验证
  18073. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18074. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18075. #endregion
  18076. #endregion
  18077. decimal _rate = 1.00M;
  18078. string _currency = string.Empty;
  18079. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  18080. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18081. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  18082. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18083. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  18084. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  18085. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  18086. if (_GroupCostParameter == null)
  18087. {
  18088. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  18089. bool isIntType = int.TryParse(_currency, out int currId);
  18090. if (isIntType)
  18091. {
  18092. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18093. }
  18094. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18095. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18096. if (currInfo == null)
  18097. {
  18098. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18099. }
  18100. else _rate = currInfo.Rate;
  18101. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  18102. {
  18103. _rate = _GroupCostParameter.Rate;
  18104. }
  18105. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18106. //string strFileName = "HotelStatement/";
  18107. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18108. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18109. var rateDatas = new List<dynamic>();
  18110. #region 数据处理
  18111. foreach (var item in hrDtas)
  18112. {
  18113. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18114. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18115. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18116. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18117. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18118. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  18119. {
  18120. continue;
  18121. }
  18122. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18123. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  18124. string singleRoomFeeStr = string.Empty,
  18125. doubleRoomFeeStr = string.Empty,
  18126. suiteRoomFeeStr = string.Empty,
  18127. otherRoomFeeStr = string.Empty,
  18128. payMoneyStr = string.Empty,
  18129. cardPriceStr = string.Empty;
  18130. if (roomCurr.Equals("CNY"))
  18131. {
  18132. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  18133. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18134. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18135. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18136. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18137. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  18138. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  18139. }
  18140. else
  18141. {
  18142. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18143. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18144. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18145. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18146. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18147. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18148. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18149. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18150. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18151. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18152. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  18153. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  18154. if (ccpPaymentCurrency.Equals("CNY"))
  18155. {
  18156. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  18157. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18158. }
  18159. else
  18160. {
  18161. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  18162. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  18163. }
  18164. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  18165. if (hotelcardPriceCurrency.Equals("CNY"))
  18166. {
  18167. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18168. }
  18169. else
  18170. {
  18171. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  18172. }
  18173. }
  18174. string breakfastPriceStr = string.Empty,
  18175. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18176. governmentRentStr = string.Empty,
  18177. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18178. cityTaxStr = string.Empty,
  18179. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18180. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  18181. if (!string.IsNullOrEmpty(breakfastCurrency1))
  18182. {
  18183. if (breakfastCurrency1.Equals("CNY"))
  18184. {
  18185. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18186. }
  18187. else
  18188. {
  18189. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  18190. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  18191. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  18192. }
  18193. }
  18194. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18195. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  18196. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  18197. {
  18198. if (governmentRentCurrency.Equals("CNY"))
  18199. {
  18200. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18201. }
  18202. else
  18203. {
  18204. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  18205. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  18206. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  18207. }
  18208. }
  18209. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18210. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  18211. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  18212. {
  18213. if (cityTaxStrCurrency1.Equals("CNY"))
  18214. {
  18215. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18216. }
  18217. else
  18218. {
  18219. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  18220. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  18221. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  18222. }
  18223. }
  18224. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18225. int payDId = roomInfo?.PayDId ?? 0;
  18226. pcfds.Add(new HotelReservations_PCFD_View()
  18227. {
  18228. City = item.City,
  18229. HotelName = item.HotelName,
  18230. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18231. // SingleRoomCount = item.SingleRoomCount,
  18232. SingleRoomPrice = singleRoomFeeStr,
  18233. // DoubleRoomCount = item.DoubleRoomCount,
  18234. DoubleRoomPrice = doubleRoomFeeStr,
  18235. //SuiteRoomCount = item.SuiteRoomCount,
  18236. SuiteRoomPrice = suiteRoomFeeStr,
  18237. OtherRoomPrice = otherRoomFeeStr,
  18238. //OtherRoomCount = item.OtherRoomCount,
  18239. BreakfastPrice = breakfastPriceStr,
  18240. GovernmentRent = governmentRentStr,
  18241. CityTax = cityTaxStr,
  18242. RoomExplanation = item.RoomExplanation,
  18243. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18244. PayTime = roomInfo?.ConsumptionDate,
  18245. BankNo = roomInfo?.BankNo,
  18246. PayMoney = payMoneyStr,
  18247. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18248. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18249. CardPrice = cardPriceStr,
  18250. Remark = ccpInfo.Remark
  18251. });
  18252. }
  18253. #endregion
  18254. //载入模板
  18255. WorkbookDesigner designer = new WorkbookDesigner();
  18256. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18257. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18258. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18259. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18260. var rateDatas1 = rateDatas.Distinct();
  18261. var rateStr = string.Empty;
  18262. foreach (var item in rateDatas1)
  18263. {
  18264. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  18265. }
  18266. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  18267. designer.SetDataSource("Opertor", userInfo.CnName);
  18268. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18269. dt.TableName = "ViewMyHotelReservations";
  18270. designer.SetDataSource(dt);
  18271. designer.Process();
  18272. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18273. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18274. designer.Workbook.Save(serverPath);
  18275. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18276. #region 删除指定行
  18277. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18278. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18279. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18280. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18281. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18282. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18283. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18284. cssIndex = dt.Columns["CityTax"].Ordinal,
  18285. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18286. remarkIndex = dt.Columns["Remark"].Ordinal;
  18287. //删除指定列
  18288. foreach (DataRow item in dt.Rows)
  18289. {
  18290. string singleStr = item["SingleRoomPrice"].ToString();
  18291. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18292. if (containsDigitButNotZero1) singleDel = false;
  18293. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18294. string doubleStr = item["DoubleRoomPrice"].ToString();
  18295. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18296. if (containsDigitButNotZero2) doubleDel = false;
  18297. string suiteStr = item["SuiteRoomPrice"].ToString();
  18298. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18299. if (containsDigitButNotZero3) suiteDel = false;
  18300. string otherStr = item["OtherRoomPrice"].ToString();
  18301. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18302. if (containsDigitButNotZero4) otherDel = false;
  18303. string zcStr = item["BreakfastPrice"].ToString();
  18304. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18305. if (containsDigitButNotZero5) zcDel = false;
  18306. string dsStr = item["GovernmentRent"].ToString();
  18307. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18308. if (containsDigitButNotZero6) dsDel = false;
  18309. string cssStr = item["CityTax"].ToString();
  18310. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18311. if (containsDigitButNotZero7) cssDel = false;
  18312. string cpStr = item["ConsumptionPatterns"].ToString();
  18313. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18314. string remarkStr = item["Remark"].ToString();
  18315. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18316. }
  18317. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18318. DeleteColumn(serverPath, cpIndex, cpDel);
  18319. DeleteColumn(serverPath, dsIndex, dsDel);
  18320. DeleteColumn(serverPath, cssIndex, cssDel);
  18321. DeleteColumn(serverPath, zcIndex, zcDel);
  18322. DeleteColumn(serverPath, otherIndex, otherDel);
  18323. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18324. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18325. DeleteColumn(serverPath, singleIndex, singleDel);
  18326. #endregion
  18327. //只保留第一个表格
  18328. DeleteSheet(serverPath);
  18329. return Ok(JsonView(true, "操作成功", url = rst));
  18330. }
  18331. else
  18332. {
  18333. _currency = _GroupCostParameter.Currency;
  18334. bool isIntType = int.TryParse(_currency, out int currId);
  18335. if (isIntType)
  18336. {
  18337. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18338. }
  18339. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18340. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18341. if (currInfo == null)
  18342. {
  18343. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18344. }
  18345. if (!_currency.ToUpper().Equals("CNY"))
  18346. {
  18347. _rate = _GroupCostParameter.Rate;
  18348. }
  18349. _rate = currInfo.Rate;
  18350. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18351. //string strFileName = "HotelStatement/";
  18352. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18353. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18354. #region 数据处理
  18355. foreach (var item in hrDtas)
  18356. {
  18357. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18358. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18359. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18360. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18361. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18362. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18363. string singleRoomFeeStr = string.Empty,
  18364. doubleRoomFeeStr = string.Empty,
  18365. suiteRoomFeeStr = string.Empty,
  18366. otherRoomFeeStr = string.Empty,
  18367. payMoneyStr = string.Empty,
  18368. cardPriceStr = string.Empty;
  18369. if (roomCurr.Equals(_currency))
  18370. {
  18371. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  18372. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  18373. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  18374. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  18375. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  18376. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  18377. }
  18378. else
  18379. {
  18380. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18381. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18382. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18383. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18384. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18385. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18386. }
  18387. string breakfastPriceStr = string.Empty,
  18388. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18389. governmentRentStr = string.Empty,
  18390. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18391. cityTaxStrStr = string.Empty,
  18392. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18393. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  18394. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  18395. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  18396. int payDId = roomInfo?.PayDId ?? 0;
  18397. pcfds.Add(new HotelReservations_PCFD_View()
  18398. {
  18399. City = item.City,
  18400. HotelName = item.HotelName,
  18401. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18402. // SingleRoomCount = item.SingleRoomCount,
  18403. SingleRoomPrice = singleRoomFeeStr,
  18404. // DoubleRoomCount = item.DoubleRoomCount,
  18405. DoubleRoomPrice = doubleRoomFeeStr,
  18406. //SuiteRoomCount = item.SuiteRoomCount,
  18407. SuiteRoomPrice = suiteRoomFeeStr,
  18408. OtherRoomPrice = otherRoomFeeStr,
  18409. //OtherRoomCount = item.OtherRoomCount,
  18410. BreakfastPrice = breakfastPriceStr,
  18411. GovernmentRent = governmentRentStr,
  18412. CityTax = cityTaxStrStr,
  18413. RoomExplanation = item.RoomExplanation,
  18414. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18415. PayTime = roomInfo?.ConsumptionDate,
  18416. BankNo = roomInfo?.BankNo,
  18417. PayMoney = payMoneyStr,
  18418. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18419. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18420. CardPrice = cardPriceStr,
  18421. Remark = ccpInfo.Remark
  18422. });
  18423. }
  18424. #endregion
  18425. //载入模板
  18426. WorkbookDesigner designer = new WorkbookDesigner();
  18427. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18428. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18429. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18430. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18431. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  18432. designer.SetDataSource("Opertor", userInfo.CnName);
  18433. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18434. dt.TableName = "ViewMyHotelReservations";
  18435. designer.SetDataSource(dt);
  18436. designer.Process();
  18437. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18438. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18439. designer.Workbook.Save(serverPath);
  18440. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18441. #region 删除指定行
  18442. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18443. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18444. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18445. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18446. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18447. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18448. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18449. cssIndex = dt.Columns["CityTax"].Ordinal,
  18450. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18451. remarkIndex = dt.Columns["Remark"].Ordinal;
  18452. //删除指定列
  18453. foreach (DataRow item in dt.Rows)
  18454. {
  18455. string singleStr = item["SingleRoomPrice"].ToString();
  18456. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18457. if (containsDigitButNotZero1) singleDel = false;
  18458. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18459. string doubleStr = item["DoubleRoomPrice"].ToString();
  18460. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18461. if (containsDigitButNotZero2) doubleDel = false;
  18462. string suiteStr = item["SuiteRoomPrice"].ToString();
  18463. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18464. if (containsDigitButNotZero3) suiteDel = false;
  18465. string otherStr = item["OtherRoomPrice"].ToString();
  18466. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18467. if (containsDigitButNotZero4) otherDel = false;
  18468. string zcStr = item["BreakfastPrice"].ToString();
  18469. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18470. if (containsDigitButNotZero5) zcDel = false;
  18471. string dsStr = item["GovernmentRent"].ToString();
  18472. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18473. if (containsDigitButNotZero6) dsDel = false;
  18474. string cssStr = item["CityTax"].ToString();
  18475. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18476. if (containsDigitButNotZero7) cssDel = false;
  18477. string cpStr = item["ConsumptionPatterns"].ToString();
  18478. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18479. string remarkStr = item["Remark"].ToString();
  18480. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18481. }
  18482. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18483. DeleteColumn(serverPath, cpIndex, cpDel);
  18484. DeleteColumn(serverPath, dsIndex, dsDel);
  18485. DeleteColumn(serverPath, cssIndex, cssDel);
  18486. DeleteColumn(serverPath, zcIndex, zcDel);
  18487. DeleteColumn(serverPath, otherIndex, otherDel);
  18488. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18489. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18490. DeleteColumn(serverPath, singleIndex, singleDel);
  18491. #endregion
  18492. //只保留第一个表格
  18493. DeleteSheet(serverPath);
  18494. return Ok(JsonView(true, "操作成功", url = rst));
  18495. }
  18496. //return Ok(JsonView(false));
  18497. }
  18498. /// <summary>
  18499. /// 删除指定列
  18500. /// </summary>
  18501. /// <param name="file"></param>
  18502. /// <param name="columnIndex"></param>
  18503. /// <param name="isDel"></param>
  18504. private void DeleteColumn(string file, int columnIndex, bool isDel)
  18505. {
  18506. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18507. //wb.Save(file);
  18508. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  18509. if (sheet1 != null)
  18510. {
  18511. if (isDel)
  18512. {
  18513. Cells cells = sheet1.Cells;
  18514. cells.DeleteColumn(columnIndex);
  18515. }
  18516. }
  18517. wb.Save(file);
  18518. }
  18519. /// <summary>
  18520. /// 删除sheet
  18521. /// </summary>
  18522. /// <param name="file"></param>
  18523. /// <param name="sheetName"></param>
  18524. private void DeleteSheet(string file, string sheetName = "")
  18525. {
  18526. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18527. //wb.Save(file);
  18528. List<string> sheets = new List<string>();
  18529. foreach (var item in wb.Worksheets)
  18530. {
  18531. sheets.Add(item.Name);
  18532. }
  18533. if (sheets.Count > 0)
  18534. {
  18535. sheets.RemoveAt(0);//不删除第一个sheet
  18536. foreach (var item in sheets)
  18537. {
  18538. wb.Worksheets.RemoveAt(item);
  18539. }
  18540. }
  18541. wb.Save(file);
  18542. }
  18543. /// <summary>
  18544. /// 酒店预订
  18545. /// 确认单
  18546. /// </summary>
  18547. /// <param name="_dto"></param>
  18548. /// <returns></returns>
  18549. [HttpPost]
  18550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18551. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  18552. {
  18553. try
  18554. {
  18555. #region 参数验证
  18556. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18557. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18558. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18559. #region 团组操作权限验证 76 酒店预定模块
  18560. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18561. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18562. #endregion
  18563. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18564. #region 页面操作权限验证
  18565. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18566. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18567. #endregion
  18568. #endregion
  18569. //团组信息
  18570. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  18571. //酒店数据
  18572. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  18573. if (listhoteldata.Count < 0)
  18574. {
  18575. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  18576. }
  18577. //利datatable存储
  18578. DataTable dt = new DataTable();
  18579. dt.Columns.Add("CheckInDate", typeof(string));
  18580. dt.Columns.Add("City", typeof(string));
  18581. dt.Columns.Add("Hotel", typeof(string));
  18582. dt.Columns.Add("Room", typeof(string));
  18583. for (int i = 0; i < listhoteldata.Count; i++)
  18584. {
  18585. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  18586. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  18587. while (dayStart < dayEnd)
  18588. {
  18589. string temp = "";
  18590. DataRow row = dt.NewRow();
  18591. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  18592. row["City"] = listhoteldata[i].City;
  18593. row["Hotel"] = listhoteldata[i].HotelName;
  18594. if (listhoteldata[i].SingleRoomCount > 0)
  18595. {
  18596. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  18597. }
  18598. if (listhoteldata[i].DoubleRoomCount > 0)
  18599. {
  18600. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  18601. }
  18602. if (listhoteldata[i].SuiteRoomCount > 0)
  18603. {
  18604. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  18605. }
  18606. if (listhoteldata[i].OtherRoomCount > 0)
  18607. {
  18608. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  18609. }
  18610. row["Room"] = temp;
  18611. dt.Rows.Add(row);
  18612. dayStart = dayStart.AddDays(1);
  18613. }
  18614. }
  18615. Dictionary<string, string> dic = new Dictionary<string, string>();
  18616. dic.Add("Dele", di.TeamName);
  18617. dic.Add("City", di.VisitCountry);
  18618. //模板路径
  18619. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  18620. //载入模板
  18621. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  18622. DocumentBuilder builder = new DocumentBuilder(doc);
  18623. foreach (var key in dic.Keys)
  18624. {
  18625. builder.MoveToBookmark(key);
  18626. builder.Write(dic[key]);
  18627. }
  18628. //获取word里所有表格
  18629. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18630. //获取所填表格的序数
  18631. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18632. var rowStart = tableOne.Rows[0]; //获取第1行
  18633. //循环赋值
  18634. for (int i = 0; i < dt.Rows.Count; i++)
  18635. {
  18636. builder.MoveToCell(0, i + 1, 0, 0);
  18637. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  18638. builder.MoveToCell(0, i + 1, 1, 0);
  18639. builder.Write(dt.Rows[i]["City"].ToString());
  18640. builder.MoveToCell(0, i + 1, 2, 0);
  18641. builder.Write(dt.Rows[i]["Hotel"].ToString());
  18642. builder.MoveToCell(0, i + 1, 3, 0);
  18643. builder.Write(dt.Rows[i]["Room"].ToString());
  18644. }
  18645. //删除多余行
  18646. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  18647. {
  18648. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  18649. }
  18650. string strFileName = di.TeamName + "酒店确认单.doc";
  18651. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  18652. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  18653. return Ok(JsonView(true, "成功", url));
  18654. }
  18655. catch (Exception ex)
  18656. {
  18657. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  18658. }
  18659. }
  18660. #endregion
  18661. #region 团组状态
  18662. /// <summary>
  18663. /// 团组状态列表 Page
  18664. /// </summary>
  18665. /// <param name="dto">团组列表请求dto</param>
  18666. /// <returns></returns>
  18667. [HttpPost]
  18668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18669. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  18670. {
  18671. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18672. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  18673. {
  18674. string sqlWhere = string.Empty;
  18675. if (dto.IsSure == 0) //未完成
  18676. {
  18677. sqlWhere += string.Format(@" And IsSure = 0");
  18678. }
  18679. else if (dto.IsSure == 1) //已完成
  18680. {
  18681. sqlWhere += string.Format(@" And IsSure = 1");
  18682. }
  18683. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  18684. {
  18685. string tj = dto.SearchCriteria;
  18686. 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}%')",
  18687. tj, tj, tj, tj, tj);
  18688. }
  18689. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  18690. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  18691. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  18692. From (
  18693. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  18694. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  18695. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  18696. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  18697. From Grp_DelegationInfo gdi
  18698. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  18699. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  18700. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  18701. Where gdi.IsDel = 0 {0}
  18702. ) temp ", sqlWhere);
  18703. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  18704. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  18705. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  18706. }
  18707. else
  18708. {
  18709. return Ok(JsonView(false, "查询失败"));
  18710. }
  18711. }
  18712. /// <summary>
  18713. /// 团组状态
  18714. /// 设置操作完成
  18715. /// </summary>
  18716. /// <param name="dto">团组列表请求dto</param>
  18717. /// <returns></returns>
  18718. [HttpPost]
  18719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18720. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  18721. {
  18722. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18723. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  18724. {
  18725. Id = dto.Id,
  18726. IsSure = 1
  18727. };
  18728. var result = await _sqlSugar.Updateable(_DelegationInfo)
  18729. .UpdateColumns(it => new { it.IsSure })
  18730. .WhereColumns(it => new { it.Id })
  18731. .ExecuteCommandAsync();
  18732. if (result > 0)
  18733. {
  18734. return Ok(JsonView(true, "操作完成!"));
  18735. }
  18736. return Ok(JsonView(false, "操作失败!"));
  18737. }
  18738. #endregion
  18739. #region 保险费用录入
  18740. /// <summary>
  18741. /// 根据团组Id查询保险费用列表
  18742. /// </summary>
  18743. /// <param name="dto"></param>
  18744. /// <returns></returns>
  18745. [HttpPost]
  18746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18747. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  18748. {
  18749. Result groupData = await _customersRep.CustomersByDiId(dto);
  18750. if (groupData.Code != 0)
  18751. {
  18752. return Ok(JsonView(false, groupData.Msg));
  18753. }
  18754. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18755. }
  18756. /// <summary>
  18757. /// 根据保险费用Id查询保险费用详细
  18758. /// </summary>
  18759. /// <param name="dto"></param>
  18760. /// <returns></returns>
  18761. [HttpPost]
  18762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18763. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  18764. {
  18765. try
  18766. {
  18767. Result groupData = await _customersRep.CustomersById(dto);
  18768. if (groupData.Code != 0)
  18769. {
  18770. return Ok(JsonView(false, groupData.Msg));
  18771. }
  18772. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18773. }
  18774. catch (Exception ex)
  18775. {
  18776. return Ok(JsonView(false, ex.Message));
  18777. }
  18778. }
  18779. /// <summary>
  18780. /// 保险费用录入页面初始化绑定
  18781. /// </summary>
  18782. /// <param name="dto"></param>
  18783. /// <returns></returns>
  18784. [HttpPost]
  18785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18786. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  18787. {
  18788. try
  18789. {
  18790. Result groupData = await _customersRep.CustomersInitialize(dto);
  18791. if (groupData.Code != 0)
  18792. {
  18793. return Ok(JsonView(false, groupData.Msg));
  18794. }
  18795. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18796. }
  18797. catch (Exception ex)
  18798. {
  18799. return Ok(JsonView(false, ex.Message));
  18800. }
  18801. }
  18802. /// <summary>
  18803. /// 保险费用操作(Status:1.新增,2.修改)
  18804. /// </summary>
  18805. /// <param name="dto"></param>
  18806. /// <returns></returns>
  18807. [HttpPost]
  18808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18809. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  18810. {
  18811. Result groupData = await _customersRep.OpCustomers(dto);
  18812. if (groupData.Code != 0)
  18813. {
  18814. return Ok(JsonView(false, groupData.Msg));
  18815. }
  18816. #region 应用推送
  18817. try
  18818. {
  18819. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  18820. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  18821. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  18822. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  18823. //自动审核
  18824. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  18825. //2024-10-21 新增LZ UID
  18826. var userIds = new List<int>() { 21 };
  18827. string title = $"系统通知";
  18828. var diId = dto.DiId;
  18829. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18830. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18831. string content = "";
  18832. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18833. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18834. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18835. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  18836. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  18837. }
  18838. catch (Exception ex)
  18839. {
  18840. }
  18841. #endregion
  18842. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18843. }
  18844. /// <summary>
  18845. /// 保险文件上传
  18846. /// </summary>
  18847. /// <param name="file"></param>
  18848. /// <returns></returns>
  18849. [HttpPost]
  18850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18851. public async Task<IActionResult> UploadCus(IFormFile file)
  18852. {
  18853. try
  18854. {
  18855. if (file != null)
  18856. {
  18857. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18858. //文件名称
  18859. string projectFileName = file.FileName;
  18860. //上传的文件的路径
  18861. string filePath = "";
  18862. if (!Directory.Exists(fileDir))
  18863. {
  18864. Directory.CreateDirectory(fileDir);
  18865. }
  18866. //上传的文件的路径
  18867. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  18868. using (FileStream fs = System.IO.File.Create(filePath))
  18869. {
  18870. file.CopyTo(fs);
  18871. fs.Flush();
  18872. }
  18873. return Ok(JsonView(true, "上传成功!", projectFileName));
  18874. }
  18875. else
  18876. {
  18877. return Ok(JsonView(false, "上传失败!"));
  18878. }
  18879. }
  18880. catch (Exception ex)
  18881. {
  18882. return Ok(JsonView(false, "程序错误!"));
  18883. throw;
  18884. }
  18885. }
  18886. /// <summary>
  18887. /// 保险删除指定文件
  18888. /// </summary>
  18889. /// <param name="dto"></param>
  18890. /// <returns></returns>
  18891. [HttpPost]
  18892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18893. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  18894. {
  18895. try
  18896. {
  18897. string filePath = "";
  18898. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18899. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  18900. //int id = 0;
  18901. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  18902. // 删除该文件
  18903. try
  18904. {
  18905. System.IO.File.Delete(filePath);
  18906. 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()
  18907. {
  18908. Attachment = "",
  18909. }).ExecuteCommandAsync();
  18910. if (result != 0)
  18911. {
  18912. return Ok(JsonView(true, "成功!"));
  18913. }
  18914. else
  18915. {
  18916. return Ok(JsonView(false, "失败!"));
  18917. }
  18918. }
  18919. catch (Exception)
  18920. {
  18921. 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()
  18922. {
  18923. Attachment = "",
  18924. }).ExecuteCommandAsync();
  18925. if (result != 0)
  18926. {
  18927. return Ok(JsonView(true, "成功!"));
  18928. }
  18929. else
  18930. {
  18931. return Ok(JsonView(false, "失败!"));
  18932. }
  18933. }
  18934. }
  18935. catch (Exception ex)
  18936. {
  18937. return Ok(JsonView(false, "程序错误!"));
  18938. throw;
  18939. }
  18940. }
  18941. /// <summary>
  18942. /// 保险费用操作(删除)
  18943. /// </summary>
  18944. /// <param name="dto"></param>
  18945. /// <returns></returns>
  18946. [HttpPost]
  18947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18948. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  18949. {
  18950. try
  18951. {
  18952. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  18953. if (!res)
  18954. {
  18955. return Ok(JsonView(false, "删除失败"));
  18956. }
  18957. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  18958. {
  18959. IsDel = 1,
  18960. DeleteUserId = dto.DeleteUserId,
  18961. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  18962. }).ExecuteCommandAsync();
  18963. return Ok(JsonView(true, "删除成功!"));
  18964. }
  18965. catch (Exception ex)
  18966. {
  18967. return Ok(JsonView(false, "程序错误!"));
  18968. throw;
  18969. }
  18970. }
  18971. #endregion
  18972. #region 接团客户名单 PageId 104
  18973. /// <summary>
  18974. /// 接团客户名单
  18975. /// 迁移数据(慎用!)
  18976. /// </summary>
  18977. /// <returns></returns>
  18978. [HttpPost]
  18979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18980. public async Task<IActionResult> PostTourClientListChange()
  18981. {
  18982. try
  18983. {
  18984. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  18985. //var groupClinetData1
  18986. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  18987. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  18988. int updateCount = 0;
  18989. if (oldOAClientList.Count > 0)
  18990. {
  18991. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  18992. _sqlSugar.BeginTran();
  18993. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  18994. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  18995. foreach (var item in oldOAClientList)
  18996. {
  18997. int comId = 0;
  18998. string format = "yyyy-MM-dd HH:mm:ss";
  18999. string data11 = "1990-01-01 00:00";
  19000. var data1 = IsValidDate(item.OPdate, format);
  19001. if (data1) data11 = item.OPdate;
  19002. //客户公司验证
  19003. if (!string.IsNullOrEmpty(item.Company))
  19004. {
  19005. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  19006. if (clientComInfo == null) // add
  19007. {
  19008. var addInfo = new Crm_CustomerCompany()
  19009. {
  19010. CompanyAbbreviation = "",
  19011. CompanyFullName = item.Company,
  19012. Address = "",
  19013. PostCodes = "",
  19014. LastedOpUserId = item.OPer,
  19015. LastedOpDt = Convert.ToDateTime(data11),
  19016. CreateUserId = item.OPer,
  19017. CreateTime = Convert.ToDateTime(data11),
  19018. IsDel = 0
  19019. };
  19020. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  19021. if (comId1 > 0) comId = comId1;
  19022. }
  19023. else comId = clientComInfo.Id;
  19024. }
  19025. //客户人员验证
  19026. int clientId = 0;
  19027. string name = item.LastName + item.Name;
  19028. if (!string.IsNullOrEmpty(name))
  19029. {
  19030. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  19031. if (clientInfo == null)
  19032. {
  19033. DateTime? dateTime = null;
  19034. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  19035. if (isDt) dateTime = birthDayDt;
  19036. var addInfo1 = new Crm_DeleClient()
  19037. {
  19038. CrmCompanyId = comId,
  19039. DiId = -1,
  19040. LastName = item.LastName,
  19041. FirstName = item.Name,
  19042. OldName = "",
  19043. Pinyin = item.Pinyin,
  19044. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  19045. Marriage = 0,
  19046. Phone = item.Phone,
  19047. Job = item.Job,
  19048. BirthDay = dateTime
  19049. };
  19050. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  19051. if (clientId1 > 0) clientId = clientId1;
  19052. }
  19053. else clientId = clientInfo.Id;
  19054. }
  19055. if (clientId < 1)
  19056. {
  19057. continue;
  19058. }
  19059. int airType = 0;
  19060. if (item.AirType == "超经舱") airType = 459;
  19061. else if (item.AirType == "公务舱") airType = 458;
  19062. else if (item.AirType == "经济舱") airType = 460;
  19063. else if (item.AirType == "其他") airType = 565;
  19064. else if (item.AirType == "头等舱") airType = 457;
  19065. var _TourClientListEntity = new Grp_TourClientList()
  19066. {
  19067. DiId = item.Diid,
  19068. ClientId = clientId,
  19069. CreateUserId = item.OPer,
  19070. CreateTime = Convert.ToDateTime(data11),
  19071. Remark = item.Remark,
  19072. IsDel = item.Isdel,
  19073. ShippingSpaceTypeId = airType,
  19074. ShippingSpaceSpecialNeeds = item.AirRemark,
  19075. HotelSpecialNeeds = item.RoomType
  19076. };
  19077. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  19078. if (_TourClientList > 0)
  19079. {
  19080. updateCount++;
  19081. }
  19082. }
  19083. _sqlSugar.CommitTran();
  19084. }
  19085. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  19086. }
  19087. catch (Exception ex)
  19088. {
  19089. _sqlSugar.RollbackTran();
  19090. return Ok(JsonView(false, ex.Message));
  19091. }
  19092. //return Ok(JsonView(true));
  19093. }
  19094. private bool IsValidDate(string dateString, string format)
  19095. {
  19096. DateTime dateValue;
  19097. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  19098. return valid;
  19099. }
  19100. /// <summary>
  19101. /// 接团客户名单
  19102. /// 根据团组Id查询List
  19103. /// </summary>
  19104. /// <param name="_dto"></param>
  19105. /// <returns></returns>
  19106. [HttpPost]
  19107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19108. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  19109. {
  19110. #region 参数验证
  19111. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  19112. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  19113. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  19114. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19115. #region 页面操作权限验证
  19116. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19117. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19118. #endregion
  19119. #endregion
  19120. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  19121. if (viewData.Code != 0)
  19122. {
  19123. return Ok(JsonView(false, viewData.Msg));
  19124. }
  19125. return Ok(JsonView(viewData.Data));
  19126. }
  19127. /// <summary>
  19128. /// 接团客户名单
  19129. /// 基础数据 Init
  19130. /// </summary>
  19131. /// <param name="_dto"></param>
  19132. /// <returns></returns>
  19133. [HttpPost]
  19134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19135. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  19136. {
  19137. #region 参数验证
  19138. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19139. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19140. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19141. #region 页面操作权限验证
  19142. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19143. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19144. #endregion
  19145. #endregion
  19146. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  19147. }
  19148. /// <summary>
  19149. /// 接团客户名单
  19150. /// 根据 Id查询 Details
  19151. /// </summary>
  19152. /// <param name="_dto"></param>
  19153. /// <returns></returns>
  19154. [HttpPost]
  19155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19156. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  19157. {
  19158. #region 参数验证
  19159. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19160. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19161. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19162. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19163. #region 页面操作权限验证
  19164. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19165. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19166. #endregion
  19167. #endregion
  19168. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  19169. if (viewData.Code != 0)
  19170. {
  19171. return Ok(JsonView(false, viewData.Msg));
  19172. }
  19173. return Ok(JsonView(viewData.Data));
  19174. }
  19175. /// <summary>
  19176. /// 接团客户名单
  19177. /// Add Or Edit
  19178. /// </summary>
  19179. /// <param name="_dto"></param>
  19180. /// <returns></returns>
  19181. [HttpPost]
  19182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19183. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  19184. {
  19185. #region 参数验证
  19186. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19187. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19188. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19189. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19190. #region 页面操作权限验证
  19191. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19192. if (_dto.Id == 0) //添加
  19193. {
  19194. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19195. }
  19196. else if (_dto.Id >= 0) //修改
  19197. {
  19198. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  19199. }
  19200. #endregion
  19201. #endregion
  19202. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  19203. if (viewData.Code != 0)
  19204. {
  19205. return Ok(JsonView(false, viewData.Msg));
  19206. }
  19207. return Ok(JsonView(true));
  19208. }
  19209. /// <summary>
  19210. /// 接团客户名单
  19211. /// json字符串 AddMultiple(添加多个)
  19212. /// </summary>
  19213. /// <param name="_dto"></param>
  19214. /// <returns></returns>
  19215. [HttpPost]
  19216. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19217. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  19218. {
  19219. #region 参数验证
  19220. string jsonLabel = _dto.JsonLabel;
  19221. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19222. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19223. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19224. #region 页面操作权限验证
  19225. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19226. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19227. #endregion
  19228. #endregion
  19229. var request = new TourClientListAddMultipleDto();
  19230. request.DiId = _dto.DiId;
  19231. request.UserId = _dto.UserId;
  19232. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  19233. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  19234. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  19235. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  19236. var infos = new List<TourClientListInfo>();
  19237. foreach (var data in datas)
  19238. {
  19239. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  19240. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  19241. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  19242. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  19243. {
  19244. continue;
  19245. }
  19246. infos.Add(new TourClientListInfo()
  19247. {
  19248. IsAccompany = 1,
  19249. LastName = lastName,
  19250. FirstName = firstName,
  19251. Pinyin = lastNameEn + @"/" + firstNameEn,
  19252. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  19253. CompanyFullName = data.CompanyFullName,
  19254. Job = data.Job
  19255. });
  19256. }
  19257. if (infos.Any())
  19258. {
  19259. var viewData = await _tourClientListRep._AddMultiple(request);
  19260. if (viewData.Code != 0)
  19261. {
  19262. return Ok(JsonView(false, viewData.Msg));
  19263. }
  19264. return Ok(JsonView(true));
  19265. }
  19266. return Ok(JsonView(false));
  19267. }
  19268. /// <summary>
  19269. /// 接团客户名单
  19270. /// AddMultiple(添加多个)
  19271. /// </summary>
  19272. /// <param name="_dto"></param>
  19273. /// <returns></returns>
  19274. [HttpPost]
  19275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19276. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  19277. {
  19278. #region 参数验证
  19279. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19280. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19281. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19282. #region 页面操作权限验证
  19283. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19284. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19285. #endregion
  19286. #endregion
  19287. var viewData = await _tourClientListRep._AddMultiple(_dto);
  19288. if (viewData.Code != 0)
  19289. {
  19290. return Ok(JsonView(false, viewData.Msg));
  19291. }
  19292. return Ok(JsonView(true));
  19293. }
  19294. /// <summary>
  19295. /// 接团客户名单
  19296. /// Del
  19297. /// </summary>
  19298. /// <param name="_dto"></param>
  19299. /// <returns></returns>
  19300. [HttpPost]
  19301. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19302. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  19303. {
  19304. #region 参数验证
  19305. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19306. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19307. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19308. #region 页面操作权限验证
  19309. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19310. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  19311. #endregion
  19312. #endregion
  19313. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  19314. if (viewData.Code != 0)
  19315. {
  19316. return Ok(JsonView(false, viewData.Msg));
  19317. }
  19318. return Ok(JsonView(true));
  19319. }
  19320. /// <summary>
  19321. /// 接团客户名单
  19322. /// 文件下载 客户名单
  19323. /// </summary>
  19324. /// <param name="_dto"></param>
  19325. /// <returns></returns>
  19326. [HttpPost]
  19327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19328. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  19329. {
  19330. #region 参数验证
  19331. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19332. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19333. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  19334. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19335. #region 页面操作权限验证
  19336. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19337. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19338. #endregion
  19339. #endregion
  19340. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  19341. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  19342. From Grp_TourClientList tcl
  19343. Left Join
  19344. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  19345. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  19346. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  19347. From Crm_DeleClient dc
  19348. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  19349. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  19350. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  19351. Where dc.IsDel = 0) temp
  19352. On temp.DcId =tcl.ClientId
  19353. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  19354. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  19355. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  19356. //载入模板
  19357. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  19358. if (_dto.Language == 1)
  19359. {
  19360. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  19361. }
  19362. //载入模板
  19363. var doc = new Document(tempPath);
  19364. DocumentBuilder builder = new DocumentBuilder(doc);
  19365. //获取word里所有表格
  19366. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19367. //获取所填表格的序数
  19368. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19369. var rowStart = tableOne.Rows[0]; //获取第1行
  19370. if (_dto.Language == 0)
  19371. {
  19372. //循环赋值
  19373. for (int i = 0; i < DcList.Count; i++)
  19374. {
  19375. EncryptionProcessor.DecryptProperties(DcList[i]);
  19376. builder.MoveToCell(0, i + 1, 0, 0);
  19377. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  19378. builder.MoveToCell(0, i + 1, 1, 0);
  19379. int sex = DcList[i].Sex;
  19380. string sexStr = string.Empty;
  19381. if (sex == 0) sexStr = "男";
  19382. else if (sex == 1) sexStr = "女";
  19383. else sexStr = "未设置";
  19384. builder.Write(sexStr);
  19385. builder.MoveToCell(0, i + 1, 2, 0);
  19386. string birthDay = DcList[i].BirthDay;
  19387. string birthDayStr = string.Empty;
  19388. if (!string.IsNullOrEmpty(birthDay))
  19389. {
  19390. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  19391. }
  19392. builder.Write(birthDayStr);
  19393. builder.MoveToCell(0, i + 1, 3, 0);
  19394. string company = "";
  19395. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19396. {
  19397. company = DcList[i].CompanyFullName.ToString();
  19398. }
  19399. builder.Write(company);
  19400. builder.MoveToCell(0, i + 1, 4, 0);
  19401. builder.Write(DcList[i].Job);
  19402. }
  19403. }
  19404. else if (_dto.Language == 1)
  19405. {
  19406. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  19407. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  19408. List<string> transArrayStr = new List<string>();
  19409. string transStrRes1 = "";
  19410. for (int i = 0; i < DcList.Count; i++)
  19411. {
  19412. var dc = DcList[i];
  19413. EncryptionProcessor.DecryptProperties(dc);
  19414. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  19415. if (dc.Job.Equals("暂无")) dc.Job = "-";
  19416. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  19417. if (DcList.Count - 1 == i) transStrRes1 += str1;
  19418. else transStrRes1 += $"{str1}|";
  19419. }
  19420. #region AI转英文
  19421. string jsonValue = JsonConvert.SerializeObject(DcList);
  19422. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  19423. List<SeedMessages> messages = new List<SeedMessages>()
  19424. {
  19425. new SeedMessages
  19426. {
  19427. Role = KimiRole.user,
  19428. Content = jsonValue + text
  19429. }
  19430. };
  19431. KiMiApiClient client = new KiMiApiClient();
  19432. var kimiApiResult = await client.SeedMessage(messages);
  19433. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19434. string clients = kimiApiResult_JObject["content"].ToString();
  19435. string startStr = "```json", endStr = "```";
  19436. // 判断并清除开头部分
  19437. if (clients.StartsWith(startStr))
  19438. {
  19439. clients = clients.Remove(0, startStr.Length);
  19440. }
  19441. // 判断并清除结尾部分
  19442. if (clients.EndsWith(endStr))
  19443. {
  19444. clients = clients.Remove(clients.Length - endStr.Length);
  19445. }
  19446. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  19447. //循环赋值
  19448. for (int i = 0; i < en_Json.Count; i++)
  19449. {
  19450. var dc = en_Json[i];
  19451. var dc1 = DcList.Find(x => x.Id == dc.Id);
  19452. string PYName = dc.FirstName + " " + dc.LastName;
  19453. builder.MoveToCell(0, i + 1, 0, 0);
  19454. builder.Write(PYName);
  19455. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  19456. builder.MoveToCell(0, i + 1, 1, 0);
  19457. builder.Write(sex);
  19458. DateTime birthDt;
  19459. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  19460. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19461. builder.MoveToCell(0, i + 1, 2, 0);
  19462. builder.Write(birthday);
  19463. string company = string.Empty, job = string.Empty;
  19464. company = dc.CompanyFullName;
  19465. job = dc.Job;
  19466. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  19467. {
  19468. //查询对照表
  19469. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  19470. if (tempCec != null)
  19471. {
  19472. company = tempCec.enName;
  19473. }
  19474. }
  19475. builder.MoveToCell(0, i + 1, 3, 0);
  19476. builder.Write(company);
  19477. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  19478. {
  19479. //查询对照表
  19480. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  19481. if (tempPec != null)
  19482. {
  19483. job = tempPec.enName;
  19484. }
  19485. }
  19486. builder.MoveToCell(0, i + 1, 4, 0);
  19487. builder.Write(job);
  19488. }
  19489. #endregion
  19490. #region 旧翻译英文处理
  19491. ////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";
  19492. //string transStrRes = "";
  19493. //if (transStrRes1.Length > 0)
  19494. //{
  19495. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  19496. //}
  19497. ////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
  19498. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  19499. ////List<string> transArray = new List<string> { };
  19500. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  19501. //if (transStrRes.Contains("|"))
  19502. //{
  19503. // string[] transArray1 = transStrRes.Split('|');
  19504. // if (transArray1.Length > 0)
  19505. // {
  19506. // foreach (var item in transArray1)
  19507. // {
  19508. // if (item.Contains("&"))
  19509. // {
  19510. // string[] transArray2 = item.Split('&');
  19511. // int index = 0;
  19512. // string companyName = "", job = "";
  19513. // if (transArray2.Length > 0)
  19514. // {
  19515. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  19516. // if (1 < transArray2.Length) companyName = transArray2[1];
  19517. // if (2 < transArray2.Length) job = transArray2[2];
  19518. // }
  19519. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  19520. // }
  19521. // }
  19522. // }
  19523. //}
  19524. ////循环赋值
  19525. //for (int i = 0; i < DcList.Count; i++)
  19526. //{
  19527. // string PYName = "";
  19528. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  19529. // {
  19530. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  19531. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  19532. // PYName = PY_First + " " + PY_Last;
  19533. // }
  19534. // else
  19535. // {
  19536. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  19537. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  19538. // PYName = PY_First + " " + PY_Last;
  19539. // }
  19540. // builder.MoveToCell(0, i + 1, 0, 0);
  19541. // builder.Write(PYName);
  19542. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  19543. // builder.MoveToCell(0, i + 1, 1, 0);
  19544. // builder.Write(sex);
  19545. // DateTime birthDt;
  19546. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  19547. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19548. // builder.MoveToCell(0, i + 1, 2, 0);
  19549. // builder.Write(birthday);
  19550. // string company = string.Empty, job = string.Empty;
  19551. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  19552. // if (dcTransInfo != null)
  19553. // {
  19554. // company = dcTransInfo.CompanyName;
  19555. // job = dcTransInfo.Job;
  19556. // }
  19557. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19558. // {
  19559. // //查询对照表
  19560. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  19561. // if (tempCec != null)
  19562. // {
  19563. // company = tempCec.enName;
  19564. // }
  19565. // //翻译
  19566. // else
  19567. // {
  19568. // }
  19569. // }
  19570. // builder.MoveToCell(0, i + 1, 3, 0);
  19571. // builder.Write(company);
  19572. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  19573. // {
  19574. // //查询对照表
  19575. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  19576. // if (tempPec != null)
  19577. // {
  19578. // job = tempPec.enName;
  19579. // }
  19580. // //翻译
  19581. // else
  19582. // {
  19583. // }
  19584. // }
  19585. // builder.MoveToCell(0, i + 1, 4, 0);
  19586. // builder.Write(job);
  19587. //}
  19588. #endregion
  19589. }
  19590. //删除多余行
  19591. while (tableOne.Rows.Count > DcList.Count + 1)
  19592. {
  19593. tableOne.Rows.RemoveAt(DcList.Count + 1);
  19594. }
  19595. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  19596. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  19597. doc.Save(fileDir);
  19598. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  19599. return Ok(JsonView(true, "操作成功!", Url));
  19600. }
  19601. private class TranslateInfo
  19602. {
  19603. public int Index { get; set; }
  19604. public string CompanyName { get; set; }
  19605. public string Job { get; set; }
  19606. }
  19607. [HttpPost]
  19608. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  19609. {
  19610. if (files.Count == 0)
  19611. {
  19612. return Ok(JsonView(false, "文件为空"));
  19613. }
  19614. KiMiApiClient KiMiApi = new KiMiApiClient();
  19615. var seedConter = await KiMiApi.UploadFilesAsync(files);
  19616. if (seedConter.Count == 0)
  19617. {
  19618. return Ok(JsonView(false, "上传结果为空!"));
  19619. }
  19620. var messages = new List<SeedMessages>
  19621. {
  19622. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  19623. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理,文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  19624. };
  19625. messages.InsertRange(1, seedConter);
  19626. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  19627. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19628. string clients = kimiApiResult_JObject["content"].ToString();
  19629. string startStr = "```json", endStr = "```";
  19630. // 判断并清除开头部分
  19631. if (clients.StartsWith(startStr))
  19632. {
  19633. clients = clients.Remove(0, startStr.Length);
  19634. }
  19635. // 判断并清除结尾部分
  19636. if (clients.EndsWith(endStr))
  19637. {
  19638. clients = clients.Remove(clients.Length - endStr.Length);
  19639. }
  19640. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  19641. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  19642. {
  19643. {"姓", "LastName" },
  19644. {"名", "FirstName" },
  19645. {"姓名拼音", "Pinyin" },
  19646. {"性别", "Sex" },
  19647. {"单位", "CompanyFullName" },
  19648. {"职务", "Job" },
  19649. {"出生日期", "Birthday" },
  19650. };
  19651. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  19652. foreach (var item in clients_JObject)
  19653. {
  19654. BaiduClientOCRView cdc = new BaiduClientOCRView();
  19655. foreach (var field in clientFieldMap.Keys)
  19656. {
  19657. if (item.TryGetValue(field, out JToken value))
  19658. {
  19659. var getValue = value.ToString();
  19660. System.Type type = cdc.GetType();
  19661. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  19662. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  19663. propertyInfo.SetValue(cdc, propertyValue);
  19664. }
  19665. }
  19666. crmClients.Add(cdc);
  19667. }
  19668. return Ok(JsonView(new
  19669. {
  19670. fileCount = files.Count,
  19671. UploadCount = seedConter.Count,
  19672. ApiResult = clients,
  19673. CrmClients = crmClients
  19674. }));
  19675. }
  19676. #endregion
  19677. #region 团组倒推表
  19678. /// <summary>
  19679. /// 倒推表基础数据
  19680. /// Init
  19681. /// </summary>
  19682. /// <returns></returns>
  19683. [HttpPost]
  19684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19685. public async Task<IActionResult> PostInvertedListInit()
  19686. {
  19687. var viewData = await _invertedListRep._Init();
  19688. if (viewData.Code != 0)
  19689. {
  19690. return Ok(JsonView(false, viewData.Msg));
  19691. }
  19692. return Ok(JsonView(viewData.Data));
  19693. }
  19694. /// <summary>
  19695. /// 倒推表
  19696. /// Info
  19697. /// </summary>
  19698. /// <param name="dto"></param>
  19699. /// <returns></returns>
  19700. [HttpPost]
  19701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19702. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  19703. {
  19704. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  19705. if (viewData.Code != 0)
  19706. {
  19707. return Ok(JsonView(false, viewData.Msg));
  19708. }
  19709. return Ok(JsonView(viewData.Data));
  19710. }
  19711. /// <summary>
  19712. /// 倒推表
  19713. /// Create
  19714. /// </summary>
  19715. /// <param name="dto"></param>
  19716. /// <returns></returns>
  19717. [HttpPost]
  19718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19719. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  19720. {
  19721. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  19722. if (viewData.Code != 0)
  19723. {
  19724. return Ok(JsonView(false, viewData.Msg));
  19725. }
  19726. return Ok(JsonView(viewData.Data));
  19727. }
  19728. /// <summary>
  19729. /// 倒推表
  19730. /// Update
  19731. /// </summary>
  19732. /// <param name="dto"></param>
  19733. /// <returns></returns>
  19734. [HttpPost]
  19735. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19736. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  19737. {
  19738. var viewData = await _invertedListRep._Update(dto);
  19739. if (viewData.Code != 0)
  19740. {
  19741. return Ok(JsonView(false, viewData.Msg));
  19742. }
  19743. return Ok(JsonView(viewData.Data));
  19744. }
  19745. /// <summary>
  19746. /// 倒推表
  19747. /// File Download
  19748. /// </summary>
  19749. /// <param name="dto"></param>
  19750. /// <returns></returns>
  19751. [HttpPost]
  19752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19753. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  19754. {
  19755. var info2 = await _invertedListRep._Info(1, dto.DiId);
  19756. if (info2.Code != 0)
  19757. {
  19758. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  19759. }
  19760. var info1 = info2.Data as InvertedListInfoView;
  19761. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  19762. string teamName = "";
  19763. if (info != null) teamName = info.TeamName;
  19764. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  19765. var doc = new Document();
  19766. var builder = new DocumentBuilder(doc);
  19767. #region old insert
  19768. ////载入模板
  19769. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  19770. //Document doc = new Document(tempPath);
  19771. //DocumentBuilder builder = new DocumentBuilder(doc);
  19772. //利用键值对存放数据
  19773. //Dictionary<string, string> dic = new Dictionary<string, string>();
  19774. //dic.Add("TeamName", teamName);
  19775. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  19776. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  19777. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  19778. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  19779. //dic.Add("SQRemark", info1.ApprovalRemark);
  19780. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  19781. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  19782. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  19783. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  19784. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  19785. //dic.Add("QZRemark", info1.VisaInformationRemark);
  19786. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  19787. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  19788. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  19789. //dic.Add("CQRemark", info1.IssueVisaRemark);
  19790. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  19791. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  19792. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  19793. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  19794. //#region 填充word模板书签内容
  19795. //foreach (var key in dic.Keys)
  19796. //{
  19797. // builder.MoveToBookmark(key);
  19798. // builder.Write(dic[key]);
  19799. //}
  19800. //#endregion
  19801. #endregion
  19802. #region New Insert
  19803. string titleFont = $"仿宋",
  19804. contentFont = $"仿宋";
  19805. var fontColor = Color.FromArgb(64, 64, 64);
  19806. //设置标题 团组名称
  19807. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19808. builder.Font.Name = titleFont;
  19809. builder.Font.Color = fontColor;
  19810. builder.Font.Size = 12;
  19811. builder.Font.Bold = true;
  19812. builder.Writeln(teamName);
  19813. //设置副标题 团组出访时间
  19814. builder.Font.Size = 12;
  19815. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  19816. builder.Writeln();
  19817. var backgroundColor = Color.FromArgb(199, 199, 199);
  19818. var table = builder.StartTable();
  19819. builder.InsertCell();
  19820. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  19821. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  19822. builder.CellFormat.Borders.LineWidth = 1;
  19823. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  19824. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  19825. builder.RowFormat.Height = 40;
  19826. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19827. builder.Font.Name = contentFont;
  19828. builder.Font.Size = 12;
  19829. builder.Font.Bold = true;
  19830. builder.Font.Color = fontColor;
  19831. builder.Write("时间");
  19832. builder.InsertCell();
  19833. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  19834. builder.Write("流程");
  19835. builder.InsertCell();
  19836. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  19837. builder.Write("说明");
  19838. builder.EndRow();
  19839. //报批资料准备
  19840. if (info1.IsSelectedAirportd)
  19841. {
  19842. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  19843. }
  19844. //报批/提供送签资料
  19845. if (info1.IsSelectedApprovalData)
  19846. {
  19847. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  19848. }
  19849. //出批件护照办理
  19850. if (info1.IsSelectedIssueApproval)
  19851. {
  19852. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  19853. }
  19854. //签证资料准备
  19855. if (info1.IsSelectedVisaInfo)
  19856. {
  19857. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  19858. }
  19859. //送签
  19860. if (info1.IsSelectedSendVisa)
  19861. {
  19862. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  19863. }
  19864. //出签
  19865. if (info1.IsSelectedIssueVisa)
  19866. {
  19867. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  19868. }
  19869. //机票
  19870. if (info1.IsSelectedAirTicket)
  19871. {
  19872. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  19873. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  19874. }
  19875. //酒店
  19876. if (info1.IsSelectedHotel)
  19877. {
  19878. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  19879. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  19880. }
  19881. //开行前会
  19882. if (info1.IsSelectedPreTripMeeting)
  19883. {
  19884. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  19885. }
  19886. //送机
  19887. if (info1.IsSelectedAirportdDropOff)
  19888. {
  19889. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  19890. }
  19891. builder.EndTable();
  19892. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  19893. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  19894. for (int i = 0; i < table.Rows.Count; i++)
  19895. {
  19896. var row = table.Rows[i];
  19897. //设置宽度
  19898. row.Cells[0].CellFormat.Width = 20.00;
  19899. row.Cells[1].CellFormat.Width = 30.00;
  19900. row.Cells[2].CellFormat.Width = 50.00;
  19901. if (i != 0)
  19902. {
  19903. //边框设置
  19904. InvertedListFileDownloadSetBorders(row.Cells, 0);
  19905. InvertedListFileDownloadSetBorders(row.Cells, 1);
  19906. InvertedListFileDownloadSetBorders(row.Cells, 2);
  19907. }
  19908. }
  19909. #region 页脚插入图片
  19910. // 创建页脚
  19911. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  19912. doc.FirstSection.HeadersFooters.Add(footer);
  19913. Paragraph para = new Paragraph(doc);
  19914. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  19915. footer.AppendChild(para);
  19916. builder.MoveTo(para);
  19917. string imagePath = "./Images/FMGJ_Log.png";
  19918. builder.InsertImage(imagePath);
  19919. #endregion
  19920. #endregion
  19921. var fileDir = AppSettingsHelper.Get("WordBasePath");
  19922. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  19923. string filePath = fileDir + $@"InvertedList/{fileName}";
  19924. doc.Save(filePath);
  19925. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  19926. return Ok(JsonView(true, "操作成功!", Url));
  19927. }
  19928. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  19929. {
  19930. var fontColor = Color.FromArgb(64, 64, 64);
  19931. builder.InsertCell();
  19932. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  19933. builder.RowFormat.Height = 40;
  19934. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19935. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19936. builder.Font.Name = fontName;
  19937. builder.Font.Size = 8;
  19938. builder.Font.Bold = true;
  19939. builder.Font.Color = fontColor;
  19940. builder.Write(dateTime);
  19941. builder.InsertCell();
  19942. builder.Font.Size = 9;
  19943. builder.Font.Bold = true;
  19944. builder.Font.Color = fontColor;
  19945. builder.Write(content);
  19946. builder.InsertCell();
  19947. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19948. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  19949. builder.Font.Size = 9;
  19950. builder.Font.Bold = false;
  19951. builder.Font.Color = fontColor;
  19952. builder.Write(reamrk);
  19953. builder.EndRow();
  19954. }
  19955. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  19956. {
  19957. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  19958. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  19959. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  19960. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  19961. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  19962. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  19963. }
  19964. #endregion
  19965. #region 会务倒推表
  19966. /// <summary>
  19967. /// 会务倒推表
  19968. /// Init
  19969. /// </summary>
  19970. /// <returns></returns>
  19971. [HttpPost]
  19972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19973. public async Task<IActionResult> InforRetrogressTableInit()
  19974. {
  19975. var groupData = await _groupRepository.PostShareGroupInfos(1);
  19976. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  19977. return Ok(JsonView(false, groupData.Msg));
  19978. }
  19979. /// <summary>
  19980. /// 会务倒推表
  19981. /// ExcelDownload
  19982. /// </summary>
  19983. /// <param name="dto"></param>
  19984. /// <returns></returns>
  19985. [HttpPost]
  19986. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  19987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19988. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  19989. {
  19990. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  19991. var validatorRes = await validator.ValidateAsync(dto);
  19992. if (!validatorRes.IsValid)
  19993. {
  19994. StringBuilder sb = new StringBuilder();
  19995. foreach (var item in validatorRes.Errors)
  19996. {
  19997. sb.AppendLine(item.ErrorMessage);
  19998. }
  19999. return Ok(JsonView(false, sb.ToString()));
  20000. }
  20001. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  20002. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  20003. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  20004. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  20005. #region Excel
  20006. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  20007. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  20008. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  20009. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  20010. var fileNamePrefix = string.Empty;
  20011. if (days >= 30)
  20012. {
  20013. tempPath += $"会务工作倒推进度表(30天).xlsx";
  20014. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  20015. }
  20016. else if (days < 30 && days > 7)
  20017. {
  20018. tempPath += $"会务工作倒推进度表(15天).xlsx";
  20019. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  20020. }
  20021. else if (days <= 7)
  20022. {
  20023. tempPath += $"会务工作倒推进度表(7天).xlsx";
  20024. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  20025. }
  20026. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  20027. fileName = CommonFun.ValidFileName(fileName);
  20028. //载入模板
  20029. WorkbookDesigner designer = new WorkbookDesigner();
  20030. designer.Workbook = new Workbook(tempPath);
  20031. designer.Process();
  20032. if (!Directory.Exists(savePath))
  20033. {
  20034. Directory.CreateDirectory(savePath);
  20035. }
  20036. string serverPath = $"{savePath}{fileName}";
  20037. designer.Workbook.Save(serverPath);
  20038. string rst = $"{servicePath}{ftpPath}{fileName}";
  20039. #endregion
  20040. return Ok(JsonView(new { url = rst }));
  20041. }
  20042. #endregion
  20043. #region 三公签证费用(签证费、代办费)
  20044. /// <summary>
  20045. /// 三公签证费用(签证费、代办费)
  20046. /// List
  20047. /// </summary>
  20048. /// <returns></returns>
  20049. [HttpPost]
  20050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20051. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  20052. {
  20053. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  20054. if (_view.Code != 0)
  20055. {
  20056. return Ok(JsonView(false, _view.Msg));
  20057. }
  20058. return Ok(JsonView(true, "操作成功!", _view.Data));
  20059. }
  20060. /// <summary>
  20061. /// 三公签证费用(签证费、代办费)
  20062. /// Add Or Update
  20063. /// </summary>
  20064. /// <returns></returns>
  20065. [HttpPost]
  20066. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20067. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  20068. {
  20069. var _view = await _visaFeeInfoRep._Update(_dto);
  20070. if (_view.Code != 0)
  20071. {
  20072. return Ok(JsonView(false, _view.Msg));
  20073. }
  20074. return Ok(JsonView(true, _view.Msg));
  20075. }
  20076. #endregion
  20077. #region 酒店询价
  20078. /// <summary>
  20079. /// 酒店询价
  20080. /// Init
  20081. /// </summary>
  20082. /// <returns></returns>
  20083. [HttpPost]
  20084. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20085. public async Task<IActionResult> PostHotelInquiryInit()
  20086. {
  20087. var res = await _hotelInquiryRep._Init();
  20088. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20089. return Ok(JsonView(true, res.Msg, res.Data));
  20090. }
  20091. /// <summary>
  20092. /// 酒店询价
  20093. /// page Item
  20094. /// </summary>
  20095. /// <param name="_dto"></param>
  20096. /// <returns></returns>
  20097. [HttpPost]
  20098. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20099. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  20100. {
  20101. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  20102. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20103. var view = res.Data as PageDataViewBase;
  20104. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  20105. }
  20106. /// <summary>
  20107. /// 酒店询价
  20108. /// info
  20109. /// </summary>
  20110. /// <param name="_dto"></param>
  20111. /// <returns></returns>
  20112. [HttpPost]
  20113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20114. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  20115. {
  20116. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  20117. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20118. return Ok(JsonView(true, res.Msg, res.Data));
  20119. }
  20120. /// <summary>
  20121. /// 酒店询价
  20122. /// Add Or Edit
  20123. /// </summary>
  20124. /// <param name="_dto"></param>
  20125. /// <returns></returns>
  20126. [HttpPost]
  20127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20128. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  20129. {
  20130. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  20131. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20132. return Ok(JsonView(true, res.Msg, res.Data));
  20133. }
  20134. /// <summary>
  20135. /// 酒店询价
  20136. /// Del
  20137. /// </summary>
  20138. /// <param name="_dto"></param>
  20139. /// <returns></returns>
  20140. [HttpPost]
  20141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20142. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  20143. {
  20144. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  20145. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20146. return Ok(JsonView(true, res.Msg, res.Data));
  20147. }
  20148. #endregion
  20149. #region 下载匹配op行程单
  20150. /// <summary>
  20151. /// 匹配op行程单
  20152. /// Init
  20153. /// </summary>
  20154. /// <param name="dto">团组列表请求dto</param>
  20155. /// <returns></returns>
  20156. [HttpPost]
  20157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20158. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  20159. {
  20160. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20161. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20162. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  20163. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  20164. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  20165. .Where(it => it.IsDel == 0)
  20166. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  20167. .OrderByDescending(it => it.VisitStartDate)
  20168. .ToList();
  20169. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  20170. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20171. var diids = groupInfos.Select(it => it.Id).ToList();
  20172. List<string> countrys = new List<string>();
  20173. foreach (var item in country)
  20174. {
  20175. var data = _groupRepository.FormartTeamName(item);
  20176. var dataArray = _groupRepository.GroupSplitCountry(data);
  20177. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20178. }
  20179. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  20180. List<string> areaArray = new List<string>(); //GetGroupCityLine
  20181. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  20182. foreach (var item in areaItem)
  20183. {
  20184. string areaStr = item.Value;
  20185. if (!string.IsNullOrEmpty(areaStr))
  20186. {
  20187. string[] str1 = areaStr.Split("-");
  20188. if (str1.Length > 0)
  20189. {
  20190. areaArray.AddRange(str1);
  20191. }
  20192. }
  20193. }
  20194. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  20195. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  20196. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  20197. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  20198. .ToList();
  20199. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  20200. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  20201. .Where(it => countriesIds.Contains(it.Id))
  20202. .Select(it => new { it.Id, Name = it.Name_CN })
  20203. .ToList();
  20204. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  20205. .Select(it => it.TeamName).ToList();
  20206. stopwatch.Stop();
  20207. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  20208. }
  20209. ///// <summary>
  20210. ///// 匹配op行程单
  20211. ///// Init 查询区域数据
  20212. ///// </summary>
  20213. ///// <param name="dto">团组列表请求dto</param>
  20214. ///// <returns></returns>
  20215. //[HttpPost]
  20216. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20217. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  20218. //{
  20219. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20220. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  20221. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  20222. // if (string.IsNullOrEmpty(countriesDataStr))
  20223. // {
  20224. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  20225. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  20226. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  20227. // }
  20228. // else
  20229. // {
  20230. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  20231. // }
  20232. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  20233. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  20234. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  20235. // List<dynamic> childList = new List<dynamic>();
  20236. // int parentId = dto.CountriesId;
  20237. // if (provinceData.Count > 1)
  20238. // {
  20239. // foreach (var item1 in provinceData)
  20240. // {
  20241. // List<dynamic> childList1 = new List<dynamic>();
  20242. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  20243. // foreach (var item2 in citiesData1)
  20244. // {
  20245. // List<dynamic> childList2 = new List<dynamic>();
  20246. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20247. // foreach (var item3 in countiesData1)
  20248. // {
  20249. // childList2.Add(new
  20250. // {
  20251. // id = item3.Id,
  20252. // parentId = item2.Id,
  20253. // level = "district",
  20254. // name = item3.Name_CN,
  20255. // });
  20256. // }
  20257. // childList1.Add(new
  20258. // {
  20259. // id = item2.Id,
  20260. // parentId = item1.Id,
  20261. // level = "city",
  20262. // name = item2.Name_CN,
  20263. // childList = childList2
  20264. // });
  20265. // }
  20266. // childList.Add(new
  20267. // {
  20268. // id = item1.Id,
  20269. // parentId = parentId,
  20270. // level = "province",
  20271. // name = item1.Name_CN,
  20272. // childList = childList1
  20273. // });
  20274. // }
  20275. // //城市
  20276. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  20277. // foreach (var item2 in citiesData2)
  20278. // {
  20279. // List<dynamic> childList22 = new List<dynamic>();
  20280. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20281. // foreach (var item3 in countiesData1)
  20282. // {
  20283. // childList22.Add(new
  20284. // {
  20285. // id = item3.Id,
  20286. // parentId = item2.Id,
  20287. // level = "district",
  20288. // name = item3.Name_CN,
  20289. // });
  20290. // }
  20291. // childList.Add(new
  20292. // {
  20293. // id = item2.Id,
  20294. // parentId = parentId,
  20295. // level = "city",
  20296. // name = item2.Name_CN,
  20297. // childList = childList22
  20298. // });
  20299. // }
  20300. // }
  20301. // else
  20302. // {
  20303. // foreach (var item2 in citiesData)
  20304. // {
  20305. // string cname = item2.Name_CN;
  20306. // List<dynamic> childList1 = new List<dynamic>();
  20307. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20308. // foreach (var item3 in countiesData1)
  20309. // {
  20310. // childList1.Add(new
  20311. // {
  20312. // Id = item3.Id,
  20313. // parentId = item2.Id,
  20314. // level = "district",
  20315. // name = item3.Name_CN
  20316. // });
  20317. // }
  20318. // childList.Add(new
  20319. // {
  20320. // id = item2.Id,
  20321. // parentId = parentId,
  20322. // level = "city",
  20323. // name = item2.Name_CN,
  20324. // childList = childList1
  20325. // });
  20326. // }
  20327. // }
  20328. // stopwatch.Stop();
  20329. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  20330. //}
  20331. /// <summary>
  20332. /// 匹配op行程单
  20333. /// 接团信息列表 Page
  20334. /// </summary>
  20335. /// <param name="dto">团组列表请求dto</param>
  20336. /// <returns></returns>
  20337. [HttpPost]
  20338. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20339. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  20340. {
  20341. var swatch = new Stopwatch();
  20342. swatch.Start();
  20343. #region 参数验证
  20344. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20345. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20346. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20347. #region 页面操作权限验证
  20348. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20349. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  20350. #endregion
  20351. #endregion
  20352. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20353. {
  20354. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  20355. //string sqlWhere = "";
  20356. if (!string.IsNullOrEmpty(dto.Country))
  20357. {
  20358. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  20359. }
  20360. if (!string.IsNullOrEmpty(dto.Area))
  20361. {
  20362. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  20363. }
  20364. if (!string.IsNullOrEmpty(dto.TeamName))
  20365. {
  20366. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  20367. }
  20368. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  20369. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  20370. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  20371. swatch.Stop();
  20372. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  20373. }
  20374. else
  20375. {
  20376. return Ok(JsonView(false, "查询失败"));
  20377. }
  20378. }
  20379. /// <summary>
  20380. /// 匹配op行程单
  20381. /// 行程单下载
  20382. /// </summary>
  20383. /// <param name="dto">团组列表请求dto</param>
  20384. /// <returns></returns>
  20385. [HttpPost]
  20386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20387. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  20388. {
  20389. #region 参数验证
  20390. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20391. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20392. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20393. #region 页面操作权限验证
  20394. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20395. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  20396. #endregion
  20397. #endregion
  20398. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20399. {
  20400. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  20401. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  20402. }
  20403. else
  20404. {
  20405. return Ok(JsonView(false, "下载失败!"));
  20406. }
  20407. }
  20408. #endregion
  20409. #region 国家信息 数据 注释
  20410. //[HttpPost]
  20411. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  20412. //{
  20413. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  20414. // foreach (var item in dto)
  20415. // {
  20416. // infos.Add(new Grp_GroupsTaskAssignment()
  20417. // {
  20418. // DIId = item,
  20419. // CTId = 82,
  20420. // UId = 248,
  20421. // IsEnable = 1,
  20422. // CreateUserId = 233,
  20423. // CreateTime = DateTime.Now,
  20424. // IsDel = 0
  20425. // });
  20426. // infos.Add(new Grp_GroupsTaskAssignment()
  20427. // {
  20428. // DIId = item,
  20429. // CTId = 82,
  20430. // UId = 286,
  20431. // IsEnable = 1,
  20432. // CreateUserId = 233,
  20433. // CreateTime = DateTime.Now,
  20434. // IsDel = 0
  20435. // });
  20436. // }
  20437. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  20438. // return Ok("操作成功");
  20439. //}
  20440. //public class paramJsonDto
  20441. //{
  20442. // public List<CountriesInfo> str { get; set; }
  20443. //}
  20444. //[HttpPost]
  20445. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  20446. //{
  20447. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  20448. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  20449. // List<Sys_Cities> cities = new List<Sys_Cities>();
  20450. // List<Sys_Cities> districts = new List<Sys_Cities>();
  20451. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20452. // _sqlSugar.BeginTran();
  20453. // int countitiesIndex = 0;
  20454. // foreach (var item in dto.str)
  20455. // {
  20456. // dynamic data = item.c;
  20457. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  20458. // if (data != null)
  20459. // {
  20460. // countitiesIndex++;
  20461. // foreach (var item1 in data)
  20462. // {
  20463. // string cnname = item1.cn;
  20464. // string enname = item1.en;
  20465. // Sys_Cities provinceInfo = new Sys_Cities()
  20466. // {
  20467. // CountriesId = countriesId,
  20468. // Name_CN = cnname,
  20469. // Name_EN = enname,
  20470. // ParentId = 0,
  20471. // IsCapital = 1,
  20472. // CreateUserId = 208,
  20473. // CreateTime = DateTime.Now,
  20474. // IsDel = 0
  20475. // };
  20476. // if (item1.lv == "province") //省份
  20477. // {
  20478. // provinceInfo.Level = 1;
  20479. // int provinceId = 0;
  20480. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  20481. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  20482. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20483. // var data1 = item1.c;
  20484. // foreach (var item2 in data1)
  20485. // {
  20486. // if (item2.lv == "city")
  20487. // {
  20488. // string citycnname = item2.cn;
  20489. // string cityenname = item2.en;
  20490. // Sys_Cities cityInfo = new Sys_Cities()
  20491. // {
  20492. // CountriesId = countriesId,
  20493. // ParentId = provinceId,
  20494. // Level = 2,
  20495. // Name_CN = citycnname,
  20496. // Name_EN = cityenname,
  20497. // IsCapital = 1,
  20498. // CreateUserId = 208,
  20499. // CreateTime = DateTime.Now,
  20500. // IsDel = 0
  20501. // };
  20502. // if (item2.c != null)
  20503. // {
  20504. // int cityId = 0;
  20505. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  20506. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20507. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  20508. // foreach (var item3 in item2.c)
  20509. // {
  20510. // if (item3.lv == "district")
  20511. // {
  20512. // var districtInfo = new Sys_Cities()
  20513. // {
  20514. // CountriesId = countriesId,
  20515. // Name_CN = item3.cn,
  20516. // Name_EN = item3.en,
  20517. // Level = 3,
  20518. // ParentId = cityId,
  20519. // IsCapital = 1,
  20520. // CreateUserId = 208,
  20521. // CreateTime = DateTime.Now,
  20522. // IsDel = 0
  20523. // };
  20524. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20525. // //{
  20526. // districts.Add(districtInfo);
  20527. // //}
  20528. // }
  20529. // }
  20530. // }
  20531. // else
  20532. // {
  20533. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  20534. // //{
  20535. // cities.Add(cityInfo);
  20536. // //}
  20537. // }
  20538. // }
  20539. // }
  20540. // }
  20541. // else if (item1.lv == "city")//城市
  20542. // {
  20543. // provinceInfo.Level = 2;
  20544. // if (item1.c != null)
  20545. // {
  20546. // int cityId = 0;
  20547. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  20548. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20549. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20550. // foreach (var item3 in item1.c)
  20551. // {
  20552. // if (item3.lv == "district")
  20553. // {
  20554. // var districtInfo = new Sys_Cities()
  20555. // {
  20556. // CountriesId = countriesId,
  20557. // Name_CN = item3.cn,
  20558. // Name_EN = item3.en,
  20559. // Level = 3,
  20560. // ParentId = cityId,
  20561. // IsCapital = 1,
  20562. // CreateUserId = 208,
  20563. // CreateTime = DateTime.Now,
  20564. // IsDel = 0
  20565. // };
  20566. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20567. // //{
  20568. // districts.Add(districtInfo);
  20569. // //}
  20570. // }
  20571. // }
  20572. // }
  20573. // else
  20574. // {
  20575. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  20576. // //{
  20577. // cities.Add(provinceInfo);
  20578. // //}
  20579. // }
  20580. // }
  20581. // }
  20582. // }
  20583. // }
  20584. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  20585. // cities = cities.Distinct().ToList();
  20586. // districts = districts.Distinct().ToList();
  20587. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  20588. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  20589. // cities.AddRange(districts);
  20590. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  20591. // //_sqlSugar.RollbackTran();
  20592. // _sqlSugar.CommitTran();
  20593. // return Ok(JsonView(false, "操作成功!"));
  20594. //}
  20595. //[HttpPost]
  20596. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  20597. //{
  20598. // List<CountitiesInfo> infos = dto.MyProperty;
  20599. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  20600. // _sqlSugar.BeginTran();
  20601. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20602. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  20603. // foreach (var item in infos)
  20604. // {
  20605. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  20606. // if (countryInfo != null)
  20607. // {
  20608. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  20609. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  20610. // if (cityInfo1 != null)
  20611. // {
  20612. // cityInfo1.IsCapital = 0;
  20613. // cityInfos.Add(cityInfo1);
  20614. // }
  20615. // }
  20616. // }
  20617. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  20618. // .UpdateColumns(it => it.IsCapital)
  20619. // .WhereColumns(it => it.Id)
  20620. // .ExecuteCommand();
  20621. // //_sqlSugar.RollbackTran();
  20622. // _sqlSugar.CommitTran();
  20623. // return Ok(JsonView(false, "操作成功!"));
  20624. //}
  20625. //public class CounrtiesDto
  20626. //{
  20627. // public List<CountitiesInfo> MyProperty { get; set; }
  20628. //}
  20629. //public class CountitiesInfo
  20630. //{
  20631. // /// <summary>
  20632. // /// 圣约翰
  20633. // /// </summary>
  20634. // public string capital_name_chinese { get; set; }
  20635. // /// <summary>
  20636. // ///
  20637. // /// </summary>
  20638. // public string capital_name { get; set; }
  20639. // /// <summary>
  20640. // ///
  20641. // /// </summary>
  20642. // public string country_type { get; set; }
  20643. // /// <summary>
  20644. // /// 安提瓜和巴布达
  20645. // /// </summary>
  20646. // public string country_name_chinese { get; set; }
  20647. // /// <summary>
  20648. // /// 安提瓜和巴布达
  20649. // /// </summary>
  20650. // public string country_name_chinese_short { get; set; }
  20651. // /// <summary>
  20652. // /// 安提瓜和巴布达
  20653. // /// </summary>
  20654. // public string country_name_chinese_UN { get; set; }
  20655. // /// <summary>
  20656. // ///
  20657. // /// </summary>
  20658. // public string country_name_english_abbreviation { get; set; }
  20659. // /// <summary>
  20660. // ///
  20661. // /// </summary>
  20662. // public string country_name_english_formal { get; set; }
  20663. // /// <summary>
  20664. // ///
  20665. // /// </summary>
  20666. // public string country_name_english_UN { get; set; }
  20667. // /// <summary>
  20668. // ///
  20669. // /// </summary>
  20670. // public string continent_name { get; set; }
  20671. // /// <summary>
  20672. // ///
  20673. // /// </summary>
  20674. // public string subregion_name { get; set; }
  20675. // /// <summary>
  20676. // ///
  20677. // /// </summary>
  20678. // public string country_code2 { get; set; }
  20679. // /// <summary>
  20680. // ///
  20681. // /// </summary>
  20682. // public string country_code3 { get; set; }
  20683. // /// <summary>
  20684. // ///
  20685. // /// </summary>
  20686. // public string phone_code { get; set; }
  20687. //}
  20688. //public class CountriesInfo : BasicInfo
  20689. //{
  20690. // public List<CitiesInfo> c { get; set; }
  20691. //}
  20692. //public class CitiesInfo : BasicInfo
  20693. //{
  20694. // public List<AreaInfo> c { get; set; }
  20695. //}
  20696. //public class AreaInfo : BasicInfo
  20697. //{
  20698. // public List<AreaInfo> c { get; set; }
  20699. //}
  20700. //public class BasicInfo
  20701. //{
  20702. // public string code { get; set; }
  20703. // public string cn { get; set; }
  20704. // public string lv { get; set; }
  20705. // public string en { get; set; }
  20706. //}
  20707. #endregion
  20708. #region 查看邀请方
  20709. /// <summary>
  20710. /// 查看邀请方
  20711. /// 邀请方信息 Init
  20712. /// </summary>
  20713. /// <param name="dto"></param>
  20714. /// <returns></returns>
  20715. [HttpPost]
  20716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20717. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  20718. {
  20719. string sqlWhere = string.Empty;
  20720. if (!string.IsNullOrEmpty(dto.Search))
  20721. {
  20722. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  20723. }
  20724. string sql = string.Format($@"Select
  20725. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  20726. Id,
  20727. UnitName
  20728. From Res_InvitationOfficialActivityData
  20729. Where IsDel = 0
  20730. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  20731. RefAsync<int> total = 0;
  20732. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20733. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  20734. }
  20735. /// <summary>
  20736. /// 查看邀请方
  20737. /// 国家信息 Init
  20738. /// </summary>
  20739. /// <param name="dto"></param>
  20740. /// <returns></returns>
  20741. [HttpPost]
  20742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20743. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  20744. {
  20745. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  20746. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20747. var diids = groupInfos.Select(it => it.Id).ToList();
  20748. List<string> countrys = new List<string>();
  20749. foreach (var item in country)
  20750. {
  20751. var data = _groupRepository.FormartTeamName(item);
  20752. var dataArray = _groupRepository.GroupSplitCountry(data);
  20753. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20754. }
  20755. countrys = countrys.Distinct().ToList();
  20756. for (int i = 0; i < countrys.Count; i++)
  20757. {
  20758. string item = countrys[i];
  20759. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  20760. {
  20761. countrys.Remove(item);
  20762. i--;
  20763. }
  20764. }
  20765. RefAsync<int> total = 0;
  20766. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  20767. .Where(it => countrys.Contains(it.Name_CN))
  20768. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20769. .Select(it => new { id = it.Id, name = it.Name_CN })
  20770. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20771. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20772. }
  20773. /// <summary>
  20774. /// 查看邀请方
  20775. /// 城市信息 Init
  20776. /// </summary>
  20777. /// <param name="dto"></param>
  20778. /// <returns></returns>
  20779. [HttpPost]
  20780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20781. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  20782. {
  20783. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  20784. RefAsync<int> total = 0;
  20785. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  20786. .Where(it => it.CountriesId == dto.CountiesId)
  20787. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20788. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  20789. .Select(it => new { id = it.Id, name = it.Name_CN })
  20790. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20791. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20792. }
  20793. /// <summary>
  20794. /// 查看邀请方
  20795. /// 团组名称 Init
  20796. /// </summary>
  20797. /// <param name="dto"></param>
  20798. /// <returns></returns>
  20799. [HttpPost]
  20800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20801. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  20802. {
  20803. var watch = new Stopwatch();
  20804. watch.Start();
  20805. RefAsync<int> total = 0;
  20806. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  20807. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  20808. .Where((oa, di) => oa.IsDel == 0)
  20809. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  20810. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  20811. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  20812. .Distinct()
  20813. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20814. watch.Stop();
  20815. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  20816. }
  20817. /// <summary>
  20818. /// 查看邀请方
  20819. /// 团组 & 邀请方信息
  20820. /// </summary>
  20821. /// <param name="dto"></param>
  20822. /// <returns></returns>
  20823. [HttpPost]
  20824. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20825. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  20826. {
  20827. var watch = new Stopwatch();
  20828. watch.Start();
  20829. RefAsync<int> total = 0;
  20830. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  20831. .AS("Grp_DelegationInfo")
  20832. .Includes(x => x.InvitingInfos)
  20833. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  20834. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  20835. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  20836. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  20837. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  20838. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  20839. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20840. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  20841. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  20842. infos.ForEach(x =>
  20843. {
  20844. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  20845. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  20846. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  20847. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  20848. });
  20849. watch.Stop();
  20850. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  20851. }
  20852. #endregion
  20853. #region 报批行程
  20854. /// <summary>
  20855. /// 报批行程初始化
  20856. /// </summary>
  20857. /// <param name="dto"></param>
  20858. /// <returns></returns>
  20859. [HttpPost]
  20860. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  20861. {
  20862. const int chiNumber = 5;
  20863. var jw = JsonView(false);
  20864. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  20865. var group = groupList.First();
  20866. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  20867. group = groupList.First(x => x.Id == diid);
  20868. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20869. .Where(x => x.DiId == diid && x.IsDel == 0)
  20870. .ToArray();
  20871. var count = 1;
  20872. foreach (var item in blackCodeList)
  20873. {
  20874. if (string.IsNullOrWhiteSpace(item.Title))
  20875. {
  20876. item.Title = "未设置名称数据" + count;
  20877. }
  20878. count++;
  20879. }
  20880. ;
  20881. if (group == null)
  20882. {
  20883. jw.Msg = "暂无团组!";
  20884. return Ok(jw);
  20885. }
  20886. var data = new
  20887. {
  20888. groupList = groupList.Select(x => new
  20889. {
  20890. x.TeamName,
  20891. x.Id
  20892. }),
  20893. content = new ArrayList(),
  20894. groupInfo = new
  20895. {
  20896. group.VisitDays,
  20897. group.TourCode,
  20898. group.VisitPNumber,
  20899. group.TeamName,
  20900. group.Id,
  20901. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  20902. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  20903. group.ClientUnit
  20904. },
  20905. blackCodeList = blackCodeList.Select(x => new
  20906. {
  20907. x.Title,
  20908. x.Id
  20909. }),
  20910. FileTempList = new ArrayList()
  20911. {
  20912. new { Index = 1,FileName = "旧模板" },
  20913. new { Index = 2,FileName = "省外办" },
  20914. new { Index = 3,FileName = "市外办" },
  20915. }
  20916. };
  20917. var resultArr = new ArrayList();
  20918. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  20919. #region 默认不生成行程
  20920. //if (content.Count == 0)
  20921. //{
  20922. // var stay = "-";
  20923. // var cityPath = "-";
  20924. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20925. // .Where(x => x.DiId == diid && x.IsDel == 0)
  20926. // .ToList();
  20927. // //添加城市路径以及住宿地
  20928. // //黑屏代码数据
  20929. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  20930. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  20931. // {
  20932. // jw = JsonView(true, "黑屏代码有误!", data);
  20933. // return Ok(jw);
  20934. // }
  20935. // data = data with
  20936. // {
  20937. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  20938. // {
  20939. // x.Title,
  20940. // x.Id,
  20941. // }).ToArray())
  20942. // };
  20943. // foreach (DataRow row in dtBlack.Rows)
  20944. // {
  20945. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  20946. // {
  20947. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  20948. // return Ok(jw);
  20949. // }
  20950. // }
  20951. // //黑屏代码获取时间区间
  20952. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  20953. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  20954. // _sqlSugar.BeginTran();
  20955. // for (int i = 0; i < timeArr.Count; i++)
  20956. // {
  20957. // stay = "-";
  20958. // cityPath = "-";
  20959. // DateTime NewData = DateTime.Parse(timeArr[i]);
  20960. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  20961. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  20962. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  20963. // if (tbSelect.Length > 0)
  20964. // {
  20965. // List<string> threeCodeStr = new List<string>();
  20966. // foreach (var item in tbSelect)
  20967. // {
  20968. // var threeCode = item["Three"].ToString() ?? "";
  20969. // if (threeCode.Length == 6)
  20970. // {
  20971. // var start = threeCode.Substring(0, 3);
  20972. // var end = threeCode.Substring(3, 3);
  20973. // if (threeCodeStr.Count == 0)
  20974. // {
  20975. // threeCodeStr.Add(start);
  20976. // threeCodeStr.Add(end);
  20977. // }
  20978. // else
  20979. // {
  20980. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  20981. // {
  20982. // threeCodeStr.Add(end);
  20983. // }
  20984. // else
  20985. // {
  20986. // threeCodeStr.Add(start);
  20987. // threeCodeStr.Add(end);
  20988. // }
  20989. // }
  20990. // }
  20991. // }
  20992. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  20993. // var last = threeCodeStr.Last();
  20994. // foreach (var item in threeCodeStr)
  20995. // {
  20996. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  20997. // if (item.Equals(last))
  20998. // {
  20999. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21000. // }
  21001. // }
  21002. // cityPath = cityPath.Trim('-');
  21003. // }
  21004. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  21005. // appro.Diid = diid ?? -1;
  21006. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21007. // appro.Id = thisId;
  21008. // appro.CreateUserId = dto.UserId;
  21009. // appro.CreateTime = DateTime.Now;
  21010. // content.Add(appro);
  21011. // }
  21012. // _sqlSugar.CommitTran();
  21013. //}
  21014. #endregion
  21015. foreach (var x in content)
  21016. {
  21017. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  21018. if (chiList.Count < chiNumber)
  21019. {
  21020. for (int i = chiList.Count; i < chiNumber; i++)
  21021. {
  21022. chiList.Add(new Grp_ApprovalTravelDetails());
  21023. }
  21024. }
  21025. resultArr.Add(new
  21026. {
  21027. x.Id,
  21028. x.Date,
  21029. x.Diid,
  21030. chiList = chiList.Select(x1 => new
  21031. {
  21032. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21033. x1.Details,
  21034. x1.ParentId,
  21035. x1.Id
  21036. })
  21037. });
  21038. }
  21039. data = data with
  21040. {
  21041. content = resultArr,
  21042. };
  21043. jw = JsonView(true, "获取成功!", data);
  21044. return Ok(jw);
  21045. }
  21046. /// <summary>
  21047. /// 报批行程删除
  21048. /// </summary>
  21049. /// <param name="dto"></param>
  21050. /// <returns></returns>
  21051. [HttpPost]
  21052. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  21053. {
  21054. var jw = JsonView(false);
  21055. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21056. if (group == null)
  21057. {
  21058. jw.Msg = "团组参数有误!";
  21059. return Ok(jw);
  21060. }
  21061. try
  21062. {
  21063. _sqlSugar.BeginTran();
  21064. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  21065. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  21066. {
  21067. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21068. DeleteUserId = dto.uesrId,
  21069. IsDel = 1
  21070. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  21071. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  21072. {
  21073. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21074. DeleteUserId = dto.uesrId,
  21075. IsDel = 1
  21076. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  21077. _sqlSugar.CommitTran();
  21078. jw = JsonView(true, "删除成功");
  21079. }
  21080. catch (Exception ex)
  21081. {
  21082. jw = JsonView(false, ex.Message);
  21083. }
  21084. return Ok(jw);
  21085. }
  21086. /// <summary>
  21087. /// 报批行程保存
  21088. /// </summary>
  21089. /// <param name="dto"></param>
  21090. /// <returns></returns>
  21091. [HttpPost]
  21092. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  21093. {
  21094. var jw = JsonView(false);
  21095. var Find = dto.Arr.Find(x => x.id == 0);
  21096. if (Find != null)
  21097. {
  21098. jw.Msg = "生成的ID为0!";
  21099. return Ok(jw);
  21100. }
  21101. foreach (var item in dto.Arr)
  21102. {
  21103. foreach (var chi in item.chiList)
  21104. {
  21105. if (chi.parentId == 0)
  21106. {
  21107. chi.parentId = item.id;
  21108. }
  21109. }
  21110. }
  21111. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  21112. _sqlSugar.BeginTran();
  21113. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  21114. {
  21115. var parentIds = dto.Arr.Select(x => x.id).ToList();
  21116. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  21117. {
  21118. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21119. DeleteUserId = dto.UserId,
  21120. IsDel = 1
  21121. }).ExecuteCommand();
  21122. }
  21123. try
  21124. {
  21125. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  21126. {
  21127. CreateTime = DateTime.Now,
  21128. CreateUserId = dto.UserId,
  21129. Details = x.details,
  21130. ParentId = x.parentId,
  21131. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21132. Remark = "",
  21133. IsDel = 0
  21134. }).ToList()).ExecuteCommand();
  21135. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  21136. {
  21137. Id = x.id,
  21138. Details = x.details,
  21139. ParentId = x.parentId,
  21140. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21141. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  21142. {
  21143. Details = x.Details,
  21144. ParentId = x.ParentId,
  21145. Time = x.Time
  21146. }).ExecuteCommand();
  21147. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  21148. {
  21149. Id = x.id,
  21150. Date = x.date,
  21151. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  21152. {
  21153. Date = x.Date
  21154. }).ExecuteCommand();
  21155. _sqlSugar.CommitTran();
  21156. jw = JsonView(true, "保存成功!");
  21157. }
  21158. catch (Exception ex)
  21159. {
  21160. _sqlSugar.RollbackTran();
  21161. jw = JsonView(false, "保存失败!" + ex.Message);
  21162. }
  21163. return Ok(jw);
  21164. }
  21165. /// <summary>
  21166. /// 报批行程生成
  21167. /// </summary>
  21168. /// <param name="dto"></param>
  21169. /// <returns></returns>
  21170. [HttpPost]
  21171. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  21172. {
  21173. var jw = JsonView(false);
  21174. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21175. if (group == null)
  21176. {
  21177. jw.Msg = "暂无该团组!";
  21178. return Ok(jw);
  21179. }
  21180. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  21181. //黑屏代码数据
  21182. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  21183. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21184. {
  21185. jw.Msg = "黑屏代码有误!";
  21186. return Ok(jw);
  21187. }
  21188. foreach (DataRow row in dtBlack.Rows)
  21189. {
  21190. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21191. {
  21192. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  21193. return Ok(jw);
  21194. }
  21195. }
  21196. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  21197. var resultArr = new ArrayList();
  21198. //if (officialActivitiesArr.Count == 0)
  21199. //{
  21200. // jw.Msg = "暂无公务出访信息!";
  21201. // return Ok(jw);
  21202. //}
  21203. try
  21204. {
  21205. _sqlSugar.BeginTran();
  21206. DeleteApprovalJourney(new
  21207. Domain.Dtos.Groups.DeleteApprovalJourney
  21208. {
  21209. Diid = dto.Diid,
  21210. uesrId = dto.Userid
  21211. });
  21212. var stay = "-";
  21213. var cityPath = "-";
  21214. var arriveCountry = string.Empty;
  21215. //添加城市路径以及住宿地
  21216. //黑屏代码获取时间区间
  21217. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21218. var empty = "【未收入该三字码!请机票同事录入】";
  21219. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21220. #region 配置公务活动时间
  21221. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  21222. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  21223. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  21224. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  21225. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  21226. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21227. {
  21228. 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" }),
  21229. 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"}),
  21230. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21231. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  21232. };
  21233. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21234. {
  21235. 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" }),
  21236. 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"}),
  21237. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21238. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  21239. };
  21240. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  21241. {
  21242. 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" }),
  21243. 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"}),
  21244. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  21245. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  21246. };
  21247. #endregion
  21248. var nextDayNum = 0;
  21249. for (int i = 0; i < timeArr.Count; i++)
  21250. {
  21251. stay = "-";
  21252. cityPath = "-";
  21253. var chiarr = new List<Grp_ApprovalTravelDetails>();
  21254. DateTime NewData = DateTime.Parse(timeArr[i]);
  21255. //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();
  21256. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21257. if (nextDayNum > 0)
  21258. {
  21259. nextDayNum--;
  21260. }
  21261. if (tbSelect.Length > 0)
  21262. {
  21263. List<string> threeCodeStr = new List<string>();
  21264. bool isTrade = false;
  21265. string trip = string.Empty;
  21266. foreach (var item in tbSelect)
  21267. {
  21268. if (nextDayNum == 0)
  21269. {
  21270. nextDayNum = Convert.ToInt32(item["Sign"]);
  21271. }
  21272. var airStartTime = item["StartTime"].ToString() ?? "0000";
  21273. var airEndTime = item["EndTime"].ToString() ?? "0000";
  21274. var takeOffTime = DateTime.Parse(timeArr[i]);
  21275. var fallToTime = DateTime.Parse(timeArr[i]);
  21276. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  21277. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  21278. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  21279. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  21280. if (nextDayNum > 0)
  21281. {
  21282. fallToTime = fallToTime.AddDays(nextDayNum);
  21283. }
  21284. trip = string.Empty;
  21285. var start = string.Empty;
  21286. var end = string.Empty;
  21287. var threeCode = item["Three"].ToString() ?? "";
  21288. if (threeCode.Length == 6)
  21289. {
  21290. start = threeCode.Substring(0, 3);
  21291. end = threeCode.Substring(3, 3);
  21292. if (threeCodeStr.Count == 0)
  21293. {
  21294. threeCodeStr.Add(start);
  21295. threeCodeStr.Add(end);
  21296. }
  21297. else
  21298. {
  21299. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21300. {
  21301. threeCodeStr.Add(end);
  21302. }
  21303. else
  21304. {
  21305. threeCodeStr.Add(start);
  21306. threeCodeStr.Add(end);
  21307. }
  21308. }
  21309. }
  21310. //处理机票信息
  21311. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  21312. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  21313. if (start_Object == null)
  21314. {
  21315. start_Object = new Res_ThreeCode()
  21316. {
  21317. AirPort = empty,
  21318. AirPort_En = empty,
  21319. City = empty,
  21320. Country = empty,
  21321. Four = empty,
  21322. Three = empty,
  21323. };
  21324. }
  21325. if (end_Object == null)
  21326. {
  21327. end_Object = new Res_ThreeCode()
  21328. {
  21329. AirPort = empty,
  21330. AirPort_En = empty,
  21331. City = empty,
  21332. Country = empty,
  21333. Four = empty,
  21334. Three = empty,
  21335. };
  21336. }
  21337. //机型判断
  21338. string airModel = item["AirModel"].ToString();
  21339. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  21340. string flightTime = item["FlightTime"].ToString();
  21341. flightTime = ParseBlackTime(flightTime);
  21342. //航班号
  21343. string flightcode = item["Fliagtcode"].ToString();
  21344. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  21345. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  21346. if (aircompany == null)
  21347. {
  21348. aircompany = new Res_AirCompany
  21349. {
  21350. CnName = hsEmpty,
  21351. EnName = hsEmpty,
  21352. ShortCode = hsEmpty,
  21353. };
  21354. }
  21355. //航班前公务安排
  21356. if (tbSelect.First().Equals(item) && i != 0)
  21357. {
  21358. foreach (var takeoff in takeoffTimes)
  21359. {
  21360. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  21361. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  21362. {
  21363. foreach (var addTime in takeoff.Item2)
  21364. {
  21365. chiarr.Add(new Grp_ApprovalTravelDetails
  21366. {
  21367. Time = addTime,
  21368. CreateTime = DateTime.Now,
  21369. CreateUserId = dto.Userid,
  21370. ParentId = 0,
  21371. Details = "公务活动"
  21372. });
  21373. }
  21374. break;
  21375. }
  21376. }
  21377. }
  21378. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  21379. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  21380. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  21381. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  21382. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  21383. if (isTrade)
  21384. {
  21385. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  21386. trip += "(转机不出机场)。";
  21387. }
  21388. //else
  21389. //{
  21390. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  21391. //}
  21392. chiarr.Add(new Grp_ApprovalTravelDetails
  21393. {
  21394. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  21395. CreateTime = DateTime.Now,
  21396. CreateUserId = dto.Userid,
  21397. ParentId = 0,
  21398. Details = trip
  21399. });
  21400. //最后一条到达的时间安排公务
  21401. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  21402. {
  21403. bool isCheckCountry = false;
  21404. if (end_Object.Country != arriveCountry)
  21405. {
  21406. arriveCountry = end_Object.Country;
  21407. isCheckCountry = true;
  21408. }
  21409. if (nextDayNum == 0)
  21410. {
  21411. //需要入境的情况
  21412. if (isCheckCountry)
  21413. {
  21414. foreach (var fallTime in fallTimesCheckCountry)
  21415. {
  21416. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21417. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21418. {
  21419. foreach (var addTime in fallTime.Item2)
  21420. {
  21421. chiarr.Add(new Grp_ApprovalTravelDetails
  21422. {
  21423. Time = addTime,
  21424. CreateTime = DateTime.Now,
  21425. CreateUserId = dto.Userid,
  21426. ParentId = 0,
  21427. Details = "公务活动"
  21428. });
  21429. }
  21430. break;
  21431. }
  21432. }
  21433. }
  21434. else
  21435. {
  21436. foreach (var fallTime in fallTimesNotCheckCountry)
  21437. {
  21438. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21439. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21440. {
  21441. foreach (var addTime in fallTime.Item2)
  21442. {
  21443. chiarr.Add(new Grp_ApprovalTravelDetails
  21444. {
  21445. Time = addTime,
  21446. CreateTime = DateTime.Now,
  21447. CreateUserId = dto.Userid,
  21448. ParentId = 0,
  21449. Details = "公务活动"
  21450. });
  21451. }
  21452. break;
  21453. }
  21454. }
  21455. }
  21456. }
  21457. }
  21458. }
  21459. //添加乘车语句
  21460. //chiarr.Add(new Grp_ApprovalTravelDetails
  21461. //{
  21462. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  21463. // CreateTime = DateTime.Now,
  21464. // CreateUserId = dto.Userid,
  21465. // ParentId = 0,
  21466. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  21467. //});
  21468. //if (i != timeArr.Count - 1)
  21469. //{
  21470. // fallToTime = fallToTime.AddHours(2.5);
  21471. // foreach (var item in Times)
  21472. // {
  21473. // //排列公务时间
  21474. // if (fallToTime.Hour < item.Item1)
  21475. // {
  21476. // chiarr.Add(new Grp_ApprovalTravelDetails
  21477. // {
  21478. // Time = $"{item.Item2} - {item.Item3}",
  21479. // CreateTime = DateTime.Now,
  21480. // CreateUserId = dto.Userid,
  21481. // ParentId = 0,
  21482. // Details = "公务活动"
  21483. // });
  21484. // }
  21485. // }
  21486. //}
  21487. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21488. var last = threeCodeStr.Last();
  21489. foreach (var item in threeCodeStr)
  21490. {
  21491. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21492. if (item.Equals(last))
  21493. {
  21494. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21495. }
  21496. }
  21497. cityPath = cityPath.Trim('-');
  21498. }
  21499. else
  21500. {
  21501. foreach (var item in Times)
  21502. {
  21503. chiarr.Add(new Grp_ApprovalTravelDetails
  21504. {
  21505. Time = $"{item.Item2} - {item.Item3}",
  21506. CreateTime = DateTime.Now,
  21507. CreateUserId = dto.Userid,
  21508. ParentId = 0,
  21509. Details = "公务活动"
  21510. });
  21511. }
  21512. }
  21513. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21514. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21515. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  21516. appro.Diid = dto.Diid;
  21517. appro.CreateUserId = dto.Userid;
  21518. appro.CreateTime = DateTime.Now;
  21519. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21520. appro.Id = thisId;
  21521. //foreach (var item in gwinfo)
  21522. //{
  21523. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  21524. // chi.Details = "拜访" + item.Client;
  21525. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  21526. // {
  21527. // chi.Details += "," + item.ReqSample;
  21528. // }
  21529. // chi.ParentId = thisId;
  21530. // chi.Time = item.Time;
  21531. // chiarr.Add(chi);
  21532. //}
  21533. if (chiarr.Count < 6)
  21534. {
  21535. for (int j = chiarr.Count; j < 6; j++)
  21536. {
  21537. chiarr.Add(new
  21538. Grp_ApprovalTravelDetails());
  21539. }
  21540. }
  21541. resultArr.Add(new
  21542. {
  21543. appro.Id,
  21544. appro.Date,
  21545. appro.Diid,
  21546. chiList = chiarr.Select(x1 => new
  21547. {
  21548. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21549. x1.Details,
  21550. x1.ParentId,
  21551. x1.Id
  21552. })
  21553. });
  21554. }
  21555. _sqlSugar.CommitTran();
  21556. jw = JsonView(true, "生成成功!", resultArr);
  21557. }
  21558. catch (Exception ex)
  21559. {
  21560. jw.Code = 400;
  21561. jw.Msg = "生成失败!" + ex.Message;
  21562. }
  21563. return Ok(jw);
  21564. }
  21565. /// <summary>
  21566. /// 报批行程word导出
  21567. /// </summary>
  21568. /// <param name="dto"></param>
  21569. /// <returns></returns>
  21570. [HttpPost]
  21571. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  21572. {
  21573. var jw = JsonView(false);
  21574. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21575. if (group == null)
  21576. {
  21577. jw.Msg = "暂无该团组!";
  21578. return Ok(jw);
  21579. }
  21580. //模板路径
  21581. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  21582. var fileName = string.Empty;
  21583. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  21584. bool bold = false;
  21585. if (dto.FileIndex == 1)
  21586. {
  21587. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  21588. }
  21589. else if (dto.FileIndex == 2)
  21590. {
  21591. fileName = "省外办-报批.docx";
  21592. bold = false;
  21593. titleFont = "方正黑体简体";
  21594. timeFont = "Times New Roman";
  21595. contentFont = "方正仿宋_GBK";
  21596. }
  21597. else if (dto.FileIndex == 3)
  21598. {
  21599. fileName = "市外办-报批.docx";
  21600. titleFont = "方正黑体简体";
  21601. timeFont = "Times New Roman";
  21602. contentFont = "方正仿宋简体";
  21603. }
  21604. tempPath = tempPath + fileName;
  21605. //载入模板
  21606. Document doc = new Document(tempPath);
  21607. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21608. //获取所填表格的序数
  21609. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21610. Aspose.Words.Tables.Row titleRowClone = null;
  21611. Aspose.Words.Tables.Row CenterRowClone = null;
  21612. int index = 0;
  21613. int indexChi = 0;
  21614. int SetIndex = 0;
  21615. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  21616. //获取数据,放到datatable
  21617. foreach (var item in ApprovalTravelArr)
  21618. {
  21619. if (index > 0)
  21620. {
  21621. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  21622. tableOne.AppendChild(titleRowClone);
  21623. }
  21624. var textTime = item.Date;
  21625. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  21626. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  21627. SetIndex++;
  21628. if (ChiRep.Count > 0)
  21629. {
  21630. foreach (var itemChi in ChiRep)
  21631. {
  21632. var txtTime = itemChi.Time;
  21633. var txtDetail = itemChi.Details;
  21634. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  21635. {
  21636. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  21637. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21638. //indexChi++;
  21639. //SetIndex++;
  21640. break;
  21641. }
  21642. if (indexChi > 0)
  21643. {
  21644. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21645. tableOne.AppendChild(CenterRowClone);
  21646. }
  21647. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  21648. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  21649. indexChi++;
  21650. SetIndex++;
  21651. }
  21652. }
  21653. //else
  21654. //{
  21655. // if (indexChi > 0)
  21656. // {
  21657. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21658. // tableOne.AppendChild(CenterRowClone);
  21659. // }
  21660. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  21661. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21662. // indexChi++;
  21663. // SetIndex++;
  21664. //}
  21665. index++;
  21666. }
  21667. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  21668. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21669. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21670. jw.Code = 200;
  21671. jw.Msg = "";
  21672. return Ok(jw);
  21673. }
  21674. private string ParseBlackTime(string time)
  21675. {
  21676. // 匹配可能只有分钟的情况
  21677. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  21678. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  21679. if (match.Success)
  21680. {
  21681. string hours = match.Groups[1].Value;
  21682. string minutes = match.Groups[2].Value;
  21683. // 如果小时部分为空,则只显示分钟
  21684. if (string.IsNullOrEmpty(hours))
  21685. {
  21686. return $"{minutes}分钟";
  21687. }
  21688. // 如果分钟部分为空,则只显示小时
  21689. else if (string.IsNullOrEmpty(minutes))
  21690. {
  21691. return $"{hours}小时";
  21692. }
  21693. // 否则显示完整格式
  21694. else
  21695. {
  21696. return $"{hours}小时{minutes}分钟";
  21697. }
  21698. }
  21699. else
  21700. {
  21701. return "未知时长";
  21702. }
  21703. }
  21704. private string intToString(int numberVal)
  21705. {
  21706. string numberval = numberVal.ToString();
  21707. Dictionary<char, string> Number = new Dictionary<char, string>();
  21708. Number.Add('1', "一");
  21709. Number.Add('2', "二");
  21710. Number.Add('3', "三");
  21711. Number.Add('4', "四");
  21712. Number.Add('5', "五");
  21713. Number.Add('6', "六");
  21714. Number.Add('7', "七");
  21715. Number.Add('8', "八");
  21716. Number.Add('9', "九");
  21717. string stringNumberVal = string.Empty;
  21718. for (int i = 0; i < numberval.Length; i++)
  21719. {
  21720. if (i == 0)
  21721. {
  21722. stringNumberVal += Number[numberval[i]];
  21723. }
  21724. else if (i >= 1)
  21725. {
  21726. if (numberval[i] == '0')
  21727. {
  21728. stringNumberVal = "十";
  21729. }
  21730. else
  21731. {
  21732. stringNumberVal += "十" + Number[numberval[i]];
  21733. }
  21734. }
  21735. }
  21736. return stringNumberVal;
  21737. }
  21738. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  21739. {
  21740. //获取table中的某个单元格,从0开始
  21741. Cell lshCell = table.Rows[rows].Cells[cells];
  21742. //将单元格中段落移除
  21743. foreach (Paragraph item in lshCell.Paragraphs)
  21744. {
  21745. lshCell.Paragraphs.Remove(item);
  21746. }
  21747. if (val.Contains("\r\n"))
  21748. {
  21749. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  21750. foreach (var item in spArr)
  21751. {
  21752. //新建一个段落
  21753. Paragraph p = new Paragraph(doc);
  21754. var r = new Run(doc, item);
  21755. //设置字体
  21756. if (!string.IsNullOrEmpty(font))
  21757. {
  21758. r.Font.Name = font;
  21759. }
  21760. r.Font.Bold = bold;
  21761. //把设置的值赋给之前新建的段落
  21762. p.AppendChild(r);
  21763. //将此段落加到单元格内
  21764. lshCell.AppendChild(p);
  21765. }
  21766. }
  21767. else
  21768. {
  21769. //新建一个段落
  21770. Paragraph p = new Paragraph(doc);
  21771. var r = new Run(doc, val);
  21772. //设置字体
  21773. if (!string.IsNullOrEmpty(font))
  21774. {
  21775. r.Font.Name = font;
  21776. }
  21777. r.Font.Bold = bold;
  21778. //把设置的值赋给之前新建的段落
  21779. p.AppendChild(r);
  21780. //将此段落加到单元格内
  21781. lshCell.AppendChild(p);
  21782. }
  21783. }
  21784. /// <summary>
  21785. /// 报批行程AI续写
  21786. /// </summary>
  21787. /// <returns></returns>
  21788. [HttpPost]
  21789. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  21790. {
  21791. var jw = JsonView(false);
  21792. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  21793. {
  21794. jw.Msg = "参数有误!";
  21795. return Ok(jw);
  21796. }
  21797. KiMiApiClient kiMi = new KiMiApiClient();
  21798. List<SeedMessages> messages = new List<SeedMessages>() {
  21799. new SeedMessages
  21800. {
  21801. Role = KimiRole.system,
  21802. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  21803. },
  21804. new SeedMessages
  21805. {
  21806. Role = KimiRole.user,
  21807. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  21808. }
  21809. };
  21810. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  21811. string data = kimi_result.Choices[0]?.Message.Content;
  21812. if (string.IsNullOrWhiteSpace(data))
  21813. {
  21814. jw.Data = "Ai续写失败!";
  21815. }
  21816. else
  21817. {
  21818. jw = JsonView(true, "success!", data);
  21819. }
  21820. return Ok(jw);
  21821. }
  21822. #endregion
  21823. #region 团组接待意见调查
  21824. /// <summary>
  21825. /// 团组接待意见调查 - 信息管理
  21826. /// 基础数据(团组)
  21827. /// </summary>
  21828. /// <returns></returns>
  21829. [HttpGet]
  21830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21831. public async Task<IActionResult> OpinionaireInit()
  21832. {
  21833. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  21834. .Select(x => new
  21835. {
  21836. x.Id,
  21837. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  21838. })
  21839. .OrderByDescending(x => x.Id)
  21840. .ToListAsync();
  21841. return Ok(JsonView(groupData, groupData.Count));
  21842. }
  21843. /// <summary>
  21844. /// 团组接待意见调查 - 信息管理
  21845. /// 列表
  21846. /// </summary>
  21847. /// <param name="groupId"></param>
  21848. /// <returns></returns>
  21849. [HttpGet("{groupId}")]
  21850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21851. public async Task<IActionResult> OpinionaireManageList(int groupId)
  21852. {
  21853. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21854. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  21855. .Select(x => new
  21856. {
  21857. x.Id,
  21858. x.TourGuideName,
  21859. x.CityName,
  21860. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  21861. x.CreateTime
  21862. })
  21863. .OrderBy(x => x.Id)
  21864. .ToListAsync();
  21865. return Ok(JsonView(data));
  21866. }
  21867. /// <summary>
  21868. /// 团组接待意见调查 - 信息管理
  21869. /// 保存
  21870. /// </summary>
  21871. /// <param name="dto"></param>
  21872. /// <returns></returns>
  21873. [HttpPost]
  21874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21875. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  21876. {
  21877. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21878. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21879. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21880. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  21881. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  21882. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  21883. _opinionaireRep.BeginTran();
  21884. if (addData != null && addData.Count > 0)
  21885. {
  21886. foreach (var item in addData)
  21887. {
  21888. item.CreateUserId = currUserInfo.UserId;
  21889. item.DiId = dto.DiId;
  21890. }
  21891. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  21892. }
  21893. if (updData != null && updData.Count > 0)
  21894. {
  21895. var upd = await _opinionaireRep._sqlSugar
  21896. .Updateable(updData)
  21897. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  21898. .WhereColumns(x => new { x.Id })
  21899. .ExecuteCommandAsync();
  21900. }
  21901. _opinionaireRep.CommitTran();
  21902. return Ok(JsonView("操作成功!"));
  21903. }
  21904. /// <summary>
  21905. /// 团组接待意见调查 - 信息管理
  21906. /// 删除
  21907. /// </summary>
  21908. /// <param name="id"></param>
  21909. /// <returns></returns>
  21910. [HttpDelete("{id}")]
  21911. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21912. public async Task<IActionResult> OpinionaireManageDel(int id)
  21913. {
  21914. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21915. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21916. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  21917. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  21918. if (!del) return Ok(JsonView("操作失败!"));
  21919. return Ok(JsonView("操作成功!"));
  21920. }
  21921. /// <summary>
  21922. /// 团组接待意见调查 - 用户
  21923. /// 列表
  21924. /// </summary>
  21925. /// <param name="diId"></param>
  21926. /// <returns></returns>
  21927. [HttpGet("{diId}")]
  21928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21929. public async Task<IActionResult> OpinionaireUserList(int diId)
  21930. {
  21931. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21932. var sql = string.Format(@"
  21933. SELECT
  21934. o.Id,
  21935. o.DiId,
  21936. di.TeamName AS 'GroupName',
  21937. di.VisitPNumber AS 'PeopleNumber',
  21938. di.ClientName AS 'LeadGroup',
  21939. di.VisitCountry AS 'Travel',
  21940. di.VisitDays AS 'Days',
  21941. o.CityName,
  21942. o.TourGuideName,
  21943. o.Catering,
  21944. o.CateringReason,
  21945. o.Stay,
  21946. o.StayReason,
  21947. o.[Route],
  21948. o.RouteReason,
  21949. o.OfficialActivity,
  21950. o.OfficialActivityReason,
  21951. o.TourGuide,
  21952. o.TourGuideReason,
  21953. o.[Translate],
  21954. o.TranslateReason,
  21955. o.Trip,
  21956. o.TripReason,
  21957. o.ESFileName,
  21958. o.SignatureDate,
  21959. o.Remark
  21960. FROM
  21961. Grp_Opinionaire o
  21962. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  21963. WHERE
  21964. o.IsDel = 0
  21965. AND o.DiId = {0}
  21966. ORDER BY
  21967. o.Id ASC", diId);
  21968. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  21969. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  21970. return Ok(JsonView(data));
  21971. }
  21972. /// <summary>
  21973. /// 团组接待意见调查 - 用户
  21974. /// 保存
  21975. /// </summary>
  21976. /// <param name="dto"></param>
  21977. /// <returns></returns>
  21978. [HttpPost]
  21979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21980. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  21981. {
  21982. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  21983. foreach (var item in dto)
  21984. {
  21985. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  21986. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  21987. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  21988. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  21989. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  21990. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  21991. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  21992. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  21993. }
  21994. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  21995. if (!Directory.Exists(filePathBase))
  21996. {
  21997. Directory.CreateDirectory(filePathBase);
  21998. }
  21999. #region 上传文件
  22000. var filePaths = new List<string>();
  22001. foreach (var item in dto)
  22002. {
  22003. var file = item.File;
  22004. // 将文件保存到指定位置
  22005. var filePath = Path.Combine(filePathBase, file.FileName);
  22006. using (var stream = new FileStream(filePath, FileMode.Create))
  22007. {
  22008. await file.CopyToAsync(stream);
  22009. }
  22010. //验证文件是否上传成功
  22011. if (!System.IO.File.Exists(filePath))
  22012. {
  22013. foreach (var filePathStr in filePaths)
  22014. {
  22015. System.IO.File.Delete(filePathStr);
  22016. }
  22017. return Ok(JsonView(false, "文件上传失败!"));
  22018. }
  22019. item.ESFileName = file.FileName;
  22020. }
  22021. #endregion
  22022. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  22023. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  22024. .UpdateColumns(x => new
  22025. {
  22026. x.Catering,
  22027. x.CateringReason,
  22028. x.Stay,
  22029. x.StayReason,
  22030. x.Route,
  22031. x.RouteReason,
  22032. x.OfficialActivity,
  22033. x.OfficialActivityReason,
  22034. x.TourGuide,
  22035. x.TourGuideReason,
  22036. x.Translate,
  22037. x.TranslateReason,
  22038. x.Trip,
  22039. x.TripReason,
  22040. x.ESFileName,
  22041. x.SignatureDate,
  22042. x.Remark
  22043. })
  22044. .WhereColumns(x => new { x.Id })
  22045. .ExecuteCommandAsync();
  22046. if (upd < 1)
  22047. {
  22048. foreach (var filePathStr in filePaths)
  22049. {
  22050. System.IO.File.Delete(filePathStr);
  22051. }
  22052. return Ok(JsonView(false));
  22053. }
  22054. return Ok(JsonView(true));
  22055. }
  22056. #endregion
  22057. #region 团组餐厅相关信息
  22058. /// <summary>
  22059. /// 团组相关餐厅信息
  22060. /// 基础数据(团组)
  22061. /// </summary>
  22062. /// <returns></returns>
  22063. [HttpGet]
  22064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22065. public async Task<IActionResult> RestaurantInit()
  22066. {
  22067. return Ok(await _restaurantRep.InitAsync());
  22068. }
  22069. /// <summary>
  22070. /// 团组相关餐厅信息
  22071. /// Item
  22072. /// </summary>
  22073. /// <param name="dto"></param>
  22074. /// <returns></returns>
  22075. [HttpPost]
  22076. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22077. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  22078. {
  22079. int portType = dto.PortType,
  22080. groupId = dto.GroupId;
  22081. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22082. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22083. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  22084. }
  22085. /// <summary>
  22086. /// 团组相关餐厅信息
  22087. /// List
  22088. /// </summary>
  22089. /// <param name="dto"></param>
  22090. /// <returns></returns>
  22091. [HttpPost]
  22092. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22093. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  22094. {
  22095. int portType = dto.PortType,
  22096. groupId = dto.GroupId;
  22097. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22098. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22099. var sql = string.Format(@" SELECT
  22100. ri.Id,
  22101. ri.GroupId,
  22102. ri.Date,
  22103. ri.StartTime,
  22104. ri.EndTime,
  22105. CASE WHEN ri.Type = 1 THEN '早餐'
  22106. WHEN ri.Type = 2 THEN '午餐'
  22107. WHEN ri.Type = 3 THEN '晚餐'
  22108. ELSE '其他'
  22109. END AS 'Type',
  22110. ri.Name,
  22111. ri.Address,
  22112. ri.Tel,
  22113. ri.Remark,
  22114. ri.CreateTime,
  22115. u.CnName AS CreateUserName
  22116. FROM
  22117. Grp_RestaurantInfo ri
  22118. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  22119. WHERE
  22120. ri.IsDel = 0
  22121. AND ri.GroupId = {0}
  22122. ORDER BY
  22123. ri.Date ASC
  22124. ", groupId);
  22125. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  22126. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  22127. return Ok(JsonView(infos));
  22128. }
  22129. /// <summary>
  22130. /// 团组相关餐厅信息
  22131. /// Info
  22132. /// </summary>
  22133. /// <param name="dto"></param>
  22134. /// <returns></returns>
  22135. [HttpPost]
  22136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22137. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  22138. {
  22139. int portType = dto.PortType,
  22140. id = dto.Id;
  22141. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22142. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22143. return Ok(await _restaurantRep.InfoAsync(portType, id));
  22144. }
  22145. /// <summary>
  22146. /// 团组相关餐厅信息
  22147. /// Op
  22148. /// </summary>
  22149. /// <param name="dto"></param>
  22150. /// <returns></returns>
  22151. [HttpPost]
  22152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22153. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  22154. {
  22155. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22156. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22157. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  22158. return Ok(await _restaurantRep.OpAsync(dto));
  22159. }
  22160. /// <summary>
  22161. /// 团组相关餐厅信息
  22162. /// Del
  22163. /// </summary>
  22164. /// <param name="dto"></param>
  22165. /// <returns></returns>
  22166. [HttpPost]
  22167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22168. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  22169. {
  22170. int userId = dto.DeleteUserId;
  22171. var id = dto.Id;
  22172. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22173. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22174. return Ok(await _restaurantRep.DelAsync(dto));
  22175. }
  22176. #endregion
  22177. /// <summary>
  22178. /// 123132123
  22179. /// </summary>
  22180. /// <param name="_dto"></param>
  22181. /// <returns></returns>
  22182. [HttpPost]
  22183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22184. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  22185. {
  22186. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  22187. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  22188. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  22189. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  22190. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  22191. dicDetail.Add(789, 1034);
  22192. dicDetail.Add(790, 1035);
  22193. dicDetail.Add(791, 1036);
  22194. dicDetail.Add(792, 1037);
  22195. dicDetail.Add(793, 1038);
  22196. dicDetail.Add(794, 1039);
  22197. dicDetail.Add(795, 1040);
  22198. dicDetail.Add(796, 1041);
  22199. dicDetail.Add(797, 1042);
  22200. dicDetail.Add(798, 1043);
  22201. dicDetail.Add(801, 1044);
  22202. dicDetail.Add(802, 1045);
  22203. dicDetail.Add(803, 1046);
  22204. Dictionary<int, int> dic = new Dictionary<int, int>();
  22205. dic.Add(806, 1027);
  22206. dic.Add(807, 1028);
  22207. dic.Add(808, 1029);
  22208. dic.Add(809, 1030);
  22209. dic.Add(810, 1031);
  22210. dic.Add(811, 1032);
  22211. dic.Add(812, 1033);
  22212. foreach (var item in list_visa)
  22213. {
  22214. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  22215. temp.Coefficient = item.coefficient;
  22216. DateTime dtCrt;
  22217. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  22218. if (b1)
  22219. {
  22220. temp.CreateTime = dtCrt;
  22221. }
  22222. else
  22223. {
  22224. temp.CreateTime = DateTime.Now;
  22225. }
  22226. temp.CreateUserId = item.Operators;
  22227. temp.DeleteTime = "";
  22228. temp.DeleteUserId = 0;
  22229. temp.DiId = int.Parse(item.DIID);
  22230. temp.FilePath = item.FilePath;
  22231. temp.IsDel = item.IsDel;
  22232. temp.Price = item.Price;
  22233. temp.PriceCount = 1;
  22234. temp.PriceCurrency = item.Currency;
  22235. int detailId = 0;
  22236. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  22237. {
  22238. detailId = dicDetail[item.PriceTypeDetail];
  22239. }
  22240. temp.PriceDetailType = detailId;
  22241. temp.PriceDt = DateTime.Now;
  22242. temp.PriceName = item.PriceName;
  22243. temp.PriceSum = item.Price;
  22244. int tid = 0;
  22245. if (dic.ContainsKey(item.PriceType))
  22246. {
  22247. tid = dic[item.PriceType];
  22248. }
  22249. temp.PriceType = tid;
  22250. temp.Remark = item.Remark;
  22251. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  22252. }
  22253. return Ok(JsonView(true, "操作成功!"));
  22254. }
  22255. [HttpPost]
  22256. public IActionResult TimeTest()
  22257. {
  22258. var jw = JsonView(false, "error");
  22259. _sqlSugar.BeginTran();
  22260. try
  22261. {
  22262. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  22263. .Select(x => new Crm_NewClientData
  22264. {
  22265. Id = x.Id,
  22266. Client = x.Client,
  22267. Contact = x.Contact,
  22268. Location = x.Location,
  22269. })
  22270. .ToList();
  22271. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  22272. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  22273. Stopwatch stopwatch = new Stopwatch();
  22274. // 开始计时
  22275. stopwatch.Start();
  22276. foreach (var item in clientList)
  22277. {
  22278. EncryptionProcessor.DecryptProperties(item);
  22279. }
  22280. stopwatch.Stop();
  22281. jw.Code = 200;
  22282. jw.Data = stopwatch.ElapsedMilliseconds;
  22283. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  22284. }
  22285. catch (Exception ex)
  22286. {
  22287. jw.Code = 400;
  22288. jw.Msg = ex.Message;
  22289. }
  22290. return Ok(jw);
  22291. }
  22292. }
  22293. }