GroupsController.cs 1.2 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765
  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. #endregion
  4864. #region 文件上传、删除
  4865. /// <summary>
  4866. /// region 文件上传 可以带参数
  4867. /// </summary>
  4868. /// <param name="file"></param>
  4869. /// <returns></returns>
  4870. [HttpPost]
  4871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4872. public async Task<IActionResult> UploadProject(IFormFile file)
  4873. {
  4874. //var TypeName = Request.Headers["TypeName"].ToString();
  4875. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  4876. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4877. ////文件名称
  4878. //string projectFileName = file.FileName;
  4879. ////上传的文件的路径
  4880. //string filePath = $"{fileDir}/{projectFileName}";
  4881. //if (TypeName == "A")//A代表团组增减款项
  4882. //{
  4883. // filePath = fileDir + $@"\团组增减款项相关文件";
  4884. // if (!Directory.Exists(filePath))
  4885. // {
  4886. // Directory.CreateDirectory(filePath);
  4887. // }
  4888. // //上传的文件的路径
  4889. // filePath += $@"\{projectFileName}";
  4890. //}
  4891. //else if (TypeName == "B")//B代表商邀相关文件
  4892. //{
  4893. // //上传的文件的路径
  4894. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4895. // if (!Directory.Exists(filePath))
  4896. // {
  4897. // Directory.CreateDirectory(filePath);
  4898. // }
  4899. // //上传的文件的路径
  4900. // filePath = $@"\{projectFileName}";
  4901. //}
  4902. //try
  4903. //{
  4904. // using (FileStream fs = System.IO.File.Create(filePath))
  4905. // {
  4906. // file.CopyTo(fs);
  4907. // fs.Flush();
  4908. // }
  4909. //}
  4910. //catch (Exception ex)
  4911. //{
  4912. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  4913. //}
  4914. //return Ok(JsonView(true, "上传成功!", projectFileName));
  4915. try
  4916. {
  4917. var TypeName = Request.Headers["TypeName"].ToString();
  4918. if (file != null)
  4919. {
  4920. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4921. //文件名称
  4922. string projectFileName = file.FileName;
  4923. //上传的文件的路径
  4924. string filePath = $"{fileDir}/{projectFileName}";
  4925. if (TypeName == "A")//A代表团组增减款项
  4926. {
  4927. if (!Directory.Exists(fileDir))
  4928. {
  4929. Directory.CreateDirectory(fileDir);
  4930. }
  4931. //上传的文件的路径
  4932. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  4933. }
  4934. else if (TypeName == "B")//B代表商邀相关文件
  4935. {
  4936. if (!Directory.Exists(fileDir))
  4937. {
  4938. Directory.CreateDirectory(fileDir);
  4939. }
  4940. //上传的文件的路径
  4941. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  4942. }
  4943. using (FileStream fs = System.IO.File.Create(filePath))
  4944. {
  4945. file.CopyTo(fs);
  4946. fs.Flush();
  4947. }
  4948. return Ok(JsonView(true, "上传成功!", projectFileName));
  4949. }
  4950. else
  4951. {
  4952. return Ok(JsonView(false, "上传失败!"));
  4953. }
  4954. }
  4955. catch (Exception ex)
  4956. {
  4957. return Ok(JsonView(false, "程序错误!"));
  4958. }
  4959. }
  4960. /// <summary>
  4961. /// 删除指定文件
  4962. /// </summary>
  4963. /// <param name="dto"></param>
  4964. /// <returns></returns>
  4965. [HttpPost]
  4966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4967. public async Task<IActionResult> DelFile(DelFileDto dto)
  4968. {
  4969. try
  4970. {
  4971. var TypeName = Request.Headers["TypeName"].ToString();
  4972. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  4973. string filePath = "";
  4974. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4975. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  4976. int id = 0;
  4977. if (TypeName == "A")
  4978. {
  4979. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  4980. // 删除该文件
  4981. System.IO.File.Delete(filePath);
  4982. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  4983. .Where(a => a.Id == dto.Id)
  4984. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  4985. .ExecuteCommandAsync();
  4986. }
  4987. else if (TypeName == "B")
  4988. {
  4989. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  4990. // 删除该文件
  4991. System.IO.File.Delete(filePath);
  4992. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  4993. if (info != null)
  4994. {
  4995. string[] files = new string[] { };
  4996. if (!string.IsNullOrEmpty(info.Attachment))
  4997. {
  4998. try
  4999. {
  5000. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  5001. }
  5002. catch (Exception)
  5003. {
  5004. files = new List<string>() { info.Attachment }.ToArray();
  5005. }
  5006. }
  5007. if (files.Length > 0)
  5008. {
  5009. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  5010. string filePath2 = string.Empty;
  5011. if (files1.Length > 0)
  5012. {
  5013. filePath2 = JsonConvert.SerializeObject(files1);
  5014. }
  5015. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5016. .Where(a => a.Id == dto.Id)
  5017. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  5018. .ExecuteCommandAsync();
  5019. }
  5020. }
  5021. }
  5022. if (id != 0)
  5023. {
  5024. return Ok(JsonView(true, "成功!"));
  5025. }
  5026. else
  5027. {
  5028. return Ok(JsonView(false, "失败!"));
  5029. }
  5030. }
  5031. catch (Exception ex)
  5032. {
  5033. return Ok(JsonView(false, "程序错误!"));
  5034. throw;
  5035. }
  5036. }
  5037. /// <summary>
  5038. /// 文件上传多个文件 可以带参数
  5039. /// </summary>
  5040. /// <param name="files"></param>
  5041. /// <returns></returns>
  5042. [HttpPost]
  5043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5044. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  5045. {
  5046. try
  5047. {
  5048. var TypeName = Request.Headers["TypeName"].ToString();
  5049. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  5050. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  5051. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  5052. var filePahts = new List<string>();
  5053. foreach (var file in files)
  5054. {
  5055. //文件名称
  5056. string projectFileName = file.FileName;
  5057. //上传的文件的路径
  5058. string filePath = $"{fileDir}/{projectFileName}";
  5059. if (TypeName == "A")//A代表团组增减款项
  5060. {
  5061. if (!Directory.Exists(fileDir))
  5062. {
  5063. Directory.CreateDirectory(fileDir);
  5064. }
  5065. //上传的文件的路径
  5066. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  5067. }
  5068. else if (TypeName == "B")//B代表商邀相关文件
  5069. {
  5070. if (!Directory.Exists(fileDir))
  5071. {
  5072. Directory.CreateDirectory(fileDir);
  5073. }
  5074. //上传的文件的路径
  5075. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  5076. }
  5077. using (FileStream fs = System.IO.File.Create(filePath))
  5078. {
  5079. file.CopyTo(fs);
  5080. fs.Flush();
  5081. }
  5082. filePahts.Add(projectFileName);
  5083. }
  5084. return Ok(JsonView(true, "上传成功!", filePahts));
  5085. }
  5086. catch (Exception ex)
  5087. {
  5088. return Ok(JsonView(false, "程序错误!"));
  5089. }
  5090. }
  5091. #endregion
  5092. #region 商邀费用录入
  5093. /// <summary>
  5094. /// 根据团组Id查询商邀费用列表
  5095. /// </summary>
  5096. /// <param name="dto"></param>
  5097. /// <returns></returns>
  5098. [HttpPost]
  5099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5100. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  5101. {
  5102. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  5103. if (groupData.Code != 0)
  5104. {
  5105. return Ok(JsonView(false, groupData.Msg));
  5106. }
  5107. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5108. }
  5109. /// <summary>
  5110. /// 商邀费用列表
  5111. /// 下载文件
  5112. /// </summary>
  5113. /// <param name="id"></param>
  5114. /// <returns></returns>
  5115. [HttpGet("{id}")]
  5116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5117. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  5118. {
  5119. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  5120. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  5121. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  5122. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  5123. var filePaths = new List<string>();
  5124. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  5125. try
  5126. {
  5127. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  5128. }
  5129. catch (Exception ex)
  5130. {
  5131. filePaths.Add(info.Attachment);
  5132. }
  5133. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  5134. for (int i = 0; i < filePaths.Count; i++)
  5135. {
  5136. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  5137. }
  5138. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  5139. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  5140. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  5141. {
  5142. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  5143. {
  5144. foreach (string filePath in filePaths)
  5145. {
  5146. if (System.IO.File.Exists(filePath))
  5147. {
  5148. // 获取文件名
  5149. string fileName = Path.GetFileName(filePath);
  5150. // 将文件添加到ZIP归档中
  5151. zipArchive.CreateEntryFromFile(filePath, fileName);
  5152. }
  5153. }
  5154. }
  5155. }
  5156. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  5157. }
  5158. /// <summary>
  5159. /// 商邀费用 Info Page 基础数据源
  5160. /// </summary>
  5161. /// <returns></returns>
  5162. [HttpPost]
  5163. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5164. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  5165. {
  5166. try
  5167. {
  5168. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  5169. if (groupData.Code != 0)
  5170. {
  5171. return Ok(JsonView(false, groupData.Msg));
  5172. }
  5173. return Ok(JsonView(true, "操作成功", groupData.Data));
  5174. }
  5175. catch (Exception ex)
  5176. {
  5177. return Ok(JsonView(false, ex.Message));
  5178. throw;
  5179. }
  5180. }
  5181. /// <summary>
  5182. /// 根据商邀费用ID查询C表和商邀费用数据
  5183. /// </summary>
  5184. /// <param name="dto"></param>
  5185. /// <returns></returns>
  5186. [HttpPost]
  5187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5188. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  5189. {
  5190. try
  5191. {
  5192. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  5193. if (groupData.Code != 0)
  5194. {
  5195. return Ok(JsonView(false, groupData.Msg));
  5196. }
  5197. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5198. }
  5199. catch (Exception ex)
  5200. {
  5201. return Ok(JsonView(false, ex.Message));
  5202. throw;
  5203. }
  5204. }
  5205. /// <summary>
  5206. /// 商邀费用录入操作(Status:1.新增,2.修改)
  5207. /// </summary>
  5208. /// <param name="dto"></param>
  5209. /// <returns></returns>
  5210. [HttpPost]
  5211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5212. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  5213. {
  5214. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  5215. if (groupData.Code != 0)
  5216. {
  5217. return Ok(JsonView(false, groupData.Msg));
  5218. }
  5219. #region 应用推送
  5220. try
  5221. {
  5222. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5223. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5224. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5225. //2024-10-21 新增LZ UID
  5226. var userIds = new List<int>() { 21 };
  5227. string title = $"系统通知";
  5228. string content = "";
  5229. var diId = dto.DiId;
  5230. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5231. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5232. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5233. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5234. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5235. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  5236. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  5237. }
  5238. catch (Exception ex)
  5239. {
  5240. }
  5241. #endregion
  5242. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5243. }
  5244. /// <summary>
  5245. /// 商邀删除
  5246. /// </summary>
  5247. /// <param name="dto"></param>
  5248. /// <returns></returns>
  5249. [HttpPost]
  5250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5251. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  5252. {
  5253. try
  5254. {
  5255. _sqlSugar.BeginTran();
  5256. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  5257. .SetColumns(it => new Grp_InvitationOfficialActivities()
  5258. {
  5259. IsDel = 1,
  5260. DeleteUserId = dto.DeleteUserId,
  5261. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5262. })
  5263. .Where(it => it.Id == dto.Id)
  5264. .ExecuteCommand();
  5265. if (res1 > 0)
  5266. {
  5267. int _diId = 0;
  5268. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  5269. if (_ioaInfo != null)
  5270. {
  5271. _diId = _ioaInfo.DiId;
  5272. }
  5273. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5274. .SetColumns(a => new Grp_CreditCardPayment()
  5275. {
  5276. IsDel = 1,
  5277. DeleteUserId = dto.DeleteUserId,
  5278. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5279. })
  5280. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  5281. .ExecuteCommand();
  5282. if (res2 > 0)
  5283. {
  5284. _sqlSugar.CommitTran();
  5285. return Ok(JsonView(true, "删除成功!"));
  5286. }
  5287. }
  5288. _sqlSugar.RollbackTran();
  5289. return Ok(JsonView(false, "删除失败"));
  5290. }
  5291. catch (Exception ex)
  5292. {
  5293. _sqlSugar.RollbackTran();
  5294. return Ok(JsonView(false, ex.Message));
  5295. }
  5296. }
  5297. #endregion
  5298. #region 票据上传
  5299. /// <summary>
  5300. /// 团组模块文件上传
  5301. /// </summary>
  5302. /// <param name="dto"></param>
  5303. /// <returns></returns>
  5304. [HttpPost]
  5305. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  5306. {
  5307. var jw = JsonView(false);
  5308. long M = 1024 * 1024;
  5309. if (dto.Files == null || dto.Files.Count == 0)
  5310. {
  5311. jw.Msg = "无文件信息!";
  5312. return Ok(jw);
  5313. }
  5314. if (dto.Files.Sum(x => x.Length) > 20 * M)
  5315. {
  5316. jw.Msg = "文件大小超过20M!";
  5317. return Ok(jw);
  5318. }
  5319. //var nameSp = dto.File.FileName.Split(".");
  5320. //if (nameSp.Length < 2)
  5321. //{
  5322. // jw.Msg = "拓展名称有误!";
  5323. // return Ok(jw);
  5324. //}
  5325. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  5326. //if (!existsName.Contains(nameSp[1].ToUpper()))
  5327. //{
  5328. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  5329. // return Ok(jw);
  5330. //}
  5331. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  5332. if (Ctable == null)
  5333. {
  5334. jw.Msg = "Ctable指向有误!";
  5335. return Ok(jw);
  5336. }
  5337. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5338. if (groupInfo == null)
  5339. {
  5340. jw.Msg = "团组信息不存在!";
  5341. return Ok(jw);
  5342. }
  5343. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  5344. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5345. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5346. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5347. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  5348. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  5349. try
  5350. {
  5351. if (!Directory.Exists(fileBase))
  5352. {
  5353. Directory.CreateDirectory(fileBase);
  5354. }
  5355. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  5356. foreach (var fileStream in dto.Files)
  5357. {
  5358. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  5359. Grp_GroupModelFile file = new Grp_GroupModelFile()
  5360. {
  5361. Cid = dto.Cid,
  5362. CreateTime = DateTime.Now,
  5363. CreateUserId = dto.Userid,
  5364. Ctable = dto.Ctable,
  5365. Diid = dto.Diid,
  5366. IsDel = 0,
  5367. FilePath = saveFilePath,
  5368. FileName = fileStream.FileName
  5369. };
  5370. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5371. {
  5372. fileStream.CopyTo(fs);
  5373. fs.Flush();
  5374. }
  5375. saveArr.Add(file);
  5376. }
  5377. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  5378. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  5379. jw = JsonView(true, "保存成功!", new
  5380. {
  5381. count = addResult,
  5382. filesName = saveArr.Select(x => x.FileName)
  5383. });
  5384. }
  5385. catch (Exception ex)
  5386. {
  5387. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  5388. {
  5389. count = 0,
  5390. filesName = new string[0],
  5391. });
  5392. }
  5393. return Ok(jw);
  5394. }
  5395. /// <summary>
  5396. /// 查询各模块已保存文件
  5397. /// </summary>
  5398. /// <param name="dto"></param>
  5399. /// <returns></returns>
  5400. [HttpPost]
  5401. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  5402. {
  5403. var expression = Expressionable.Create<Grp_GroupModelFile>()
  5404. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  5405. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  5406. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  5407. {
  5408. expression = Expressionable.Create<Grp_GroupModelFile>()
  5409. .And(x => visaIds.Contains(x.CreateUserId));
  5410. }
  5411. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  5412. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  5413. .Where(expression.ToExpression())
  5414. .ToList();
  5415. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  5416. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  5417. {
  5418. x.FileName,
  5419. x.Id,
  5420. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  5421. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  5422. })));
  5423. }
  5424. /// <summary>
  5425. /// 下载该团组下的所有文件
  5426. /// </summary>
  5427. /// <param name="dto"></param>
  5428. /// <returns></returns>
  5429. [HttpPost]
  5430. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  5431. {
  5432. var jw = JsonView(false);
  5433. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5434. if (groupInfo == null)
  5435. {
  5436. jw.Msg = "团组信息不存在!";
  5437. return Ok(jw);
  5438. }
  5439. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  5440. var isModule = Convert.ToBoolean(dto.isModule);
  5441. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5442. IOOperatorHelper io = new IOOperatorHelper();
  5443. if (isModule)
  5444. {
  5445. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  5446. foreach (var moduleArr in moduleGroup)
  5447. {
  5448. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  5449. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5450. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5451. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  5452. foreach (var item in moduleArr)
  5453. {
  5454. if (System.IO.File.Exists(item.FilePath))
  5455. {
  5456. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5457. {
  5458. byte[] bytes = new byte[fileStream.Length];
  5459. fileStream.Read(bytes, 0, bytes.Length);
  5460. fileStream.Close();
  5461. Stream stream = new MemoryStream(bytes);
  5462. chiZips.Add(item.FileName, stream);
  5463. }
  5464. }
  5465. }
  5466. if (chiZips.Count > 0)
  5467. {
  5468. var byts = io.ConvertZipStream(chiZips);
  5469. Stream stream = new MemoryStream(byts);
  5470. Zips.Add(key.Name + "_.zip", stream);
  5471. }
  5472. }
  5473. }
  5474. else
  5475. {
  5476. foreach (var item in dbQuery)
  5477. {
  5478. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5479. {
  5480. byte[] bytes = new byte[fileStream.Length];
  5481. fileStream.Read(bytes, 0, bytes.Length);
  5482. fileStream.Close();
  5483. Stream stream = new MemoryStream(bytes);
  5484. while (Zips.Keys.Contains(item.FileName))
  5485. {
  5486. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5487. }
  5488. Zips.Add(item.FileName, stream);
  5489. }
  5490. }
  5491. }
  5492. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5493. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5494. if (Zips.Count > 0)
  5495. {
  5496. var byts = io.ConvertZipStream(Zips);
  5497. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5498. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  5499. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  5500. }
  5501. else
  5502. {
  5503. jw.Msg = "暂无生成文件!";
  5504. }
  5505. return Ok(jw);
  5506. }
  5507. /// <summary>
  5508. /// 下载该团组下此模块的所有文件
  5509. /// </summary>
  5510. /// <param name="dto"></param>
  5511. /// <returns></returns>
  5512. [HttpPost]
  5513. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  5514. {
  5515. var jw = JsonView(false);
  5516. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  5517. if (groupInfo == null)
  5518. {
  5519. jw.Msg = "团组信息不存在!";
  5520. return Ok(jw);
  5521. }
  5522. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  5523. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  5524. && x.IsDel == 0);
  5525. if (key == null)
  5526. {
  5527. jw.Msg = "Ctable指向错误!";
  5528. return Ok(jw);
  5529. }
  5530. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  5531. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5532. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  5533. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  5534. IOOperatorHelper io = new IOOperatorHelper();
  5535. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5536. foreach (var item in dbQuery)
  5537. {
  5538. if (System.IO.File.Exists(item.FilePath))
  5539. {
  5540. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  5541. {
  5542. byte[] bytes = new byte[fileStream.Length];
  5543. fileStream.Read(bytes, 0, bytes.Length);
  5544. fileStream.Close();
  5545. Stream stream = new MemoryStream(bytes);
  5546. while (Zips.Keys.Contains(item.FileName))
  5547. {
  5548. item.FileName = new Random().Next(100) + "_" + item.FileName;
  5549. }
  5550. Zips.Add(item.FileName, stream);
  5551. }
  5552. }
  5553. }
  5554. if (Zips.Count > 0)
  5555. {
  5556. var byts = io.ConvertZipStream(Zips);
  5557. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  5558. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  5559. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  5560. }
  5561. else
  5562. {
  5563. jw.Msg = "暂无生成文件!";
  5564. }
  5565. return Ok(jw);
  5566. }
  5567. /// <summary>
  5568. /// 删除该团组下的指定文件
  5569. /// </summary>
  5570. /// <param name="dto"></param>
  5571. /// <returns></returns>
  5572. [HttpPost]
  5573. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  5574. {
  5575. var jw = JsonView(false);
  5576. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5577. if (sing == null)
  5578. {
  5579. jw.Msg = "暂无";
  5580. return Ok(jw);
  5581. }
  5582. if (System.IO.File.Exists(sing.FilePath))
  5583. {
  5584. try
  5585. {
  5586. System.IO.File.Delete(sing.FilePath);
  5587. }
  5588. catch (Exception ex)
  5589. {
  5590. jw.Msg = "删除失败!" + ex.Message;
  5591. return Ok(jw);
  5592. }
  5593. }
  5594. sing.IsDel = 1;
  5595. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5596. sing.DeleteUserId = dto.UserId;
  5597. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  5598. jw = JsonView(true, "删除成功!");
  5599. return Ok(jw);
  5600. }
  5601. #endregion
  5602. #region 共享文件上传
  5603. /// <summary>
  5604. /// 共享文件数据初始化
  5605. /// </summary>
  5606. /// <returns></returns>
  5607. [HttpGet]
  5608. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  5609. {
  5610. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  5611. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  5612. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  5613. .Select(x => x.Id)
  5614. .ToList()
  5615. .Contains(userid);
  5616. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  5617. .Where(x => x.STid == 111 && x.IsDel == 0)
  5618. .Select(x => new
  5619. {
  5620. x.Name,
  5621. x.Id,
  5622. }).ToList();
  5623. if (isMarketingDepartment)
  5624. {
  5625. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  5626. }
  5627. if (portType == 1)
  5628. {
  5629. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  5630. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  5631. .Where(x => x.IsDel == 0)
  5632. .OrderByDescending(x => x.VisitDate)
  5633. .Select(x => new
  5634. {
  5635. x.TeamName,
  5636. x.Id,
  5637. x.CityId,
  5638. })
  5639. .ToList()
  5640. .Select(x =>
  5641. {
  5642. var provinceId = x.CityId;
  5643. var isDefualtVal = true;
  5644. if (provinceId > 0)
  5645. {
  5646. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  5647. if (parentId != null)
  5648. {
  5649. isDefualtVal = false;
  5650. provinceId = (int)parentId;
  5651. }
  5652. }
  5653. if (isDefualtVal)
  5654. {
  5655. provinceId = 122; //默认四川
  5656. }
  5657. return new
  5658. {
  5659. x.TeamName,
  5660. x.Id,
  5661. provinceId,
  5662. };
  5663. })
  5664. .ToList();
  5665. return Ok(JsonView(true, "SUCCESS!", new
  5666. {
  5667. dropDownType,
  5668. dropDownGroupList,
  5669. isMarketingDepartment
  5670. }));
  5671. }
  5672. else if (portType == 2 || portType == 3)
  5673. {
  5674. return Ok(JsonView(true, "SUCCESS!", new
  5675. {
  5676. dropDownType,
  5677. isMarketingDepartment
  5678. }));
  5679. }
  5680. else
  5681. {
  5682. return Ok(JsonView(false, "portType有误!"));
  5683. }
  5684. }
  5685. /// <summary>
  5686. /// 共享文件上传
  5687. /// </summary>
  5688. /// <param name="dto"></param>
  5689. /// <returns></returns>
  5690. [HttpPost]
  5691. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  5692. {
  5693. var isGroup = new List<int> { 1412 };
  5694. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  5695. {
  5696. return Ok(JsonView(false, "该文件需要关联团组!"));
  5697. }
  5698. if (dto.Files == null || dto.Files.Count == 0)
  5699. {
  5700. return Ok(JsonView(false, "无文件信息!"));
  5701. }
  5702. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  5703. {
  5704. return Ok(JsonView(false, "文件大小超过20M!"));
  5705. }
  5706. if (dto.Userid < 1)
  5707. {
  5708. return Ok(JsonView(false, "请传入有效的Userid!"));
  5709. }
  5710. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  5711. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  5712. .Select((u, j) => new
  5713. {
  5714. u.CnName,
  5715. UserId = u.Id,
  5716. j.JobName,
  5717. })
  5718. .First();
  5719. if (jobInfo == null)
  5720. {
  5721. return Ok(JsonView(false, "请传入有效的Userid!"));
  5722. }
  5723. List<string> commonFileExtensions = new List<string>
  5724. {
  5725. // 文本文件
  5726. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  5727. // 图片文件
  5728. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  5729. // 视频文件
  5730. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  5731. // 音频文件
  5732. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  5733. // 压缩文件
  5734. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  5735. // 数据文件
  5736. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  5737. };
  5738. try
  5739. {
  5740. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  5741. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  5742. commonFileExtensions.AddRange(settingExtend);
  5743. }
  5744. catch (Exception)
  5745. { }
  5746. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  5747. if (setdata == null)
  5748. {
  5749. return Ok(JsonView(false, "请传入有效的FileType!"));
  5750. }
  5751. List<Grp_GroupShareFile> insertList = new List<Grp_GroupShareFile>();
  5752. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  5753. if (!Directory.Exists(winPath))
  5754. {
  5755. Directory.CreateDirectory(winPath);
  5756. }
  5757. foreach (var item in dto.Files)
  5758. {
  5759. var houzui = Path.GetExtension(item.FileName);
  5760. if (!commonFileExtensions.Contains(houzui))
  5761. {
  5762. return Ok(JsonView(false, "未知后缀名称!"));
  5763. }
  5764. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  5765. var saveFilePath = winPath + fileName;
  5766. using (FileStream fs = System.IO.File.Create(saveFilePath))
  5767. {
  5768. item.CopyTo(fs);
  5769. fs.Flush();
  5770. }
  5771. var fileDetail = new Grp_GroupShareFile()
  5772. {
  5773. CreateUserId = dto.Userid,
  5774. CreateTime = DateTime.Now,
  5775. UploadJob = jobInfo.JobName,
  5776. FileName = fileName,
  5777. FileType = dto.FileType,
  5778. Diid = dto.Diid,
  5779. FilePath = winPath + fileName,
  5780. };
  5781. insertList.Add(fileDetail);
  5782. }
  5783. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  5784. return Ok(JsonView(true, "保存成功!"));
  5785. }
  5786. /// <summary>
  5787. /// 查询共享文件列表
  5788. /// </summary>
  5789. /// <param name="dto"></param>
  5790. /// <returns></returns>
  5791. [HttpPost]
  5792. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  5793. {
  5794. var isGroup = new List<int> { 1412 };
  5795. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  5796. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  5797. .And(x => x.Diid == dto.Diid)
  5798. .And(x => x.FileType == dto.FileType)
  5799. .And(x => x.IsDel == 0)
  5800. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  5801. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  5802. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  5803. int totalCount = 0;
  5804. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  5805. .Where(queryExpression.ToExpression())
  5806. .OrderBy(x => x.UploadJob)
  5807. .Select(x => new
  5808. {
  5809. x.Id,
  5810. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  5811. x.FileName,
  5812. x.FileType,
  5813. x.CreateTime,
  5814. })
  5815. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  5816. return Ok(JsonView(true, "SUCCESS!", new
  5817. {
  5818. FileList = dbQuery,
  5819. dto.PageSize,
  5820. dto.PageIndex,
  5821. totalCount
  5822. }));
  5823. }
  5824. /// <summary>
  5825. /// 删除共享文件模块下的指定文件
  5826. /// </summary>
  5827. /// <param name="dto"></param>
  5828. /// <returns></returns>
  5829. [HttpPost]
  5830. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  5831. {
  5832. var jw = JsonView(false);
  5833. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  5834. if (sing == null)
  5835. {
  5836. jw.Msg = "暂无文件信息!";
  5837. return Ok(jw);
  5838. }
  5839. if (sing.CreateUserId != dto.UserId)
  5840. {
  5841. jw.Msg = "只能删除自己上传的文件!";
  5842. return Ok(jw);
  5843. }
  5844. if (System.IO.File.Exists(sing.FilePath))
  5845. {
  5846. try
  5847. {
  5848. System.IO.File.Delete(sing.FilePath);
  5849. }
  5850. catch (Exception ex)
  5851. {
  5852. jw.Msg = "删除失败!" + ex.Message;
  5853. return Ok(jw);
  5854. }
  5855. }
  5856. sing.IsDel = 1;
  5857. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  5858. sing.DeleteUserId = dto.UserId;
  5859. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  5860. jw = JsonView(true, "删除成功!");
  5861. return Ok(jw);
  5862. }
  5863. #endregion
  5864. #region 团组英文资料
  5865. /// <summary>
  5866. /// 查询团组英文所有资料
  5867. /// </summary>
  5868. /// <param name="dto"></param>
  5869. /// <returns></returns>
  5870. [HttpPost]
  5871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5872. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  5873. {
  5874. try
  5875. {
  5876. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  5877. if (groupData.Code != 0)
  5878. {
  5879. return Ok(JsonView(false, groupData.Msg));
  5880. }
  5881. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5882. }
  5883. catch (Exception ex)
  5884. {
  5885. return Ok(JsonView(false, "程序错误!"));
  5886. throw;
  5887. }
  5888. }
  5889. /// <summary>
  5890. /// 团组英文资料操作(Status:1.新增,2.修改)
  5891. /// </summary>
  5892. /// <param name="dto"></param>
  5893. /// <returns></returns>
  5894. [HttpPost]
  5895. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5896. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  5897. {
  5898. try
  5899. {
  5900. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  5901. if (groupData.Code != 0)
  5902. {
  5903. return Ok(JsonView(false, groupData.Msg));
  5904. }
  5905. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5906. }
  5907. catch (Exception ex)
  5908. {
  5909. return Ok(JsonView(false, "程序错误!"));
  5910. throw;
  5911. }
  5912. }
  5913. /// <summary>
  5914. /// 团组英文资料Id查询数据
  5915. /// </summary>
  5916. /// <param name="dto"></param>
  5917. /// <returns></returns>
  5918. [HttpPost]
  5919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5920. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  5921. {
  5922. try
  5923. {
  5924. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  5925. if (_DelegationEnData != null)
  5926. {
  5927. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  5928. }
  5929. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  5930. }
  5931. catch (Exception ex)
  5932. {
  5933. return Ok(JsonView(false, "程序错误!"));
  5934. throw;
  5935. }
  5936. }
  5937. /// <summary>
  5938. /// 团组英文资料删除
  5939. /// </summary>
  5940. /// <param name="dto"></param>
  5941. /// <returns></returns>
  5942. [HttpPost]
  5943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5944. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  5945. {
  5946. try
  5947. {
  5948. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  5949. if (!res)
  5950. {
  5951. return Ok(JsonView(false, "删除失败"));
  5952. }
  5953. return Ok(JsonView(true, "删除成功!"));
  5954. }
  5955. catch (Exception ex)
  5956. {
  5957. return Ok(JsonView(false, "程序错误!"));
  5958. throw;
  5959. }
  5960. }
  5961. #endregion
  5962. #region 导出邀请函
  5963. /// <summary>
  5964. /// 导出邀请函页面初始化
  5965. /// </summary>
  5966. /// <param name="dto"></param>
  5967. /// <returns></returns>
  5968. [HttpPost]
  5969. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5970. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  5971. {
  5972. try
  5973. {
  5974. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  5975. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  5976. if (dto.DiId == 0)
  5977. {
  5978. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  5979. }
  5980. else
  5981. {
  5982. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  5983. }
  5984. return Ok(JsonView(true, "查询成功!", new
  5985. {
  5986. deleClient = crm_Deles,
  5987. delegations = grp_Delegations
  5988. }));
  5989. }
  5990. catch (Exception ex)
  5991. {
  5992. return Ok(JsonView(false, "程序错误!"));
  5993. throw;
  5994. }
  5995. }
  5996. /// <summary>
  5997. /// 导出邀请函
  5998. /// </summary>
  5999. /// <param name="dto"></param>
  6000. /// <returns></returns>
  6001. [HttpPost]
  6002. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6003. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  6004. {
  6005. #region 参数验证
  6006. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  6007. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  6008. #endregion
  6009. try
  6010. {
  6011. Dictionary<string, string> transDic = new Dictionary<string, string>();
  6012. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  6013. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  6014. From Grp_TourClientList tcl
  6015. Left Join
  6016. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  6017. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  6018. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  6019. From Crm_DeleClient dc
  6020. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  6021. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  6022. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  6023. Where dc.IsDel = 0) temp
  6024. On temp.DcId =tcl.ClientId
  6025. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  6026. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  6027. List<string> texts = new List<string>();
  6028. if (datas.Count != 0)
  6029. {
  6030. foreach (TourClientListDetailsView item in datas)
  6031. {
  6032. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  6033. {
  6034. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  6035. }
  6036. else
  6037. {
  6038. string name = item.LastName + item.FirstName;
  6039. texts.Add(name);
  6040. }
  6041. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  6042. {
  6043. if (!transDic.ContainsKey(item.Job))
  6044. {
  6045. texts.Add(item.Job);
  6046. }
  6047. }
  6048. if (!string.IsNullOrEmpty(item.CompanyFullName))
  6049. {
  6050. texts.Add(item.CompanyFullName);
  6051. }
  6052. }
  6053. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  6054. if (transData.Count > 0)
  6055. {
  6056. foreach (TranslateResult item in transData)
  6057. {
  6058. if (!transDic.ContainsKey(item.Query))
  6059. {
  6060. transDic.Add(item.Query, item.Translation);
  6061. }
  6062. }
  6063. }
  6064. List<GuestList> list = new List<GuestList>();
  6065. foreach (TourClientListDetailsView dele in datas)
  6066. {
  6067. GuestList guestList = new GuestList();
  6068. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  6069. {
  6070. guestList.Name = dele.Pinyin;
  6071. }
  6072. else
  6073. {
  6074. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  6075. guestList.Name = Name;
  6076. }
  6077. if (dele.Sex == 0)
  6078. {
  6079. guestList.Sex = "Male";
  6080. }
  6081. else if (dele.Sex == 1)
  6082. {
  6083. guestList.Sex = "Female";
  6084. }
  6085. guestList.DOB = dele.BirthDay.Replace('-', '.');
  6086. if (!string.IsNullOrEmpty(dele.Job))
  6087. {
  6088. guestList.Job = dele.Job;
  6089. }
  6090. list.Add(guestList);
  6091. }
  6092. //载入模板
  6093. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  6094. DocumentBuilder builder = new DocumentBuilder(doc);
  6095. //获取word里所有表格
  6096. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6097. //获取所填表格的序数
  6098. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6099. var rowStart = tableOne.Rows[0]; //获取第1行
  6100. //循环赋值
  6101. for (int i = 0; i < list.Count; i++)
  6102. {
  6103. builder.MoveToCell(0, i + 1, 0, 0);
  6104. builder.Write(list[i].Name.ToString());
  6105. builder.MoveToCell(0, i + 1, 1, 0);
  6106. builder.Write(list[i].Sex.ToString());
  6107. builder.MoveToCell(0, i + 1, 2, 0);
  6108. builder.Write(list[i].DOB.ToString());
  6109. builder.MoveToCell(0, i + 1, 3, 0);
  6110. builder.Write(list[i].Job.ToString());
  6111. }
  6112. //删除多余行
  6113. while (tableOne.Rows.Count > list.Count + 1)
  6114. {
  6115. tableOne.Rows.RemoveAt(list.Count + 1);
  6116. }
  6117. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6118. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  6119. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  6120. doc.Save(filePath);
  6121. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  6122. return Ok(JsonView(true, "操作成功!", Url));
  6123. }
  6124. else
  6125. {
  6126. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  6127. }
  6128. }
  6129. catch (Exception ex)
  6130. {
  6131. return Ok(JsonView(false, ex.Message));
  6132. throw;
  6133. }
  6134. }
  6135. #endregion
  6136. #region 团组经理模块 出入境费用
  6137. /// <summary>
  6138. /// 团组模块 - 出入境费用 - 省份基础数据源
  6139. /// </summary>
  6140. /// <returns></returns>
  6141. [HttpGet]
  6142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6143. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  6144. {
  6145. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  6146. }
  6147. /// <summary>
  6148. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  6149. /// </summary>
  6150. /// <returns></returns>
  6151. [HttpPost]
  6152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6153. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  6154. {
  6155. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  6156. var groupNamFirst = groupNameData.FirstOrDefault();
  6157. //SetDataInfoView
  6158. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  6159. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6160. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6161. //验证城市归属并给默认值
  6162. int provinceId = 122;
  6163. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  6164. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  6165. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  6166. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  6167. return Ok(JsonView(true, "查询成功!", new
  6168. {
  6169. GroupNameData = groupNameData,
  6170. CurrencyData = _CurrencyData,
  6171. WordTypeData = wordTypeData,
  6172. ExcelTypeData = excelTypeData,
  6173. CurrencyInit = _currencyInfos,
  6174. ViewPermissionData = viewPermissionData
  6175. }));
  6176. }
  6177. /// <summary>
  6178. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  6179. /// </summary>
  6180. /// <returns></returns>
  6181. [HttpGet("{provinceId}")]
  6182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6183. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  6184. {
  6185. //验证城市归属并给默认值
  6186. if (provinceId < 1) provinceId = 122;
  6187. /*
  6188. * 122 四川
  6189. * 108 贵州
  6190. * 103 重庆
  6191. * 132 云南
  6192. */
  6193. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  6194. return Ok(JsonView(true, "查询成功!", new
  6195. {
  6196. WordTypeData = wordTypeData,
  6197. ExcelTypeData = excelTypeData,
  6198. }));
  6199. }
  6200. /// <summary>
  6201. /// 团组模块 - 出入境费用
  6202. /// 实时汇率 tips
  6203. /// 签证费用 tips
  6204. /// 机票费用 tips
  6205. /// </summary>
  6206. /// <returns></returns>
  6207. [HttpPost]
  6208. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6209. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  6210. {
  6211. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6212. //默认币种显示
  6213. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  6214. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  6215. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  6216. return Ok(JsonView(true, "查询成功!", new
  6217. {
  6218. //GroupNameData = groupNameData.Data,
  6219. visaData = visaData.Data,
  6220. airData = airData,
  6221. reteInfos = reteInfos
  6222. }));
  6223. }
  6224. /// <summary>
  6225. /// 团组模块 - 出入境费用 - Info
  6226. /// </summary>
  6227. /// <returns></returns>
  6228. [HttpPost]
  6229. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  6230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6231. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  6232. {
  6233. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6234. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6235. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  6236. }
  6237. /// <summary>
  6238. /// 团组模块 - 出入境费用 - 设置view权限
  6239. /// </summary>
  6240. /// <returns></returns>
  6241. [HttpPost]
  6242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6243. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  6244. {
  6245. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6246. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6247. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6248. var permissions = new List<Grp_EnterExitCostPermission>();
  6249. foreach (var userId in dto.UserIds)
  6250. {
  6251. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  6252. }
  6253. if (permissions.Any())
  6254. {
  6255. _sqlSugar.BeginTran();
  6256. try
  6257. {
  6258. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  6259. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6260. if (result < 1)
  6261. {
  6262. _sqlSugar.RollbackTran();
  6263. return Ok(JsonView(false));
  6264. }
  6265. }
  6266. catch (Exception ex)
  6267. {
  6268. _sqlSugar.RollbackTran();
  6269. return Ok(JsonView(false, ex.Message));
  6270. }
  6271. _sqlSugar.CommitTran();
  6272. return Ok(JsonView(true));
  6273. }
  6274. return Ok(JsonView(false));
  6275. }
  6276. /// <summary>
  6277. /// 团组模块 - 出入境费用 - Add And Update
  6278. /// </summary>
  6279. /// <returns></returns>
  6280. [HttpPost]
  6281. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  6282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6283. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  6284. {
  6285. try
  6286. {
  6287. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6288. if (dto.DayOtherPriceData.Any())
  6289. {
  6290. var inserList = dto.DayOtherPriceData
  6291. .Where(x => x.Id == 0)
  6292. .Select(x => new Grp_DayOtherPrice
  6293. {
  6294. Cost = x.Cost,
  6295. Id = x.Id,
  6296. CreateTime = DateTime.Now,
  6297. CreateUserId = dto.UserId,
  6298. Currency = x.Currency,
  6299. Diid = x.DiId,
  6300. Index = x.Index,
  6301. IsDel = 0,
  6302. SetDataId = x.SetDataId,
  6303. SubTotal = x.SubTotal,
  6304. Remark = x.Remark
  6305. })
  6306. .ToList();
  6307. var updateList = dto.DayOtherPriceData
  6308. .Where(x => x.Id != 0)
  6309. .Select(x => new Grp_DayOtherPrice
  6310. {
  6311. Cost = x.Cost,
  6312. Id = x.Id,
  6313. CreateTime = DateTime.Now,
  6314. CreateUserId = dto.UserId,
  6315. Currency = x.Currency,
  6316. Diid = x.DiId,
  6317. Index = x.Index,
  6318. IsDel = 0,
  6319. SetDataId = x.SetDataId,
  6320. SubTotal = x.SubTotal,
  6321. Remark = x.Remark
  6322. })
  6323. .ToList();
  6324. //添加
  6325. _sqlSugar.BeginTran();
  6326. if (inserList.Any())
  6327. {
  6328. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  6329. }
  6330. if (updateList.Any())
  6331. {
  6332. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  6333. }
  6334. _sqlSugar.CommitTran();
  6335. }
  6336. if (data.Code != 0)
  6337. {
  6338. return Ok(JsonView(false, data.Msg));
  6339. }
  6340. //生成默认文件pdf并且通知人员
  6341. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6342. {
  6343. DiId = dto.DiId,
  6344. ExportType = 1,
  6345. SubTypeId = 1005
  6346. }, "pdf");
  6347. //发送通知
  6348. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6349. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6350. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  6351. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  6352. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  6353. //汇率信息记录
  6354. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6355. return Ok(JsonView(true, data.Msg, data.Data));
  6356. }
  6357. catch (Exception ex)
  6358. {
  6359. return Ok(JsonView(false, ex.Message));
  6360. }
  6361. }
  6362. /// <summary>
  6363. /// 团组模块 - 出入境费用 - Confirm 费用
  6364. /// </summary>
  6365. /// <returns></returns>
  6366. [HttpPost]
  6367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6368. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  6369. {
  6370. //TODO:测试完毕需把对应的用户ID更改
  6371. //1、数据表添加字段
  6372. //2、更改字段接口()
  6373. var _view = await _enterExitCostRep.ConfirmCost(dto);
  6374. //3、确认成功 给财务发送消息
  6375. if (_view.Code == 200)
  6376. {
  6377. if (dto.Type == 1)
  6378. {
  6379. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  6380. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  6381. }
  6382. }
  6383. return Ok(_view);
  6384. }
  6385. /// <summary>
  6386. /// 团组模块 - 出入境费用 - File download
  6387. /// </summary>
  6388. /// <param name="dto"></param>
  6389. /// <returns></returns>
  6390. [HttpPost]
  6391. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  6392. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6393. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  6394. {
  6395. try
  6396. {
  6397. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6398. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6399. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6400. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6401. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6402. 3 团组成员名单 1 团组成员名单", ""));
  6403. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  6404. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  6405. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  6406. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  6407. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6408. //数据源
  6409. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6410. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6411. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6412. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6413. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6414. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6415. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6416. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  6417. .Select((x, a, b) => new
  6418. {
  6419. x.Index,
  6420. itemName = a.Name,
  6421. CurrencyStr = b.Name,
  6422. x.Cost,
  6423. x.SubTotal,
  6424. x.Remark
  6425. })
  6426. .OrderBy((x) => x.Index)
  6427. .ToList(); //其他款项费用
  6428. var peiceItemCurrencys = new List<string>();
  6429. if (_DayAndCosts.Any())
  6430. {
  6431. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6432. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6433. }
  6434. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6435. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6436. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6437. {
  6438. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6439. }
  6440. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6441. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  6442. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  6443. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  6444. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  6445. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  6446. .Select((tcl, dc, cc) => new ClientInfo
  6447. {
  6448. LastName = dc.LastName,
  6449. FirstName = dc.FirstName,
  6450. Sex = dc.Sex,
  6451. Birthday = dc.BirthDay,
  6452. Company = cc.CompanyFullName,
  6453. Job = dc.Job
  6454. })
  6455. .ToList();
  6456. foreach (var item in DeleClientList)
  6457. {
  6458. EncryptionProcessor.DecryptProperties(item);
  6459. }
  6460. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  6461. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6462. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6463. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6464. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  6465. if (dto.ExportType == 1) //明细表
  6466. {
  6467. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6468. {
  6469. //获取模板
  6470. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6471. //载入模板
  6472. Document doc = new Document(tempPath);
  6473. DocumentBuilder builder = new DocumentBuilder(doc);
  6474. //利用键值对存放数据
  6475. Dictionary<string, string> dic = new Dictionary<string, string>();
  6476. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6477. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6478. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6479. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6480. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6481. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6482. //境内费用(其他费用)
  6483. if (_EnterExitCosts.ChoiceOne == 1)
  6484. {
  6485. string row1_1 = "";
  6486. if (_EnterExitCosts.Visa > 0)
  6487. {
  6488. //insidePayTotal += _EnterExitCosts.Visa;
  6489. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6490. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6491. //{
  6492. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  6493. //}
  6494. }
  6495. string row1_2 = "";
  6496. if (_EnterExitCosts.YiMiao > 0)
  6497. {
  6498. //insidePayTotal += _EnterExitCosts.YiMiao;
  6499. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6500. }
  6501. if (_EnterExitCosts.HeSuan > 0)
  6502. {
  6503. //insidePayTotal += _EnterExitCosts.HeSuan;
  6504. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6505. }
  6506. if (_EnterExitCosts.Service > 0)
  6507. {
  6508. //insidePayTotal += _EnterExitCosts.Service;
  6509. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6510. }
  6511. string row1_3 = "";
  6512. if (_EnterExitCosts.Safe > 0)
  6513. {
  6514. //insidePayTotal += _EnterExitCosts.Safe;
  6515. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6516. }
  6517. if (_EnterExitCosts.Ticket > 0)
  6518. {
  6519. //insidePayTotal += _EnterExitCosts.Ticket;
  6520. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6521. }
  6522. string row1 = "";
  6523. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6524. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6525. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6526. row1 += $"备注:{_EnterExitCosts.Remark}";
  6527. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6528. dic.Add("Row1Str", row1);
  6529. }
  6530. string airTotalStr = string.Empty,
  6531. airPriceStr = string.Empty;
  6532. //经济舱
  6533. if (_EnterExitCosts.SumJJC == 1)
  6534. {
  6535. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6536. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6537. }
  6538. //公务舱
  6539. if (_EnterExitCosts.SumGWC == 1)
  6540. {
  6541. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6542. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6543. }
  6544. //头等舱
  6545. if (_EnterExitCosts.SumTDC == 1)
  6546. {
  6547. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6548. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6549. }
  6550. //汇率描述
  6551. string rateStr = "";
  6552. if (peiceItemCurrencyInfos.Any())
  6553. {
  6554. rateStr = "\r\n汇率描述:";
  6555. foreach (var item in peiceItemCurrencyInfos)
  6556. {
  6557. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6558. }
  6559. }
  6560. string twoItemRemark = "备注:";
  6561. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  6562. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6563. dic.Add("AirTotalStr", airTotalStr);
  6564. dic.Add("AirPriceStr", airPriceStr);
  6565. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6566. dic.Add("TwoItemRemark", twoItemRemark);
  6567. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6568. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6569. int table1Row = 0,
  6570. table2Row = 0,
  6571. table3Row = 0,
  6572. table4Row = 0,
  6573. table5Row = 0;
  6574. //住宿费
  6575. if (_EnterExitCosts.ChoiceThree == 1)
  6576. {
  6577. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6578. table1Row = dac1.Count;
  6579. #region 填充word表格内容
  6580. for (int i = 0; i < dac1.Count; i++)
  6581. {
  6582. Grp_DayAndCost dac = dac1[i];
  6583. if (dac == null) continue;
  6584. builder.MoveToCell(0, i, 0, 0);
  6585. builder.Write("第" + dac.Days.ToString() + "晚:");
  6586. builder.MoveToCell(0, i, 1, 0);
  6587. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6588. //builder.Write(dac.Place == null ? "" : dac.Place);
  6589. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6590. builder.MoveToCell(0, i, 2, 0);
  6591. builder.Write("费用标准:");
  6592. string curr = "";
  6593. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6594. if (currData != null)
  6595. {
  6596. curr = currData.Name;
  6597. }
  6598. builder.MoveToCell(0, i, 3, 0);
  6599. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6600. builder.MoveToCell(0, i, 4, 0);
  6601. builder.Write("费用小计:");
  6602. builder.MoveToCell(0, i, 5, 0);
  6603. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6604. }
  6605. #endregion
  6606. }
  6607. else dic.Add("SubZS", "0.00");
  6608. //删除多余行
  6609. while (table1.Rows.Count > table1Row)
  6610. {
  6611. table1.Rows.RemoveAt(table1Row);
  6612. }
  6613. //伙食费
  6614. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6615. if (_EnterExitCosts.ChoiceFour == 1)
  6616. {
  6617. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6618. table2Row = dac2.Count;
  6619. #region 填充word表格内容
  6620. for (int i = 0; i < dac2.Count; i++)
  6621. {
  6622. Grp_DayAndCost dac = dac2[i];
  6623. if (dac == null) continue;
  6624. builder.MoveToCell(1, i, 0, 0);
  6625. builder.Write("第" + dac.Days.ToString() + "天:");
  6626. builder.MoveToCell(1, i, 1, 0);
  6627. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6628. builder.MoveToCell(1, i, 2, 0);
  6629. builder.Write("费用标准:");
  6630. string curr = "";
  6631. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6632. if (currData != null)
  6633. {
  6634. curr = currData.Name;
  6635. }
  6636. builder.MoveToCell(1, i, 3, 0);
  6637. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6638. builder.MoveToCell(1, i, 4, 0);
  6639. builder.Write("费用小计:");
  6640. builder.MoveToCell(1, i, 5, 0);
  6641. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6642. }
  6643. #endregion
  6644. }
  6645. else dic.Add("SubHS", "0.00");
  6646. //删除多余行
  6647. while (table2.Rows.Count > table2Row)
  6648. {
  6649. table2.Rows.RemoveAt(table2Row);
  6650. }
  6651. //公杂费
  6652. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6653. if (_EnterExitCosts.ChoiceFive == 1)
  6654. {
  6655. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6656. table3Row = dac3.Count;
  6657. #region 填充word表格内容
  6658. for (int i = 0; i < dac3.Count; i++)
  6659. {
  6660. Grp_DayAndCost dac = dac3[i];
  6661. if (dac == null) continue;
  6662. builder.MoveToCell(2, i, 0, 0);
  6663. builder.Write("第" + dac.Days.ToString() + "天:");
  6664. builder.MoveToCell(2, i, 1, 0);
  6665. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6666. builder.MoveToCell(2, i, 2, 0);
  6667. builder.Write("费用标准:");
  6668. string curr = "";
  6669. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6670. if (currData != null)
  6671. {
  6672. curr = currData.Name;
  6673. }
  6674. builder.MoveToCell(2, i, 3, 0);
  6675. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6676. builder.MoveToCell(2, i, 4, 0);
  6677. builder.Write("费用小计:");
  6678. builder.MoveToCell(2, i, 5, 0);
  6679. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6680. }
  6681. //删除多余行
  6682. while (table3.Rows.Count > table3Row)
  6683. {
  6684. table3.Rows.RemoveAt(table3Row);
  6685. }
  6686. #endregion
  6687. }
  6688. else dic.Add("SubGZF", "0.00");
  6689. //删除多余行
  6690. while (table3.Rows.Count > table3Row)
  6691. {
  6692. table3.Rows.RemoveAt(table3Row);
  6693. }
  6694. //培训费
  6695. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6696. if (_EnterExitCosts.ChoiceSix == 1)
  6697. {
  6698. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6699. dic.Add("SubPX", pxStr);
  6700. table4Row = dac4.Count;
  6701. #region 填充word表格内容
  6702. for (int i = 0; i < dac4.Count; i++)
  6703. {
  6704. Grp_DayAndCost dac = dac4[i];
  6705. if (dac == null) continue;
  6706. builder.MoveToCell(3, i, 0, 0);
  6707. builder.Write("第" + dac.Days.ToString() + "天:");
  6708. builder.MoveToCell(3, i, 1, 0);
  6709. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6710. builder.MoveToCell(3, i, 2, 0);
  6711. builder.Write("费用标准:");
  6712. string curr = "";
  6713. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6714. if (currData != null)
  6715. {
  6716. curr = currData.Name;
  6717. }
  6718. builder.MoveToCell(3, i, 3, 0);
  6719. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6720. builder.MoveToCell(3, i, 4, 0);
  6721. builder.Write("费用小计:");
  6722. builder.MoveToCell(3, i, 5, 0);
  6723. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6724. }
  6725. #endregion
  6726. }
  6727. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  6728. //删除多余行
  6729. while (table4.Rows.Count > table4Row)
  6730. {
  6731. table4.Rows.RemoveAt(table4Row);
  6732. }
  6733. //其他费用
  6734. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6735. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6736. {
  6737. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6738. dic.Add("titleQi", qtStr);
  6739. table5Row = dac5.Count;
  6740. #region 填充word表格内容
  6741. for (int i = 0; i < dac5.Count; i++)
  6742. {
  6743. var dac = dac5[i];
  6744. if (dac == null) continue;
  6745. builder.MoveToCell(4, i, 0, 0);
  6746. builder.Write("第" + dac.Index.ToString() + "项:");
  6747. builder.MoveToCell(4, i, 1, 0);
  6748. builder.Write(dac.itemName);
  6749. builder.MoveToCell(4, i, 2, 0);
  6750. builder.Write("费用标准:");
  6751. builder.MoveToCell(4, i, 3, 0);
  6752. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6753. builder.MoveToCell(4, i, 4, 0);
  6754. builder.Write("费用小计:");
  6755. builder.MoveToCell(4, i, 5, 0);
  6756. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6757. builder.MoveToCell(4, i, 6, 0);
  6758. builder.Write("备注:");
  6759. builder.MoveToCell(4, i, 7, 0);
  6760. builder.Write(dac.Remark);
  6761. }
  6762. #endregion
  6763. }
  6764. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  6765. //删除多余行
  6766. while (table5.Rows.Count > table5Row)
  6767. {
  6768. table5.Rows.RemoveAt(table5Row);
  6769. }
  6770. //加上其他费用
  6771. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  6772. decimal subJJC = 0.00M,
  6773. subGWC = 0.00M,
  6774. subTDC = 0.00M;
  6775. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  6776. string totalLabel = string.Format("全部费用总计:");
  6777. //经济舱
  6778. if (_EnterExitCosts.SumJJC == 1)
  6779. {
  6780. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  6781. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  6782. }
  6783. //公务舱
  6784. if (_EnterExitCosts.SumGWC == 1)
  6785. {
  6786. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  6787. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  6788. }
  6789. //头等舱
  6790. if (_EnterExitCosts.SumTDC == 1)
  6791. {
  6792. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  6793. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  6794. }
  6795. //TotalLabel
  6796. dic.Add("TotalLabel", totalLabel);
  6797. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  6798. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  6799. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  6800. #region 填充word模板书签内容
  6801. foreach (var key in dic.Keys)
  6802. {
  6803. Bookmark bookmark = doc.Range.Bookmarks[key];
  6804. if (bookmark != null)
  6805. {
  6806. builder.MoveToBookmark(key);
  6807. builder.Write(dic[key]);
  6808. }
  6809. }
  6810. #endregion
  6811. #region 设置页眉
  6812. string userLabel = string.Empty;
  6813. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6814. if (currUserInfo != null)
  6815. {
  6816. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  6817. if (userInfo != null)
  6818. {
  6819. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  6820. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  6821. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  6822. }
  6823. }
  6824. //设置页脚
  6825. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  6826. #endregion
  6827. //文件名
  6828. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  6829. AsposeHelper.removewatermark_v2180();
  6830. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6831. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6832. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6833. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6834. }
  6835. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  6836. {
  6837. //获取模板
  6838. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  6839. //载入模板
  6840. Document doc = new Document(tempPath);
  6841. DocumentBuilder builder = new DocumentBuilder(doc);
  6842. Dictionary<string, string> dic = new Dictionary<string, string>();
  6843. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  6844. {
  6845. List<string> list = new List<string>();
  6846. try
  6847. {
  6848. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  6849. foreach (var item in spilitArr)
  6850. {
  6851. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  6852. var depCode = spDotandEmpty[2].Substring(0, 3);
  6853. var arrCode = spDotandEmpty[2].Substring(3, 3);
  6854. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  6855. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  6856. list.Add(depName);
  6857. list.Add(arrName);
  6858. }
  6859. list = list.Distinct().ToList();
  6860. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  6861. }
  6862. catch (Exception)
  6863. {
  6864. dic.Add("ReturnCode", "行程录入不正确!");
  6865. }
  6866. }
  6867. else
  6868. {
  6869. dic.Add("ReturnCode", "未录入行程!");
  6870. }
  6871. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  6872. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  6873. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  6874. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  6875. {
  6876. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  6877. dic.Add("Day", sp.Days.ToString());
  6878. }
  6879. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  6880. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  6881. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  6882. //dic.Add("Names", Names);
  6883. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6884. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6885. decimal dac1totalPrice = 0.00M;
  6886. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  6887. foreach (var dac in dac1)
  6888. {
  6889. if (dac.SubTotal == 0.00M)
  6890. {
  6891. continue;
  6892. }
  6893. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6894. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6895. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6896. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6897. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6898. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6899. builder.Write(currency);//币种
  6900. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6901. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6902. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6903. builder.Write("");//人数
  6904. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6905. builder.Write("");//天数
  6906. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6907. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6908. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6909. decimal rate = 0.00M;
  6910. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6911. builder.Write(rate.ToString("#0.0000"));//汇率
  6912. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6913. decimal rbmPrice = dac.SubTotal;
  6914. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6915. accommodationStartIndex++;
  6916. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6917. }
  6918. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6919. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  6920. {
  6921. table1.Rows.RemoveAt(i - 1);
  6922. foodandotherStartIndex--;
  6923. }
  6924. if (dac2.Count == dac3.Count)//国家 币种 金额
  6925. {
  6926. for (int i = 0; i < dac2.Count; i++)
  6927. {
  6928. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6929. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6930. }
  6931. }
  6932. decimal dac2totalPrice = 0.00M;
  6933. foreach (var dac in dac2)
  6934. {
  6935. if (dac.SubTotal == 0)
  6936. {
  6937. continue;
  6938. }
  6939. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6940. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  6941. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6942. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  6943. builder.Write(currency);//币种
  6944. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6945. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6946. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6947. builder.Write("");//人数
  6948. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6949. builder.Write("");//天数
  6950. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6951. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6952. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6953. decimal rate = 0.00M;
  6954. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  6955. builder.Write(rate.ToString("#0.0000"));//汇率
  6956. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6957. decimal rbmPrice = dac.SubTotal;
  6958. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6959. foodandotherStartIndex++;
  6960. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  6961. }
  6962. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6963. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  6964. {
  6965. table1.Rows.RemoveAt(i - 1);
  6966. }
  6967. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6968. string otherFeeStr = "";
  6969. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  6970. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  6971. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  6972. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6973. foreach (var otherInfo in dac5)
  6974. {
  6975. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6976. }
  6977. #endregion
  6978. if (otherFeeStr.Length > 0)
  6979. {
  6980. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6981. otherFeeStr = $"({otherFeeStr})";
  6982. dic.Add("OtherFeeStr", otherFeeStr);
  6983. }
  6984. //总计
  6985. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  6986. //国际旅费
  6987. string outsideAir = string.Empty;
  6988. string allPriceAir = string.Empty;
  6989. if (_EnterExitCosts.SumJJC == 1)
  6990. {
  6991. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  6992. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  6993. }
  6994. if (_EnterExitCosts.SumGWC == 1)
  6995. {
  6996. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  6997. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  6998. }
  6999. if (_EnterExitCosts.SumTDC == 1)
  7000. {
  7001. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7002. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7003. }
  7004. dic.Add("InTravelPrice", $"({outsideAir})");
  7005. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7006. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7007. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7008. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7009. foreach (var key in dic.Keys)
  7010. {
  7011. builder.MoveToBookmark(key);
  7012. builder.Write(dic[key]);
  7013. }
  7014. //模板文件名
  7015. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7016. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7017. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7018. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7019. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7020. }
  7021. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7022. {
  7023. //获取模板
  7024. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7025. //载入模板
  7026. WorkbookDesigner designer = new WorkbookDesigner();
  7027. designer.Workbook = new Workbook(tempPath);
  7028. Dictionary<string, string> dic = new Dictionary<string, string>();
  7029. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7030. {
  7031. List<string> list = new List<string>();
  7032. try
  7033. {
  7034. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7035. foreach (var item in spilitArr)
  7036. {
  7037. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7038. var depCode = spDotandEmpty[2].Substring(0, 3);
  7039. var arrCode = spDotandEmpty[2].Substring(3, 3);
  7040. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  7041. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  7042. list.Add(depName);
  7043. list.Add(arrName);
  7044. }
  7045. list = list.Distinct().ToList();
  7046. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7047. }
  7048. catch (Exception)
  7049. {
  7050. dic.Add("ReturnCode", "行程录入不正确!");
  7051. }
  7052. }
  7053. else
  7054. {
  7055. dic.Add("ReturnCode", "未录入行程!");
  7056. }
  7057. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7058. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7059. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7060. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7061. {
  7062. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7063. dic.Add("Day", sp.Days.ToString());
  7064. }
  7065. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7066. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7067. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7068. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  7069. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  7070. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  7071. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  7072. designer.SetDataSource("Name", Names);
  7073. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  7074. designer.SetDataSource("Day", dic["Day"] + "天");
  7075. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  7076. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  7077. int startIndex = 10;
  7078. const int startIndexcopy = 10;
  7079. if (dac2.Count == dac3.Count)//国家 币种 金额
  7080. {
  7081. for (int i = 0; i < dac2.Count; i++)
  7082. {
  7083. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7084. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7085. }
  7086. }
  7087. DataTable dtdac1 = new DataTable();
  7088. List<string> place = new List<string>();
  7089. dtdac1.Columns.AddRange(new DataColumn[] {
  7090. new DataColumn(){ ColumnName = "city"},
  7091. new DataColumn(){ ColumnName = "curr"},
  7092. new DataColumn(){ ColumnName = "criterion"},
  7093. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7094. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7095. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7096. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7097. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7098. });
  7099. DataTable dtdac2 = new DataTable();
  7100. dtdac2.Columns.AddRange(new DataColumn[] {
  7101. new DataColumn(){ ColumnName = "city"},
  7102. new DataColumn(){ ColumnName = "curr"},
  7103. new DataColumn(){ ColumnName = "criterion"},
  7104. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7105. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7106. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7107. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7108. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7109. });
  7110. dtdac1.TableName = "tb1";
  7111. dtdac2.TableName = "tb2";
  7112. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7113. foreach (var item in dac1)
  7114. {
  7115. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7116. if (place.Contains(item.Place))
  7117. {
  7118. continue;
  7119. }
  7120. DataRow row = dtdac1.NewRow();
  7121. row["city"] = item.Place;
  7122. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7123. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7124. row["curr"] = currency;
  7125. row["rate"] = rate.ToString("#0.0000");
  7126. row["criterion"] = item.Cost.ToString("#0.00");
  7127. row["number"] = 1;
  7128. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7129. //row["costRMB"] = rbmPrice;
  7130. dtdac1.Rows.Add(row);
  7131. place.Add(item.Place);
  7132. }
  7133. place = new List<string>();
  7134. foreach (var item in dac2)
  7135. {
  7136. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  7137. if (place.Contains(item.Place))
  7138. {
  7139. continue;
  7140. }
  7141. DataRow row = dtdac2.NewRow();
  7142. row["city"] = item.Place;
  7143. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7144. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7145. row["curr"] = currency;
  7146. row["rate"] = rate.ToString("#0.0000");
  7147. row["criterion"] = item.Cost.ToString("#0.00");
  7148. row["number"] = 1;
  7149. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7150. //row["cost"] = item.SubTotal;
  7151. //row["costRMB"] = rbmPrice;
  7152. dtdac2.Rows.Add(row);
  7153. place.Add(item.Place);
  7154. //dac2totalPrice += rbmPrice;
  7155. }
  7156. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7157. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7158. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7159. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7160. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  7161. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  7162. string cell4Str1 = string.Empty;
  7163. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  7164. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  7165. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  7166. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7167. string cellStr = $" 5.其他费用(";
  7168. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7169. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7170. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7171. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7172. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7173. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7174. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7175. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7176. foreach (var otherInfo in dac5)
  7177. {
  7178. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7179. }
  7180. #endregion
  7181. if (cellStr.Length > 8)
  7182. {
  7183. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7184. }
  7185. cellStr += ")";
  7186. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7187. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7188. decimal pxFee = dac4.Sum(it => it.Cost);
  7189. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7190. string celllastStr1 = "";
  7191. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  7192. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  7193. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  7194. celllastStr1 += $",国际旅费 元";
  7195. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  7196. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7197. designer.SetDataSource("cell4Str", cell4Str);
  7198. designer.SetDataSource("cellStr", cellStr);
  7199. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7200. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7201. designer.SetDataSource("celllastStr", celllastStr);
  7202. Workbook wb = designer.Workbook;
  7203. var sheet = wb.Worksheets[0];
  7204. //绑定datatable数据集
  7205. designer.SetDataSource(dtdac1);
  7206. designer.SetDataSource(dtdac2);
  7207. designer.Process();
  7208. var rowStart = dtdac1.Rows.Count;
  7209. while (rowStart > 0)
  7210. {
  7211. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7212. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7213. startIndex++;
  7214. rowStart--;
  7215. }
  7216. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7217. startIndex += 1; //总计行
  7218. rowStart = dtdac2.Rows.Count;
  7219. while (rowStart > 0)
  7220. {
  7221. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7222. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7223. startIndex++;
  7224. rowStart--;
  7225. }
  7226. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7227. wb.CalculateFormula(true);
  7228. //模板文件名
  7229. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7230. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7231. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7232. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7233. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7234. }
  7235. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7236. {
  7237. //获取模板
  7238. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7239. //载入模板
  7240. Document doc = new Document(tempPath);
  7241. DocumentBuilder builder = new DocumentBuilder(doc);
  7242. Dictionary<string, string> dic = new Dictionary<string, string>();
  7243. dic.Add("GroupName", _DelegationInfo.TeamName);
  7244. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7245. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7246. string missionLeaderJob = "";//负责人job
  7247. //int groupNumber = 0; //团人数
  7248. if (DeleClientList.Count > 0)
  7249. {
  7250. missionLeader = DeleClientList[0]?.Name ?? "";
  7251. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  7252. }
  7253. dic.Add("MissionLeader", missionLeader); //团负责人
  7254. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  7255. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  7256. #region MyRegion
  7257. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  7258. //{
  7259. // List<string> list = new List<string>();
  7260. // try
  7261. // {
  7262. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  7263. // foreach (var item in spilitArr)
  7264. // {
  7265. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  7266. // var depCode = spDotandEmpty[2].Substring(0, 3);
  7267. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  7268. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  7269. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  7270. // list.Add(depName);
  7271. // list.Add(arrName);
  7272. // }
  7273. // list = list.Distinct().ToList();
  7274. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  7275. // }
  7276. // catch (Exception)
  7277. // {
  7278. // dic.Add("ReturnCode", "行程录入不正确!");
  7279. // }
  7280. //}
  7281. //else
  7282. //{
  7283. // dic.Add("ReturnCode", "未录入行程!");
  7284. //}
  7285. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  7286. dic.Add("ReturnCode", string.Join("、", countrys));
  7287. #endregion
  7288. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  7289. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7290. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7291. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  7292. //{
  7293. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7294. // dic.Add("Day", sp.Days.ToString());
  7295. //}
  7296. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  7297. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7298. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7299. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7300. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7301. //培训人员名单
  7302. int cultivateRowIndex = 7;
  7303. foreach (var item in DeleClientList)
  7304. {
  7305. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  7306. builder.Write(item.Name);
  7307. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  7308. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  7309. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  7310. string birthDay = "";
  7311. if (item.Birthday != null)
  7312. {
  7313. DateTime dt = Convert.ToDateTime(item.Birthday);
  7314. birthDay = $"{dt.Year}.{dt.Month}";
  7315. }
  7316. builder.Write(birthDay);
  7317. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  7318. builder.Write(item.Company);
  7319. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  7320. builder.Write(item.Job);
  7321. cultivateRowIndex++;
  7322. }
  7323. //删除多余行
  7324. //cultivateRowIndex -= 2;
  7325. int delRows = 10 + 7 - cultivateRowIndex;
  7326. if (delRows > 0)
  7327. {
  7328. for (int i = 0; i < delRows; i++)
  7329. {
  7330. table1.Rows.RemoveAt(cultivateRowIndex);
  7331. //cultivateRowIndex++;
  7332. }
  7333. }
  7334. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7335. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7336. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7337. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7338. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7339. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7340. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7341. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7342. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7343. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7344. //其他费用
  7345. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7346. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7347. //其他费用合计
  7348. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7349. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7350. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7351. //公务舱合计
  7352. //国际旅费
  7353. //string outsideJJ = "";
  7354. //string allPriceJJ = "";
  7355. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7356. {
  7357. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7358. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7359. }
  7360. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7361. {
  7362. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7363. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7364. }
  7365. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7366. {
  7367. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7368. dic.Add("AirFeeTotal", airFeeTotalStr);
  7369. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7370. dic.Add("FeeTotal", feeTotalStr);
  7371. }
  7372. foreach (var key in dic.Keys)
  7373. {
  7374. builder.MoveToBookmark(key);
  7375. builder.Write(dic[key]);
  7376. }
  7377. //模板文件名
  7378. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7379. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7380. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7381. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7382. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7383. }
  7384. }
  7385. else if (dto.ExportType == 2) //表格
  7386. {
  7387. //利用键值对存放数据
  7388. Dictionary<string, string> dic = new Dictionary<string, string>();
  7389. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  7390. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  7391. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  7392. dic.Add("Day", sp.Days.ToString());
  7393. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7394. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  7395. {
  7396. //获取模板
  7397. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  7398. //载入模板
  7399. Document doc = new Document(tempPath);
  7400. DocumentBuilder builder = new DocumentBuilder(doc);
  7401. dic.Add("TeamName", _DelegationInfo.TeamName);
  7402. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  7403. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  7404. string missionLeaderName = "",
  7405. missionLeaderJob = "";
  7406. if (DeleClientList.Count > 0)
  7407. {
  7408. missionLeaderName = DeleClientList[0].Name;
  7409. missionLeaderJob = DeleClientList[0].Job;
  7410. }
  7411. dic.Add("MissionLeaderName", missionLeaderName);
  7412. dic.Add("MissionLeaderJob", missionLeaderJob);
  7413. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  7414. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  7415. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7416. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7417. int rowCount = 10;//总人数行
  7418. int startRowIndex = 7; //起始行
  7419. for (int i = 0; i < DeleClientList.Count; i++)
  7420. {
  7421. builder.MoveToCell(0, startRowIndex, 0, 0);
  7422. builder.Write(DeleClientList[i].Name); //出国人员姓名
  7423. builder.MoveToCell(0, startRowIndex, 1, 0);
  7424. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7425. builder.Write(sex);//性别
  7426. builder.MoveToCell(0, startRowIndex, 2, 0);
  7427. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  7428. builder.MoveToCell(0, startRowIndex, 3, 0);
  7429. builder.Write(DeleClientList[i].Company);//工作单位
  7430. builder.MoveToCell(0, startRowIndex, 4, 0);
  7431. builder.Write(DeleClientList[i].Job);//职务及级别
  7432. builder.MoveToCell(0, startRowIndex, 5, 0);
  7433. builder.Write("");//人员属性
  7434. builder.MoveToCell(0, startRowIndex, 6, 0);
  7435. builder.Write("");//上次出国时间
  7436. startRowIndex++;
  7437. }
  7438. int nullRow = rowCount - DeleClientList.Count;//空行
  7439. for (int i = 0; i < nullRow; i++)
  7440. {
  7441. table1.Rows.Remove(table1.Rows[startRowIndex]);
  7442. }
  7443. foreach (var key in dic.Keys)
  7444. {
  7445. builder.MoveToBookmark(key);
  7446. builder.Write(dic[key]);
  7447. }
  7448. //模板文件名
  7449. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  7450. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7451. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7452. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  7453. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  7454. }
  7455. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  7456. {
  7457. //获取模板
  7458. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  7459. //载入模板
  7460. Document doc = new Document(tempPath);
  7461. DocumentBuilder builder = new DocumentBuilder(doc);
  7462. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  7463. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  7464. dic.Add("Names", Names);
  7465. int accommodationRows = 12;
  7466. //int foodandotherRows = 12;
  7467. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7468. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  7469. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7470. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7471. int accommodationStartIndex = 6;
  7472. decimal dac1totalPrice = 0.00M;
  7473. foreach (var dac in dac1)
  7474. {
  7475. if (dac.SubTotal == 0)
  7476. {
  7477. continue;
  7478. }
  7479. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7480. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7481. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7482. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7483. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7484. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7485. builder.Write(currency);//币种
  7486. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7487. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7488. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7489. builder.Write("");//人数
  7490. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7491. builder.Write("");//天数
  7492. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7493. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7494. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7495. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7496. builder.Write(rate.ToString("#0.0000"));//汇率
  7497. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7498. decimal rbmPrice = rate * dac.SubTotal;
  7499. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7500. accommodationStartIndex++;
  7501. dac1totalPrice += rbmPrice;
  7502. }
  7503. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7504. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7505. builder.Write("小计");
  7506. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7507. builder.Write(dac1totalPrice.ToString("#0.00"));
  7508. accommodationStartIndex++;
  7509. int nullRow = accommodationRows - dac1.Count;
  7510. //删除空行
  7511. //if (nullRow > 0)
  7512. //{
  7513. // int rowIndex = accommodationStartIndex;
  7514. // for (int i = 0; i < nullRow; i++)
  7515. // {
  7516. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  7517. // row.Remove();
  7518. // rowIndex++;
  7519. // }
  7520. //}
  7521. if (dac2.Count == dac3.Count)//国家 币种 金额
  7522. {
  7523. for (int i = 0; i < dac2.Count; i++)
  7524. {
  7525. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7526. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7527. }
  7528. }
  7529. int foodandotherStartIndex = 19;//
  7530. decimal dac2totalPrice = 0.00M;
  7531. foreach (var dac in dac2)
  7532. {
  7533. if (dac.SubTotal == 0)
  7534. {
  7535. continue;
  7536. }
  7537. //foodandotherStartIndex = 12;
  7538. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7539. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  7540. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7541. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  7542. builder.Write(currency);//币种
  7543. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7544. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7545. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7546. builder.Write("");//人数
  7547. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7548. builder.Write("");//天数
  7549. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7550. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7551. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7552. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7553. builder.Write(rate.ToString("#0.0000"));//汇率
  7554. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7555. decimal rbmPrice = rate * dac.SubTotal;
  7556. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7557. foodandotherStartIndex++;
  7558. dac2totalPrice += rbmPrice;
  7559. }
  7560. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7561. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7562. //删除空行
  7563. //if (dac2.Count < foodandotherRows)
  7564. //{
  7565. // while (table2.Rows.Count > dac2.Count)
  7566. // {
  7567. // table2.Rows.RemoveAt(dac2.Count);
  7568. // }
  7569. //}
  7570. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7571. string otherFeeStr = "";
  7572. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7573. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7574. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7575. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7576. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7577. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7578. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7579. foreach (var otherInfo in dac5)
  7580. {
  7581. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7582. }
  7583. #endregion
  7584. if (otherFeeStr.Length > 0)
  7585. {
  7586. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7587. otherFeeStr = $"({otherFeeStr})";
  7588. dic.Add("OtherFeeStr", otherFeeStr);
  7589. }
  7590. foreach (var key in dic.Keys)
  7591. {
  7592. builder.MoveToBookmark(key);
  7593. builder.Write(dic[key]);
  7594. }
  7595. //模板文件名
  7596. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7597. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7598. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7599. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7600. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7601. }
  7602. }
  7603. else if (dto.ExportType == 3)
  7604. {
  7605. if (dto.SubTypeId == 1) //团组成员名单
  7606. {
  7607. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  7608. //获取模板
  7609. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  7610. //载入模板
  7611. Document doc = new Document(tempPath);
  7612. DocumentBuilder builder = new DocumentBuilder(doc);
  7613. //获取word里所有表格
  7614. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7615. //获取所填表格的序数
  7616. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7617. var rowStart = tableOne.Rows[0]; //获取第1行
  7618. //循环赋值
  7619. for (int i = 0; i < DeleClientList.Count; i++)
  7620. {
  7621. builder.MoveToCell(0, i + 1, 0, 0);
  7622. builder.Write(DeleClientList[i].Name);
  7623. builder.MoveToCell(0, i + 1, 1, 0);
  7624. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  7625. builder.Write(sex);
  7626. builder.MoveToCell(0, i + 1, 2, 0);
  7627. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  7628. builder.MoveToCell(0, i + 1, 3, 0);
  7629. builder.Write(DeleClientList[i].Company);
  7630. builder.MoveToCell(0, i + 1, 4, 0);
  7631. builder.Write(DeleClientList[i].Job);
  7632. }
  7633. //删除多余行
  7634. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  7635. {
  7636. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  7637. }
  7638. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  7639. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  7640. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  7641. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7642. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7643. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7644. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7645. }
  7646. }
  7647. return Ok(JsonView(400, "操作失败!", ""));
  7648. }
  7649. catch (Exception ex)
  7650. {
  7651. return Ok(JsonView(400, ex.Message, ""));
  7652. }
  7653. }
  7654. /// <summary>
  7655. /// 获取三公费用标准city
  7656. /// </summary>
  7657. /// <param name="placeData"></param>
  7658. /// <param name="nationalTravelFeeId"></param>
  7659. /// <returns></returns>
  7660. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7661. {
  7662. string _city = string.Empty;
  7663. if (placeData.Count < 1) return _city;
  7664. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7665. if (data == null) return _city;
  7666. string country = data.Country;
  7667. string city = data.City;
  7668. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7669. else _city = city;
  7670. return _city;
  7671. }
  7672. ///// <summary>
  7673. ///// 团组模块 - 出入境费用 - 明细表导出
  7674. ///// </summary>
  7675. ///// <returns></returns>
  7676. //[HttpPost]
  7677. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7678. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  7679. //{
  7680. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7681. // if (data.Code != 0)
  7682. // {
  7683. // return Ok(JsonView(false, data.Msg));
  7684. // }
  7685. // return Ok(JsonView(true, data.Msg, data.Data));
  7686. //}
  7687. /// <summary>
  7688. /// 团组模块 - 出入境费用 - 一键清空
  7689. /// </summary>
  7690. /// <returns></returns>
  7691. [HttpPost]
  7692. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7694. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  7695. {
  7696. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  7697. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7698. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7699. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  7700. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7701. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  7702. .SetColumns(x => new Grp_DayOtherPrice
  7703. {
  7704. IsDel = 1,
  7705. DeleteUserId = dto.UserId,
  7706. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7707. })
  7708. .ExecuteCommandAsync();
  7709. if (_view.Code == 0)
  7710. {
  7711. return Ok(JsonView(true, "操作成功"));
  7712. }
  7713. return Ok(JsonView(false, "操作失败"));
  7714. }
  7715. /// <summary>
  7716. /// 团组模块 - 出入境费用 - 子项删除
  7717. /// </summary>
  7718. /// <returns></returns>
  7719. [HttpPost]
  7720. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7722. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  7723. {
  7724. try
  7725. {
  7726. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7727. if (data.Code != 0)
  7728. {
  7729. return Ok(JsonView(false, data.Msg));
  7730. }
  7731. return Ok(JsonView(true, "操作成功!", data.Data));
  7732. }
  7733. catch (Exception ex)
  7734. {
  7735. return Ok(JsonView(false, ex.Message));
  7736. }
  7737. }
  7738. /// <summary>
  7739. /// 删除三公其他费用
  7740. /// </summary>
  7741. /// <param name="dto"></param>
  7742. /// <returns></returns>
  7743. [HttpPost]
  7744. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  7745. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  7746. {
  7747. var jw = JsonView(false, "删除失败!");
  7748. var data = new Grp_DayOtherPrice()
  7749. {
  7750. Id = dto.Id,
  7751. IsDel = 1,
  7752. DeleteUserId = dto.DeleteUserId,
  7753. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7754. };
  7755. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7756. if (del > 0)
  7757. {
  7758. jw.Code = 200;
  7759. jw.Msg = "删除成功!";
  7760. }
  7761. return Ok(jw);
  7762. }
  7763. /// <summary>
  7764. /// 团组模块 - 出入境国家费用标准 List
  7765. /// </summary>
  7766. /// <returns></returns>
  7767. [HttpPost]
  7768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7769. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  7770. {
  7771. int provinceId = dto.ProvinceId;
  7772. if (provinceId < 1) provinceId = 122; //默认四川省数据
  7773. var nftData = await _sqlSugar
  7774. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  7775. JoinType.Left, ntf.Currency == sd1.Id,
  7776. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7777. JoinType.Left, ntf.ProvinceId == c.Id
  7778. ))
  7779. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  7780. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  7781. {
  7782. Id = ntf.Id,
  7783. ProvinceId = ntf.ProvinceId,
  7784. ProvinceName = c.Name_CN,
  7785. Continent = ntf.Continent,
  7786. Country = ntf.Country,
  7787. City = ntf.City,
  7788. Currency = ntf.Currency,
  7789. CurrencyCode = sd1.Name,
  7790. CurrencyName = sd1.Remark,
  7791. RoomCost = ntf.RoomCost,
  7792. FoodCost = ntf.FoodCost,
  7793. PublicCost = ntf.PublicCost,
  7794. LastUpdateUserId = ntf.LastUpdateUserId,
  7795. LastUpdateUserName = u.CnName,
  7796. LastUpdateTime = ntf.LastUpdateTime
  7797. })
  7798. .ToListAsync();
  7799. return Ok(JsonView(true, "查询成功!", nftData));
  7800. }
  7801. /// <summary>
  7802. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  7803. /// </summary>
  7804. /// <returns></returns>
  7805. [HttpPost]
  7806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7807. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  7808. {
  7809. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  7810. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  7811. List<string> countryData = new List<string>();
  7812. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  7813. countryData = countryData.Distinct().ToList();
  7814. List<dynamic> dataSource = new List<dynamic>();
  7815. foreach (var item in countryData)
  7816. {
  7817. var cityData1 = new List<string>();
  7818. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  7819. var countryData2 = new
  7820. {
  7821. CountryName = item,
  7822. CityData = cityData1
  7823. };
  7824. if (!dataSource.Contains(countryData2))
  7825. {
  7826. dataSource.Add(countryData2);
  7827. }
  7828. }
  7829. return Ok(JsonView(true, "查询成功!", dataSource));
  7830. }
  7831. /// <summary>
  7832. /// 团组模块 - 出入境国家费用标准 Page List
  7833. /// </summary>
  7834. /// <returns></returns>
  7835. [HttpPost]
  7836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7837. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  7838. {
  7839. int portId = dto.PortType,
  7840. pageIndex = dto.PageIndex,
  7841. pageSize = dto.PageSize;
  7842. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7843. if (pageIndex == 0) pageIndex = 1;
  7844. if (pageSize == 0) pageSize = 10;
  7845. RefAsync<int> total = 0;
  7846. var nationalTravelFeeData = await _sqlSugar
  7847. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  7848. JoinType.Left, ntf.Currency == sd1.Id,
  7849. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  7850. JoinType.Left, ntf.ProvinceId == sd2.Id
  7851. ))
  7852. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  7853. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  7854. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  7855. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  7856. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  7857. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  7858. {
  7859. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  7860. Id = ntf.Id,
  7861. ProvinceId = ntf.ProvinceId,
  7862. ProvinceName = sd2.Name_CN,
  7863. Continent = ntf.Continent,
  7864. Country = ntf.Country,
  7865. City = ntf.City,
  7866. Currency = ntf.Currency,
  7867. CurrencyCode = sd1.Name,
  7868. CurrencyName = sd1.Remark,
  7869. RoomCost = ntf.RoomCost,
  7870. FoodCost = ntf.FoodCost,
  7871. PublicCost = ntf.PublicCost,
  7872. LastUpdateUserId = ntf.LastUpdateUserId,
  7873. LastUpdateUserName = u.CnName,
  7874. LastUpdateTime = ntf.LastUpdateTime,
  7875. Remark = ntf.Remark
  7876. })
  7877. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7878. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  7879. }
  7880. /// <summary>
  7881. /// 团组模块 - 出入境国家费用标准 根据城市查询
  7882. /// </summary>
  7883. /// <returns></returns>
  7884. [HttpPost]
  7885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7886. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  7887. {
  7888. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  7889. int portId = dto.PortType;
  7890. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  7891. string whereSql = string.Empty;
  7892. if (!string.IsNullOrEmpty(dto.Country))
  7893. {
  7894. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  7895. }
  7896. if (!string.IsNullOrEmpty(dto.City))
  7897. {
  7898. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  7899. }
  7900. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  7901. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  7902. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  7903. From Grp_NationalTravelFee gntf
  7904. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  7905. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  7906. Where gntf.Isdel = 0 {0} ", whereSql);
  7907. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  7908. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  7909. }
  7910. /// <summary>
  7911. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  7912. /// </summary>
  7913. /// <returns></returns>
  7914. [HttpPost]
  7915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7916. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  7917. {
  7918. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  7919. }
  7920. /// <summary>
  7921. /// 团组模块 - 出入境国家费用标准 - Del
  7922. /// </summary>
  7923. /// <returns></returns>
  7924. [HttpPost]
  7925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7926. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  7927. {
  7928. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  7929. {
  7930. Id = dto.Id,
  7931. DeleteUserId = dto.DeleteUserId,
  7932. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  7933. IsDel = 1
  7934. };
  7935. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  7936. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  7937. .WhereColumns(it => new { it.Id })
  7938. .ExecuteCommandAsync();
  7939. if (delStatus <= 0)
  7940. {
  7941. return Ok(JsonView(false, "删除失败!"));
  7942. }
  7943. return Ok(JsonView(true, "操作成功!"));
  7944. }
  7945. /// <summary>
  7946. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  7947. /// 注:Get 请求Headers 加 Token
  7948. /// </summary>
  7949. /// <param name="groupId"></param>
  7950. /// <returns></returns>
  7951. [HttpGet("{groupId}")]
  7952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7953. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  7954. {
  7955. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  7956. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  7957. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  7958. data.ForEach(x =>
  7959. {
  7960. x.CreateUserId = _currUserInfo.UserId;
  7961. });
  7962. if (data.Any())
  7963. {
  7964. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  7965. if (add > 0)
  7966. {
  7967. return Ok(JsonView(true, "操作成功!"));
  7968. }
  7969. }
  7970. return Ok(JsonView(false, "未操作!"));
  7971. }
  7972. #endregion
  7973. #region 团组经理模块 出入境费用-草稿
  7974. /// <summary>
  7975. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  7976. /// </summary>
  7977. /// <returns></returns>
  7978. [HttpGet]
  7979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7980. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  7981. {
  7982. var provData = await _groupRepository.ProvinceBasicSource();
  7983. return Ok(JsonView(true, "查询成功!", provData));
  7984. }
  7985. /// <summary>
  7986. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  7987. /// </summary>
  7988. /// <returns></returns>
  7989. [HttpGet("{provinceId}")]
  7990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7991. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  7992. {
  7993. //验证城市归属并给默认值
  7994. if (provinceId < 1) provinceId = 122;
  7995. /*
  7996. * 122 四川
  7997. * 108 贵州
  7998. * 103 重庆
  7999. * 132 云南
  8000. */
  8001. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  8002. return Ok(JsonView(true, "查询成功!", new
  8003. {
  8004. WordTypeData = wordTypeData,
  8005. ExcelTypeData = excelTypeData,
  8006. }));
  8007. }
  8008. /// <summary>
  8009. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  8010. /// </summary>
  8011. /// <returns></returns>
  8012. [HttpPost]
  8013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8014. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  8015. {
  8016. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  8017. .Where(x => x.IsDel == 0)
  8018. .OrderByDescending(x => x.CreateTime)
  8019. .Select(x => new { x.Id, x.DraftName })
  8020. .ToListAsync();
  8021. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8022. //SetDataInfoView
  8023. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  8024. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  8025. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  8026. int provinceId = dto.ProvinceId;
  8027. if (provinceId < 1) provinceId = 122;
  8028. /*
  8029. * 122 四川
  8030. * 108 贵州
  8031. * 103 重庆
  8032. * 132 云南
  8033. */
  8034. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  8035. //默认币种显示
  8036. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  8037. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  8038. return Ok(JsonView(true, "查询成功!", new
  8039. {
  8040. DraftNameDatas = draftNameDatas,
  8041. CurrencyData = _CurrencyData,
  8042. WordTypeData = wordTypeData,
  8043. ExcelTypeData = excelTypeData,
  8044. CurrencyInit = _currencyInfos,
  8045. ViewPermissionData = viewPermissionData
  8046. }));
  8047. }
  8048. /// <summary>
  8049. /// 团组模块 - 出入境费用-草稿
  8050. /// 实时汇率 tips
  8051. /// 机票费用 tips
  8052. /// </summary>
  8053. /// <returns></returns>
  8054. [HttpPost]
  8055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8056. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  8057. {
  8058. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  8059. return Ok(JsonView(true, "查询成功!", new
  8060. {
  8061. //GroupNameData = groupNameData.Data,
  8062. //visaData = visaData.Data,
  8063. //airData = airData.Data,
  8064. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  8065. }));
  8066. }
  8067. /// <summary>
  8068. /// 团组模块 - 出入境费用-草稿
  8069. /// 签证费用 tips
  8070. /// </summary>
  8071. /// <returns></returns>
  8072. [HttpPost]
  8073. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8074. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  8075. {
  8076. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  8077. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  8078. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  8079. .Select(x => x.NationalTravelFeeId)
  8080. .Distinct()
  8081. .ToListAsync();
  8082. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8083. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8084. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  8085. .Select(x => x.Country)
  8086. .Distinct()
  8087. .ToArrayAsync();
  8088. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  8089. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  8090. return Ok(JsonView(true, "查询成功!", new
  8091. {
  8092. totalAmt = totalAmt,
  8093. remark = remark
  8094. }));
  8095. }
  8096. /// <summary>
  8097. /// 团组模块 - 出入境费用-草稿 - Info
  8098. /// </summary>
  8099. /// <returns></returns>
  8100. [HttpPost]
  8101. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  8102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8103. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  8104. {
  8105. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  8106. }
  8107. /// <summary>
  8108. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  8109. /// </summary>
  8110. /// <returns></returns>
  8111. [HttpPost]
  8112. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8113. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  8114. {
  8115. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8116. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  8117. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8118. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  8119. foreach (var userId in dto.UserIds)
  8120. {
  8121. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  8122. }
  8123. if (permissions.Any())
  8124. {
  8125. _sqlSugar.BeginTran();
  8126. try
  8127. {
  8128. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  8129. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8130. if (result < 1)
  8131. {
  8132. _sqlSugar.RollbackTran();
  8133. return Ok(JsonView(false));
  8134. }
  8135. }
  8136. catch (Exception ex)
  8137. {
  8138. _sqlSugar.RollbackTran();
  8139. return Ok(JsonView(false, ex.Message));
  8140. }
  8141. _sqlSugar.CommitTran();
  8142. return Ok(JsonView(true));
  8143. }
  8144. return Ok(JsonView(false));
  8145. }
  8146. /// <summary>
  8147. /// 团组模块 - 出入境费用-草稿 - Add And Update
  8148. /// </summary>
  8149. /// <returns></returns>
  8150. [HttpPost]
  8151. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  8152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8153. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  8154. {
  8155. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  8156. if (data.Code != 0)
  8157. {
  8158. return Ok(JsonView(false, data.Msg));
  8159. }
  8160. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  8161. //汇率信息记录
  8162. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  8163. return Ok(JsonView(true, data.Msg, data.Data));
  8164. }
  8165. /// <summary>
  8166. /// 团组模块 - 出入境费用-草稿 - File downlaod
  8167. /// </summary>
  8168. /// <param name="dto"></param>
  8169. /// <returns></returns>
  8170. [HttpPost]
  8171. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  8172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8173. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  8174. {
  8175. try
  8176. {
  8177. var id = dto.Id;
  8178. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  8179. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  8180. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  8181. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  8182. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  8183. 3 团组成员名单 1 团组成员名单", ""));
  8184. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  8185. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  8186. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  8187. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  8188. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  8189. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  8190. //数据源
  8191. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  8192. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  8193. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  8194. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  8195. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  8196. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  8197. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  8198. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  8199. .Select((x, a, b) => new
  8200. {
  8201. x.Index,
  8202. itemName = a.Name,
  8203. CurrencyStr = b.Name,
  8204. x.Cost,
  8205. x.SubTotal,
  8206. x.Remark
  8207. })
  8208. .OrderBy((x) => x.Index)
  8209. .ToList(); //其他款项费用
  8210. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8211. var peiceItemCurrencys = new List<string>();
  8212. if (_DayAndCosts.Any())
  8213. {
  8214. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  8215. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  8216. }
  8217. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  8218. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  8219. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  8220. {
  8221. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  8222. }
  8223. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  8224. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  8225. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  8226. if (dto.ExportType == 1) //明细表
  8227. {
  8228. if (dto.SubTypeId == 1005) //1005(默认明细表)
  8229. {
  8230. //获取模板
  8231. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  8232. //载入模板
  8233. Document doc = new Document(tempPath);
  8234. DocumentBuilder builder = new DocumentBuilder(doc);
  8235. //利用键值对存放数据
  8236. Dictionary<string, string> dic = new Dictionary<string, string>();
  8237. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  8238. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  8239. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  8240. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  8241. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  8242. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  8243. //境内费用(其他费用)
  8244. if (_EnterExitCosts.ChoiceOne == 1)
  8245. {
  8246. string row1_1 = "";
  8247. if (_EnterExitCosts.Visa > 0)
  8248. {
  8249. //insidePayTotal += _EnterExitCosts.Visa;
  8250. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  8251. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  8252. //{
  8253. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  8254. //}
  8255. }
  8256. string row1_2 = "";
  8257. if (_EnterExitCosts.YiMiao > 0)
  8258. {
  8259. //insidePayTotal += _EnterExitCosts.YiMiao;
  8260. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  8261. }
  8262. if (_EnterExitCosts.HeSuan > 0)
  8263. {
  8264. //insidePayTotal += _EnterExitCosts.HeSuan;
  8265. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  8266. }
  8267. if (_EnterExitCosts.Service > 0)
  8268. {
  8269. //insidePayTotal += _EnterExitCosts.Service;
  8270. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  8271. }
  8272. string row1_3 = "";
  8273. if (_EnterExitCosts.Safe > 0)
  8274. {
  8275. //insidePayTotal += _EnterExitCosts.Safe;
  8276. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  8277. }
  8278. if (_EnterExitCosts.Ticket > 0)
  8279. {
  8280. //insidePayTotal += _EnterExitCosts.Ticket;
  8281. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  8282. }
  8283. string row1 = "";
  8284. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  8285. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  8286. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  8287. row1 += $"备注:{_EnterExitCosts.Remark}";
  8288. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  8289. dic.Add("Row1Str", row1);
  8290. }
  8291. string airTotalStr = string.Empty,
  8292. airPriceStr = string.Empty;
  8293. //经济舱
  8294. if (_EnterExitCosts.SumJJC == 1)
  8295. {
  8296. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  8297. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  8298. }
  8299. //公务舱
  8300. if (_EnterExitCosts.SumGWC == 1)
  8301. {
  8302. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  8303. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  8304. }
  8305. //头等舱
  8306. if (_EnterExitCosts.SumTDC == 1)
  8307. {
  8308. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  8309. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  8310. }
  8311. //汇率描述
  8312. string rateStr = "";
  8313. if (peiceItemCurrencyInfos.Any())
  8314. {
  8315. rateStr = "\r\n汇率描述:";
  8316. foreach (var item in peiceItemCurrencyInfos)
  8317. {
  8318. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  8319. }
  8320. }
  8321. string twoItemRemark = "备注:";
  8322. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  8323. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  8324. dic.Add("AirTotalStr", airTotalStr);
  8325. dic.Add("AirPriceStr", airPriceStr);
  8326. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8327. dic.Add("TwoItemRemark", twoItemRemark);
  8328. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8329. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8330. int table1Row = 0,
  8331. table2Row = 0,
  8332. table3Row = 0,
  8333. table4Row = 0,
  8334. table5Row = 0;
  8335. //住宿费
  8336. if (_EnterExitCosts.ChoiceThree == 1)
  8337. {
  8338. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  8339. table1Row = dac1.Count;
  8340. #region 填充word表格内容
  8341. for (int i = 0; i < dac1.Count; i++)
  8342. {
  8343. var dac = dac1[i];
  8344. if (dac == null) continue;
  8345. builder.MoveToCell(0, i, 0, 0);
  8346. builder.Write("第" + dac.Days.ToString() + "晚:");
  8347. builder.MoveToCell(0, i, 1, 0);
  8348. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  8349. //builder.Write(dac.Place == null ? "" : dac.Place);
  8350. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8351. builder.MoveToCell(0, i, 2, 0);
  8352. builder.Write("费用标准:");
  8353. string curr = "";
  8354. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8355. if (currData != null)
  8356. {
  8357. curr = currData.Name;
  8358. }
  8359. builder.MoveToCell(0, i, 3, 0);
  8360. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8361. builder.MoveToCell(0, i, 4, 0);
  8362. builder.Write("费用小计:");
  8363. builder.MoveToCell(0, i, 5, 0);
  8364. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8365. }
  8366. #endregion
  8367. }
  8368. else dic.Add("SubZS", "0.00");
  8369. //删除多余行
  8370. while (table1.Rows.Count > table1Row)
  8371. {
  8372. table1.Rows.RemoveAt(table1Row);
  8373. }
  8374. //伙食费
  8375. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8376. if (_EnterExitCosts.ChoiceFour == 1)
  8377. {
  8378. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  8379. table2Row = dac2.Count;
  8380. #region 填充word表格内容
  8381. for (int i = 0; i < dac2.Count; i++)
  8382. {
  8383. var dac = dac2[i];
  8384. if (dac == null) continue;
  8385. builder.MoveToCell(1, i, 0, 0);
  8386. builder.Write("第" + dac.Days.ToString() + "天:");
  8387. builder.MoveToCell(1, i, 1, 0);
  8388. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8389. builder.MoveToCell(1, i, 2, 0);
  8390. builder.Write("费用标准:");
  8391. string curr = "";
  8392. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8393. if (currData != null)
  8394. {
  8395. curr = currData.Name;
  8396. }
  8397. builder.MoveToCell(1, i, 3, 0);
  8398. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8399. builder.MoveToCell(1, i, 4, 0);
  8400. builder.Write("费用小计:");
  8401. builder.MoveToCell(1, i, 5, 0);
  8402. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8403. }
  8404. #endregion
  8405. }
  8406. else dic.Add("SubHS", "0.00");
  8407. //删除多余行
  8408. while (table2.Rows.Count > table2Row)
  8409. {
  8410. table2.Rows.RemoveAt(table2Row);
  8411. }
  8412. //公杂费
  8413. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  8414. if (_EnterExitCosts.ChoiceFive == 1)
  8415. {
  8416. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  8417. table3Row = dac3.Count;
  8418. #region 填充word表格内容
  8419. for (int i = 0; i < dac3.Count; i++)
  8420. {
  8421. var dac = dac3[i];
  8422. if (dac == null) continue;
  8423. builder.MoveToCell(2, i, 0, 0);
  8424. builder.Write("第" + dac.Days.ToString() + "天:");
  8425. builder.MoveToCell(2, i, 1, 0);
  8426. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8427. builder.MoveToCell(2, i, 2, 0);
  8428. builder.Write("费用标准:");
  8429. string curr = "";
  8430. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8431. if (currData != null)
  8432. {
  8433. curr = currData.Name;
  8434. }
  8435. builder.MoveToCell(2, i, 3, 0);
  8436. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8437. builder.MoveToCell(2, i, 4, 0);
  8438. builder.Write("费用小计:");
  8439. builder.MoveToCell(2, i, 5, 0);
  8440. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8441. }
  8442. //删除多余行
  8443. while (table3.Rows.Count > table3Row)
  8444. {
  8445. table3.Rows.RemoveAt(table3Row);
  8446. }
  8447. #endregion
  8448. }
  8449. else dic.Add("SubGZF", "0.00");
  8450. //删除多余行
  8451. while (table3.Rows.Count > table3Row)
  8452. {
  8453. table3.Rows.RemoveAt(table3Row);
  8454. }
  8455. //培训费
  8456. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  8457. if (_EnterExitCosts.ChoiceSix == 1)
  8458. {
  8459. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  8460. dic.Add("SubPX", pxStr);
  8461. table4Row = dac4.Count;
  8462. #region 填充word表格内容
  8463. for (int i = 0; i < dac4.Count; i++)
  8464. {
  8465. var dac = dac4[i];
  8466. if (dac == null) continue;
  8467. builder.MoveToCell(3, i, 0, 0);
  8468. builder.Write("第" + dac.Days.ToString() + "天:");
  8469. builder.MoveToCell(3, i, 1, 0);
  8470. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  8471. builder.MoveToCell(3, i, 2, 0);
  8472. builder.Write("费用标准:");
  8473. string curr = "";
  8474. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  8475. if (currData != null)
  8476. {
  8477. curr = currData.Name;
  8478. }
  8479. builder.MoveToCell(3, i, 3, 0);
  8480. builder.Write(dac.Cost.ToString("#0.00") + curr);
  8481. builder.MoveToCell(3, i, 4, 0);
  8482. builder.Write("费用小计:");
  8483. builder.MoveToCell(3, i, 5, 0);
  8484. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8485. }
  8486. #endregion
  8487. }
  8488. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  8489. //删除多余行
  8490. while (table4.Rows.Count > table4Row)
  8491. {
  8492. table4.Rows.RemoveAt(table4Row);
  8493. }
  8494. //其他费用
  8495. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8496. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8497. {
  8498. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  8499. dic.Add("titleQi", qtStr);
  8500. table5Row = dac5.Count;
  8501. #region 填充word表格内容
  8502. for (int i = 0; i < dac5.Count; i++)
  8503. {
  8504. var dac = dac5[i];
  8505. if (dac == null) continue;
  8506. builder.MoveToCell(4, i, 0, 0);
  8507. builder.Write("第" + dac.Index.ToString() + "项:");
  8508. builder.MoveToCell(4, i, 1, 0);
  8509. builder.Write(dac.itemName);
  8510. builder.MoveToCell(4, i, 2, 0);
  8511. builder.Write("费用标准:");
  8512. builder.MoveToCell(4, i, 3, 0);
  8513. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8514. builder.MoveToCell(4, i, 4, 0);
  8515. builder.Write("费用小计:");
  8516. builder.MoveToCell(4, i, 5, 0);
  8517. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8518. builder.MoveToCell(4, i, 6, 0);
  8519. builder.Write("备注:");
  8520. builder.MoveToCell(4, i, 7, 0);
  8521. builder.Write(dac.Remark);
  8522. }
  8523. #endregion
  8524. }
  8525. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8526. //删除多余行
  8527. while (table5.Rows.Count > table5Row)
  8528. {
  8529. table5.Rows.RemoveAt(table5Row);
  8530. }
  8531. //加上其他费用
  8532. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8533. decimal subJJC = 0.00M,
  8534. subGWC = 0.00M,
  8535. subTDC = 0.00M;
  8536. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8537. string totalLabel = string.Format("全部费用总计:");
  8538. //经济舱
  8539. if (_EnterExitCosts.SumJJC == 1)
  8540. {
  8541. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8542. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  8543. }
  8544. //公务舱
  8545. if (_EnterExitCosts.SumGWC == 1)
  8546. {
  8547. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8548. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  8549. }
  8550. //头等舱
  8551. if (_EnterExitCosts.SumTDC == 1)
  8552. {
  8553. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8554. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  8555. }
  8556. //TotalLabel
  8557. dic.Add("TotalLabel", totalLabel);
  8558. #region 填充word模板书签内容
  8559. foreach (var key in dic.Keys)
  8560. {
  8561. Bookmark bookmark = doc.Range.Bookmarks[key];
  8562. if (bookmark != null)
  8563. {
  8564. builder.MoveToBookmark(key);
  8565. builder.Write(dic[key]);
  8566. }
  8567. }
  8568. #endregion
  8569. //文件名
  8570. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  8571. strFileName = CommonFun.ValidFileName(strFileName);
  8572. AsposeHelper.removewatermark_v2180();
  8573. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8574. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8575. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8576. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8577. }
  8578. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8579. {
  8580. //获取模板
  8581. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8582. //载入模板
  8583. Document doc = new Document(tempPath);
  8584. DocumentBuilder builder = new DocumentBuilder(doc);
  8585. Dictionary<string, string> dic = new Dictionary<string, string>();
  8586. string returnCodeLabel = string.Empty;
  8587. if (nationalTravelFeeData.Any())
  8588. {
  8589. List<string> list = new List<string>();
  8590. foreach (var item in nationalTravelFeeData)
  8591. {
  8592. list.Add($"{item.Country}({item.City})");
  8593. }
  8594. list = list.Distinct().ToList();
  8595. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8596. }
  8597. var countryLabel = string.Empty;
  8598. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8599. if (countryData.Any())
  8600. {
  8601. countryLabel = string.Join("、", countryData);
  8602. }
  8603. dic.Add("ReturnCodeAir", returnCodeLabel);
  8604. dic.Add("VisitStartDate", "-");
  8605. dic.Add("VisitEndDate", "-");
  8606. dic.Add("Day", "-");
  8607. dic.Add("VisitCountry", countryLabel);
  8608. dic.Add("ClientUnit", "-");
  8609. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8610. //dic.Add("Names", Names);
  8611. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8612. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8613. decimal dac1totalPrice = 0.00M;
  8614. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8615. foreach (var dac in dac1)
  8616. {
  8617. if (dac.SubTotal == 0.00M)
  8618. {
  8619. continue;
  8620. }
  8621. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8622. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8623. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8624. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8625. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8626. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8627. builder.Write(currency);//币种
  8628. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8629. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8630. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8631. builder.Write("");//人数
  8632. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8633. builder.Write("");//天数
  8634. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8635. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8636. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8637. decimal rate = 0.00M;
  8638. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8639. builder.Write(rate.ToString("#0.0000"));//汇率
  8640. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8641. decimal rbmPrice = dac.SubTotal;
  8642. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8643. accommodationStartIndex++;
  8644. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8645. }
  8646. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8647. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8648. {
  8649. table1.Rows.RemoveAt(i - 1);
  8650. foodandotherStartIndex--;
  8651. }
  8652. if (dac2.Count == dac3.Count)//国家 币种 金额
  8653. {
  8654. for (int i = 0; i < dac2.Count; i++)
  8655. {
  8656. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8657. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8658. }
  8659. }
  8660. decimal dac2totalPrice = 0.00M;
  8661. foreach (var dac in dac2)
  8662. {
  8663. if (dac.SubTotal == 0)
  8664. {
  8665. continue;
  8666. }
  8667. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8668. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8669. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8670. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8671. builder.Write(currency);//币种
  8672. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8673. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8674. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8675. builder.Write("");//人数
  8676. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8677. builder.Write("");//天数
  8678. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8679. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8680. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8681. decimal rate = 0.00M;
  8682. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8683. builder.Write(rate.ToString("#0.0000"));//汇率
  8684. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8685. decimal rbmPrice = dac.SubTotal;
  8686. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8687. foodandotherStartIndex++;
  8688. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8689. }
  8690. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8691. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8692. {
  8693. table1.Rows.RemoveAt(i - 1);
  8694. }
  8695. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8696. string otherFeeStr = "";
  8697. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  8698. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  8699. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  8700. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8701. foreach (var otherInfo in dac5)
  8702. {
  8703. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8704. }
  8705. #endregion
  8706. if (otherFeeStr.Length > 0)
  8707. {
  8708. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8709. otherFeeStr = $"({otherFeeStr})";
  8710. dic.Add("OtherFeeStr", otherFeeStr);
  8711. }
  8712. //总计
  8713. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8714. //国际旅费
  8715. string outsideAir = string.Empty;
  8716. string allPriceAir = string.Empty;
  8717. if (_EnterExitCosts.SumJJC == 1)
  8718. {
  8719. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8720. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8721. }
  8722. if (_EnterExitCosts.SumGWC == 1)
  8723. {
  8724. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8725. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8726. }
  8727. if (_EnterExitCosts.SumTDC == 1)
  8728. {
  8729. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8730. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8731. }
  8732. dic.Add("InTravelPrice", $"({outsideAir})");
  8733. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8734. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8735. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8736. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8737. foreach (var key in dic.Keys)
  8738. {
  8739. builder.MoveToBookmark(key);
  8740. builder.Write(dic[key]);
  8741. }
  8742. //模板文件名
  8743. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8744. strFileName = CommonFun.ValidFileName(strFileName);
  8745. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8746. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8747. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8748. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8749. }
  8750. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8751. {
  8752. //获取模板
  8753. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8754. //载入模板
  8755. WorkbookDesigner designer = new WorkbookDesigner();
  8756. designer.Workbook = new Workbook(tempPath);
  8757. Dictionary<string, string> dic = new Dictionary<string, string>();
  8758. string returnCodeLabel = string.Empty;
  8759. if (nationalTravelFeeData.Any())
  8760. {
  8761. List<string> list = new List<string>();
  8762. foreach (var item in nationalTravelFeeData)
  8763. {
  8764. list.Add($"{item.Country}({item.City})");
  8765. }
  8766. list = list.Distinct().ToList();
  8767. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  8768. }
  8769. var countryLabel = string.Empty;
  8770. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  8771. if (countryData.Any())
  8772. {
  8773. countryLabel = string.Join("、", countryData);
  8774. }
  8775. dic.Add("ReturnCodeAir", returnCodeLabel);
  8776. dic.Add("VisitStartDate", "-");
  8777. dic.Add("VisitEndDate", "-");
  8778. dic.Add("Day", "0");
  8779. dic.Add("VisitCountry", countryLabel);
  8780. dic.Add("ClientUnit", "-");
  8781. designer.SetDataSource("ClientUnit", "-");
  8782. designer.SetDataSource("VisitCountry", countryLabel);
  8783. designer.SetDataSource("Group", "-");
  8784. designer.SetDataSource("ClientUnitTitle", "-");
  8785. designer.SetDataSource("Name", "-");
  8786. designer.SetDataSource("VisitStartDate", "-");
  8787. designer.SetDataSource("Day", "0");
  8788. designer.SetDataSource("ReturnCode", returnCodeLabel);
  8789. designer.SetDataSource("ReturnCodeAir", "-");
  8790. int startIndex = 10;
  8791. const int startIndexcopy = 10;
  8792. if (dac2.Count == dac3.Count)//国家 币种 金额
  8793. {
  8794. for (int i = 0; i < dac2.Count; i++)
  8795. {
  8796. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8797. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8798. }
  8799. }
  8800. DataTable dtdac1 = new DataTable();
  8801. List<string> place = new List<string>();
  8802. dtdac1.Columns.AddRange(new DataColumn[] {
  8803. new DataColumn(){ ColumnName = "city"},
  8804. new DataColumn(){ ColumnName = "curr"},
  8805. new DataColumn(){ ColumnName = "criterion"},
  8806. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8807. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8808. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8809. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8810. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8811. });
  8812. DataTable dtdac2 = new DataTable();
  8813. dtdac2.Columns.AddRange(new DataColumn[] {
  8814. new DataColumn(){ ColumnName = "city"},
  8815. new DataColumn(){ ColumnName = "curr"},
  8816. new DataColumn(){ ColumnName = "criterion"},
  8817. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  8818. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  8819. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  8820. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  8821. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8822. });
  8823. dtdac1.TableName = "tb1";
  8824. dtdac2.TableName = "tb2";
  8825. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8826. foreach (var item in dac1)
  8827. {
  8828. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8829. if (place.Contains(item.Place))
  8830. {
  8831. continue;
  8832. }
  8833. DataRow row = dtdac1.NewRow();
  8834. row["city"] = item.Place;
  8835. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8836. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8837. row["curr"] = currency;
  8838. row["rate"] = rate.ToString("#0.0000");
  8839. row["criterion"] = item.Cost.ToString("#0.00");
  8840. row["number"] = 1;
  8841. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8842. //row["costRMB"] = rbmPrice;
  8843. dtdac1.Rows.Add(row);
  8844. place.Add(item.Place);
  8845. }
  8846. place = new List<string>();
  8847. foreach (var item in dac2)
  8848. {
  8849. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  8850. if (place.Contains(item.Place))
  8851. {
  8852. continue;
  8853. }
  8854. DataRow row = dtdac2.NewRow();
  8855. row["city"] = item.Place;
  8856. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8857. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8858. row["curr"] = currency;
  8859. row["rate"] = rate.ToString("#0.0000");
  8860. row["criterion"] = item.Cost.ToString("#0.00");
  8861. row["number"] = 1;
  8862. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8863. //row["cost"] = item.SubTotal;
  8864. //row["costRMB"] = rbmPrice;
  8865. dtdac2.Rows.Add(row);
  8866. place.Add(item.Place);
  8867. //dac2totalPrice += rbmPrice;
  8868. }
  8869. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8870. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8871. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8872. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8873. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8874. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8875. string cell4Str1 = string.Empty;
  8876. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8877. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8878. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8879. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8880. string cellStr = $" 5.其他费用(";
  8881. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8882. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8883. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8884. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8885. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8886. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8887. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8888. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8889. foreach (var otherInfo in dac5)
  8890. {
  8891. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8892. }
  8893. #endregion
  8894. if (cellStr.Length > 8)
  8895. {
  8896. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8897. }
  8898. cellStr += ")";
  8899. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8900. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8901. decimal pxFee = dac4.Sum(it => it.Cost);
  8902. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8903. string celllastStr1 = "";
  8904. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8905. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8906. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8907. celllastStr1 += $",国际旅费 元";
  8908. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8909. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8910. designer.SetDataSource("cell4Str", cell4Str);
  8911. designer.SetDataSource("cellStr", cellStr);
  8912. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8913. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8914. designer.SetDataSource("celllastStr", celllastStr);
  8915. Workbook wb = designer.Workbook;
  8916. var sheet = wb.Worksheets[0];
  8917. //绑定datatable数据集
  8918. designer.SetDataSource(dtdac1);
  8919. designer.SetDataSource(dtdac2);
  8920. designer.Process();
  8921. var rowStart = dtdac1.Rows.Count;
  8922. while (rowStart > 0)
  8923. {
  8924. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8925. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8926. startIndex++;
  8927. rowStart--;
  8928. }
  8929. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8930. startIndex += 1; //总计行
  8931. rowStart = dtdac2.Rows.Count;
  8932. while (rowStart > 0)
  8933. {
  8934. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8935. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8936. startIndex++;
  8937. rowStart--;
  8938. }
  8939. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8940. wb.CalculateFormula(true);
  8941. //模板文件名
  8942. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8943. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8944. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8945. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8946. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8947. }
  8948. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8949. {
  8950. //获取模板
  8951. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8952. //载入模板
  8953. Document doc = new Document(tempPath);
  8954. DocumentBuilder builder = new DocumentBuilder(doc);
  8955. Dictionary<string, string> dic = new Dictionary<string, string>();
  8956. dic.Add("GroupName", "-");
  8957. dic.Add("ClientUnit", "-");
  8958. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8959. //string missionLeaderJob = "";//负责人job
  8960. //int groupNumber = 0; //团人数
  8961. dic.Add("MissionLeader", "-"); //团负责人
  8962. dic.Add("MissionLeaderJob", "-"); //团负责人job
  8963. dic.Add("GroupNumber", "0"); //团人数
  8964. dic.Add("Day", "0");
  8965. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8966. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8967. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8968. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8969. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8970. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8971. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8972. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8973. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8974. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8975. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8976. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8977. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8978. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  8979. //其他费用
  8980. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8981. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8982. //其他费用合计
  8983. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8984. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  8985. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  8986. //公务舱合计
  8987. //国际旅费
  8988. //string outsideJJ = "";
  8989. //string allPriceJJ = "";
  8990. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8991. {
  8992. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8993. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8994. }
  8995. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8996. {
  8997. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  8998. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8999. }
  9000. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  9001. {
  9002. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  9003. dic.Add("AirFeeTotal", airFeeTotalStr);
  9004. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  9005. dic.Add("FeeTotal", feeTotalStr);
  9006. }
  9007. foreach (var key in dic.Keys)
  9008. {
  9009. builder.MoveToBookmark(key);
  9010. builder.Write(dic[key]);
  9011. }
  9012. //模板文件名
  9013. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  9014. strFileName = CommonFun.ValidFileName(strFileName);
  9015. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9016. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9017. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9018. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9019. }
  9020. }
  9021. else if (dto.ExportType == 2) //表格
  9022. {
  9023. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9024. }
  9025. else if (dto.ExportType == 3)
  9026. {
  9027. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  9028. }
  9029. return Ok(JsonView(400, "只可导出明细表!", ""));
  9030. }
  9031. catch (Exception ex)
  9032. {
  9033. return Ok(JsonView(400, ex.Message, ""));
  9034. }
  9035. }
  9036. /// <summary>
  9037. /// 获取三公费用标准city
  9038. /// </summary>
  9039. /// <param name="placeData"></param>
  9040. /// <param name="nationalTravelFeeId"></param>
  9041. /// <returns></returns>
  9042. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  9043. {
  9044. string _city = string.Empty;
  9045. if (!placeData.Any()) return _city;
  9046. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  9047. if (data == null) return _city;
  9048. string country = data.Country;
  9049. string city = data.City;
  9050. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  9051. else _city = city;
  9052. return _city;
  9053. }
  9054. /// <summary>
  9055. /// 团组模块 - 出入境费用-草稿 - 一键清空
  9056. /// </summary>
  9057. /// <returns></returns>
  9058. [HttpPost]
  9059. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9061. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  9062. {
  9063. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  9064. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  9065. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  9066. if (_view.Code == 0)
  9067. {
  9068. return Ok(JsonView(true, "操作成功"));
  9069. }
  9070. return Ok(JsonView(false, "操作失败"));
  9071. }
  9072. /// <summary>
  9073. /// 团组模块 - 出入境费用-草稿 - 子项删除
  9074. /// </summary>
  9075. /// <returns></returns>
  9076. [HttpPost]
  9077. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9079. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  9080. {
  9081. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  9082. if (data.Code != 0)
  9083. {
  9084. return Ok(JsonView(false, data.Msg));
  9085. }
  9086. return Ok(JsonView(true, "操作成功!", data.Data));
  9087. }
  9088. /// <summary>
  9089. /// 三公其他费用草稿 删除
  9090. /// </summary>
  9091. /// <param name="dto"></param>
  9092. /// <returns></returns>
  9093. [HttpPost]
  9094. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  9095. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  9096. {
  9097. var jw = JsonView(false, "删除失败!");
  9098. var data = new Grp_DayOtherPriceDraft()
  9099. {
  9100. Id = dto.Id,
  9101. IsDel = 1,
  9102. DeleteUserId = dto.DeleteUserId,
  9103. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9104. };
  9105. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9106. if (del > 0)
  9107. {
  9108. jw.Code = 200;
  9109. jw.Msg = "删除成功!";
  9110. }
  9111. return Ok(jw);
  9112. }
  9113. /// <summary>
  9114. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  9115. /// </summary>
  9116. /// <returns></returns>
  9117. [HttpPost]
  9118. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  9119. {
  9120. var jw = JsonView(false);
  9121. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  9122. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  9123. jw.Code = StatusCodes.Status200OK;
  9124. jw.Msg = "操作成功!";
  9125. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  9126. return Ok(jw);
  9127. }
  9128. /// <summary>
  9129. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  9130. /// </summary>
  9131. /// <param name="dto"></param>
  9132. /// <returns></returns>
  9133. [HttpPost]
  9134. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  9135. {
  9136. int userId = dto.UserId,
  9137. portId = dto.PortType,
  9138. groupId = dto.GroupId,
  9139. draftId = dto.DraftId;
  9140. _portTypeData.Add(1);
  9141. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9142. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  9143. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  9144. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  9145. _sqlSugar.BeginTran();
  9146. try
  9147. {
  9148. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  9149. if (draftDatas == null)
  9150. {
  9151. _sqlSugar.RollbackTran();
  9152. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  9153. }
  9154. //验证可覆盖已有数据 两边创建人需为同一人;
  9155. int draftCreateUserId = draftDatas.CreateUserId,
  9156. formalCreateUserId = 0;
  9157. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9158. if (formalData != null)
  9159. {
  9160. formalCreateUserId = formalData.CreateUserId;
  9161. if (draftCreateUserId != formalCreateUserId)
  9162. {
  9163. _sqlSugar.RollbackTran();
  9164. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  9165. }
  9166. }
  9167. //默认添加查看、编辑权限(创建人、自己)
  9168. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  9169. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9170. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  9171. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  9172. newExterData.DiId = groupId;
  9173. newExterData.CreateUserId = userId;
  9174. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  9175. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  9176. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  9177. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  9178. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  9179. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  9180. //数据如果存在执行删除
  9181. if (enterExitCostInfo != null)
  9182. {
  9183. _sqlSugar.Updateable<Grp_EnterExitCost>()
  9184. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  9185. .Where(x => x.Id == enterExitCostInfo.Id)
  9186. .ExecuteCommand();
  9187. _sqlSugar.Updateable<Grp_DayAndCost>()
  9188. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9189. .Where(x => x.DiId == groupId)
  9190. .ExecuteCommand();
  9191. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  9192. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9193. .Where(x => x.Diid == groupId)
  9194. .ExecuteCommand();
  9195. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  9196. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  9197. .Where(x => x.GroupId == groupId)
  9198. .ExecuteCommand();
  9199. }
  9200. //执行insert
  9201. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  9202. if (insertId < 1)
  9203. {
  9204. _sqlSugar.RollbackTran();
  9205. return Ok(JsonView(false, "草稿数据导入失败!"));
  9206. }
  9207. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  9208. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  9209. #region 默认添加权限
  9210. #endregion
  9211. _sqlSugar.CommitTran();
  9212. //执行操作之后
  9213. //生成默认文件pdf并且通知人员
  9214. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9215. {
  9216. DiId = groupId,
  9217. ExportType = 1,
  9218. SubTypeId = 1005
  9219. }, "pdf");
  9220. //发送通知
  9221. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9222. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  9223. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  9224. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9225. //汇率信息记录
  9226. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  9227. return Ok(JsonView(true));
  9228. }
  9229. catch (Exception ex)
  9230. {
  9231. _sqlSugar.RollbackTran();
  9232. return Ok(JsonView(false, ex.Message));
  9233. }
  9234. }
  9235. #endregion
  9236. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  9237. /// <summary>
  9238. /// 获取币种基础数据(含逻辑处理)
  9239. /// </summary>
  9240. /// <returns></returns>
  9241. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  9242. {
  9243. return await GeneralMethod.EnterExitCostInitRate();
  9244. }
  9245. /// <summary>
  9246. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9247. /// </summary>
  9248. /// <returns></returns>
  9249. [HttpPost]
  9250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9251. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  9252. {
  9253. //验证城市归属并给默认值
  9254. int provinceId = dto.ProvinceId;
  9255. if (provinceId < 1) provinceId = 122;
  9256. var dataSource = await _sqlSugar
  9257. .Queryable<Sys_SetData>()
  9258. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  9259. .ToListAsync();
  9260. var fileTypes = new List<EecSetDataInfoView>();
  9261. //三公费用-Word明细类型
  9262. var wordTypeData = dataSource
  9263. .Where(it => it.STid == 72)
  9264. .Select(x => new EecSetDataInfoView
  9265. {
  9266. ParentId = 1,
  9267. Id = x.Id,
  9268. Name = x.Name
  9269. })
  9270. .ToArray();
  9271. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  9272. var excelTypeData = dataSource
  9273. .Where(it => it.STid == 73)
  9274. .Select(x => new EecSetDataInfoView
  9275. {
  9276. ParentId = 2,
  9277. Id = x.Id,
  9278. Name = x.Name
  9279. })
  9280. .ToArray();
  9281. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  9282. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  9283. fileTypes.Add(groupNameList);
  9284. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  9285. //默认币种显示
  9286. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9287. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9288. return Ok(JsonView(true, "查询成功!", new
  9289. {
  9290. FileTypeData = fileTypes,
  9291. CurrencyInit = _currencyInfos,
  9292. viewPermissionData = viewPermissionData
  9293. }));
  9294. }
  9295. /// <summary>
  9296. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  9297. /// </summary>
  9298. /// <returns></returns>
  9299. [HttpPost]
  9300. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9301. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  9302. {
  9303. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9304. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9305. RefAsync<int> total = 0;
  9306. int diId = 0;
  9307. var status = int.TryParse(dto.GroupName, out diId);
  9308. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  9309. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9310. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9311. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9312. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9313. .OrderByDescending(x => x.VisitStartDate)
  9314. .Select(x => new EnterExitCostMobileGroupView()
  9315. {
  9316. Id = x.Id,
  9317. GroupName = x.TeamName,
  9318. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  9319. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  9320. ProvinceId = x.CityId
  9321. })
  9322. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9323. //处理省份Id
  9324. if (data.Any())
  9325. {
  9326. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  9327. if (provCityDatas.Any())
  9328. {
  9329. foreach (var item in data)
  9330. {
  9331. var provinceId = item.ProvinceId;
  9332. var isDefualtVal = true;
  9333. if (provinceId > 0)
  9334. {
  9335. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  9336. if (parentId != null)
  9337. {
  9338. isDefualtVal = false;
  9339. item.ProvinceId = (int)parentId;
  9340. }
  9341. }
  9342. if (isDefualtVal)
  9343. {
  9344. item.ProvinceId = 122; //默认四川
  9345. }
  9346. }
  9347. }
  9348. }
  9349. //处理是否显示
  9350. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  9351. {
  9352. foreach (var item in data)
  9353. {
  9354. item.IsView = true;
  9355. }
  9356. }
  9357. return Ok(JsonView(true, "查询成功!", data, total));
  9358. }
  9359. /// <summary>
  9360. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  9361. /// </summary>
  9362. /// <returns></returns>
  9363. [HttpPost]
  9364. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9365. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  9366. {
  9367. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9368. RefAsync<int> total = 0;
  9369. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9370. .Where(x => x.IsDel == 0 && x.STid == 66)
  9371. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9372. .Select(x => new
  9373. {
  9374. id = x.Id,
  9375. name = x.Name,
  9376. remark = x.Remark,
  9377. })
  9378. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9379. return Ok(JsonView(true, "查询成功!", data, total));
  9380. }
  9381. /// <summary>
  9382. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9383. /// </summary>
  9384. /// <returns></returns>
  9385. [HttpPost]
  9386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9387. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  9388. {
  9389. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9390. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9391. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  9392. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9393. var groupOtherRateData = groupRateData.TeamRates;
  9394. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9395. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9396. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9397. groupOtherRateData = groupOtherRateData
  9398. .Select(x => new TeamRateDescAddCurrencyIdView
  9399. {
  9400. CurrencyId = x.CurrencyId,
  9401. CurrencyName = x.CurrencyName,
  9402. CurrencyCode = x.CurrencyCode,
  9403. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9404. }).ToList();
  9405. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9406. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9407. }
  9408. /// <summary>
  9409. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9410. /// </summary>
  9411. /// <returns></returns>
  9412. [HttpPost]
  9413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9414. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  9415. {
  9416. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9417. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9418. var tipsData = new List<int>() { 1, 2, 3 };
  9419. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9420. if (dto.TipsType == 1)
  9421. {
  9422. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  9423. }
  9424. else if (dto.TipsType == 2)
  9425. {
  9426. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  9427. return Ok(JsonView(true, "查询成功!", visaData.Data));
  9428. }
  9429. else if (dto.TipsType == 3)
  9430. {
  9431. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  9432. return Ok(JsonView(true, "查询成功!", airData));
  9433. }
  9434. return Ok(JsonView(false));
  9435. }
  9436. /// <summary>
  9437. /// 团组模块 - 出入境国家费用标准-移动端 List
  9438. /// </summary>
  9439. /// <returns></returns>
  9440. [HttpPost]
  9441. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9442. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  9443. {
  9444. Stopwatch sw = new Stopwatch();
  9445. sw.Start();
  9446. int provinceId = dto.ProvinceId;
  9447. if (provinceId < 1) provinceId = 122; // 默认四川
  9448. RefAsync<int> total = 0;
  9449. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9450. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  9451. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  9452. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  9453. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9454. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  9455. .Select((ntf, sd, u, sd1) => new
  9456. {
  9457. Id = ntf.Id,
  9458. Area = $"{ntf.Country}-{ntf.City}",
  9459. Currency = ntf.Currency,
  9460. CurrencyCode = sd.Name,
  9461. CurrencyName = sd.Remark,
  9462. RoomCost = ntf.RoomCost,
  9463. FoodCost = ntf.FoodCost,
  9464. PublicCost = ntf.PublicCost,
  9465. TrainCost = ntf.TrainCost,
  9466. LastUpdateUserId = ntf.LastUpdateUserId,
  9467. LastUpdateUserName = u.CnName,
  9468. LastUpdateTime = ntf.LastUpdateTime
  9469. })
  9470. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9471. sw.Stop();
  9472. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  9473. }
  9474. /// <summary>
  9475. /// 团组模块 - 出入境费用-移动端 - Info
  9476. /// </summary>
  9477. /// <returns></returns>
  9478. [HttpPost]
  9479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9480. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  9481. {
  9482. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9483. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9484. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  9485. return Ok(data);
  9486. }
  9487. /// <summary>
  9488. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  9489. /// </summary>
  9490. /// <returns></returns>
  9491. [HttpPost]
  9492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9493. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  9494. {
  9495. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9496. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9497. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9498. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9499. var mobileInfo = new EnterExitCostMobileParentInfoView();
  9500. mobileInfo.DiId = dto.DiId;
  9501. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9502. if (eecInfo == null) return Ok(mobileInfo);
  9503. //验证查看权限
  9504. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  9505. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  9506. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9507. mobileInfo.IsAssignPerm = isSet;
  9508. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9509. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9510. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9511. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9512. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9513. {
  9514. SubId = dac.Id,
  9515. DiId = dac.DiId,
  9516. Type = dac.Type,
  9517. Days = dac.Days,
  9518. NationalTravelFeeId = dac.NationalTravelFeeId,
  9519. Arae = $"{ntf.Country}-{ntf.City}",
  9520. Cost = dac.Cost,
  9521. Currency = dac.Currency,
  9522. CurrencyName = sd.Name,
  9523. SubTotal = dac.SubTotal,
  9524. })
  9525. .ToList();
  9526. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9527. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9528. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9529. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9530. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9531. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9532. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9533. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9534. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9535. //其他款项
  9536. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9537. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9538. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9539. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9540. .OrderBy((dop, sd1, sd2) => dop.Index)
  9541. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9542. {
  9543. SubId = dop.Id,
  9544. DiId = dop.Diid,
  9545. Index = dop.Index,
  9546. SetDataId = dop.SetDataId,
  9547. SetDataName = sd1.Name,
  9548. Cost = dop.Cost,
  9549. Currency = dop.Currency,
  9550. CurrencyName = sd2.Remark,
  9551. SubTotal = dop.SubTotal,
  9552. Remark = dop.Remark,
  9553. })
  9554. .ToArray();
  9555. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9556. return Ok(mobileInfo);
  9557. }
  9558. /// <summary>
  9559. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  9560. /// </summary>
  9561. /// <returns></returns>
  9562. [HttpPost]
  9563. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9564. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  9565. {
  9566. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9567. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9568. //验证查看权限
  9569. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  9570. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  9571. var userIds = await _sqlSugar
  9572. .Queryable<Grp_EnterExitCostPermission>()
  9573. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  9574. .Select(x => x.UserId)
  9575. .ToArrayAsync();
  9576. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  9577. var perUsersView = new List<dynamic>();
  9578. foreach (var item in perUsers)
  9579. {
  9580. bool isView1 = false;
  9581. if (userIds.Any(x => x == item.Id)) isView1 = true;
  9582. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  9583. }
  9584. return Ok(JsonView(perUsersView));
  9585. }
  9586. /// <summary>
  9587. /// 团组模块 - 出入境费用-移动端 - SubInfo
  9588. /// </summary>
  9589. /// <returns></returns>
  9590. [HttpPost]
  9591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9592. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9593. {
  9594. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9595. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9596. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9597. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9598. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9599. //验证查看权限
  9600. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  9601. //if (!isView) return Ok(JsonView(false, msg));
  9602. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9603. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9604. var subType = dto.SubType;
  9605. if (subType == 1) //1:境内费用
  9606. {
  9607. var oneData = new ChoiceOneMobileSubInfoView()
  9608. {
  9609. Id = eecInfo.Id,
  9610. ChoiceOne = eecInfo.ChoiceOne,
  9611. ChoiceOneTotalCost = eecInfo.InsidePay,
  9612. Visa = eecInfo.Visa,
  9613. VisaRemark = eecInfo.VisaRemark,
  9614. YiMiao = eecInfo.YiMiao,
  9615. HeSuan = eecInfo.HeSuan,
  9616. Service = eecInfo.Service,
  9617. Ticket = eecInfo.Ticket,
  9618. Safe = eecInfo.Safe,
  9619. FirstItemRemark = eecInfo.FirstItemRemark
  9620. };
  9621. return Ok(JsonView(oneData));
  9622. }
  9623. else if (subType == 2) //2:国际旅费
  9624. {
  9625. var twoData = new ChoiceTwoMobileSubInfoView()
  9626. {
  9627. Id = eecInfo.Id,
  9628. ChoiceTwoJJ = eecInfo.SumJJC,
  9629. OutsideJJPay = eecInfo.OutsideJJPay,
  9630. ChoiceTwoGW = eecInfo.SumGWC,
  9631. OutsideGWPay = eecInfo.OutsideGWPay,
  9632. ChoiceTwoTD = eecInfo.SumTDC,
  9633. OutsideTDPay = eecInfo.OutsideTDPay,
  9634. AirJJ = eecInfo.AirJJ,
  9635. AirGW = eecInfo.AirGW,
  9636. AirTD = eecInfo.AirTD,
  9637. CityTranffic = eecInfo.CityTranffic,
  9638. TwoItemRemark = eecInfo.TwoItemRemark
  9639. };
  9640. return Ok(JsonView(twoData));
  9641. }
  9642. else if (subType == 3) //3:住宿费
  9643. {
  9644. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9645. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9646. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9647. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9648. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9649. {
  9650. SubId = dac.Id,
  9651. DiId = dac.DiId,
  9652. Type = dac.Type,
  9653. Days = dac.Days,
  9654. NationalTravelFeeId = dac.NationalTravelFeeId,
  9655. Arae = $"{ntf.Country}-{ntf.City}",
  9656. Cost = dac.Cost,
  9657. Currency = dac.Currency,
  9658. CurrencyName = sd.Name,
  9659. SubTotal = dac.SubTotal,
  9660. })
  9661. .ToArray();
  9662. var data = new ChoiceMobileSubInfo3To6View()
  9663. {
  9664. ParentId = eecInfo.Id,
  9665. Choice = eecInfo.ChoiceThree,
  9666. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9667. Details = dayAndCostDatas
  9668. };
  9669. return Ok(JsonView(data));
  9670. }
  9671. else if (subType == 4) //4:伙食费
  9672. {
  9673. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9674. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9675. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9676. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9677. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9678. {
  9679. SubId = dac.Id,
  9680. DiId = dac.DiId,
  9681. Type = dac.Type,
  9682. Days = dac.Days,
  9683. NationalTravelFeeId = dac.NationalTravelFeeId,
  9684. Arae = $"{ntf.Country}-{ntf.City}",
  9685. Cost = dac.Cost,
  9686. Currency = dac.Currency,
  9687. CurrencyName = sd.Name,
  9688. SubTotal = dac.SubTotal,
  9689. })
  9690. .ToArray();
  9691. var data = new ChoiceMobileSubInfo3To6View()
  9692. {
  9693. ParentId = eecInfo.Id,
  9694. Choice = eecInfo.ChoiceFour,
  9695. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9696. Details = dayAndCostDatas
  9697. };
  9698. return Ok(JsonView(data));
  9699. }
  9700. else if (subType == 5) //5:公杂费
  9701. {
  9702. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9703. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9704. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9705. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9706. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9707. {
  9708. SubId = dac.Id,
  9709. DiId = dac.DiId,
  9710. Type = dac.Type,
  9711. Days = dac.Days,
  9712. NationalTravelFeeId = dac.NationalTravelFeeId,
  9713. Arae = $"{ntf.Country}-{ntf.City}",
  9714. Cost = dac.Cost,
  9715. Currency = dac.Currency,
  9716. CurrencyName = sd.Name,
  9717. SubTotal = dac.SubTotal,
  9718. })
  9719. .ToArray();
  9720. var data = new ChoiceMobileSubInfo3To6View()
  9721. {
  9722. ParentId = eecInfo.Id,
  9723. Choice = eecInfo.ChoiceFive,
  9724. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9725. Details = dayAndCostDatas
  9726. };
  9727. return Ok(JsonView(data));
  9728. }
  9729. else if (subType == 6) //6:培训费
  9730. {
  9731. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9732. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9733. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9734. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9735. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9736. {
  9737. SubId = dac.Id,
  9738. DiId = dac.DiId,
  9739. Type = dac.Type,
  9740. Days = dac.Days,
  9741. NationalTravelFeeId = dac.NationalTravelFeeId,
  9742. Arae = $"{ntf.Country}-{ntf.City}",
  9743. Cost = dac.Cost,
  9744. Currency = dac.Currency,
  9745. CurrencyName = sd.Name,
  9746. SubTotal = dac.SubTotal,
  9747. })
  9748. .ToArray();
  9749. var data = new ChoiceMobileSubInfo3To6View()
  9750. {
  9751. ParentId = eecInfo.Id,
  9752. Choice = eecInfo.ChoiceSix,
  9753. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9754. Details = dayAndCostDatas
  9755. };
  9756. return Ok(JsonView(data));
  9757. }
  9758. else if (subType == 7) //7:其他
  9759. {
  9760. //其他款项
  9761. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9762. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9763. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9764. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9765. .OrderBy((dop, sd1, sd2) => dop.Index)
  9766. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9767. {
  9768. SubId = dop.Id,
  9769. DiId = dop.Diid,
  9770. Index = dop.Index,
  9771. SetDataId = dop.SetDataId,
  9772. SetDataName = sd1.Name,
  9773. Cost = dop.Cost,
  9774. Currency = dop.Currency,
  9775. CurrencyName = sd2.Name,
  9776. SubTotal = dop.SubTotal,
  9777. Remark = dop.Remark,
  9778. })
  9779. .ToArray();
  9780. var data = new ChoiceSevenMobileSubInfoView()
  9781. {
  9782. ParentId = eecInfo.Id,
  9783. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9784. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9785. Details = otherData
  9786. };
  9787. return Ok(JsonView(data));
  9788. }
  9789. return Ok(JsonView(false));
  9790. }
  9791. #region op
  9792. /// <summary>
  9793. /// 移动端更新费用消息通知
  9794. /// </summary>
  9795. /// <param name="diid"></param>
  9796. /// <param name="id"></param>
  9797. /// <param name="currUserId"></param>
  9798. private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9799. {
  9800. try
  9801. {
  9802. ////生成默认文件pdf并且通知人员
  9803. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9804. //{
  9805. // DiId = diid,
  9806. // ExportType = 1,
  9807. // SubTypeId = 1005
  9808. //}, "pdf");
  9809. ////发送通知
  9810. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9811. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9812. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9813. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9814. ////汇率信息记录
  9815. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9816. }
  9817. catch (Exception ex)
  9818. {
  9819. //记录日志
  9820. throw;
  9821. }
  9822. }
  9823. /// <summary>
  9824. /// 验证出入境费用数据是否存在
  9825. /// 不存在添加
  9826. /// </summary>
  9827. /// <param name="diId"></param>
  9828. /// <param name="currUserId"></param>
  9829. /// <returns></returns>
  9830. /// <exception cref="CustomException"></exception>
  9831. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9832. {
  9833. var parentId = 0;
  9834. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9835. if (info != null)
  9836. {
  9837. parentId = info.Id;
  9838. }
  9839. else
  9840. {
  9841. var currencys = await EnterExitCostMobileGetCurrencyInit();
  9842. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9843. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9844. parentId = addId;
  9845. }
  9846. return parentId;
  9847. }
  9848. /// <summary>
  9849. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  9850. /// </summary>
  9851. /// <returns></returns>
  9852. [HttpPost]
  9853. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9854. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  9855. {
  9856. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9857. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9858. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9859. //验证编辑权限
  9860. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9861. //if (!isEdit) return Ok(JsonView(false, msg));
  9862. var permissions = new List<Grp_EnterExitCostPermission>();
  9863. foreach (var userId in dto.UserIds)
  9864. {
  9865. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  9866. }
  9867. if (permissions.Any())
  9868. {
  9869. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  9870. {
  9871. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  9872. }
  9873. _sqlSugar.BeginTran();
  9874. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  9875. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9876. if (result < 1)
  9877. {
  9878. _sqlSugar.RollbackTran();
  9879. return Ok(JsonView(false));
  9880. }
  9881. _sqlSugar.CommitTran();
  9882. return Ok(JsonView(true));
  9883. }
  9884. return Ok(JsonView(false));
  9885. }
  9886. /// <summary>
  9887. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  9888. /// </summary>
  9889. /// <returns></returns>
  9890. [HttpPost]
  9891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9892. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  9893. {
  9894. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9895. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9896. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9897. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9898. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9899. int id = dto.Id;
  9900. if (id <= 0) //add
  9901. {
  9902. //int provinceId = dto.ProvinceId;
  9903. int groupId = dto.DiId;
  9904. //if (provinceId < 1) provinceId = 122;
  9905. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  9906. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  9907. if (add < 1) return Ok(JsonView(false));
  9908. id = add;
  9909. }
  9910. else //update
  9911. {
  9912. ////验证编辑权限
  9913. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  9914. //if (!isEdit) return Ok(JsonView(false, msg));
  9915. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  9916. if (upd < 1) return Ok(JsonView(false));
  9917. }
  9918. #region 汇率变更时更改币种相关费用
  9919. var opDayCosts = new List<Grp_DayAndCost>();
  9920. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  9921. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9922. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  9923. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9924. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9925. .Select((dac, sd) => new
  9926. {
  9927. dac.Id,
  9928. dac.DiId,
  9929. CurrencyCode = sd.Name,
  9930. dac.Cost
  9931. })
  9932. .ToList();
  9933. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9934. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9935. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9936. .Select((dop, sd) => new
  9937. {
  9938. dop.Id,
  9939. dop.Diid,
  9940. CurrencyCode = sd.Name,
  9941. dop.Cost
  9942. })
  9943. .ToList();
  9944. if (dayCosts.Count > 0)
  9945. {
  9946. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9947. foreach (var dc in new_dayCosts)
  9948. {
  9949. var thisCurrency = dc.Key.ToUpper();
  9950. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9951. if (thisRate == 0.00M) continue;
  9952. foreach (var dcSub in dc)
  9953. {
  9954. opDayCosts.Add(new Grp_DayAndCost()
  9955. {
  9956. Id = dcSub.Id,
  9957. DiId = dcSub.DiId,
  9958. Cost = dcSub.Cost,
  9959. SubTotal = dcSub.Cost * thisRate,
  9960. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9961. });
  9962. }
  9963. }
  9964. if (opDayCosts.Count > 0)
  9965. {
  9966. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9967. }
  9968. }
  9969. if (dayOtherCosts.Count > 0)
  9970. {
  9971. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9972. foreach (var dc in new_dayOtherCosts)
  9973. {
  9974. var thisCurrency = dc.Key.ToUpper();
  9975. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9976. if (thisRate == 0.00M) continue;
  9977. foreach (var dcSub in dc)
  9978. {
  9979. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  9980. {
  9981. Id = dcSub.Id,
  9982. Diid = dcSub.Diid,
  9983. Cost = dcSub.Cost,
  9984. SubTotal = dcSub.Cost * thisRate,
  9985. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9986. });
  9987. }
  9988. }
  9989. if (opDayOtherCosts.Count > 0)
  9990. {
  9991. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9992. }
  9993. }
  9994. #endregion
  9995. //消息通知
  9996. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9997. //汇率信息记录
  9998. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9999. return Ok(JsonView(new { parentId = id }));
  10000. }
  10001. /// <summary>
  10002. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  10003. /// </summary>
  10004. /// <returns></returns>
  10005. [HttpPost]
  10006. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10007. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  10008. {
  10009. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10010. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10011. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10012. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10013. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  10014. int id = dto.Id;
  10015. if (id <= 0) //add
  10016. {
  10017. checkboxInfo.CreateUserId = dto.CurrUserId;
  10018. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10019. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10020. if (add < 1) return Ok(JsonView(false));
  10021. }
  10022. else //update
  10023. {
  10024. ////验证编辑权限
  10025. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10026. //if (!isEdit) return Ok(JsonView(false, msg));
  10027. var upd = await _sqlSugar.Updateable(checkboxInfo)
  10028. .UpdateColumns(x => new
  10029. {
  10030. x.ChoiceOne,
  10031. x.ChoiceTwo,
  10032. x.SumJJC,
  10033. x.SumGWC,
  10034. x.SumTDC,
  10035. x.ChoiceThree,
  10036. x.ChoiceFour,
  10037. x.ChoiceFive,
  10038. x.ChoiceSix,
  10039. x.OtherExpenses_Checked
  10040. })
  10041. .Where(x => x.Id == id)
  10042. .ExecuteCommandAsync();
  10043. if (upd < 1) return Ok(JsonView(false));
  10044. }
  10045. return Ok(JsonView(new { parentId = id }));
  10046. }
  10047. /// <summary>
  10048. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  10049. /// </summary>
  10050. /// <returns></returns>
  10051. [HttpPost]
  10052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10053. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  10054. {
  10055. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  10056. // if (provinceId < 1) provinceId = 122;
  10057. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  10058. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10059. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10060. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10061. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  10062. var checkboxInfo = new Grp_EnterExitCost()
  10063. {
  10064. Id = id,
  10065. //ProvinceId = provinceId,
  10066. DiId = diId,
  10067. CreateUserId = currUserId
  10068. };
  10069. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  10070. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  10071. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  10072. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  10073. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  10074. if (id <= 0) //add
  10075. {
  10076. checkboxInfo.CreateUserId = dto.CurrUserId;
  10077. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10078. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  10079. if (add < 1) return Ok(JsonView(false));
  10080. }
  10081. else //update
  10082. {
  10083. ////验证编辑权限
  10084. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10085. //if (!isEdit) return Ok(JsonView(false, msg));
  10086. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  10087. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  10088. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  10089. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  10090. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  10091. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  10092. .Where(x => x.Id == id)
  10093. .ExecuteCommandAsync();
  10094. if (upd < 1) return Ok(JsonView(false));
  10095. }
  10096. return Ok(JsonView(new { parentId = id }));
  10097. }
  10098. /// <summary>
  10099. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  10100. /// </summary>
  10101. /// <returns></returns>
  10102. [HttpPost]
  10103. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10104. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  10105. {
  10106. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10107. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10108. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10109. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10110. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10111. info.FirstItemRemark = dto.FirstItemRemark;
  10112. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  10113. int id = dto.Id;
  10114. if (id <= 0) //add
  10115. {
  10116. info.CreateUserId = dto.CurrUserId;
  10117. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10118. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10119. if (add < 1) return Ok(JsonView(false));
  10120. id = add;
  10121. }
  10122. else //update
  10123. {
  10124. ////验证编辑权限
  10125. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10126. //if (!isEdit) return Ok(JsonView(false, msg));
  10127. var upd = await _sqlSugar.Updateable(info)
  10128. .UpdateColumns(x => new
  10129. {
  10130. x.ChoiceOne,
  10131. x.InsidePay,
  10132. x.VisaRemark,
  10133. x.Visa,
  10134. x.Service,
  10135. x.Safe,
  10136. x.Ticket,
  10137. x.HeSuan,
  10138. x.YiMiao,
  10139. x.FirstItemRemark
  10140. })
  10141. .Where(x => x.Id == id)
  10142. .ExecuteCommandAsync();
  10143. if (upd < 1) return Ok(JsonView(false));
  10144. }
  10145. //消息通知
  10146. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10147. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  10148. }
  10149. /// <summary>
  10150. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  10151. /// </summary>
  10152. /// <returns></returns>
  10153. [HttpPost]
  10154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10155. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  10156. {
  10157. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10158. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10159. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10160. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10161. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  10162. info.DiId = dto.DiId;
  10163. //info.ProvinceId = dto.ProvinceId;
  10164. info.OutsideJJPay = dto.OutsideJJPay;
  10165. info.OutsideGWPay = dto.OutsideGWPay;
  10166. info.OutsideTDPay = dto.OutsideTDPay;
  10167. info.AirJJ = dto.AirJJ;
  10168. info.AirGW = dto.AirGW;
  10169. info.AirTD = dto.AirTD;
  10170. info.CityTranffic = dto.CityTranffic;
  10171. info.TwoItemRemark = dto.TwoItemRemark;
  10172. info.SumJJC = dto.ChoiceTwoJJ;
  10173. info.SumGWC = dto.ChoiceTwoGW;
  10174. info.SumTDC = dto.ChoiceTwoTD;
  10175. int id = dto.Id;
  10176. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  10177. if (id <= 0) //add
  10178. {
  10179. info.CreateUserId = dto.CurrUserId;
  10180. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  10181. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10182. if (addId <= 0) return Ok(JsonView(false));
  10183. id = addId;
  10184. }
  10185. else //update
  10186. {
  10187. ////验证编辑权限
  10188. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10189. //if (!isEdit) return Ok(JsonView(false, msg));
  10190. var upd = await _sqlSugar.Updateable(info)
  10191. .UpdateColumns(x => new
  10192. {
  10193. x.SumJJC,
  10194. x.OutsideJJPay,
  10195. x.SumGWC,
  10196. x.OutsideGWPay,
  10197. x.SumTDC,
  10198. x.OutsideTDPay,
  10199. x.AirJJ,
  10200. x.AirGW,
  10201. x.AirTD,
  10202. x.CityTranffic,
  10203. x.TwoItemRemark
  10204. })
  10205. .Where(x => x.Id == id)
  10206. .ExecuteCommandAsync();
  10207. if (upd < 1) return Ok(JsonView(false));
  10208. }
  10209. jjcItemTotal = info.AirJJ + info.CityTranffic;
  10210. gwcItemTotal = info.AirGW + info.CityTranffic;
  10211. tdcItemTotal = info.AirTD + info.CityTranffic;
  10212. //消息通知
  10213. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10214. return Ok(JsonView(new
  10215. {
  10216. parentId = id,
  10217. choiceTwoJJ = dto.ChoiceTwoJJ,
  10218. jjcItemTotal = jjcItemTotal,
  10219. choiceTwoGW = dto.ChoiceTwoGW,
  10220. gwcItemTotal = gwcItemTotal,
  10221. choiceTwoTD = dto.ChoiceTwoTD,
  10222. tdcItemTotal = tdcItemTotal
  10223. }));
  10224. }
  10225. /// <summary>
  10226. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  10227. /// </summary>
  10228. /// <returns></returns>
  10229. [HttpPost]
  10230. [ApiExplorerSettings(IgnoreApi = true)]
  10231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10232. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  10233. {
  10234. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10235. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10236. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10237. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  10238. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  10239. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10240. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  10241. var infos = infos1.Select(x => new Grp_DayAndCost
  10242. {
  10243. Id = x.Id,
  10244. DiId = dto.DiId,
  10245. Type = dto.FeeType,
  10246. Days = x.Days,
  10247. NationalTravelFeeId = x.NationalTravelFeeId,
  10248. Cost = x.Cost,
  10249. Currency = x.Currency,
  10250. SubTotal = x.SubTotal,
  10251. CreateUserId = dto.CurrUserId
  10252. })
  10253. .ToList();
  10254. var adds = infos.Where(x => x.Id <= 0).ToList();
  10255. var upds = infos.Where(x => x.Id > 0).ToList();
  10256. if (adds.Count > 0)
  10257. {
  10258. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10259. if (add < 1) return Ok(JsonView(false));
  10260. }
  10261. if (upds.Count > 0)
  10262. {
  10263. var upd = await _sqlSugar.Updateable(adds)
  10264. .UpdateColumns(x => new
  10265. {
  10266. x.Days,
  10267. x.NationalTravelFeeId,
  10268. x.Cost,
  10269. x.Currency,
  10270. x.SubTotal
  10271. })
  10272. .WhereColumns(x => new { x.Id })
  10273. .ExecuteCommandAsync();
  10274. if (upd < 1) return Ok(JsonView(false));
  10275. }
  10276. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  10277. //消息通知
  10278. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10279. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10280. return Ok(JsonView(new { itemTotal = itemTotal }));
  10281. }
  10282. /// <summary>
  10283. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  10284. /// </summary>
  10285. /// <returns></returns>
  10286. [HttpPost]
  10287. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10288. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  10289. {
  10290. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  10291. int subId = dto.SubId, feeType = dto.FeeType;
  10292. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10293. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10294. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10295. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  10296. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  10297. subInfo.Id = subId;
  10298. subInfo.DiId = dto.DiId;
  10299. if (feeType == 3) subInfo.Type = 1;
  10300. else if (feeType == 4) subInfo.Type = 2;
  10301. else if (feeType == 5) subInfo.Type = 3;
  10302. else if (feeType == 6) subInfo.Type = 4;
  10303. subInfo.CreateUserId = dto.CurrUserId;
  10304. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  10305. if (parentId < 1) return Ok(JsonView(false));
  10306. //子表op
  10307. if (subId < 1)
  10308. {
  10309. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10310. if (subAdd < 1) return Ok(JsonView(false));
  10311. }
  10312. else
  10313. {
  10314. ////验证编辑权限
  10315. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  10316. //if (!isEdit) return Ok(JsonView(false, msg));
  10317. var subUpd = await _sqlSugar.Updateable(subInfo)
  10318. .UpdateColumns(x => new
  10319. {
  10320. x.Days,
  10321. x.NationalTravelFeeId,
  10322. x.Cost,
  10323. x.Currency,
  10324. x.SubTotal
  10325. })
  10326. .WhereColumns(x => new { x.Id })
  10327. .ExecuteCommandAsync();
  10328. if (subUpd < 1) return Ok(JsonView(false));
  10329. }
  10330. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  10331. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  10332. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10333. }
  10334. /// <summary>
  10335. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  10336. /// </summary>
  10337. /// <returns></returns>
  10338. [HttpPost]
  10339. [ApiExplorerSettings(IgnoreApi = true)]
  10340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10341. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  10342. {
  10343. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10344. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10345. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10346. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  10347. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  10348. {
  10349. Id = x.Id,
  10350. Diid = dto.DiId,
  10351. SetDataId = x.SetDataId,
  10352. Index = x.Index,
  10353. Cost = x.Cost,
  10354. Currency = x.Currency,
  10355. SubTotal = x.SubTotal,
  10356. CreateUserId = dto.CurrUserId,
  10357. Remark = x.Remark
  10358. }).ToList();
  10359. var adds = infos.Where(x => x.Id <= 0).ToList();
  10360. var upds = infos.Where(x => x.Id > 0).ToList();
  10361. if (adds.Count > 0)
  10362. {
  10363. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10364. if (add < 1) return Ok(JsonView(false));
  10365. }
  10366. if (upds.Count > 0)
  10367. {
  10368. var upd = await _sqlSugar.Updateable(adds)
  10369. .UpdateColumns(x => new
  10370. {
  10371. x.Index,
  10372. x.SetDataId,
  10373. x.Cost,
  10374. x.Currency,
  10375. x.SubTotal,
  10376. x.Remark
  10377. })
  10378. .WhereColumns(x => new { x.Id })
  10379. .ExecuteCommandAsync();
  10380. if (upd < 1) return Ok(JsonView(false));
  10381. }
  10382. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  10383. //消息通知
  10384. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  10385. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10386. return Ok(JsonView(new { itemTotal = itemTotal }));
  10387. }
  10388. /// <summary>
  10389. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  10390. /// </summary>
  10391. /// <returns></returns>
  10392. [HttpPost]
  10393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10394. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  10395. {
  10396. int subId = dto.SubId;
  10397. int diId = dto.Diid;
  10398. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10399. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10400. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10401. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  10402. subInfo.Id = subId;
  10403. subInfo.Diid = dto.Diid;
  10404. subInfo.CreateUserId = dto.CurrUserId;
  10405. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  10406. if (parentId < 1) return Ok(JsonView(false));
  10407. #region 子表op
  10408. if (subId < 1)//add
  10409. {
  10410. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10411. if (subAdd < 1) return Ok(JsonView(false));
  10412. }
  10413. else //upd
  10414. {
  10415. ////验证编辑权限
  10416. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  10417. //if (!isEdit) return Ok(JsonView(false, msg));
  10418. var subUpd = await _sqlSugar.Updateable(subInfo)
  10419. .UpdateColumns(x => new
  10420. {
  10421. x.Index,
  10422. x.SetDataId,
  10423. x.Cost,
  10424. x.Currency,
  10425. x.SubTotal,
  10426. x.Remark
  10427. })
  10428. .WhereColumns(x => new { x.Id })
  10429. .ExecuteCommandAsync();
  10430. if (subUpd < 1) return Ok(JsonView(false));
  10431. }
  10432. #endregion
  10433. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  10434. //消息通知
  10435. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10436. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10437. }
  10438. /// <summary>
  10439. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  10440. /// </summary>
  10441. /// <returns></returns>
  10442. [HttpPost]
  10443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10444. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  10445. {
  10446. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10447. if (data.Code != 0)
  10448. {
  10449. return Ok(JsonView(false, data.Msg));
  10450. }
  10451. return Ok(JsonView(true, "操作成功!", data.Data));
  10452. }
  10453. /// <summary>
  10454. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  10455. /// </summary>
  10456. /// <param name="dto"></param>
  10457. /// <returns></returns>
  10458. [HttpPost]
  10459. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  10460. {
  10461. var data = new Grp_DayOtherPrice()
  10462. {
  10463. Id = dto.Id,
  10464. IsDel = 1,
  10465. DeleteUserId = dto.DeleteUserId,
  10466. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10467. };
  10468. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10469. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10470. return Ok(JsonView(false, "删除失败!"));
  10471. }
  10472. #endregion
  10473. #endregion
  10474. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  10475. /// <summary>
  10476. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  10477. /// </summary>
  10478. /// <returns></returns>
  10479. [HttpGet]
  10480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10481. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  10482. {
  10483. var provData = await _groupRepository.ProvinceBasicSource();
  10484. return Ok(JsonView(true, "查询成功!", provData));
  10485. }
  10486. /// <summary>
  10487. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  10488. /// </summary>
  10489. /// <returns></returns>
  10490. [HttpPost]
  10491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10492. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  10493. {
  10494. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10495. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10496. RefAsync<int> total = 0;
  10497. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  10498. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  10499. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  10500. .Select(x => new
  10501. {
  10502. Id = x.Id,
  10503. DraftName = x.DraftName,
  10504. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  10505. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  10506. .Any()
  10507. })
  10508. .OrderByDescending(x => x.Id)
  10509. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10510. return Ok(JsonView(true, "查询成功!", data, total));
  10511. }
  10512. /// <summary>
  10513. /// 出入境费用-草稿 移动端
  10514. /// 获取币种基础数据(含逻辑处理)
  10515. /// </summary>
  10516. /// <returns></returns>
  10517. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  10518. {
  10519. return await GeneralMethod.EnterExitCostInitRate();
  10520. }
  10521. /// <summary>
  10522. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10523. /// </summary>
  10524. /// <returns></returns>
  10525. [HttpPost]
  10526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10527. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  10528. {
  10529. //验证城市归属并给默认值
  10530. int provinceId = dto.ProvinceId;
  10531. if (provinceId < 1) provinceId = 122;
  10532. var dataSource = await _sqlSugar
  10533. .Queryable<Sys_SetData>()
  10534. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10535. .ToListAsync();
  10536. //三公费用-Word明细类型
  10537. var wordTypeData = dataSource.Where(it => it.STid == 72)
  10538. .Select(x => new SetDataInfoView
  10539. {
  10540. Id = x.Id,
  10541. Name = x.Name,
  10542. Remark = x.Remark
  10543. })
  10544. .ToList();
  10545. //三公费用-Excel明细类型
  10546. var excelTypeData = dataSource.Where(it => it.STid == 73)
  10547. .Select(x => new SetDataInfoView
  10548. {
  10549. Id = x.Id,
  10550. Name = x.Name,
  10551. Remark = x.Remark
  10552. })
  10553. .ToList();
  10554. //默认币种显示
  10555. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10556. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10557. return Ok(JsonView(true, "查询成功!", new
  10558. {
  10559. WordTypeData = wordTypeData,
  10560. ExcelTypeData = excelTypeData,
  10561. CurrencyInit = _currencyInfos,
  10562. viewPermissionData = viewPermissionData
  10563. }));
  10564. }
  10565. /// <summary>
  10566. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  10567. /// </summary>
  10568. /// <returns></returns>
  10569. [HttpPost]
  10570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10571. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  10572. {
  10573. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10574. RefAsync<int> total = 0;
  10575. int diId = 0;
  10576. var status = int.TryParse(dto.GroupName, out diId);
  10577. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10578. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10579. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10580. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10581. .OrderByDescending(x => x.VisitStartDate)
  10582. .Select(x => new
  10583. {
  10584. Id = x.Id,
  10585. GroupName = x.TeamName
  10586. })
  10587. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10588. return Ok(JsonView(true, "查询成功!", data, total));
  10589. }
  10590. /// <summary>
  10591. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  10592. /// </summary>
  10593. /// <returns></returns>
  10594. [HttpPost]
  10595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10596. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  10597. {
  10598. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10599. RefAsync<int> total = 0;
  10600. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10601. .Where(x => x.IsDel == 0 && x.STid == 66)
  10602. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10603. .Select(x => new
  10604. {
  10605. id = x.Id,
  10606. name = x.Name,
  10607. remark = x.Remark,
  10608. })
  10609. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10610. return Ok(JsonView(true, "查询成功!", data, total));
  10611. }
  10612. /// <summary>
  10613. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10614. /// </summary>
  10615. /// <returns></returns>
  10616. [HttpPost]
  10617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10618. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  10619. {
  10620. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10621. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10622. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  10623. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10624. var groupOtherRateData = groupRateData.TeamRates;
  10625. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10626. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10627. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10628. groupOtherRateData = groupOtherRateData
  10629. .Select(x => new TeamRateDescAddCurrencyIdView
  10630. {
  10631. CurrencyId = x.CurrencyId,
  10632. CurrencyName = x.CurrencyName,
  10633. CurrencyCode = x.CurrencyCode,
  10634. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10635. }).ToList();
  10636. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10637. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10638. }
  10639. /// <summary>
  10640. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  10641. /// </summary>
  10642. /// <returns></returns>
  10643. [HttpPost]
  10644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10645. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  10646. {
  10647. int portType = dto.PortType;
  10648. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10649. var tipsData = new List<int>() { 1, 2, 3 };
  10650. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10651. if (dto.TipsType == 1)
  10652. {
  10653. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10654. }
  10655. else if (dto.TipsType == 2)
  10656. {
  10657. if (portType == 2)
  10658. {
  10659. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10660. }
  10661. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10662. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  10663. .Select(x => x.NationalTravelFeeId)
  10664. .Distinct()
  10665. .ToListAsync();
  10666. if (portType == 2)
  10667. {
  10668. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10669. }
  10670. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10671. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  10672. .Select(x => x.Country)
  10673. .Distinct()
  10674. .ToArrayAsync();
  10675. if (portType == 2)
  10676. {
  10677. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  10678. }
  10679. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  10680. return Ok(JsonView(true, "查询成功!", new
  10681. {
  10682. totalAmt = totalAmt,
  10683. remark = remark
  10684. }));
  10685. }
  10686. else if (dto.TipsType == 3)
  10687. {
  10688. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  10689. }
  10690. return Ok(JsonView(false));
  10691. }
  10692. /// <summary>
  10693. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  10694. /// </summary>
  10695. /// <returns></returns>
  10696. [HttpPost]
  10697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10698. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  10699. {
  10700. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  10701. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10702. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  10703. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  10704. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  10705. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  10706. var info = new Grp_EnterExitCostDraft()
  10707. {
  10708. ProvinceId = dto.ProvinceId,
  10709. DraftName = dto.DraftName,
  10710. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  10711. CreateUserId = dto.CurrUserId
  10712. };
  10713. _sqlSugar.BeginTran();
  10714. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  10715. if (draftId < 1)
  10716. {
  10717. _sqlSugar.RollbackTran();
  10718. return Ok(JsonView(false, "草稿创建失败!"));
  10719. }
  10720. //添加默认权限
  10721. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  10722. _sqlSugar.CommitTran();
  10723. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  10724. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10725. mobileInfo.Id = draftId;
  10726. mobileInfo.DraftName = dto.DraftName;
  10727. mobileInfo.Currencys = rateInfos;
  10728. mobileInfo.IsAssignPerm = assignPerm;
  10729. return Ok(JsonView(mobileInfo));
  10730. }
  10731. /// <summary>
  10732. /// 出入境费用-草稿-移动端 查看编辑提示消息
  10733. /// </summary>
  10734. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  10735. /// <summary>
  10736. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  10737. /// </summary>
  10738. /// <returns></returns>
  10739. [HttpPost]
  10740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10741. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  10742. {
  10743. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10744. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10745. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10746. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  10747. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10748. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  10749. //验证查看编辑权限
  10750. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10751. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10752. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  10753. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  10754. mobileInfo.IsAssignPerm = assignPerm;
  10755. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10756. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10757. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10758. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  10759. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10760. {
  10761. ParentId = dac.ParentId,
  10762. SubId = dac.Id,
  10763. Type = dac.Type,
  10764. Days = dac.Days,
  10765. NationalTravelFeeId = dac.NationalTravelFeeId,
  10766. Arae = $"{ntf.Country}-{ntf.City}",
  10767. Cost = dac.Cost,
  10768. Currency = dac.Currency,
  10769. CurrencyName = sd.Name,
  10770. SubTotal = dac.SubTotal,
  10771. })
  10772. .ToList();
  10773. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10774. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10775. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10776. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10777. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10778. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10779. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10780. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10781. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10782. //其他款项
  10783. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10784. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10785. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10786. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10787. .OrderBy((dop, sd1, sd2) => dop.Index)
  10788. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10789. {
  10790. ParentId = dop.ParentId,
  10791. SubId = dop.Id,
  10792. Index = dop.Index,
  10793. SetDataId = dop.SetDataId,
  10794. SetDataName = sd1.Name,
  10795. Cost = dop.Cost,
  10796. Currency = dop.Currency,
  10797. CurrencyName = sd2.Remark,
  10798. SubTotal = dop.SubTotal,
  10799. Remark = dop.Remark,
  10800. })
  10801. .ToArray();
  10802. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10803. return Ok(mobileInfo);
  10804. }
  10805. /// <summary>
  10806. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  10807. /// </summary>
  10808. /// <returns></returns>
  10809. [HttpPost]
  10810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10811. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  10812. {
  10813. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10814. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  10815. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10816. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10817. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10818. //验证查看编辑权限
  10819. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  10820. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  10821. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  10822. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10823. var subType = dto.SubType;
  10824. if (subType == 1) //1:境内费用
  10825. {
  10826. var oneData = new ChoiceOneMobileSubInfoView()
  10827. {
  10828. Id = eecInfo.Id,
  10829. ChoiceOne = eecInfo.ChoiceOne,
  10830. ChoiceOneTotalCost = eecInfo.InsidePay,
  10831. Visa = eecInfo.Visa,
  10832. VisaRemark = eecInfo.VisaRemark,
  10833. YiMiao = eecInfo.YiMiao,
  10834. HeSuan = eecInfo.HeSuan,
  10835. Service = eecInfo.Service,
  10836. Ticket = eecInfo.Ticket,
  10837. Safe = eecInfo.Safe,
  10838. FirstItemRemark = eecInfo.FirstItemRemark
  10839. };
  10840. return Ok(JsonView(oneData));
  10841. }
  10842. else if (subType == 2) //2:国际旅费
  10843. {
  10844. var twoData = new ChoiceTwoMobileSubInfoView()
  10845. {
  10846. Id = eecInfo.Id,
  10847. ChoiceTwoJJ = eecInfo.SumJJC,
  10848. OutsideJJPay = eecInfo.OutsideJJPay,
  10849. ChoiceTwoGW = eecInfo.SumGWC,
  10850. OutsideGWPay = eecInfo.OutsideGWPay,
  10851. ChoiceTwoTD = eecInfo.SumTDC,
  10852. OutsideTDPay = eecInfo.OutsideTDPay,
  10853. AirJJ = eecInfo.AirJJ,
  10854. AirGW = eecInfo.AirGW,
  10855. AirTD = eecInfo.AirTD,
  10856. CityTranffic = eecInfo.CityTranffic,
  10857. TwoItemRemark = eecInfo.TwoItemRemark
  10858. };
  10859. return Ok(JsonView(twoData));
  10860. }
  10861. else if (subType == 3) //3:住宿费
  10862. {
  10863. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10864. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10865. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10866. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  10867. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10868. {
  10869. ParentId = dac.ParentId,
  10870. SubId = dac.Id,
  10871. Type = dac.Type,
  10872. Days = dac.Days,
  10873. NationalTravelFeeId = dac.NationalTravelFeeId,
  10874. Arae = $"{ntf.Country}-{ntf.City}",
  10875. Cost = dac.Cost,
  10876. Currency = dac.Currency,
  10877. CurrencyName = sd.Name,
  10878. SubTotal = dac.SubTotal,
  10879. })
  10880. .ToArray();
  10881. var data = new ChoiceDraftMobileSubInfo3To6View()
  10882. {
  10883. ParentId = eecInfo.Id,
  10884. Choice = eecInfo.ChoiceThree,
  10885. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10886. Details = dayAndCostDatas
  10887. };
  10888. return Ok(JsonView(data));
  10889. }
  10890. else if (subType == 4) //4:伙食费
  10891. {
  10892. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10893. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10894. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10895. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  10896. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10897. {
  10898. ParentId = dac.ParentId,
  10899. SubId = dac.Id,
  10900. Type = dac.Type,
  10901. Days = dac.Days,
  10902. NationalTravelFeeId = dac.NationalTravelFeeId,
  10903. Arae = $"{ntf.Country}-{ntf.City}",
  10904. Cost = dac.Cost,
  10905. Currency = dac.Currency,
  10906. CurrencyName = sd.Name,
  10907. SubTotal = dac.SubTotal,
  10908. })
  10909. .ToArray();
  10910. var data = new ChoiceDraftMobileSubInfo3To6View()
  10911. {
  10912. ParentId = eecInfo.Id,
  10913. Choice = eecInfo.ChoiceFour,
  10914. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10915. Details = dayAndCostDatas
  10916. };
  10917. return Ok(JsonView(data));
  10918. }
  10919. else if (subType == 5) //5:公杂费
  10920. {
  10921. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10922. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10923. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10924. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  10925. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10926. {
  10927. ParentId = dac.ParentId,
  10928. SubId = dac.Id,
  10929. Type = dac.Type,
  10930. Days = dac.Days,
  10931. NationalTravelFeeId = dac.NationalTravelFeeId,
  10932. Arae = $"{ntf.Country}-{ntf.City}",
  10933. Cost = dac.Cost,
  10934. Currency = dac.Currency,
  10935. CurrencyName = sd.Name,
  10936. SubTotal = dac.SubTotal,
  10937. })
  10938. .ToArray();
  10939. var data = new ChoiceDraftMobileSubInfo3To6View()
  10940. {
  10941. ParentId = eecInfo.Id,
  10942. Choice = eecInfo.ChoiceFive,
  10943. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10944. Details = dayAndCostDatas
  10945. };
  10946. return Ok(JsonView(data));
  10947. }
  10948. else if (subType == 6) //6:培训费
  10949. {
  10950. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  10951. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10952. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10953. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  10954. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  10955. {
  10956. ParentId = dac.ParentId,
  10957. SubId = dac.Id,
  10958. Type = dac.Type,
  10959. Days = dac.Days,
  10960. NationalTravelFeeId = dac.NationalTravelFeeId,
  10961. Arae = $"{ntf.Country}-{ntf.City}",
  10962. Cost = dac.Cost,
  10963. Currency = dac.Currency,
  10964. CurrencyName = sd.Name,
  10965. SubTotal = dac.SubTotal,
  10966. })
  10967. .ToArray();
  10968. var data = new ChoiceDraftMobileSubInfo3To6View()
  10969. {
  10970. ParentId = eecInfo.Id,
  10971. Choice = eecInfo.ChoiceSix,
  10972. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10973. Details = dayAndCostDatas
  10974. };
  10975. return Ok(JsonView(data));
  10976. }
  10977. else if (subType == 7) //7:其他
  10978. {
  10979. //其他款项
  10980. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  10981. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10982. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10983. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  10984. .OrderBy((dop, sd1, sd2) => dop.Index)
  10985. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  10986. {
  10987. ParentId = dop.ParentId,
  10988. SubId = dop.Id,
  10989. Index = dop.Index,
  10990. SetDataId = dop.SetDataId,
  10991. SetDataName = sd1.Name,
  10992. Cost = dop.Cost,
  10993. Currency = dop.Currency,
  10994. CurrencyName = sd2.Name,
  10995. SubTotal = dop.SubTotal,
  10996. Remark = dop.Remark,
  10997. })
  10998. .ToArray();
  10999. var data = new ChoiceSevenDraftMobileSubInfoView()
  11000. {
  11001. ParentId = eecInfo.Id,
  11002. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11003. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11004. Details = otherData
  11005. };
  11006. return Ok(JsonView(data));
  11007. }
  11008. return Ok(JsonView(false));
  11009. }
  11010. #region op
  11011. /// <summary>
  11012. /// 移动端更新费用消息通知
  11013. /// </summary>
  11014. /// <param name="draftId"></param>
  11015. /// <param name="id"></param>
  11016. /// <param name="currUserId"></param>
  11017. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  11018. {
  11019. try
  11020. {
  11021. ////生成默认文件pdf并且通知人员
  11022. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11023. //{
  11024. // DiId = draftId,
  11025. // ExportType = 1,
  11026. // SubTypeId = 1005
  11027. //}, "pdf");
  11028. ////发送通知
  11029. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11030. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11031. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11032. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  11033. ////汇率信息记录
  11034. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11035. }
  11036. catch (Exception ex)
  11037. {
  11038. //记录日志
  11039. throw;
  11040. }
  11041. }
  11042. /// <summary>
  11043. /// 验证出入境费用数据是否存在
  11044. /// 不存在添加
  11045. /// </summary>
  11046. /// <param name="draftId"></param>
  11047. /// <param name="currUserId"></param>
  11048. /// <returns></returns>
  11049. /// <exception cref="CustomException"></exception>
  11050. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  11051. {
  11052. var parentId = 0;
  11053. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11054. if (info != null) parentId = info.Id;
  11055. else
  11056. {
  11057. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  11058. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11059. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11060. parentId = addId;
  11061. }
  11062. return parentId;
  11063. }
  11064. /// <summary>
  11065. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  11066. /// </summary>
  11067. /// <returns></returns>
  11068. [HttpPost]
  11069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11070. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  11071. {
  11072. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11073. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11074. //验证查看权限
  11075. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11076. if (!isView) return Ok(JsonView(false, _viewPermStr));
  11077. var userIds = await _sqlSugar
  11078. .Queryable<Grp_EnterExitCostDraftPermission>()
  11079. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  11080. .Select(x => x.UserId)
  11081. .ToArrayAsync();
  11082. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11083. var perUsersView = new List<dynamic>();
  11084. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  11085. var viewPermissionData = new List<PermissionViewUserview>();
  11086. if (feeBasePerm.Any())
  11087. {
  11088. foreach (var item in feeBasePerm)
  11089. {
  11090. if (item.Users.Any())
  11091. {
  11092. viewPermissionData.AddRange(item.Users);
  11093. }
  11094. }
  11095. }
  11096. foreach (var item in perUsers)
  11097. {
  11098. bool isView1 = false;
  11099. if (userIds.Any(x => x == item.Id)) isView1 = true;
  11100. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  11101. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  11102. }
  11103. return Ok(JsonView(perUsersView));
  11104. }
  11105. /// <summary>
  11106. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  11107. /// </summary>
  11108. /// <returns></returns>
  11109. [HttpPost]
  11110. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11111. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  11112. {
  11113. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11114. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11115. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11116. //验证查看编辑权限
  11117. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11118. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11119. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  11120. foreach (var userId in dto.UserIds)
  11121. {
  11122. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11123. }
  11124. if (permissions.Any())
  11125. {
  11126. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11127. {
  11128. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11129. }
  11130. _sqlSugar.BeginTran();
  11131. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11132. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11133. if (result < 1)
  11134. {
  11135. _sqlSugar.RollbackTran();
  11136. return Ok(JsonView(false));
  11137. }
  11138. _sqlSugar.CommitTran();
  11139. return Ok(JsonView(true));
  11140. }
  11141. return Ok(JsonView(false));
  11142. }
  11143. /// <summary>
  11144. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  11145. /// </summary>
  11146. /// <returns></returns>
  11147. [HttpPost]
  11148. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11149. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  11150. {
  11151. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11152. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11153. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11154. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  11155. int id = dto.DraftId;
  11156. if (id <= 0) //add
  11157. {
  11158. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11159. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11160. if (add < 1) return Ok(JsonView(false));
  11161. id = add;
  11162. }
  11163. else //update
  11164. {
  11165. //验证查看编辑权限
  11166. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11167. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11168. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11169. if (upd < 1) return Ok(JsonView(false));
  11170. }
  11171. return Ok(JsonView(new { parentId = id }));
  11172. }
  11173. /// <summary>
  11174. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  11175. /// </summary>
  11176. /// <returns></returns>
  11177. [HttpPost]
  11178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11179. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  11180. {
  11181. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11182. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11183. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11184. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11185. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11186. int id = dto.DraftId;
  11187. if (id <= 0) //add
  11188. {
  11189. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11190. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  11191. if (add < 1) return Ok(JsonView(false));
  11192. id = add;
  11193. }
  11194. else //update
  11195. {
  11196. //验证查看编辑权限
  11197. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  11198. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  11199. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  11200. if (upd < 1) return Ok(JsonView(false));
  11201. }
  11202. #region 汇率变更时更改币种相关费用
  11203. var opDayCosts = new List<Grp_DayAndCostDraft>();
  11204. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  11205. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11206. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11207. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11208. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  11209. .Select((dac, sd) => new
  11210. {
  11211. dac.Id,
  11212. dac.ParentId,
  11213. CurrencyCode = sd.Name,
  11214. dac.Cost
  11215. })
  11216. .ToList();
  11217. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11218. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11219. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  11220. .Select((dop, sd) => new
  11221. {
  11222. dop.Id,
  11223. dop.ParentId,
  11224. CurrencyCode = sd.Name,
  11225. dop.Cost
  11226. })
  11227. .ToList();
  11228. if (dayCosts.Count > 0)
  11229. {
  11230. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11231. foreach (var dc in new_dayCosts)
  11232. {
  11233. var thisCurrency = dc.Key.ToUpper();
  11234. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11235. if (thisRate == 0.00M) continue;
  11236. foreach (var dcSub in dc)
  11237. {
  11238. opDayCosts.Add(new Grp_DayAndCostDraft()
  11239. {
  11240. Id = dcSub.Id,
  11241. ParentId = dcSub.ParentId,
  11242. Cost = dcSub.Cost,
  11243. SubTotal = dcSub.Cost * thisRate,
  11244. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  11245. });
  11246. }
  11247. }
  11248. if (opDayCosts.Count > 0)
  11249. {
  11250. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11251. }
  11252. }
  11253. if (dayOtherCosts.Count > 0)
  11254. {
  11255. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11256. foreach (var dc in new_dayOtherCosts)
  11257. {
  11258. var thisCurrency = dc.Key.ToUpper();
  11259. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11260. if (thisRate == 0.00M) continue;
  11261. foreach (var dcSub in dc)
  11262. {
  11263. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  11264. {
  11265. Id = dcSub.Id,
  11266. ParentId = dcSub.ParentId,
  11267. Cost = dcSub.Cost,
  11268. SubTotal = dcSub.Cost * thisRate,
  11269. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11270. });
  11271. }
  11272. }
  11273. if (opDayOtherCosts.Count > 0)
  11274. {
  11275. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11276. }
  11277. }
  11278. #endregion
  11279. ////消息通知
  11280. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11281. ////汇率信息记录
  11282. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11283. return Ok(JsonView(new { parentId = id }));
  11284. }
  11285. /// <summary>
  11286. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  11287. /// </summary>
  11288. /// <returns></returns>
  11289. [HttpPost]
  11290. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11291. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  11292. {
  11293. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11294. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11295. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11296. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11297. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11298. int id = dto.DraftId;
  11299. if (id <= 0) //add
  11300. {
  11301. checkboxInfo.ProvinceId = dto.ProvinceId;
  11302. checkboxInfo.CreateUserId = dto.CurrUserId;
  11303. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  11304. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11305. if (add < 1) return Ok(JsonView(false));
  11306. }
  11307. else //update
  11308. {
  11309. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11310. .UpdateColumns(x => new
  11311. {
  11312. x.ChoiceOne,
  11313. x.ChoiceTwo,
  11314. x.SumJJC,
  11315. x.SumGWC,
  11316. x.SumTDC,
  11317. x.ChoiceThree,
  11318. x.ChoiceFour,
  11319. x.ChoiceFive,
  11320. x.ChoiceSix,
  11321. x.OtherExpenses_Checked
  11322. })
  11323. .Where(x => x.Id == id)
  11324. .ExecuteCommandAsync();
  11325. if (upd < 1) return Ok(JsonView(false));
  11326. }
  11327. return Ok(JsonView(new { parentId = id }));
  11328. }
  11329. /// <summary>
  11330. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  11331. /// </summary>
  11332. /// <returns></returns>
  11333. [HttpPost]
  11334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11335. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  11336. {
  11337. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  11338. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11339. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11340. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11341. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11342. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11343. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11344. var checkboxInfo = new Grp_EnterExitCostDraft()
  11345. {
  11346. Id = draftId,
  11347. ProvinceId = dto.ProvinceId,
  11348. CreateUserId = currUserId
  11349. };
  11350. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11351. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11352. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11353. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11354. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11355. if (draftId <= 0) //add
  11356. {
  11357. checkboxInfo.CreateUserId = dto.CurrUserId;
  11358. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11359. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11360. if (add < 1) return Ok(JsonView(false));
  11361. }
  11362. else //update
  11363. {
  11364. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  11365. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11366. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11367. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11368. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11369. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11370. .Where(x => x.Id == draftId)
  11371. .ExecuteCommandAsync();
  11372. if (upd < 1) return Ok(JsonView(false));
  11373. }
  11374. return Ok(JsonView(new { parentId = draftId }));
  11375. }
  11376. /// <summary>
  11377. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  11378. /// </summary>
  11379. /// <returns></returns>
  11380. [HttpPost]
  11381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11382. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  11383. {
  11384. int id = dto.DraftId, currUserId = dto.CurrUserId;
  11385. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11386. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11387. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11388. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11389. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11390. info.ProvinceId = dto.ProvinceId;
  11391. info.FirstItemRemark = dto.FirstItemRemark;
  11392. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11393. if (id <= 0) //add
  11394. {
  11395. info.CreateUserId = dto.CurrUserId;
  11396. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11397. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11398. if (add < 1) return Ok(JsonView(false));
  11399. id = add;
  11400. }
  11401. else //update
  11402. {
  11403. var upd = await _sqlSugar.Updateable(info)
  11404. .UpdateColumns(x => new
  11405. {
  11406. x.ChoiceOne,
  11407. x.InsidePay,
  11408. x.VisaRemark,
  11409. x.Visa,
  11410. x.Service,
  11411. x.Safe,
  11412. x.Ticket,
  11413. x.HeSuan,
  11414. x.YiMiao,
  11415. x.FirstItemRemark
  11416. })
  11417. .Where(x => x.Id == id)
  11418. .ExecuteCommandAsync();
  11419. if (upd < 1) return Ok(JsonView(false));
  11420. }
  11421. ////消息通知
  11422. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11423. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11424. }
  11425. /// <summary>
  11426. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  11427. /// </summary>
  11428. /// <returns></returns>
  11429. [HttpPost]
  11430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11431. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  11432. {
  11433. int id = dto.DraftId;
  11434. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11435. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  11436. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11437. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11438. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  11439. info.ProvinceId = dto.ProvinceId;
  11440. info.OutsideJJPay = dto.OutsideJJPay;
  11441. info.OutsideGWPay = dto.OutsideGWPay;
  11442. info.OutsideTDPay = dto.OutsideTDPay;
  11443. info.AirJJ = dto.AirJJ;
  11444. info.AirGW = dto.AirGW;
  11445. info.AirTD = dto.AirTD;
  11446. info.CityTranffic = dto.CityTranffic;
  11447. info.TwoItemRemark = dto.TwoItemRemark;
  11448. info.SumJJC = dto.ChoiceTwoJJ;
  11449. info.SumGWC = dto.ChoiceTwoGW;
  11450. info.SumTDC = dto.ChoiceTwoTD;
  11451. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11452. if (id <= 0) //add
  11453. {
  11454. info.CreateUserId = dto.CurrUserId;
  11455. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11456. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11457. if (addId <= 0) return Ok(JsonView(false));
  11458. id = addId;
  11459. }
  11460. else //update
  11461. {
  11462. var upd = await _sqlSugar.Updateable(info)
  11463. .UpdateColumns(x => new
  11464. {
  11465. x.SumJJC,
  11466. x.OutsideJJPay,
  11467. x.SumGWC,
  11468. x.OutsideGWPay,
  11469. x.SumTDC,
  11470. x.OutsideTDPay,
  11471. x.AirJJ,
  11472. x.AirGW,
  11473. x.AirTD,
  11474. x.CityTranffic,
  11475. x.TwoItemRemark
  11476. })
  11477. .Where(x => x.Id == id)
  11478. .ExecuteCommandAsync();
  11479. if (upd < 1) return Ok(JsonView(false));
  11480. }
  11481. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11482. gwcItemTotal = info.AirGW + info.CityTranffic;
  11483. tdcItemTotal = info.AirTD + info.CityTranffic;
  11484. ////消息通知
  11485. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11486. return Ok(JsonView(new
  11487. {
  11488. parentId = id,
  11489. choiceTwoJJ = dto.ChoiceTwoJJ,
  11490. jjcItemTotal = jjcItemTotal,
  11491. choiceTwoGW = dto.ChoiceTwoGW,
  11492. gwcItemTotal = gwcItemTotal,
  11493. choiceTwoTD = dto.ChoiceTwoTD,
  11494. tdcItemTotal = tdcItemTotal
  11495. }));
  11496. }
  11497. /// <summary>
  11498. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11499. /// </summary>
  11500. /// <returns></returns>
  11501. [HttpPost]
  11502. [ApiExplorerSettings(IgnoreApi = true)]
  11503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11504. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  11505. {
  11506. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11507. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11508. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11509. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11510. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11511. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11512. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  11513. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  11514. {
  11515. Id = x.Id,
  11516. ParentId = dto.DraftId,
  11517. Type = dto.FeeType,
  11518. Days = x.Days,
  11519. NationalTravelFeeId = x.NationalTravelFeeId,
  11520. Cost = x.Cost,
  11521. Currency = x.Currency,
  11522. SubTotal = x.SubTotal,
  11523. CreateUserId = dto.CurrUserId
  11524. })
  11525. .ToList();
  11526. var adds = infos.Where(x => x.Id <= 0).ToList();
  11527. var upds = infos.Where(x => x.Id > 0).ToList();
  11528. if (adds.Count > 0)
  11529. {
  11530. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11531. if (add < 1) return Ok(JsonView(false));
  11532. }
  11533. if (upds.Count > 0)
  11534. {
  11535. var upd = await _sqlSugar.Updateable(adds)
  11536. .UpdateColumns(x => new
  11537. {
  11538. x.Days,
  11539. x.NationalTravelFeeId,
  11540. x.Cost,
  11541. x.Currency,
  11542. x.SubTotal
  11543. })
  11544. .WhereColumns(x => new { x.Id })
  11545. .ExecuteCommandAsync();
  11546. if (upd < 1) return Ok(JsonView(false));
  11547. }
  11548. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11549. ////消息通知
  11550. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  11551. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11552. return Ok(JsonView(new { itemTotal = itemTotal }));
  11553. }
  11554. /// <summary>
  11555. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11556. /// </summary>
  11557. /// <returns></returns>
  11558. [HttpPost]
  11559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11560. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  11561. {
  11562. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11563. int subId = dto.SubId, feeType = dto.FeeType;
  11564. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11565. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11566. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11567. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11568. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  11569. subInfo.Id = subId;
  11570. subInfo.ParentId = dto.DraftId;
  11571. if (feeType == 3) subInfo.Type = 1;
  11572. else if (feeType == 4) subInfo.Type = 2;
  11573. else if (feeType == 5) subInfo.Type = 3;
  11574. else if (feeType == 6) subInfo.Type = 4;
  11575. subInfo.CreateUserId = dto.CurrUserId;
  11576. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  11577. if (parentId < 1) return Ok(JsonView(false));
  11578. //子表op
  11579. if (subId < 1)
  11580. {
  11581. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11582. if (subAdd < 1) return Ok(JsonView(false));
  11583. }
  11584. else
  11585. {
  11586. var subUpd = await _sqlSugar.Updateable(subInfo)
  11587. .UpdateColumns(x => new
  11588. {
  11589. x.Days,
  11590. x.NationalTravelFeeId,
  11591. x.Cost,
  11592. x.Currency,
  11593. x.SubTotal
  11594. })
  11595. .WhereColumns(x => new { x.Id })
  11596. .ExecuteCommandAsync();
  11597. if (subUpd < 1) return Ok(JsonView(false));
  11598. }
  11599. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  11600. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11601. }
  11602. /// <summary>
  11603. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  11604. /// </summary>
  11605. /// <returns></returns>
  11606. [HttpPost]
  11607. [ApiExplorerSettings(IgnoreApi = true)]
  11608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11609. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  11610. {
  11611. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11612. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11613. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11614. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  11615. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  11616. {
  11617. Id = x.Id,
  11618. ParentId = dto.DraftId,
  11619. SetDataId = x.SetDataId,
  11620. Index = x.Index,
  11621. Cost = x.Cost,
  11622. Currency = x.Currency,
  11623. SubTotal = x.SubTotal,
  11624. CreateUserId = dto.CurrUserId,
  11625. Remark = x.Remark
  11626. }).ToList();
  11627. var adds = infos.Where(x => x.Id <= 0).ToList();
  11628. var upds = infos.Where(x => x.Id > 0).ToList();
  11629. if (adds.Count > 0)
  11630. {
  11631. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11632. if (add < 1) return Ok(JsonView(false));
  11633. }
  11634. if (upds.Count > 0)
  11635. {
  11636. var upd = await _sqlSugar.Updateable(adds)
  11637. .UpdateColumns(x => new
  11638. {
  11639. x.Index,
  11640. x.SetDataId,
  11641. x.Cost,
  11642. x.Currency,
  11643. x.SubTotal,
  11644. x.Remark
  11645. })
  11646. .WhereColumns(x => new { x.Id })
  11647. .ExecuteCommandAsync();
  11648. if (upd < 1) return Ok(JsonView(false));
  11649. }
  11650. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  11651. //消息通知
  11652. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  11653. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11654. return Ok(JsonView(new { itemTotal = itemTotal }));
  11655. }
  11656. /// <summary>
  11657. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  11658. /// </summary>
  11659. /// <returns></returns>
  11660. [HttpPost]
  11661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11662. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  11663. {
  11664. int subId = dto.SubId, id = dto.DraftId;
  11665. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11666. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  11667. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11668. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  11669. subInfo.Id = subId;
  11670. subInfo.ParentId = id;
  11671. subInfo.CreateUserId = dto.CurrUserId;
  11672. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  11673. if (parentId < 1) return Ok(JsonView(false));
  11674. #region 子表op
  11675. if (subId < 1)//add
  11676. {
  11677. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11678. if (subAdd < 1) return Ok(JsonView(false));
  11679. }
  11680. else //upd
  11681. {
  11682. var subUpd = await _sqlSugar.Updateable(subInfo)
  11683. .UpdateColumns(x => new
  11684. {
  11685. x.Index,
  11686. x.SetDataId,
  11687. x.Cost,
  11688. x.Currency,
  11689. x.SubTotal,
  11690. x.Remark
  11691. })
  11692. .WhereColumns(x => new { x.Id })
  11693. .ExecuteCommandAsync();
  11694. if (subUpd < 1) return Ok(JsonView(false));
  11695. }
  11696. #endregion
  11697. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  11698. ////消息通知
  11699. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11700. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11701. }
  11702. /// <summary>
  11703. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  11704. /// </summary>
  11705. /// <returns></returns>
  11706. [HttpPost]
  11707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11708. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  11709. {
  11710. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  11711. if (data.Code != 0)
  11712. {
  11713. return Ok(JsonView(false, data.Msg));
  11714. }
  11715. return Ok(JsonView(true, "操作成功!", data.Data));
  11716. }
  11717. /// <summary>
  11718. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  11719. /// </summary>
  11720. /// <param name="dto"></param>
  11721. /// <returns></returns>
  11722. [HttpPost]
  11723. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  11724. {
  11725. var data = new Grp_DayOtherPriceDraft()
  11726. {
  11727. Id = dto.Id,
  11728. IsDel = 1,
  11729. DeleteUserId = dto.DeleteUserId,
  11730. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11731. };
  11732. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11733. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11734. return Ok(JsonView(false, "删除失败!"));
  11735. }
  11736. #endregion
  11737. #endregion
  11738. #region 团组经理模块 出入境费用报价表
  11739. /// <summary>
  11740. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  11741. /// </summary>
  11742. /// <returns></returns>
  11743. [HttpPost]
  11744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11745. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  11746. {
  11747. var initRates = await GeneralMethod.EnterExitCostInitRate();
  11748. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  11749. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  11750. initRates.Insert(0, cnyInfo);
  11751. liveRates.Insert(0, cnyInfo);
  11752. return Ok(JsonView(true, "查询成功!", new
  11753. {
  11754. InitRates = initRates,
  11755. LiveRates = liveRates
  11756. }));
  11757. }
  11758. /// <summary>
  11759. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  11760. /// </summary>
  11761. /// <returns></returns>
  11762. [HttpPost]
  11763. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11764. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  11765. {
  11766. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  11767. }
  11768. /// <summary>
  11769. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  11770. /// </summary>
  11771. /// <returns></returns>
  11772. [HttpPost]
  11773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11774. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  11775. {
  11776. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  11777. }
  11778. /// <summary>
  11779. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  11780. /// </summary>
  11781. /// <returns></returns>
  11782. [HttpPost]
  11783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11784. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  11785. {
  11786. int groupId = dto.DiId,
  11787. currUserId = dto.CurrUserId;
  11788. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  11789. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  11790. //验证报价数据是否存在
  11791. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  11792. if (isNull != null)
  11793. {
  11794. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  11795. if (!info1.Rates.Any())
  11796. {
  11797. var rates = await GeneralMethod.EnterExitCostInitRate();
  11798. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11799. info1.Rates = rates.ToArray();
  11800. }
  11801. return Ok(JsonView(info1));
  11802. }
  11803. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  11804. result.GroupId = groupId;
  11805. //处理报价名称
  11806. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  11807. if (groupInfo != null)
  11808. {
  11809. var visitCountry = groupInfo.VisitCountry;
  11810. if (!string.IsNullOrEmpty(visitCountry))
  11811. {
  11812. string quoteName = string.Empty;
  11813. if (visitCountry.Contains("|"))
  11814. {
  11815. var countrys = visitCountry.Split("|");
  11816. quoteName = string.Join("、", countrys);
  11817. }
  11818. else quoteName = visitCountry;
  11819. quoteName += $"团组报价表";
  11820. result.Name = quoteName;
  11821. }
  11822. }
  11823. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  11824. if (info.Code != StatusCodes.Status200OK)
  11825. {
  11826. if (!result.Rates.Any())
  11827. {
  11828. var rates = await GeneralMethod.EnterExitCostInitRate();
  11829. result.Rates = rates.ToArray();
  11830. }
  11831. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  11832. }
  11833. var infoView = info.Data as EnterExitCostInfoView;
  11834. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  11835. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  11836. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  11837. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11838. var eecRates = infoView.Currencys;
  11839. //默认添加人名币
  11840. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  11841. {
  11842. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  11843. }
  11844. //处理团组人数
  11845. int pplNum = 1;
  11846. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  11847. var views = new List<QuoteSubItemInfo>();
  11848. #region 数据填充
  11849. var intTravelCosts = new List<QuoteSubItemInfo>();
  11850. #region 机票费用 1354
  11851. int intTravelIndex = 1;
  11852. if (infoView.SumJJC == 1)
  11853. {
  11854. intTravelCosts.Add(new QuoteSubItemInfo
  11855. {
  11856. ItemId = 1354,
  11857. Index = intTravelIndex,
  11858. FeeName = "经济舱",
  11859. UnitPrice = infoView.AirJJ,
  11860. Currency = "CNY",
  11861. Quantity = 1,
  11862. PplNum = 1,
  11863. TotalAmt = infoView.AirJJ,
  11864. Remark = "",
  11865. });
  11866. intTravelIndex++;
  11867. }
  11868. if (infoView.SumGWC == 1)
  11869. {
  11870. intTravelCosts.Add(new QuoteSubItemInfo
  11871. {
  11872. ItemId = 1354,
  11873. Index = intTravelIndex,
  11874. FeeName = "公务舱",
  11875. UnitPrice = infoView.AirGW,
  11876. Currency = "CNY",
  11877. Quantity = 1,
  11878. PplNum = 1,
  11879. TotalAmt = infoView.AirGW,
  11880. Remark = "",
  11881. });
  11882. intTravelIndex++;
  11883. }
  11884. if (infoView.SumTDC == 1)
  11885. {
  11886. intTravelCosts.Add(new QuoteSubItemInfo
  11887. {
  11888. ItemId = 1354,
  11889. Index = intTravelIndex,
  11890. FeeName = "头等舱",
  11891. UnitPrice = infoView.AirTD,
  11892. Currency = "CNY",
  11893. Quantity = 1,
  11894. PplNum = 1,
  11895. TotalAmt = infoView.AirTD,
  11896. Remark = "",
  11897. });
  11898. intTravelIndex++;
  11899. }
  11900. intTravelCosts.Add(new QuoteSubItemInfo
  11901. {
  11902. ItemId = 1354,
  11903. Index = intTravelIndex,
  11904. FeeName = "城市间交通费用",
  11905. UnitPrice = infoView.CityTranffic,
  11906. Currency = "CNY",
  11907. Quantity = 1,
  11908. PplNum = pplNum,
  11909. TotalAmt = infoView.CityTranffic * pplNum,
  11910. Remark = "",
  11911. });
  11912. views.AddRange(intTravelCosts);
  11913. #endregion
  11914. var accomCosts = new List<QuoteSubItemInfo>();
  11915. #region 住宿费 1355
  11916. if (infoView.QuarterageData.Any())
  11917. {
  11918. int accomIndex = 1;
  11919. int accomItemTypeId = 1355;
  11920. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  11921. foreach (var item in groupData)
  11922. {
  11923. string feeName = string.Empty;
  11924. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11925. if (countryInfo != null)
  11926. {
  11927. feeName = countryInfo.Country;
  11928. var city = countryInfo.City;
  11929. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11930. {
  11931. feeName += $"-{city}";
  11932. }
  11933. }
  11934. var hotelInfo = item.FirstOrDefault();
  11935. if (hotelInfo == null) continue;
  11936. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  11937. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11938. int quantity = item.ToList().Count;
  11939. accomCosts.Add(new QuoteSubItemInfo
  11940. {
  11941. ItemId = accomItemTypeId,
  11942. Index = accomIndex,
  11943. FeeName = feeName,
  11944. UnitPrice = hotelInfo.Cost,
  11945. Currency = thisCurrency,
  11946. Quantity = quantity,
  11947. PplNum = pplNum,
  11948. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  11949. Remark = "",
  11950. });
  11951. accomIndex++;
  11952. }
  11953. views.AddRange(accomCosts);
  11954. }
  11955. #endregion
  11956. var mealCosts = new List<QuoteSubItemInfo>();
  11957. #region 餐饮费 1356
  11958. if (infoView.BoardWagesData.Any())
  11959. {
  11960. var mealIndex = 1;
  11961. int mealItemTypeId = 1356;
  11962. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  11963. foreach (var item in groupData)
  11964. {
  11965. string feeName = string.Empty;
  11966. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  11967. if (countryInfo != null)
  11968. {
  11969. feeName = countryInfo.Country;
  11970. var city = countryInfo.City;
  11971. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  11972. {
  11973. feeName += $"-{city}";
  11974. }
  11975. }
  11976. var mealInfo = item.FirstOrDefault();
  11977. if (mealInfo == null) continue;
  11978. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  11979. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  11980. int quantity = item.ToList().Count;
  11981. mealCosts.Add(new QuoteSubItemInfo
  11982. {
  11983. ItemId = mealItemTypeId,
  11984. Index = mealIndex,
  11985. FeeName = feeName,
  11986. UnitPrice = mealInfo.Cost,
  11987. Currency = thisCurrency,
  11988. Quantity = quantity,
  11989. PplNum = pplNum,
  11990. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  11991. Remark = "",
  11992. });
  11993. mealIndex++;
  11994. }
  11995. views.AddRange(mealCosts);
  11996. }
  11997. #endregion
  11998. var miscCosts = new List<QuoteSubItemInfo>();
  11999. #region 公杂费 1364
  12000. if (infoView.MiscellaneousFeeData.Any())
  12001. {
  12002. var miscIndex = 1;
  12003. int miscItemTypeId = 1364;
  12004. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  12005. foreach (var item in groupData)
  12006. {
  12007. string feeName = string.Empty;
  12008. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  12009. if (countryInfo != null)
  12010. {
  12011. feeName = countryInfo.Country;
  12012. var city = countryInfo.City;
  12013. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  12014. {
  12015. feeName += $"-{city}";
  12016. }
  12017. }
  12018. var miscInfo = item.FirstOrDefault();
  12019. if (miscInfo == null) continue;
  12020. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  12021. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  12022. int quantity = item.ToList().Count;
  12023. miscCosts.Add(new QuoteSubItemInfo
  12024. {
  12025. ItemId = miscItemTypeId,
  12026. Index = miscIndex,
  12027. FeeName = feeName,
  12028. UnitPrice = miscInfo.Cost,
  12029. Currency = thisCurrency,
  12030. Quantity = quantity,
  12031. PplNum = pplNum,
  12032. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  12033. Remark = "",
  12034. });
  12035. miscIndex++;
  12036. }
  12037. views.AddRange(miscCosts);
  12038. }
  12039. #endregion
  12040. #region 签证+保险 1362
  12041. int visaInsIndex = 1;
  12042. int visaInsItemTypeId = 1362;
  12043. if (infoView.Visa > 0)
  12044. {
  12045. views.Add(new QuoteSubItemInfo()
  12046. {
  12047. ItemId = visaInsItemTypeId,
  12048. Index = visaInsIndex,
  12049. FeeName = $"签证",
  12050. UnitPrice = infoView.Visa,
  12051. Currency = $"CNY",
  12052. Quantity = 1,
  12053. PplNum = pplNum,
  12054. TotalAmt = infoView.Visa * pplNum,
  12055. Remark = "",
  12056. });
  12057. visaInsIndex++;
  12058. }
  12059. if (infoView.Safe > 0)
  12060. {
  12061. views.Add(new QuoteSubItemInfo()
  12062. {
  12063. ItemId = visaInsItemTypeId,
  12064. Index = visaInsIndex,
  12065. FeeName = $"保险",
  12066. UnitPrice = infoView.Safe,
  12067. Currency = $"CNY",
  12068. Quantity = 1,
  12069. PplNum = pplNum,
  12070. TotalAmt = infoView.Safe * pplNum,
  12071. Remark = "",
  12072. });
  12073. }
  12074. #endregion
  12075. #region 服务费 1363
  12076. int serviceFeeIndex = 1;
  12077. int serviceFeeItemTypeId = 1363;
  12078. if (infoView.Service > 0)
  12079. {
  12080. views.Add(new QuoteSubItemInfo()
  12081. {
  12082. ItemId = serviceFeeItemTypeId,
  12083. Index = serviceFeeIndex,
  12084. FeeName = $"服务费",
  12085. UnitPrice = infoView.Service,
  12086. Currency = $"CNY",
  12087. Quantity = 1,
  12088. PplNum = pplNum,
  12089. TotalAmt = infoView.Service * pplNum,
  12090. Remark = "",
  12091. });
  12092. }
  12093. #endregion
  12094. #endregion
  12095. if (result.FeeItems.Any())
  12096. {
  12097. result.FeeItems.Select(x =>
  12098. {
  12099. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  12100. if (feeInfos.Any()) x.Infos = feeInfos;
  12101. return x;
  12102. }
  12103. ).OrderBy(x => x.Index)
  12104. .ToList();
  12105. if (!result.Rates.Any())
  12106. {
  12107. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  12108. else
  12109. {
  12110. var rates = await GeneralMethod.EnterExitCostInitRate();
  12111. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12112. result.Rates = rates.ToArray();
  12113. }
  12114. }
  12115. }
  12116. return Ok(JsonView(result));
  12117. }
  12118. /// <summary>
  12119. /// 团组模块 - 出入境费用报价表 - Info
  12120. /// </summary>
  12121. /// <returns></returns>
  12122. [HttpPost]
  12123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12124. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  12125. {
  12126. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  12127. if (!info.Rates.Any())
  12128. {
  12129. var rates = await GeneralMethod.EnterExitCostInitRate();
  12130. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  12131. info.Rates = rates.ToArray();
  12132. }
  12133. return Ok(JsonView(info));
  12134. }
  12135. /// <summary>
  12136. /// 团组模块 - 出入境费用报价表 - OP
  12137. /// </summary>
  12138. /// <returns></returns>
  12139. [HttpPost]
  12140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12141. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  12142. {
  12143. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  12144. }
  12145. /// <summary>
  12146. /// 团组模块 - 出入境费用报价表 - 删除 项
  12147. /// </summary>
  12148. /// <returns></returns>
  12149. [HttpPost]
  12150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12151. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  12152. {
  12153. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12154. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12155. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  12156. }
  12157. /// <summary>
  12158. /// 团组模块 - 出入境费用报价表 - 导出
  12159. /// </summary>
  12160. /// <returns></returns>
  12161. [HttpPost]
  12162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12163. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  12164. {
  12165. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  12166. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12167. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  12168. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  12169. var rates = info.Rates;
  12170. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  12171. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  12172. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  12173. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  12174. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  12175. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  12176. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  12177. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  12178. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  12179. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  12180. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  12181. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  12182. //获取模板
  12183. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  12184. var designer = new WorkbookDesigner();
  12185. designer.Workbook = new Workbook(tempPath);
  12186. designer.SetDataSource("QuoteName", info.Name);
  12187. designer.SetDataSource("CompanyTitle", "公司名称");
  12188. designer.SetDataSource("CompanyLabel", "");
  12189. #region 国际旅费
  12190. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  12191. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  12192. {
  12193. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  12194. StringBuilder label = new StringBuilder();
  12195. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  12196. if (infos.Any())
  12197. {
  12198. label.Append(infos.Sum(x => x.PplNum));
  12199. label.Append("人全程机票:");
  12200. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  12201. label.AppendLine("元");
  12202. }
  12203. foreach (var item in intTravelCosts.Infos)
  12204. {
  12205. label.Append(item.FeeName);
  12206. label.Append(":");
  12207. label.Append(item.UnitPrice.TruncDecimals(2));
  12208. label.Append("元/人*");
  12209. label.Append(item.PplNum);
  12210. label.AppendLine("人");
  12211. }
  12212. if (label.HasValue())
  12213. {
  12214. label.Append("\r\n以上小计:");
  12215. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  12216. label.Append("元");
  12217. }
  12218. designer.SetDataSource("IntTravelLabel", label.ToString());
  12219. }
  12220. #endregion
  12221. #region 住宿费
  12222. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  12223. if (accomCosts != null && accomCosts.Infos.Any())
  12224. {
  12225. string currencyName = string.Empty,
  12226. countryName = string.Empty;
  12227. decimal rate = 1.0000M;
  12228. StringBuilder label = new StringBuilder();
  12229. label.AppendLine("全程五星酒店,每人1间房");
  12230. foreach (var item in accomCosts.Infos)
  12231. {
  12232. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  12233. string name = string.Empty, thisCountryName = string.Empty;
  12234. if (item.FeeName.Contains("-"))
  12235. {
  12236. var feeName = item.FeeName.Split('-');
  12237. thisCountryName = feeName[0];
  12238. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12239. name = feeName[1];
  12240. }
  12241. else name = item.FeeName;
  12242. string thisFeeName = string.Empty;
  12243. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12244. else thisFeeName = $"\r\n{name}:";
  12245. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12246. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12247. rate = rateInfo?.Rate ?? 1.0000M;
  12248. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  12249. label.AppendLine(subLabel);
  12250. }
  12251. if (label.HasValue())
  12252. {
  12253. //以上小计:52440元(美金汇率:7.5 )
  12254. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  12255. label.AppendLine(subLabel);
  12256. }
  12257. designer.SetDataSource("AccomLabel", label.ToString());
  12258. }
  12259. #endregion
  12260. #region 餐饮费
  12261. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  12262. if (mealCosts != null && mealCosts.Infos.Any())
  12263. {
  12264. string currencyName = string.Empty;
  12265. decimal rate = 1.0000M;
  12266. StringBuilder label = new StringBuilder();
  12267. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  12268. foreach (var item in mealCosts.Infos)
  12269. {
  12270. string name = string.Empty;
  12271. if (item.FeeName.Contains("-"))
  12272. {
  12273. var feeName = item.FeeName.Split('-');
  12274. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  12275. }
  12276. else name = $"\r\n{item.FeeName}:";
  12277. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12278. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12279. rate = rateInfo?.Rate ?? 1.0000M;
  12280. label.Append(name);
  12281. label.Append(item.UnitPrice.TruncDecimals(2));
  12282. label.Append(currencyName);
  12283. label.Append("/天*");
  12284. label.Append(item.Quantity.ToString("#0"));
  12285. label.Append("*");
  12286. label.Append(item.PplNum);
  12287. label.Append("人\r\n");
  12288. }
  12289. if (label.HasValue())
  12290. {
  12291. label.Append("\r\n以上小计:");
  12292. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  12293. label.Append("元\r\n(");
  12294. label.Append("汇率:");
  12295. label.Append(rate.TruncDecimals(4));
  12296. label.Append(")");
  12297. }
  12298. designer.SetDataSource("MealLabel", label.ToString());
  12299. }
  12300. #endregion
  12301. #region 车辆安排
  12302. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  12303. if (vehArranges != null && vehArranges.Infos.Any())
  12304. {
  12305. string currencyName = string.Empty;
  12306. //decimal rate = 1.0000M;
  12307. StringBuilder label = new StringBuilder();
  12308. foreach (var item in vehArranges.Infos)
  12309. {
  12310. label.AppendLine();
  12311. label.AppendLine();
  12312. label.Append(item.FeeName);
  12313. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  12314. }
  12315. designer.SetDataSource("VehArrangeLabel", label.ToString());
  12316. }
  12317. #endregion
  12318. #region 邀请函发放对象
  12319. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  12320. designer.SetDataSource("InviteToContent", "");
  12321. #endregion
  12322. #region 邀请函费
  12323. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  12324. StringBuilder is_label = new StringBuilder();
  12325. if (inviteCosts != null && inviteCosts.Infos.Any())
  12326. {
  12327. string currencyName = string.Empty;
  12328. decimal rate = 1.0000M;
  12329. foreach (var item in inviteCosts.Infos)
  12330. {
  12331. //乌兹别克斯坦:2000美金
  12332. currencyName = item.Currency;
  12333. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12334. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  12335. is_label.AppendLine(label);
  12336. }
  12337. if (is_label.HasValue())
  12338. {
  12339. //以上小计:28500元(美金汇率:7.5)
  12340. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  12341. is_label.AppendLine(label);
  12342. }
  12343. }
  12344. designer.SetDataSource("InviteCostContent", is_label.ToString());
  12345. #endregion
  12346. #region 邀请函发放时间
  12347. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  12348. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  12349. #endregion
  12350. #region 公务活动(含翻译)
  12351. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  12352. StringBuilder oa_label = new StringBuilder();
  12353. if (officialActs != null && officialActs.Infos.Any())
  12354. {
  12355. string currencyName = string.Empty;
  12356. decimal rate = 1.0000M;
  12357. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  12358. foreach (var item in officialActs.Infos)
  12359. {
  12360. //乌兹别克斯坦:1000美金/场
  12361. currencyName = item.Currency;
  12362. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  12363. string label_remark = string.Empty;
  12364. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  12365. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  12366. }
  12367. label_content += "*总费用中未含超出公务活动价格";
  12368. //8场公务活动(以上小计:60000元)
  12369. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  12370. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  12371. oa_label.AppendLine(label_title);
  12372. oa_label.AppendLine(label_content);
  12373. }
  12374. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  12375. #endregion
  12376. #region 签证+保险
  12377. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  12378. StringBuilder vi_label = new StringBuilder();
  12379. if (visaIns != null && visaIns.Infos.Any())
  12380. {
  12381. foreach (var item in visaIns.Infos)
  12382. {
  12383. //签证:500元/人
  12384. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  12385. vi_label.AppendLine(label);
  12386. }
  12387. if (vi_label.HasValue())
  12388. {
  12389. //以上小计:6000元
  12390. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  12391. vi_label.AppendLine(label);
  12392. }
  12393. }
  12394. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  12395. #endregion
  12396. #region 服务费
  12397. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  12398. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12399. #endregion
  12400. #region 公杂费
  12401. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  12402. StringBuilder pm_label = new StringBuilder();
  12403. if (pubMiscs != null && pubMiscs.Infos.Any())
  12404. {
  12405. string currencyName = string.Empty,
  12406. countryName = string.Empty;
  12407. decimal rate = 1.0000M;
  12408. foreach (var item in pubMiscs.Infos)
  12409. {
  12410. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  12411. string name = string.Empty, thisCountryName = string.Empty;
  12412. if (item.FeeName.Contains("-"))
  12413. {
  12414. var feeName = item.FeeName.Split('-');
  12415. thisCountryName = feeName[0];
  12416. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  12417. name = feeName[1];
  12418. }
  12419. else name = item.FeeName;
  12420. string thisFeeName = string.Empty;
  12421. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  12422. else thisFeeName = $"\r\n{name}:";
  12423. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  12424. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  12425. rate = rateInfo?.Rate ?? 1.0000M;
  12426. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  12427. pm_label.AppendLine(label);
  12428. }
  12429. if (pm_label.HasValue())
  12430. {
  12431. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  12432. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  12433. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  12434. pm_label.AppendLine(string.Format("部分发放成员"));
  12435. }
  12436. }
  12437. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  12438. #endregion
  12439. #region 税费
  12440. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  12441. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  12442. #endregion
  12443. #region 合计(单位:元)
  12444. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  12445. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  12446. #endregion
  12447. #region 汇率 Remark
  12448. var rate_label = new StringBuilder();
  12449. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  12450. foreach (var item in rateGroups)
  12451. {
  12452. //美元汇率按\r\n1:7.5
  12453. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  12454. rate_label.AppendLine(label);
  12455. }
  12456. designer.SetDataSource("RateLabel", rate_label.ToString());
  12457. #endregion
  12458. designer.Process();
  12459. //文件名
  12460. string fileName = $"{info.Name}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12461. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  12462. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  12463. return Ok(JsonView(true, "成功", url));
  12464. }
  12465. #endregion
  12466. #region 签证费用录入
  12467. /// <summary>
  12468. /// 根据diid查询签证费用列表
  12469. /// </summary>
  12470. /// <param name="dto"></param>
  12471. /// <returns></returns>
  12472. [HttpPost]
  12473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12474. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  12475. {
  12476. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  12477. if (groupData.Code != 0)
  12478. {
  12479. return Ok(JsonView(false, groupData.Msg));
  12480. }
  12481. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12482. }
  12483. /// <summary>
  12484. /// 根据签证费用Id查询单条数据及c表数据
  12485. /// </summary>
  12486. /// <param name="dto"></param>
  12487. /// <returns></returns>
  12488. [HttpPost]
  12489. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12490. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  12491. {
  12492. Result groupData = await _visaPriceRep.PostVisaById(dto);
  12493. if (groupData.Code != 0)
  12494. {
  12495. return Ok(JsonView(false, groupData.Msg));
  12496. }
  12497. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12498. }
  12499. /// <summary>
  12500. /// 签证费用删除
  12501. /// </summary>
  12502. /// <param name="dto"></param>
  12503. /// <returns></returns>
  12504. [HttpPost]
  12505. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12506. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  12507. {
  12508. _sqlSugar.BeginTran();
  12509. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  12510. if (!res)
  12511. {
  12512. _sqlSugar.RollbackTran();
  12513. return Ok(JsonView(false, "删除失败"));
  12514. }
  12515. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  12516. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  12517. .SetColumns(a => new Grp_CreditCardPayment()
  12518. {
  12519. IsDel = 1,
  12520. DeleteUserId = dto.DeleteUserId,
  12521. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12522. })
  12523. .ExecuteCommand();
  12524. if (resSub < 1)
  12525. {
  12526. _sqlSugar.RollbackTran();
  12527. return Ok(JsonView(false, "删除失败"));
  12528. }
  12529. _sqlSugar.CommitTran();
  12530. return Ok(JsonView(true, "删除成功!"));
  12531. }
  12532. /// <summary>
  12533. /// 签证费用录入下拉框初始化
  12534. /// </summary>
  12535. /// <returns></returns>
  12536. [HttpPost]
  12537. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12538. public async Task<IActionResult> VisaPriceAddSelect()
  12539. {
  12540. //支付方式
  12541. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  12542. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  12543. //币种
  12544. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  12545. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  12546. //乘客类型
  12547. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  12548. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  12549. //卡类型
  12550. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  12551. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  12552. //代办费类型
  12553. var agencyFeeTypeData = new List<dynamic>() {
  12554. new { id = 0 , Text = "未选择" },
  12555. new { id = 1 , Text = "小公务" },
  12556. new { id = 2 , Text = "大公务" },
  12557. };
  12558. //签证费用标准国家Data
  12559. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  12560. var data = new
  12561. {
  12562. Payment = _Payment,
  12563. CurrencyList = _CurrencyList,
  12564. PassengerType = _PassengerType,
  12565. BankCard = _BankCard,
  12566. AgencyFeeType = agencyFeeTypeData,
  12567. CountryFeeData = visaCountryFeeData
  12568. };
  12569. return Ok(JsonView(true, "查询成功!", data));
  12570. }
  12571. /// <summary>
  12572. /// 签证费用录入操作(Status:1.新增,2.修改)
  12573. /// </summary>
  12574. /// <param name="dto"></param>
  12575. /// <returns></returns>
  12576. [HttpPost]
  12577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12578. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  12579. {
  12580. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  12581. if (groupData.Code != 0)
  12582. {
  12583. return Ok(JsonView(false, groupData.Msg));
  12584. }
  12585. #region 应用推送
  12586. try
  12587. {
  12588. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12589. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12590. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12591. //2024-10-21 新增LZ UID
  12592. var userIds = new List<int>() { 21 };
  12593. string title = $"系统通知";
  12594. string content = "";
  12595. var diId = dto.DiId;
  12596. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12597. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12598. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12599. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  12600. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12601. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  12602. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12603. }
  12604. catch (Exception ex)
  12605. {
  12606. }
  12607. #endregion
  12608. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12609. }
  12610. #endregion
  12611. #region 签证提成录入
  12612. /// <summary>
  12613. /// 签证提成录入
  12614. /// 基础数据
  12615. /// </summary>
  12616. /// <returns></returns>
  12617. [HttpGet]
  12618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12619. public async Task<IActionResult> VisaCommissionInit()
  12620. {
  12621. return Ok(await _visaCommissionRep.Init());
  12622. }
  12623. /// <summary>
  12624. /// 签证提成录入
  12625. /// Item
  12626. /// </summary>
  12627. /// <param name="_dto"></param>
  12628. /// <returns></returns>
  12629. [HttpPost]
  12630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12631. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  12632. {
  12633. var validator = new VisaCommissionItemDtoValidator();
  12634. var validatorRes = await validator.ValidateAsync(_dto);
  12635. if (!validatorRes.IsValid)
  12636. {
  12637. StringBuilder sb = new StringBuilder();
  12638. foreach (var item in validatorRes.Errors)
  12639. {
  12640. sb.AppendLine(item.ErrorMessage);
  12641. }
  12642. return Ok(JsonView(false, sb.ToString()));
  12643. }
  12644. return Ok(await _visaCommissionRep.Item(_dto));
  12645. }
  12646. /// <summary>
  12647. /// 签证提成录入
  12648. /// Save
  12649. /// </summary>
  12650. /// <param name="_dto"></param>
  12651. /// <returns></returns>
  12652. [HttpPost]
  12653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12654. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  12655. {
  12656. //参数验证
  12657. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  12658. foreach (var item in _dto.Items)
  12659. {
  12660. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  12661. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  12662. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  12663. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  12664. }
  12665. return Ok(await _visaCommissionRep.Save(_dto));
  12666. }
  12667. /// <summary>
  12668. /// 签证提成录入
  12669. /// Create
  12670. /// </summary>
  12671. /// <param name="_dto"></param>
  12672. /// <returns></returns>
  12673. [HttpPost]
  12674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12675. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  12676. {
  12677. var validator = new VisaCommissionCreateDtoValidator();
  12678. var validatorRes = await validator.ValidateAsync(_dto);
  12679. if (!validatorRes.IsValid)
  12680. {
  12681. StringBuilder sb = new StringBuilder();
  12682. foreach (var item in validatorRes.Errors)
  12683. {
  12684. sb.AppendLine(item.ErrorMessage);
  12685. }
  12686. return Ok(JsonView(false, sb.ToString()));
  12687. }
  12688. return Ok(await _visaCommissionRep.Create(_dto));
  12689. }
  12690. /// <summary>
  12691. /// 签证提成录入
  12692. /// Put(编辑)
  12693. /// </summary>
  12694. /// <param name="id"></param>
  12695. /// <param name="_dto"></param>
  12696. /// <returns></returns>
  12697. [HttpPut]
  12698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12699. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  12700. {
  12701. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12702. var validator = new VisaCommissionCreateDtoValidator();
  12703. var validatorRes = await validator.ValidateAsync(_dto);
  12704. if (!validatorRes.IsValid)
  12705. {
  12706. StringBuilder sb = new StringBuilder();
  12707. foreach (var item in validatorRes.Errors)
  12708. {
  12709. sb.AppendLine(item.ErrorMessage);
  12710. }
  12711. return Ok(JsonView(false, sb.ToString()));
  12712. }
  12713. return Ok(await _visaCommissionRep.Edit(id, _dto));
  12714. }
  12715. /// <summary>
  12716. /// 签证提成录入
  12717. /// Del
  12718. /// </summary>
  12719. /// <param name="id"></param>
  12720. /// <param name="currUserId"></param>
  12721. /// <returns></returns>
  12722. [HttpPost]
  12723. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12724. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  12725. {
  12726. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  12727. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  12728. return Ok(await _visaCommissionRep.Del(id, currUserId));
  12729. }
  12730. #endregion
  12731. #region op费用录入
  12732. /// <summary>
  12733. /// 根据diid查询op费用列表
  12734. /// </summary>
  12735. /// <param name="dto"></param>
  12736. /// <returns></returns>
  12737. [HttpPost]
  12738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12739. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  12740. {
  12741. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  12742. if (groupData.Code != 0)
  12743. {
  12744. return Ok(JsonView(false, groupData.Msg));
  12745. }
  12746. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12747. }
  12748. /// <summary>
  12749. /// 根据op费用Id查询单条数据及c表数据
  12750. /// </summary>
  12751. /// <param name="dto"></param>
  12752. /// <returns></returns>
  12753. [HttpPost]
  12754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12755. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  12756. {
  12757. try
  12758. {
  12759. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  12760. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  12761. var data = new
  12762. {
  12763. CarTouristGuideGround = _groupData,
  12764. CreditCardPayment = _creditCardPayment
  12765. };
  12766. return Ok(JsonView(true, "查询成功!", data));
  12767. }
  12768. catch (Exception ex)
  12769. {
  12770. return Ok(JsonView(false, "程序错误!"));
  12771. }
  12772. }
  12773. /// <summary>
  12774. /// op费用删除
  12775. /// </summary>
  12776. /// <param name="dto"></param>
  12777. /// <returns></returns>
  12778. [HttpPost]
  12779. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12780. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  12781. {
  12782. try
  12783. {
  12784. _sqlSugar.BeginTran();
  12785. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  12786. if (!res)
  12787. {
  12788. return Ok(JsonView(false, "删除失败"));
  12789. }
  12790. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  12791. {
  12792. IsDel = 1,
  12793. DeleteUserId = dto.DeleteUserId,
  12794. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12795. }).ExecuteCommandAsync();
  12796. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  12797. {
  12798. IsDel = 1,
  12799. DeleteUserId = dto.DeleteUserId,
  12800. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12801. }).ExecuteCommandAsync();
  12802. #region 删除超支相关数据
  12803. //删除导入的超支数据
  12804. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  12805. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  12806. {
  12807. IsDel = 1,
  12808. DeleteUserId = dto.DeleteUserId,
  12809. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12810. }).ExecuteCommand();
  12811. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  12812. {
  12813. IsDel = 1,
  12814. DeleteUserId = dto.DeleteUserId,
  12815. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12816. }).ExecuteCommand();
  12817. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  12818. {
  12819. IsDel = 1,
  12820. DeleteUserId = dto.DeleteUserId,
  12821. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12822. }).ExecuteCommand();
  12823. #endregion
  12824. _sqlSugar.CommitTran();
  12825. return Ok(JsonView(true, "删除成功!"));
  12826. }
  12827. catch (Exception ex)
  12828. {
  12829. _sqlSugar.RollbackTran();
  12830. return Ok(JsonView(false, "程序错误!" + ex.Message));
  12831. }
  12832. }
  12833. /// <summary>
  12834. /// op费用录入操作(Status:1.新增,2.修改)
  12835. /// </summary>
  12836. /// <param name="dto"></param>
  12837. /// <returns></returns>
  12838. [HttpPost]
  12839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12840. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  12841. {
  12842. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  12843. if (groupData.Code != 0)
  12844. {
  12845. return Ok(JsonView(false, groupData.Msg));
  12846. }
  12847. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12848. }
  12849. /// <summary>
  12850. /// 填写费用详细页面初始化绑定
  12851. /// </summary>
  12852. /// <param name="dto"></param>
  12853. /// <returns></returns>
  12854. [HttpPost]
  12855. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12856. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  12857. {
  12858. try
  12859. {
  12860. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  12861. if (groupData.Code != 0)
  12862. {
  12863. return Ok(JsonView(false, groupData.Msg));
  12864. }
  12865. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12866. }
  12867. catch (Exception ex)
  12868. {
  12869. return Ok(JsonView(false, ex.Message));
  12870. }
  12871. }
  12872. /// <summary>
  12873. /// 根据op费用Id查询详细数据
  12874. /// </summary>
  12875. /// <param name="dto"></param>
  12876. /// <returns></returns>
  12877. [HttpPost]
  12878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12879. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  12880. {
  12881. try
  12882. {
  12883. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(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费用录入填写详情
  12897. /// </summary>
  12898. /// <param name="dto"></param>
  12899. /// <returns></returns>
  12900. [HttpPost]
  12901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12902. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  12903. {
  12904. try
  12905. {
  12906. #region 参数校验
  12907. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  12908. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  12909. if (di == null) return Ok(JsonView(false, "团组错误!"));
  12910. #endregion
  12911. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  12912. if (groupData.Code != 0)
  12913. {
  12914. return Ok(JsonView(false, groupData.Msg));
  12915. }
  12916. //自动审核
  12917. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  12918. #region 应用推送
  12919. try
  12920. {
  12921. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12922. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12923. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12924. //2024-10-21 新增LZ UID
  12925. var userIds = new List<int>() { 21 };
  12926. string title = $"系统通知";
  12927. var diId = dto.DiId;
  12928. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12929. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12930. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  12931. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12932. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  12933. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12934. }
  12935. catch (Exception ex)
  12936. {
  12937. }
  12938. #endregion
  12939. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12940. }
  12941. catch (Exception ex)
  12942. {
  12943. return Ok(JsonView(false, ex.Message));
  12944. }
  12945. }
  12946. /// <summary>
  12947. /// 获取三公详细所有城市
  12948. /// </summary>
  12949. /// <returns></returns>
  12950. [HttpGet]
  12951. public IActionResult OpCarCityResult()
  12952. {
  12953. var jw = JsonView(false);
  12954. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  12955. {
  12956. x.Id,
  12957. x.Country,
  12958. x.City,
  12959. }).ToList();
  12960. if (data.Count > 0)
  12961. {
  12962. jw = JsonView(true, "获取成功!", data);
  12963. }
  12964. else
  12965. {
  12966. jw.Msg = "城市数据为空!";
  12967. jw.Data = new string[0];
  12968. }
  12969. return Ok(jw);
  12970. }
  12971. /// <summary>
  12972. /// 导出地接费用明细
  12973. /// </summary>
  12974. /// <param name="dto"></param>
  12975. /// <returns></returns>
  12976. [HttpPost]
  12977. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  12978. {
  12979. var jw = JsonView(false);
  12980. if (dto.Diid < 1)
  12981. {
  12982. jw.Msg = "请输入正确的diid!";
  12983. return Ok(jw);
  12984. }
  12985. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12986. if (group == null)
  12987. {
  12988. jw.Msg = "未找到团组信息!";
  12989. return Ok(jw);
  12990. }
  12991. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12992. if (localGuideArr.Count == 0)
  12993. {
  12994. jw.Msg = "该团组暂无地接信息!";
  12995. return Ok(jw);
  12996. }
  12997. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  12998. var overspendSoure = new Dictionary<int, int>
  12999. {
  13000. { 91, 982 }, //车
  13001. { 92 , 1059} ,//导游
  13002. { 994 , 1073}, //翻译
  13003. { 988 , 1074 }, //早餐
  13004. { 93 , 1075 }, //午餐
  13005. { 989 , 1076 }, //晚餐
  13006. };
  13007. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  13008. foreach (var groupArr in localGroup)
  13009. {
  13010. var keyValue = groupArr.Key;
  13011. if (int.TryParse(keyValue, out int cityid))
  13012. {
  13013. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  13014. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  13015. }
  13016. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  13017. foreach (var item in groupArr)
  13018. {
  13019. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  13020. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  13021. new Grp_CarTouristGuideGroundReservationsContentExtend
  13022. {
  13023. Count = a.Count,
  13024. CreateTime = a.CreateTime,
  13025. CreateUserId = a.CreateUserId,
  13026. CTGGRId = a.CTGGRId,
  13027. Currency = a.Currency,
  13028. DatePrice = a.DatePrice,
  13029. DeleteTime = a.DeleteTime,
  13030. DeleteUserId = a.DeleteUserId,
  13031. DiId = a.DiId,
  13032. Id = a.Id,
  13033. IsDel = a.IsDel,
  13034. Price = a.Price,
  13035. PriceContent = a.PriceContent,
  13036. Remark = a.Remark,
  13037. SId = a.SId,
  13038. SidName = b.Name,
  13039. Units = a.Units,
  13040. }
  13041. ).ToList();
  13042. if (content.Count > 0)
  13043. {
  13044. contentArr.Add(content);
  13045. }
  13046. }
  13047. //open excel
  13048. //set excel
  13049. //save excel
  13050. try
  13051. {
  13052. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  13053. IWorkbook workbook;
  13054. if (Path.GetExtension(filePath).ToLower() == ".xls")
  13055. {
  13056. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13057. }
  13058. else
  13059. {
  13060. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  13061. }
  13062. ISheet sheet = workbook.GetSheetAt(0);
  13063. var rowStartIndex = 2;
  13064. var clounmCount = 10;
  13065. var initStyleRow = sheet.GetRow(2);
  13066. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  13067. //var overspendArrDetail =
  13068. var existsId = new List<CarCompare>();
  13069. var lastElem = arr.Last();
  13070. var thisSid = -1;
  13071. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  13072. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  13073. {
  13074. Name = "未知币种!",
  13075. Remark = "未知币种!",
  13076. };
  13077. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  13078. Action cloneRowFn = () =>
  13079. {
  13080. rowStartIndex++;
  13081. var cloneRow = sheet.CreateRow(rowStartIndex);
  13082. // 复制样式
  13083. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  13084. {
  13085. ICell sourceCell = initStyleRow.GetCell(i);
  13086. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  13087. // 确保单元格存在样式
  13088. if (sourceCell.CellStyle != null)
  13089. {
  13090. targetCell.CellStyle = sourceCell.CellStyle;
  13091. }
  13092. }
  13093. };
  13094. var mergeRow = () =>
  13095. {
  13096. for (int i = 2; i < sheet.LastRowNum; i++)
  13097. {
  13098. var row = sheet.GetRow(i);
  13099. var cellFirst = row.GetCell(0);
  13100. var thisIndex = i + 1;
  13101. while (thisIndex < sheet.LastRowNum)
  13102. {
  13103. var nextRow = sheet.GetRow(thisIndex);
  13104. var nextCellFirst = nextRow.GetCell(0);
  13105. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  13106. {
  13107. thisIndex++;
  13108. }
  13109. else
  13110. {
  13111. break;
  13112. }
  13113. }
  13114. thisIndex--;
  13115. if (thisIndex != i)
  13116. {
  13117. //合并row
  13118. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  13119. i, // 起始行索引(0-based)
  13120. thisIndex, // 结束行索引(0-based)
  13121. 0, // 起始列索引(0-based)
  13122. 0 // 结束列索引(0-based)
  13123. );
  13124. sheet.AddMergedRegion(cellRangeAddress);
  13125. i = thisIndex;
  13126. }
  13127. }
  13128. };
  13129. var chaoshiNumber = 0;
  13130. var totalNumber = 0.00M;
  13131. string lastStr = "";
  13132. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  13133. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  13134. {
  13135. b.IsAuditGM,
  13136. x.Id,
  13137. x.Area,
  13138. b.PayPercentage,
  13139. b.PayMoney,
  13140. }).ToList();
  13141. string yesPayment = "", noPayment = "";
  13142. foreach (var item in queryCarArrByCityAndDiid)
  13143. {
  13144. if (item.IsAuditGM == 1)
  13145. {
  13146. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13147. }
  13148. else
  13149. {
  13150. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  13151. }
  13152. }
  13153. lastStr = yesPayment + noPayment;
  13154. foreach (var item in arr)
  13155. {
  13156. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  13157. {
  13158. if (thisSid != item.SId)
  13159. {
  13160. if (thisSid == -1)
  13161. {
  13162. thisSid = item.SId;
  13163. }
  13164. else
  13165. {
  13166. //合并小计行
  13167. //创建合并区域的实例
  13168. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  13169. rowStartIndex, // 起始行索引(0-based)
  13170. rowStartIndex, // 结束行索引(0-based)
  13171. 0, // 起始列索引(0-based)
  13172. 3 // 结束列索引(0-based)
  13173. );
  13174. sheet.AddMergedRegion(cellRangeAddress);
  13175. var CellStyle = workbook.CreateCellStyle();
  13176. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13177. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13178. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13179. for (int i = 0; i <= clounmCount; i++)
  13180. {
  13181. if (i > 6)
  13182. {
  13183. var CellStyle1 = workbook.CreateCellStyle();
  13184. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13185. IFont Font = workbook.CreateFont(); // 创建字体
  13186. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13187. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13188. CellStyle1.SetFont(Font);
  13189. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13190. }
  13191. else
  13192. {
  13193. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13194. }
  13195. }
  13196. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13197. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13198. //超时合计
  13199. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13200. //超时数
  13201. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13202. //超时合计费用
  13203. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13204. thisSid = item.SId;
  13205. cloneRowFn();
  13206. chaoshiNumber = 0;
  13207. totalNumber = 0;
  13208. }
  13209. }
  13210. IRow row = sheet.GetRow(rowStartIndex);
  13211. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13212. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  13213. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  13214. if (isOpenOverspendSoure)
  13215. {
  13216. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13217. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  13218. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  13219. }
  13220. for (int i = 0; i <= clounmCount; i++)
  13221. {
  13222. var cell = row.GetCell(i);
  13223. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  13224. if (cell == null)
  13225. {
  13226. cell = row.CreateCell(i);
  13227. }
  13228. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  13229. fontRed.CloneStyleFrom(cell.CellStyle);
  13230. IFont Font = workbook.CreateFont(); // 创建字体
  13231. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  13232. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13233. fontRed.SetFont(Font);
  13234. byte[] rgb = new byte[3] { 255, 242, 204 };
  13235. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  13236. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  13237. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  13238. if (workbook is XSSFWorkbook)
  13239. {
  13240. BackgroundColor255_242_204.FillForegroundColor = 0;
  13241. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  13242. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13243. }
  13244. else
  13245. {
  13246. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  13247. }
  13248. if (i == 1 || i > 6)
  13249. {
  13250. if (i > 6)
  13251. {
  13252. fontRed.FillForegroundColor = 0;
  13253. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  13254. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  13255. }
  13256. cell.CellStyle = fontRed;
  13257. }
  13258. if (i > 2 && i < 7)
  13259. {
  13260. cell.CellStyle = BackgroundColor255_242_204;
  13261. }
  13262. cell.SetCellValue(setCellValue); //写入单元格
  13263. }
  13264. if (overspendSoure.ContainsKey(thisSid))
  13265. {
  13266. var overspendId = overspendSoure[thisSid];
  13267. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  13268. }
  13269. cloneRowFn();
  13270. existsId.Add(new CarCompare
  13271. {
  13272. DataPrice = item.DatePrice.ObjToDate(),
  13273. Sid = item.SId
  13274. });
  13275. }
  13276. if (item.Equals(lastElem))
  13277. {
  13278. //合并小计行
  13279. //创建合并区域的实例
  13280. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  13281. rowStartIndex, // 起始行索引(0-based)
  13282. rowStartIndex, // 结束行索引(0-based)
  13283. 0, // 起始列索引(0-based)
  13284. 3 // 结束列索引(0-based)
  13285. );
  13286. sheet.AddMergedRegion(cellRangeAddress);
  13287. var CellStyle = workbook.CreateCellStyle();
  13288. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13289. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  13290. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  13291. for (int i = 0; i <= clounmCount; i++)
  13292. {
  13293. if (i > 6)
  13294. {
  13295. var CellStyle1 = workbook.CreateCellStyle();
  13296. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  13297. IFont Font = workbook.CreateFont(); // 创建字体
  13298. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  13299. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  13300. CellStyle1.SetFont(Font);
  13301. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  13302. }
  13303. else
  13304. {
  13305. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  13306. }
  13307. }
  13308. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  13309. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  13310. //超时合计
  13311. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  13312. //超时数
  13313. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  13314. //超时合计费用
  13315. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  13316. cloneRowFn();
  13317. // 创建合并区域的实例
  13318. cellRangeAddress = new CellRangeAddress(
  13319. rowStartIndex, // 起始行索引(0-based)
  13320. rowStartIndex, // 结束行索引(0-based)
  13321. 0, // 起始列索引(0-based)
  13322. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  13323. );
  13324. // 添加合并区域
  13325. sheet.AddMergedRegion(cellRangeAddress);
  13326. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  13327. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  13328. }
  13329. }
  13330. mergeRow();
  13331. // 保存修改后的Excel文件到新文件
  13332. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  13333. // new FileStream(newFilePath, FileMode.CreateNew)
  13334. using (var stream = new MemoryStream())
  13335. {
  13336. workbook.Write(stream, true);
  13337. stream.Flush();
  13338. stream.Seek(0, SeekOrigin.Begin);
  13339. MemoryStream memoryStream = new MemoryStream();
  13340. stream.CopyTo(memoryStream);
  13341. memoryStream.Seek(0, SeekOrigin.Begin);
  13342. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  13343. }
  13344. workbook.Close();
  13345. workbook.Dispose();
  13346. }
  13347. catch (Exception ex)
  13348. {
  13349. jw.Msg = "出现异常!" + ex.Message;
  13350. return Ok(jw);
  13351. }
  13352. }
  13353. if (Zips.Count > 0)
  13354. {
  13355. IOOperatorHelper io = new IOOperatorHelper();
  13356. var byts = io.ConvertZipStream(Zips);
  13357. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  13358. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  13359. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  13360. }
  13361. else
  13362. {
  13363. jw.Msg = "暂无生成文件!";
  13364. }
  13365. return Ok(jw);
  13366. }
  13367. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  13368. {
  13369. string outStr = string.Empty;
  13370. switch (i)
  13371. {
  13372. case 0:
  13373. outStr = arr[0].SidName;
  13374. break;
  13375. case 1:
  13376. outStr = arr[0].DataPriceStr;
  13377. break;
  13378. case 2:
  13379. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  13380. break;
  13381. case 4:
  13382. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  13383. break;
  13384. case 7:
  13385. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13386. {
  13387. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  13388. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  13389. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  13390. }
  13391. break;
  13392. case 8:
  13393. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13394. {
  13395. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  13396. }
  13397. break;
  13398. case 9:
  13399. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13400. {
  13401. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  13402. }
  13403. break;
  13404. case 10:
  13405. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  13406. {
  13407. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  13408. }
  13409. break;
  13410. }
  13411. return outStr;
  13412. }
  13413. #region OP行程单
  13414. /// <summary>
  13415. /// OP行程单初始化
  13416. /// </summary>
  13417. /// <param name="dto"></param>
  13418. /// <returns></returns>
  13419. [HttpPost]
  13420. public IActionResult InitOpTravel(InitOpTravelDto dto)
  13421. {
  13422. var jw = JsonView(false);
  13423. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  13424. var group = groupList.First();
  13425. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  13426. if (group == null)
  13427. {
  13428. jw.Msg = "暂无团组!";
  13429. return Ok(jw);
  13430. }
  13431. group = groupList.Find(x => x.Id == diid);
  13432. if (group == null)
  13433. {
  13434. jw.Msg = "请输入正确的团组ID!";
  13435. return Ok(jw);
  13436. }
  13437. string city = string.Empty;
  13438. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  13439. if (blackCode.Count > 0)
  13440. {
  13441. var black = blackCode.First();
  13442. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  13443. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  13444. if (blackSp.Length > 0)
  13445. {
  13446. try
  13447. {
  13448. var cityArrCode = new List<string>(20);
  13449. foreach (var item in blackSp)
  13450. {
  13451. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  13452. var IndexSelect = itemSp[2];
  13453. var cityArrCodeLength = cityArrCode.Count - 1;
  13454. var startCity = IndexSelect.Substring(0, 3);
  13455. if (cityArrCodeLength > 0)
  13456. {
  13457. var arrEndCity = cityArrCode[cityArrCodeLength];
  13458. if (arrEndCity != startCity)
  13459. {
  13460. cityArrCode.Add(startCity.ToUpper());
  13461. }
  13462. }
  13463. else
  13464. {
  13465. cityArrCode.Add(startCity.ToUpper());
  13466. }
  13467. var endCity = IndexSelect.Substring(3, 3);
  13468. cityArrCode.Add(endCity.ToUpper());
  13469. }
  13470. var cityThree = string.Empty;
  13471. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  13472. cityThree = cityThree.TrimEnd(',');
  13473. if (string.IsNullOrWhiteSpace(cityThree))
  13474. {
  13475. throw new
  13476. Exception("error");
  13477. }
  13478. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  13479. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  13480. foreach (var item in cityArrCode)
  13481. {
  13482. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  13483. if (find != null)
  13484. {
  13485. city += find.City + "/";
  13486. }
  13487. else
  13488. {
  13489. city += item + "三字码未收入/";
  13490. }
  13491. }
  13492. city = city.TrimEnd('/');
  13493. }
  13494. catch (Exception e)
  13495. {
  13496. city = "黑屏代码格式不正确!";
  13497. }
  13498. }
  13499. }
  13500. else
  13501. {
  13502. city = "未录入黑屏代码";
  13503. }
  13504. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  13505. {
  13506. Date = x.Date,
  13507. Days = x.Days,
  13508. Diffgroup = x.Diffgroup,
  13509. Diid = x.Diid,
  13510. Traffic_First = x.Traffic_First,
  13511. Traffic_Second = x.Traffic_Second,
  13512. Trip = x.Trip,
  13513. WeekDay = x.WeekDay,
  13514. Id = x.Id
  13515. }).ToList();
  13516. jw.Data = new
  13517. {
  13518. groupList = groupList.Select(x => new
  13519. {
  13520. x.Id,
  13521. x.TeamName,
  13522. x.TourCode
  13523. }).ToList(),
  13524. groupInfo = new
  13525. {
  13526. group.VisitDays,
  13527. group.TourCode,
  13528. group.VisitPNumber,
  13529. group.TeamName,
  13530. city
  13531. },
  13532. OpTravelList
  13533. };
  13534. jw.Code = 200;
  13535. jw.Msg = "操作成功!";
  13536. return Ok(jw);
  13537. }
  13538. /// <summary>
  13539. /// 删除团组行程单
  13540. /// </summary>
  13541. /// <returns></returns>
  13542. [HttpPost]
  13543. public IActionResult DelTravel(DelOpTravelDto dto)
  13544. {
  13545. var jw = JsonView(false);
  13546. if (dto.UserId <= 0 || dto.Diid <= 0)
  13547. {
  13548. jw.Msg = "请输入正确的参数!";
  13549. return Ok(jw);
  13550. }
  13551. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  13552. .SetColumns(x => new Grp_TravelList
  13553. {
  13554. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  13555. DeleteUserId = dto.UserId,
  13556. IsDel = 1,
  13557. }).ExecuteCommand();
  13558. jw = JsonView(true);
  13559. return Ok(jw);
  13560. }
  13561. /// <summary>
  13562. /// 行程单保存
  13563. /// </summary>
  13564. /// <returns></returns>
  13565. [HttpPost]
  13566. public IActionResult TravelSave(TravelSaveDto dto)
  13567. {
  13568. var jw = JsonView(false);
  13569. if (dto.Arr.Count > 0)
  13570. {
  13571. try
  13572. {
  13573. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  13574. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  13575. .ToList();
  13576. _sqlSugar.BeginTran();
  13577. foreach (var item in dto.Arr)
  13578. {
  13579. if (item.Id == 0)
  13580. {
  13581. throw new Exception("请传入正确的Id");
  13582. }
  13583. //比较上一次的差异
  13584. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  13585. if (findTravel != null)
  13586. {
  13587. item.Trip = item.Trip.Replace("[++]", string.Empty);
  13588. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  13589. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  13590. }
  13591. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  13592. .SetColumns(x => new Grp_TravelList
  13593. {
  13594. Trip = item.Trip
  13595. }).ExecuteCommand();
  13596. }
  13597. _sqlSugar.CommitTran();
  13598. jw = JsonView(true);
  13599. }
  13600. catch (Exception ex)
  13601. {
  13602. _sqlSugar.RollbackTran();
  13603. jw.Msg = "程序异常!" + ex.Message;
  13604. }
  13605. }
  13606. else
  13607. {
  13608. jw.Msg = "请传入正确的参数!";
  13609. }
  13610. return Ok(jw);
  13611. }
  13612. private string CheckStr(string original, string changed)
  13613. {
  13614. // 创建diff_match_patch对象
  13615. var dmp = new diff_match_patch();
  13616. // 计算差异
  13617. List<Diff> diffs = dmp.diff_main(original, changed);
  13618. // 清理和合并差异
  13619. dmp.diff_cleanupSemantic(diffs);
  13620. // 使用StringBuilder构建最终的字符串
  13621. StringBuilder finalString = new StringBuilder();
  13622. // 输出差异结果,并构建变动后的字符串
  13623. foreach (Diff diff in diffs)
  13624. {
  13625. switch (diff.operation)
  13626. {
  13627. case Operation.EQUAL:
  13628. // 相等的部分,直接添加到最终字符串
  13629. finalString.Append(diff.text);
  13630. break;
  13631. case Operation.INSERT:
  13632. // 插入的部分,添加标记并添加到最终字符串
  13633. finalString.Append("[++]" + diff.text + "[++]");
  13634. break;
  13635. case Operation.DELETE:
  13636. // 删除的部分,不添加到最终字符串
  13637. //finalString.Append("[++]" + diff.text + "[++]");
  13638. break;
  13639. }
  13640. }
  13641. // 输出变动后的字符串
  13642. return finalString.ToString();
  13643. }
  13644. private class tagContent
  13645. {
  13646. public DateTime Date { get; set; }
  13647. public string StartTag { get; set; }
  13648. public string EndTag { get; set; }
  13649. public string Content { get; set; }
  13650. public static int tagLength { get { return 3; } }
  13651. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  13652. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  13653. public bool IsFinally { get; set; }
  13654. }
  13655. private List<string> ExtractContentBetweenTags(string input, string tag)
  13656. {
  13657. List<string> results = new List<string>();
  13658. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  13659. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  13660. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  13661. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  13662. string[] strValueArr = new string[1];
  13663. foreach (System.Text.RegularExpressions.Match match in matches)
  13664. {
  13665. var strValue = match.Groups[1].Value;
  13666. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  13667. }
  13668. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  13669. return results;
  13670. }
  13671. /// <summary>
  13672. /// 导出行程单
  13673. /// </summary>
  13674. /// <param name="dto"></param>
  13675. /// <returns></returns>
  13676. [HttpPost]
  13677. public IActionResult ExportTravel(ExportTravelDto dto)
  13678. {
  13679. var jw = JsonView(false);
  13680. jw.Data = "";
  13681. int diid = 0;
  13682. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  13683. if (Find == null)
  13684. {
  13685. jw.Msg = "请选择正确的团组!";
  13686. return Ok(jw);
  13687. }
  13688. else
  13689. {
  13690. diid = Find.Id;
  13691. }
  13692. //数据源
  13693. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  13694. DataTable dtBlack = null;
  13695. try
  13696. {
  13697. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  13698. }
  13699. catch (Exception)
  13700. {
  13701. jw.Msg = "机票黑屏代码有误!";
  13702. return Ok(jw);
  13703. }
  13704. string CityStr = string.Empty;
  13705. if (dtBlack.Rows.Count == 0)
  13706. {
  13707. jw.Msg = "机票黑屏代码有误!";
  13708. return Ok(jw);
  13709. }
  13710. else
  13711. {
  13712. foreach (DataRow row in dtBlack.Rows)
  13713. {
  13714. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  13715. {
  13716. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  13717. return Ok(jw);
  13718. }
  13719. }
  13720. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  13721. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  13722. }
  13723. // 指定的文字
  13724. var targetTextDic = new Dictionary<string, List<string>>();
  13725. //创建数据源Table
  13726. DataTable dtSource = new DataTable();
  13727. dtSource.Columns.Add("Days", typeof(string));
  13728. dtSource.Columns.Add("Date", typeof(string));
  13729. dtSource.Columns.Add("Week", typeof(string));
  13730. dtSource.Columns.Add("Traffic", typeof(string));
  13731. dtSource.Columns.Add("Trip", typeof(string));
  13732. //获取数据,放到datatable
  13733. foreach (var item in _travelList)
  13734. {
  13735. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  13736. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  13737. .Replace(tagContent.TagFormat.Item2, string.Empty)
  13738. .Replace("[++]", string.Empty);
  13739. DataRow dr = dtSource.NewRow();
  13740. dr["Days"] = item.Days;
  13741. dr["Date"] = item.Date;
  13742. dr["Week"] = item.WeekDay;
  13743. dr["Traffic"] = item.Traffic_First
  13744. + "\r\n"
  13745. + item.Traffic_Second;
  13746. dr["Trip"] = item.Trip;
  13747. dtSource.Rows.Add(dr);
  13748. }
  13749. Dictionary<string, string> dic = new Dictionary<string, string>();
  13750. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  13751. dic.Add("City", CityStr);
  13752. dic.Add("Days", Find.VisitDays.ToString());
  13753. dic.Add("DeleCode", Find.TourCode);
  13754. dic.Add("Pnum", Find.VisitPNumber.ToString());
  13755. //模板路径
  13756. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  13757. //载入模板
  13758. Document doc = null;
  13759. DocumentBuilder builder = null;
  13760. try
  13761. {
  13762. //载入模板
  13763. doc = new Document(tempPath);
  13764. builder = new DocumentBuilder(doc);
  13765. }
  13766. catch (Exception)
  13767. {
  13768. jw.Msg = "模板位置不存在!";
  13769. return Ok(jw);
  13770. }
  13771. foreach (var key in dic.Keys)
  13772. {
  13773. Bookmark bookmark = doc.Range.Bookmarks[key];
  13774. if (bookmark != null)
  13775. {
  13776. builder.MoveToBookmark(key);
  13777. builder.Write(dic[key]);
  13778. }
  13779. }
  13780. //获取word里所有表格
  13781. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13782. //获取所填表格的序数
  13783. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13784. try
  13785. {
  13786. //循环赋值
  13787. for (int i = 0; i < dtSource.Rows.Count; i++)
  13788. {
  13789. builder.MoveToCell(0, i + 1, 0, 0);
  13790. builder.Write(dtSource.Rows[i]["Days"].ToString());
  13791. builder.MoveToCell(0, i + 1, 1, 0);
  13792. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  13793. builder.MoveToCell(0, i + 1, 2, 0);
  13794. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  13795. var trip = dtSource.Rows[i]["Trip"].ToString();
  13796. builder.MoveToCell(0, i + 1, 3, 0);
  13797. builder.Write(trip);
  13798. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  13799. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13800. // 获取特定索引的段落
  13801. Paragraph paragraph = (Paragraph)paragraphs[0];
  13802. Run run = paragraph.Runs[0];
  13803. Aspose.Words.Font font = run.Font;
  13804. font.Name = "黑体";
  13805. //设置双休红色
  13806. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  13807. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  13808. paragraph = (Paragraph)paragraphs[1];
  13809. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  13810. {
  13811. run = paragraph.Runs[0];
  13812. font = run.Font;
  13813. font.Color = Color.Red;
  13814. }
  13815. }
  13816. }
  13817. catch (Exception ex)
  13818. {
  13819. }
  13820. //删除多余行
  13821. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  13822. {
  13823. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  13824. }
  13825. var targetTextList = new List<string>();
  13826. // 遍历文档中的表格
  13827. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  13828. {
  13829. foreach (Aspose.Words.Tables.Row row in table.Rows)
  13830. {
  13831. var cellIndex = 0;
  13832. foreach (Cell cell in row.Cells)
  13833. {
  13834. if (cellIndex == 1 && row.Cells.Count == 4)
  13835. {
  13836. foreach (var target in targetTextDic.Keys)
  13837. {
  13838. if (cell.GetText().Contains(target))
  13839. {
  13840. targetTextList = targetTextDic[target];
  13841. break;
  13842. }
  13843. }
  13844. }
  13845. // 遍历单元格中的所有段落
  13846. foreach (Paragraph paragraph in cell.Paragraphs)
  13847. {
  13848. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  13849. List<Run> runs = new List<Run>();
  13850. foreach (Run run in paragraph.Runs)
  13851. {
  13852. runs.Add(run);
  13853. }
  13854. foreach (Run run in runs)
  13855. {
  13856. foreach (var targetText in targetTextList)
  13857. {
  13858. // 检查文字是否包含指定文字
  13859. if (run.Text.Contains(targetText))
  13860. {
  13861. // 将包含的部分设置为红色
  13862. HighlightText(run, targetText, Color.Red);
  13863. }
  13864. }
  13865. }
  13866. }
  13867. cellIndex++;
  13868. }
  13869. }
  13870. }
  13871. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  13872. if (!Directory.Exists(savePath))
  13873. {
  13874. try
  13875. {
  13876. Directory.CreateDirectory(savePath);
  13877. }
  13878. catch
  13879. {
  13880. }
  13881. }
  13882. string path = savePath + Find.TeamName + "出访日程";
  13883. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  13884. try
  13885. {
  13886. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  13887. string postfix = ".docx";
  13888. if (dto.IsPDF == 1)
  13889. {
  13890. saveFormat = Aspose.Words.SaveFormat.Pdf;
  13891. postfix = ".pdf";
  13892. }
  13893. doc.Save(path + postfix, saveFormat);
  13894. jw = JsonView(true, "导出成功", ftpPath + postfix);
  13895. }
  13896. catch (Exception)
  13897. {
  13898. jw = JsonView(false);
  13899. }
  13900. return Ok(jw);
  13901. }
  13902. /// <summary>
  13903. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  13904. /// </summary>
  13905. /// <param name="num"></param>
  13906. /// <returns></returns>
  13907. string GetNum(string num)
  13908. {
  13909. string str = "";
  13910. switch (num)
  13911. {
  13912. case "1":
  13913. str = "一";
  13914. break;
  13915. case "2":
  13916. str = "二";
  13917. break;
  13918. case "3":
  13919. str = "三";
  13920. break;
  13921. case "4":
  13922. str = "四";
  13923. break;
  13924. case "5":
  13925. str = "五";
  13926. break;
  13927. case "6":
  13928. str = "六";
  13929. break;
  13930. case "7":
  13931. str = "七";
  13932. break;
  13933. case "8":
  13934. str = "八";
  13935. break;
  13936. case "9":
  13937. str = "九";
  13938. break;
  13939. case "10":
  13940. str = "十";
  13941. break;
  13942. case "11":
  13943. str = "十一";
  13944. break;
  13945. case "12":
  13946. str = "十二";
  13947. break;
  13948. case "一":
  13949. str = "1";
  13950. break;
  13951. case "二":
  13952. str = "2";
  13953. break;
  13954. case "三":
  13955. str = "3";
  13956. break;
  13957. case "四":
  13958. str = "4";
  13959. break;
  13960. case "五":
  13961. str = "5";
  13962. break;
  13963. case "六":
  13964. str = "6";
  13965. break;
  13966. case "七":
  13967. str = "7";
  13968. break;
  13969. case "八":
  13970. str = "8";
  13971. break;
  13972. case "九":
  13973. str = "9";
  13974. break;
  13975. case "十":
  13976. str = "10";
  13977. break;
  13978. case "十一":
  13979. str = "11";
  13980. break;
  13981. case "十二":
  13982. str = "12";
  13983. break;
  13984. }
  13985. return str;
  13986. }
  13987. // 高亮包含指定文字的部分
  13988. void HighlightText(Run run, string targetText, Color color)
  13989. {
  13990. string text = run.Text;
  13991. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  13992. if (startIndex >= 0)
  13993. {
  13994. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  13995. // 前部分
  13996. if (startIndex > 0)
  13997. {
  13998. Run beforeRun = (Run)run.Clone(true);
  13999. beforeRun.Text = text.Substring(0, startIndex);
  14000. parentParagraph.InsertBefore(beforeRun, run);
  14001. }
  14002. // 匹配部分
  14003. Run matchRun = (Run)run.Clone(true);
  14004. matchRun.Text = text.Substring(startIndex, targetText.Length);
  14005. matchRun.Font.Color = color;
  14006. parentParagraph.InsertBefore(matchRun, run);
  14007. // 后部分
  14008. if (startIndex + targetText.Length < text.Length)
  14009. {
  14010. Run afterRun = (Run)run.Clone(true);
  14011. afterRun.Text = text.Substring(startIndex + targetText.Length);
  14012. parentParagraph.InsertBefore(afterRun, run);
  14013. }
  14014. // 删除原始Run
  14015. run.Remove();
  14016. }
  14017. }
  14018. #endregion
  14019. #endregion
  14020. #region 团组成本
  14021. /// <summary>
  14022. /// 团组成本数据初始化
  14023. /// </summary>
  14024. /// <param name="dto"></param>
  14025. /// <returns></returns>
  14026. [HttpPost]
  14027. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  14028. {
  14029. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  14030. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  14031. WHEN COUNT(*) >= 0 THEN 'True'
  14032. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  14033. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  14034. ").ToList(); //团组列表
  14035. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  14036. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  14037. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  14038. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  14039. if (groupinfoValue != null)
  14040. {
  14041. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  14042. var spArr = new string[1] { countryArr };
  14043. if (countryArr.Contains("|"))
  14044. {
  14045. spArr = countryArr.Split("|");
  14046. }
  14047. else if (countryArr.Contains("、"))
  14048. {
  14049. spArr = countryArr.Split("、");
  14050. }
  14051. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  14052. {
  14053. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  14054. if (dbQueryCountry != null)
  14055. {
  14056. visaCountryInfoArr.Add(dbQueryCountry);
  14057. }
  14058. }
  14059. }
  14060. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  14061. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  14062. #region 屏蔽黑屏代码生成
  14063. //var create = _GroupCostRepository.
  14064. // CreateGroupCostByBlackCode(dto.Diid);
  14065. //if (groupCost.Count == 0 && create.Code == 0)
  14066. //{
  14067. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  14068. //}
  14069. #endregion
  14070. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  14071. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  14072. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  14073. groupCostMap = groupCostMap.Select(x =>
  14074. {
  14075. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  14076. {
  14077. x.Date = dataForamt.ToString("yyyy-MM-dd");
  14078. }
  14079. return x;
  14080. }).ToList();
  14081. //GroupCostParameter.Add(new
  14082. // Grp_GroupCostParameter());
  14083. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  14084. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  14085. return Ok(JsonView(new
  14086. {
  14087. groupList,
  14088. groupInfo,
  14089. groupChecks,
  14090. groupCost = groupCostMap,
  14091. hotelNumber,
  14092. GroupCostParameter = GroupCostParameterMap,
  14093. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  14094. {
  14095. x.VisaCountry,
  14096. x.VisaPrice,
  14097. x.Id,
  14098. }).ToList(),
  14099. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  14100. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  14101. hotelIsTrue = hotelIsTrue,
  14102. }));
  14103. }
  14104. /// <summary>
  14105. /// 团组成本信息保存
  14106. /// </summary>
  14107. /// <param name="dto"></param>
  14108. /// <returns></returns>
  14109. [HttpPost]
  14110. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  14111. {
  14112. if (dto.Diid <= 0 || dto.Userid <= 0)
  14113. {
  14114. return Ok(JsonView(false));
  14115. }
  14116. JsonView jw = null;
  14117. bool isTrue = false;
  14118. #region 复制团组成本
  14119. //if (dto.Diid == 2581)
  14120. //{
  14121. // dto.Diid = 2599;
  14122. // dto.CheckBoxs.ForEach(x =>
  14123. // {
  14124. // x.Diid = 2599;
  14125. // });
  14126. // dto.GroupCosts.ForEach(x =>
  14127. // {
  14128. // x.Diid = 2599;
  14129. // });
  14130. // dto.CostTypeHotelNumbers.ForEach(x =>
  14131. // {
  14132. // x.Diid = 2599;
  14133. // });
  14134. // dto.GroupCostParameters.ForEach(x =>
  14135. // {
  14136. // x.DiId = 2599;
  14137. // });
  14138. //}
  14139. #endregion
  14140. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14141. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14142. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14143. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14144. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14145. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14146. try
  14147. {
  14148. _sqlSugar.BeginTran();
  14149. isTrue = await _GroupCostRepository.
  14150. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14151. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14152. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14153. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14154. _sqlSugar.CommitTran();
  14155. jw = JsonView(true, "保存成功!", isTrue);
  14156. }
  14157. catch (Exception)
  14158. {
  14159. _sqlSugar.RollbackTran();
  14160. jw = JsonView(false);
  14161. }
  14162. return Ok(jw);
  14163. }
  14164. /// <summary>
  14165. /// 复制团组成本信息
  14166. /// </summary>
  14167. /// <param name="dto"></param>
  14168. /// <returns></returns>
  14169. [HttpPost]
  14170. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  14171. {
  14172. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  14173. {
  14174. return Ok(JsonView(false, "参数有误!"));
  14175. }
  14176. #region 复制团组成本
  14177. dto.Diid = dto.ToGroupId;
  14178. dto.CheckBoxs.ForEach(x =>
  14179. {
  14180. x.Diid = dto.ToGroupId;
  14181. });
  14182. dto.GroupCosts.ForEach(x =>
  14183. {
  14184. x.Diid = dto.ToGroupId;
  14185. });
  14186. dto.CostTypeHotelNumbers.ForEach(x =>
  14187. {
  14188. x.Diid = dto.ToGroupId;
  14189. });
  14190. dto.GroupCostParameters.ForEach(x =>
  14191. {
  14192. x.DiId = dto.ToGroupId;
  14193. });
  14194. #endregion
  14195. JsonView jw = null;
  14196. bool isTrue = false;
  14197. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  14198. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  14199. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  14200. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  14201. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  14202. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  14203. try
  14204. {
  14205. _sqlSugar.BeginTran();
  14206. isTrue = await _GroupCostRepository.
  14207. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  14208. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  14209. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  14210. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  14211. _sqlSugar.CommitTran();
  14212. jw = JsonView(true, "保存成功!", isTrue);
  14213. }
  14214. catch (Exception)
  14215. {
  14216. _sqlSugar.RollbackTran();
  14217. jw = JsonView(false);
  14218. }
  14219. return Ok(jw);
  14220. }
  14221. /// <summary>
  14222. /// 司兼导数据
  14223. /// </summary>
  14224. /// <param name="dto"></param>
  14225. /// <returns></returns>
  14226. [HttpPost]
  14227. public IActionResult GetCarGuides(CarGuidesDto dto)
  14228. {
  14229. JsonView jw = null;
  14230. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  14231. jw = JsonView(true, "获取成功!", Data);
  14232. return Ok(jw);
  14233. }
  14234. /// <summary>
  14235. /// 导游数据
  14236. /// </summary>
  14237. /// <param name="dto"></param>
  14238. /// <returns></returns>
  14239. [HttpPost]
  14240. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  14241. {
  14242. JsonView jw = null;
  14243. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  14244. // 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
  14245. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  14246. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  14247. jw = JsonView(true, "获取成功!", Data);
  14248. return Ok(jw);
  14249. }
  14250. /// <summary>
  14251. /// 成本车数据
  14252. /// </summary>
  14253. /// <param name="dto"></param>
  14254. /// <returns></returns>
  14255. [HttpPost]
  14256. public IActionResult GetCarInfo(CarGuidesDto dto)
  14257. {
  14258. JsonView jw = null;
  14259. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  14260. jw = JsonView(true, "获取成功!", Data);
  14261. return Ok(jw);
  14262. }
  14263. /// <summary>
  14264. /// 景点数据
  14265. /// </summary>
  14266. /// <param name="dto"></param>
  14267. /// <returns></returns>
  14268. [HttpPost]
  14269. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  14270. {
  14271. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  14272. return Ok(JsonView(true, "获取成功!", Data));
  14273. }
  14274. /// <summary>
  14275. /// 成本通知
  14276. /// </summary>
  14277. /// <param name="dto"></param>
  14278. /// <returns></returns>
  14279. [HttpPost]
  14280. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  14281. {
  14282. if (dto.Diid < 0)
  14283. {
  14284. return Ok(JsonView(false));
  14285. }
  14286. JsonView jw = null;
  14287. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  14288. if (GroupCostParameter != null)
  14289. {
  14290. int IsShare = 0;
  14291. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  14292. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  14293. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  14294. string msg = string.Empty;
  14295. if (isTrue)
  14296. {
  14297. if (IsShare == 0)
  14298. {
  14299. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  14300. }
  14301. else
  14302. {
  14303. #region 企微通知对应岗位用户
  14304. try
  14305. {
  14306. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  14307. }
  14308. catch (Exception ex)
  14309. {
  14310. }
  14311. #endregion
  14312. msg = "通知成功,其他模块操作人员可见此成本信息!";
  14313. }
  14314. jw = JsonView(isTrue, msg, new { IsShare });
  14315. }
  14316. else
  14317. {
  14318. msg = "修改失败!";
  14319. jw = JsonView(isTrue, msg);
  14320. }
  14321. }
  14322. else
  14323. {
  14324. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  14325. }
  14326. return Ok(jw);
  14327. }
  14328. /// <summary>
  14329. /// 导出报价单
  14330. /// </summary>
  14331. /// <param name="dto"></param>
  14332. /// <returns></returns>
  14333. [HttpPost]
  14334. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  14335. {
  14336. if (dto.Diid == 0)
  14337. {
  14338. return Ok(JsonView(false, "请传递团组id"));
  14339. }
  14340. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14341. if (deleInfo.Code != 0)
  14342. {
  14343. return Ok(JsonView(false, "团组信息查询失败!"));
  14344. }
  14345. var di = deleInfo.Data as DelegationInfoWebView;
  14346. if (di != null)
  14347. {
  14348. di.TeamName = di.TeamName.Replace("|", "、");
  14349. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  14350. //文件名
  14351. string strFileName = di.TeamName + "-收款账单.doc";
  14352. //获取模板
  14353. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  14354. //载入模板
  14355. Document doc = new Document(tmppath);
  14356. decimal TotalPrice = 0.00M;
  14357. string itemStr = string.Empty;
  14358. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  14359. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14360. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  14361. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  14362. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  14363. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  14364. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  14365. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  14366. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  14367. foreach (var cost in groupCostType)
  14368. {
  14369. var List = cost.ToList();
  14370. if (cost.Key == "A")
  14371. {
  14372. foreach (var ListItem in List)
  14373. {
  14374. if (ListItem.number > 0)
  14375. {
  14376. if (ListItem.code.Contains("TBR"))
  14377. {
  14378. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14379. }
  14380. else
  14381. {
  14382. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14383. }
  14384. TotalPrice += (ListItem.number * ListItem.price);
  14385. }
  14386. }
  14387. }
  14388. else
  14389. {
  14390. itemStr = itemStr.Insert(0, "A段\r\n");
  14391. itemStr += "B段\r\n";
  14392. foreach (var ListItem in List)
  14393. {
  14394. if (ListItem.number > 0)
  14395. {
  14396. if (ListItem.code.Contains("TBR"))
  14397. {
  14398. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14399. }
  14400. else
  14401. {
  14402. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  14403. }
  14404. TotalPrice += (ListItem.number * ListItem.price);
  14405. }
  14406. }
  14407. }
  14408. }
  14409. #region 替换Word模板书签内容
  14410. Dictionary<string, string> marks = new Dictionary<string, string>();
  14411. marks.Add("To", di.ClientUnit);//付款方
  14412. marks.Add("ToTel", di.TellPhone);//付款方电话
  14413. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  14414. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  14415. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  14416. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  14417. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  14418. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  14419. marks.Add("PayItemContent", itemStr);//详细信息
  14420. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  14421. #endregion
  14422. ////注
  14423. //if (doc.Range.Bookmarks["Attention"] != null)
  14424. //{
  14425. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  14426. // mark.Text = frList[0].Attention;
  14427. //}
  14428. foreach (var item in marks.Keys)
  14429. {
  14430. if (doc.Range.Bookmarks[item] != null)
  14431. {
  14432. Bookmark mark = doc.Range.Bookmarks[item];
  14433. mark.Text = marks[item];
  14434. }
  14435. }
  14436. byte[] bytes = null;
  14437. using (MemoryStream stream = new MemoryStream())
  14438. {
  14439. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  14440. bytes = stream.ToArray();
  14441. }
  14442. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  14443. return Ok(JsonView(true, "", new
  14444. {
  14445. Data = bytes,
  14446. strFileName,
  14447. }));
  14448. }
  14449. else
  14450. {
  14451. return Ok(JsonView(false, "团组信息不存在!"));
  14452. }
  14453. }
  14454. /// <summary>
  14455. /// 导出团组成本
  14456. /// </summary>
  14457. /// <param name="dto"></param>
  14458. /// <returns></returns>
  14459. [HttpPost]
  14460. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  14461. {
  14462. var jw = JsonView(false);
  14463. if (dto.Diid == 0)
  14464. {
  14465. return Ok(JsonView(false, "请传递团组id"));
  14466. }
  14467. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  14468. if (deleInfo.Code != 0)
  14469. {
  14470. return Ok(JsonView(false, "团组信息查询失败!"));
  14471. }
  14472. var di = deleInfo.Data as DelegationInfoWebView;
  14473. if (di == null)
  14474. {
  14475. return Ok(JsonView(false, "团组信息查询失败!"));
  14476. }
  14477. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  14478. WorkbookDesigner designer = new WorkbookDesigner();
  14479. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  14480. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  14481. for (int i = 0; i < List_GC.Count; i++)
  14482. {
  14483. GroupCost_Excel gc = new GroupCost_Excel();
  14484. gc.Id = List_GC[i].Id;
  14485. gc.Diid = List_GC[i].Diid.ToString();
  14486. gc.DAY = List_GC[i].DAY;
  14487. string week = "";
  14488. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  14489. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  14490. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  14491. gc.ITIN = List_GC[i].ITIN;
  14492. gc.CarType = List_GC[i].CarType;
  14493. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  14494. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  14495. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  14496. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  14497. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  14498. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  14499. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  14500. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  14501. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  14502. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  14503. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  14504. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  14505. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14506. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  14507. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  14508. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  14509. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  14510. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  14511. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  14512. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  14513. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  14514. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  14515. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  14516. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  14517. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  14518. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  14519. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  14520. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  14521. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  14522. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  14523. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  14524. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  14525. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  14526. List_GC1.Add(gc);
  14527. }
  14528. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  14529. dt.TableName = "TB";
  14530. //报表标题等不用dt的值
  14531. designer.SetDataSource("TeamName", dto.title.TeamName);
  14532. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  14533. designer.SetDataSource("Tax", dto.title.Tax);
  14534. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  14535. designer.SetDataSource("Currency", dto.title.Currency);
  14536. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  14537. designer.SetDataSource("Rate", dto.title.Rate);
  14538. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  14539. var Aparams = hotels.Find(x => x.Type == "Default");
  14540. if (Aparams == null)
  14541. {
  14542. return Ok(jw);
  14543. }
  14544. //酒店数量
  14545. var txtSGRNumber = Aparams.SGR.ToString();
  14546. var txtTBRNumber = Aparams.TBR.ToString();
  14547. var txtJSESNumber = Aparams.JSES.ToString();
  14548. var txtSUITENumbe = Aparams.SUITE.ToString();
  14549. if (dto.costType == "B")
  14550. {
  14551. Aparams = hotels.Find(x => x.Type == "A");
  14552. var Bparams = hotels.Find(x => x.Type == "B");
  14553. if (Aparams == null || Bparams == null)
  14554. {
  14555. return Ok(jw);
  14556. }
  14557. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  14558. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  14559. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  14560. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  14561. }
  14562. designer.SetDataSource("SGRNumber", txtSGRNumber);
  14563. designer.SetDataSource("TBRNumber", txtTBRNumber);
  14564. designer.SetDataSource("JSESNumber", txtJSESNumber);
  14565. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  14566. var ws = designer.Workbook.Worksheets[0];
  14567. int Row = List_GC.Count;
  14568. int startIndex = 11;
  14569. int HideRows = 0;
  14570. List<int> hideRowsList = new List<int>();
  14571. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  14572. #region A段left数据
  14573. var left = dto.leftInfo.Find(x => x.Type == "A");
  14574. if (left == null)
  14575. {
  14576. return Ok(jw);
  14577. }
  14578. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  14579. if (leftBindData != null)
  14580. {
  14581. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  14582. designer.SetDataSource("VisaRS", leftBindData.rs);
  14583. designer.SetDataSource("VisaXS", leftBindData.xs);
  14584. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14585. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14586. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14587. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14588. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14589. }
  14590. else
  14591. {
  14592. hideRowsList.Add(Row + startIndex + HideRows);
  14593. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14594. }
  14595. HideRows += 2;
  14596. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  14597. if (leftBindData != null)
  14598. {
  14599. designer.SetDataSource("BXDRCB", leftBindData.cb);
  14600. designer.SetDataSource("BXRS", leftBindData.rs);
  14601. designer.SetDataSource("BXXS", leftBindData.xs);
  14602. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14603. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14604. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14605. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14606. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14607. }
  14608. else
  14609. {
  14610. hideRowsList.Add(Row + startIndex + HideRows);
  14611. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14612. }
  14613. HideRows += 2;
  14614. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  14615. if (leftBindData != null)
  14616. {
  14617. designer.SetDataSource("HSDRCB", leftBindData.cb);
  14618. designer.SetDataSource("HSRS", leftBindData.rs);
  14619. designer.SetDataSource("HSXS", leftBindData.xs);
  14620. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14621. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14622. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14623. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14624. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14625. }
  14626. else
  14627. {
  14628. hideRowsList.Add(Row + startIndex + HideRows);
  14629. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14630. }
  14631. HideRows += 2;
  14632. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  14633. if (leftBindData != null)
  14634. {
  14635. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  14636. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  14637. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  14638. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14639. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14640. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14641. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14642. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14643. }
  14644. else
  14645. {
  14646. hideRowsList.Add(Row + startIndex + HideRows);
  14647. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14648. }
  14649. HideRows += 2;
  14650. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  14651. if (leftBindData != null)
  14652. {
  14653. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  14654. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  14655. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  14656. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14657. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14658. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14659. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14660. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14661. }
  14662. else
  14663. {
  14664. hideRowsList.Add(Row + startIndex + HideRows);
  14665. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14666. }
  14667. HideRows += 2;
  14668. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  14669. if (leftBindData != null)
  14670. {
  14671. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  14672. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  14673. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  14674. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14675. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14676. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14677. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14678. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14679. }
  14680. else
  14681. {
  14682. hideRowsList.Add(Row + startIndex + HideRows);
  14683. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14684. }
  14685. HideRows += 2;
  14686. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  14687. if (leftBindData != null)
  14688. {
  14689. ////TBR
  14690. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  14691. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  14692. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  14693. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14694. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14695. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14696. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14697. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14698. }
  14699. else
  14700. {
  14701. hideRowsList.Add(Row + startIndex + HideRows);
  14702. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14703. }
  14704. HideRows += 2;
  14705. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  14706. if (leftBindData != null)
  14707. {
  14708. ////SGR
  14709. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  14710. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  14711. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  14712. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14713. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14714. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14715. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14716. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14717. }
  14718. else
  14719. {
  14720. hideRowsList.Add(Row + startIndex + HideRows);
  14721. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14722. }
  14723. HideRows += 2;
  14724. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  14725. if (leftBindData != null)
  14726. {
  14727. ////JS/ES
  14728. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  14729. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  14730. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  14731. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14732. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14733. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14734. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14735. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14736. }
  14737. else
  14738. {
  14739. hideRowsList.Add(Row + startIndex + HideRows);
  14740. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14741. }
  14742. HideRows += 2;
  14743. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  14744. if (leftBindData != null)
  14745. {
  14746. ////SUITE
  14747. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  14748. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  14749. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  14750. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14751. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14752. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14753. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14754. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14755. }
  14756. else
  14757. {
  14758. hideRowsList.Add(Row + startIndex + HideRows);
  14759. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14760. }
  14761. HideRows += 2;
  14762. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  14763. if (leftBindData != null)
  14764. {
  14765. designer.SetDataSource("DJDRCB", leftBindData.cb);
  14766. designer.SetDataSource("DJRS", leftBindData.rs);
  14767. designer.SetDataSource("DJXS", leftBindData.xs);
  14768. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14769. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14770. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14771. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14772. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14773. }
  14774. else
  14775. {
  14776. hideRowsList.Add(Row + startIndex + HideRows);
  14777. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14778. }
  14779. HideRows += 2;
  14780. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  14781. if (leftBindData != null)
  14782. {
  14783. designer.SetDataSource("HCPCB", leftBindData.cb);
  14784. designer.SetDataSource("HCPRS", leftBindData.rs);
  14785. designer.SetDataSource("HCPXS", leftBindData.xs);
  14786. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14787. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14788. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14789. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14790. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14791. }
  14792. else
  14793. {
  14794. hideRowsList.Add(Row + startIndex + HideRows);
  14795. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14796. }
  14797. HideRows += 2;
  14798. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  14799. if (leftBindData != null)
  14800. {
  14801. designer.SetDataSource("CPCB", leftBindData.cb);
  14802. designer.SetDataSource("CPRS", leftBindData.rs);
  14803. designer.SetDataSource("CPXS", leftBindData.xs);
  14804. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14805. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14806. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14807. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14808. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14809. }
  14810. else
  14811. {
  14812. hideRowsList.Add(Row + startIndex + HideRows);
  14813. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14814. }
  14815. HideRows += 2;
  14816. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  14817. if (leftBindData != null)
  14818. {
  14819. designer.SetDataSource("GWDRCD", leftBindData.cb);
  14820. designer.SetDataSource("GWRS", leftBindData.rs);
  14821. designer.SetDataSource("GWXS", leftBindData.xs);
  14822. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14823. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14824. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14825. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14826. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14827. }
  14828. else
  14829. {
  14830. hideRowsList.Add(Row + startIndex + HideRows);
  14831. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14832. }
  14833. HideRows += 2;
  14834. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  14835. if (leftBindData != null)
  14836. {
  14837. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  14838. designer.SetDataSource("LYJRS", leftBindData.rs);
  14839. designer.SetDataSource("LYJXS", leftBindData.xs);
  14840. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  14841. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  14842. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  14843. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  14844. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  14845. }
  14846. else
  14847. {
  14848. hideRowsList.Add(Row + startIndex + HideRows);
  14849. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  14850. }
  14851. #endregion
  14852. #region A段Right信息
  14853. var right = dto.rightInfo.Find(x => x.Type == "A");
  14854. if (right == null)
  14855. {
  14856. return Ok(jw);
  14857. }
  14858. HideRows += 4;
  14859. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  14860. if (rightBindData != null)
  14861. {
  14862. //经济舱 + 双人间 TBR
  14863. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  14864. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  14865. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14866. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  14867. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14868. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14869. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14870. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14871. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14872. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14873. }
  14874. else
  14875. {
  14876. hideRowsList.Add(Row + startIndex + HideRows);
  14877. }
  14878. HideRows += 2;
  14879. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  14880. if (rightBindData != null)
  14881. {
  14882. //经济舱 + 单人间 SGR
  14883. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  14884. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  14885. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14886. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  14887. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14888. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14889. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14890. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14891. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14892. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14893. }
  14894. else
  14895. {
  14896. hideRowsList.Add(Row + startIndex + HideRows);
  14897. }
  14898. HideRows += 2;
  14899. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  14900. if (rightBindData != null)
  14901. {
  14902. //公务舱 + 单人间 SGR
  14903. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  14904. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  14905. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14906. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  14907. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14908. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14909. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14910. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14911. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14912. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14913. }
  14914. else
  14915. {
  14916. hideRowsList.Add(Row + startIndex + HideRows);
  14917. }
  14918. HideRows += 2;
  14919. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  14920. if (rightBindData != null)
  14921. {
  14922. //公务舱 + 小套房 JSES
  14923. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  14924. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  14925. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14926. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  14927. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14928. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14929. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14930. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14931. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14932. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14933. }
  14934. else
  14935. {
  14936. hideRowsList.Add(Row + startIndex + HideRows);
  14937. }
  14938. HideRows += 2;
  14939. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  14940. if (rightBindData != null)
  14941. {
  14942. //公务舱 + 小套房 JSES
  14943. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  14944. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  14945. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14946. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  14947. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14948. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14949. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14950. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14951. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14952. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14953. }
  14954. else
  14955. {
  14956. hideRowsList.Add(Row + startIndex + HideRows);
  14957. }
  14958. HideRows += 2;
  14959. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  14960. if (rightBindData != null)
  14961. {
  14962. //经济舱 + 大套房
  14963. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  14964. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  14965. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14966. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  14967. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14968. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14969. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14970. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14971. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14972. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14973. }
  14974. else
  14975. {
  14976. hideRowsList.Add(Row + startIndex + HideRows);
  14977. }
  14978. HideRows += 2;
  14979. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  14980. if (rightBindData != null)
  14981. {
  14982. //头等舱 + 小套房 JSES
  14983. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  14984. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  14985. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  14986. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  14987. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  14988. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  14989. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  14990. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  14991. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  14992. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  14993. }
  14994. else
  14995. {
  14996. hideRowsList.Add(Row + startIndex + HideRows);
  14997. }
  14998. HideRows += 2;
  14999. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15000. if (rightBindData != null)
  15001. {
  15002. //头等舱 + 大套房
  15003. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  15004. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  15005. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15006. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  15007. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15008. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15009. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15010. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15011. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15012. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15013. }
  15014. else
  15015. {
  15016. hideRowsList.Add(Row + startIndex + HideRows);
  15017. }
  15018. #endregion
  15019. #region B段标题清空
  15020. designer.SetDataSource("CostBDRCB", "");
  15021. designer.SetDataSource("CostBRS", "");
  15022. designer.SetDataSource("CostBXS", "");
  15023. designer.SetDataSource("CostBZCB", "");
  15024. designer.SetDataSource("CostBDRBJ", "");
  15025. designer.SetDataSource("CostBZBJ", "");
  15026. designer.SetDataSource("CostBDRLR", "");
  15027. designer.SetDataSource("CostBZLR", "");
  15028. designer.SetDataSource("CostBDRCBOM", "");
  15029. designer.SetDataSource("CostBRSOM", "");
  15030. designer.SetDataSource("CostBZCBOM", "");
  15031. designer.SetDataSource("CostBDRBJOM", "");
  15032. designer.SetDataSource("CostBZBJOM", "");
  15033. designer.SetDataSource("CostBDRLROM", "");
  15034. designer.SetDataSource("CostBZLROM", "");
  15035. #endregion
  15036. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  15037. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  15038. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  15039. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  15040. designer.SetDataSource("DJName", "地接(CNY)");
  15041. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  15042. designer.SetDataSource("CPName", "地接-船票(CNY)");
  15043. designer.SetDataSource("GWName", "公务(CNY)");
  15044. designer.SetDataSource("YQHName", "邀请函(CNY)");
  15045. designer.SetDataSource("LYJName", "零用金(CNY)");
  15046. designer.SetDataSource("HSName", "核酸检测(CNY)");
  15047. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  15048. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  15049. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  15050. designer.SetDataSource("BXName", "保险(CNY)");
  15051. designer.SetDataSource("VisaName", "签证(CNY)");
  15052. #region B段基本数据
  15053. if (dto.costType == "B")
  15054. {
  15055. left = dto.leftInfo.Find(x => x.Type == "B");
  15056. if (left == null)
  15057. {
  15058. return Ok(jw);
  15059. }
  15060. #region B段left数据
  15061. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  15062. if (leftBindData != null)
  15063. {
  15064. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  15065. designer.SetDataSource("BHSRS", leftBindData.rs);
  15066. designer.SetDataSource("BHSXS", leftBindData.xs);
  15067. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15068. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15069. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15070. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15071. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15072. }
  15073. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  15074. if (leftBindData != null)
  15075. {
  15076. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  15077. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  15078. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  15079. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15080. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15081. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15082. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15083. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15084. }
  15085. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  15086. if (leftBindData != null)
  15087. {
  15088. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  15089. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  15090. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  15091. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15092. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15093. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15094. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15095. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15096. }
  15097. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  15098. if (leftBindData != null)
  15099. {
  15100. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  15101. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  15102. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  15103. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15104. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15105. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15106. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15107. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15108. }
  15109. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  15110. if (leftBindData != null)
  15111. {
  15112. designer.SetDataSource("BHCPCB", leftBindData.cb);
  15113. designer.SetDataSource("BHCPRS", leftBindData.rs);
  15114. designer.SetDataSource("BHCPXS", leftBindData.xs);
  15115. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15116. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15117. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15118. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15119. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15120. }
  15121. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  15122. if (leftBindData != null)
  15123. {
  15124. designer.SetDataSource("BCPCB", leftBindData.cb);
  15125. designer.SetDataSource("BCPRS", leftBindData.rs);
  15126. designer.SetDataSource("BCPXS", leftBindData.xs);
  15127. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15128. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15129. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15130. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15131. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15132. }
  15133. //TBR
  15134. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  15135. if (leftBindData != null)
  15136. {
  15137. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  15138. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  15139. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  15140. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15141. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15142. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15143. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15144. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15145. }
  15146. //SGR
  15147. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  15148. if (leftBindData != null)
  15149. {
  15150. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  15151. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  15152. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  15153. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15154. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15155. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15156. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15157. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15158. }
  15159. //JS/ES
  15160. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  15161. if (leftBindData != null)
  15162. {
  15163. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  15164. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  15165. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  15166. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15167. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15168. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15169. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15170. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15171. }
  15172. //SUITE
  15173. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  15174. if (leftBindData != null)
  15175. {
  15176. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  15177. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  15178. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  15179. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15180. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15181. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15182. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15183. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15184. }
  15185. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  15186. if (leftBindData != null)
  15187. {
  15188. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  15189. designer.SetDataSource("BDJRS", leftBindData.rs);
  15190. designer.SetDataSource("BDJXS", leftBindData.xs);
  15191. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15192. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15193. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15194. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15195. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15196. }
  15197. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  15198. if (leftBindData != null)
  15199. {
  15200. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  15201. designer.SetDataSource("BGWRS", leftBindData.rs);
  15202. designer.SetDataSource("BGWXS", leftBindData.xs);
  15203. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15204. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15205. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15206. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15207. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15208. }
  15209. #region 优化方案
  15210. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  15211. //excelBind.Add("零用金", new {
  15212. //cb="",
  15213. //rs="",
  15214. //xs ="",
  15215. //zcb = "",
  15216. //});
  15217. #endregion
  15218. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  15219. if (leftBindData != null)
  15220. {
  15221. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  15222. designer.SetDataSource("BLYJRS", leftBindData.rs);
  15223. designer.SetDataSource("BLYJXS", leftBindData.xs);
  15224. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  15225. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  15226. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  15227. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  15228. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  15229. }
  15230. #endregion
  15231. #region B段Right信息
  15232. right = dto.rightInfo.Find(x => x.Type == "B");
  15233. if (right == null)
  15234. {
  15235. return Ok(jw);
  15236. }
  15237. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  15238. if (rightBindData != null)
  15239. {
  15240. //经济舱 + 双人间 TBR
  15241. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  15242. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  15243. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15244. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  15245. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15246. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15247. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15248. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15249. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15250. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15251. }
  15252. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  15253. if (rightBindData != null)
  15254. {
  15255. //经济舱 + 单人间 SGR
  15256. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  15257. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  15258. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15259. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  15260. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15261. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15262. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15263. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15264. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15265. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15266. }
  15267. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  15268. if (rightBindData != null)
  15269. {
  15270. //公务舱 + 单人间 SGR
  15271. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  15272. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  15273. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15274. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  15275. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15276. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15277. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15278. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15279. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15280. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15281. }
  15282. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  15283. if (rightBindData != null)
  15284. {
  15285. //公务舱 + 小套房 JSES
  15286. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  15287. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  15288. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15289. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  15290. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15291. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15292. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15293. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15294. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15295. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15296. }
  15297. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  15298. if (rightBindData != null)
  15299. {
  15300. //公务舱 + 小套房 JSES
  15301. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  15302. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  15303. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15304. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  15305. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15306. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15307. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15308. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15309. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15310. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15311. }
  15312. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  15313. if (rightBindData != null)
  15314. {
  15315. //经济舱 + 大套房
  15316. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  15317. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  15318. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15319. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  15320. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15321. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15322. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15323. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15324. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15325. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15326. }
  15327. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  15328. if (rightBindData != null)
  15329. {
  15330. //头等舱 + 小套房 JSES
  15331. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  15332. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  15333. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15334. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  15335. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15336. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15337. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15338. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15339. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15340. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15341. }
  15342. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  15343. if (rightBindData != null)
  15344. {
  15345. //头等舱 + 大套房
  15346. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  15347. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  15348. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  15349. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  15350. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  15351. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  15352. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  15353. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  15354. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  15355. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  15356. }
  15357. #endregion
  15358. #region 标题
  15359. designer.SetDataSource("CostBDRCB", "单人成本");
  15360. designer.SetDataSource("CostBRS", "人数");
  15361. designer.SetDataSource("CostBXS", "系数");
  15362. designer.SetDataSource("CostBZCB", "总成本");
  15363. designer.SetDataSource("CostBDRBJ", "单人报价");
  15364. designer.SetDataSource("CostBZBJ", "总报价");
  15365. designer.SetDataSource("CostBDRLR", "单人利润");
  15366. designer.SetDataSource("CostBZLR", "总利润");
  15367. designer.SetDataSource("CostBDRCBOM", "单人成本");
  15368. designer.SetDataSource("CostBRSOM", "人数");
  15369. designer.SetDataSource("CostBZCBOM", "总成本");
  15370. designer.SetDataSource("CostBDRBJOM", "单人报价");
  15371. designer.SetDataSource("CostBZBJOM", "总报价");
  15372. designer.SetDataSource("CostBDRLROM", "单人利润");
  15373. designer.SetDataSource("CostBZLROM", "总利润");
  15374. #endregion
  15375. }
  15376. #endregion
  15377. designer.SetDataSource("TzZCB2", TzZCB2);
  15378. designer.SetDataSource("TzZBJ2", TzZBJ2);
  15379. designer.SetDataSource("TzZLR2", TzZLR2);
  15380. string[] dataSourceKeys = new string[]
  15381. {
  15382. "VF",
  15383. "TGS",
  15384. "TGOF",
  15385. "TGM",
  15386. "TGA",
  15387. "TGTF",
  15388. "TGEF",
  15389. "CFM",
  15390. "CFOF",
  15391. "B",
  15392. "L",
  15393. "D",
  15394. "TBR",
  15395. "SGR",
  15396. "JSES",
  15397. "Suite",
  15398. "TV",
  15399. "1L",
  15400. "IF",
  15401. "EF",
  15402. "BRF",
  15403. "TE",
  15404. "TGT",
  15405. "DRVT",
  15406. "PC",
  15407. "TLF",
  15408. "ECT"
  15409. };
  15410. foreach (var item in dataSourceKeys)
  15411. {
  15412. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  15413. if (find != null)
  15414. {
  15415. designer.SetDataSource(item, find.text);
  15416. }
  15417. else
  15418. {
  15419. designer.SetDataSource(item, 0);
  15420. }
  15421. }
  15422. designer.SetDataSource(dt);
  15423. //根据数据源处理生成报表内容
  15424. designer.Process();
  15425. designer.Workbook.Worksheets[0].Name = "清单";
  15426. Worksheet sheet = designer.Workbook.Worksheets[0];
  15427. foreach (var Rowindex in hideRowsList)
  15428. {
  15429. ws.Cells.HideRows(Rowindex, 2);
  15430. }
  15431. byte[] bytes = null;
  15432. string strFileName = di.TeamName + "-团组-成本.xls";
  15433. using (MemoryStream stream = new MemoryStream())
  15434. {
  15435. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  15436. bytes = stream.ToArray();
  15437. }
  15438. return Ok(JsonView(true, "", new
  15439. {
  15440. Data = bytes,
  15441. strFileName,
  15442. }));
  15443. }
  15444. /// <summary>
  15445. /// 导出客户报表
  15446. /// </summary>
  15447. /// <returns></returns>
  15448. [HttpPost]
  15449. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  15450. {
  15451. var jw = JsonView(false);
  15452. if (dto.Diid == 0)
  15453. {
  15454. return Ok(JsonView(false, "请传递团组id"));
  15455. }
  15456. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15457. if (deleInfo.Code != 0)
  15458. {
  15459. return Ok(JsonView(false, "团组信息查询失败!"));
  15460. }
  15461. var di = deleInfo.Data as DelegationInfoWebView;
  15462. if (di == null)
  15463. {
  15464. return Ok(JsonView(false, "团组信息查询失败!"));
  15465. }
  15466. //文件名
  15467. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  15468. //获取模板
  15469. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  15470. //载入模板
  15471. Document doc = new Document(tmppath);
  15472. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  15473. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  15474. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  15475. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  15476. var AParameter = ParameterList.Find(x => x.CostType == "A");
  15477. var BParameter = ParameterList.Find(x => x.CostType == "B");
  15478. if (AParameter == null)
  15479. {
  15480. return Ok(JsonView(false, "系数不存在!"));
  15481. }
  15482. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  15483. , TzAirDesc, TzZCost;
  15484. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  15485. = TzAirDesc = TzZCost = string.Empty;
  15486. TzNumber = AParameter.CostTypenumber.ToString();
  15487. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  15488. CarGuides1 = dto.CarGuides1;
  15489. Meal = dto.Meal;
  15490. SubsidizedMeals = dto.SubsidizedMeals;
  15491. NightRepair = dto.NightRepair;
  15492. AttractionsTickets = dto.AttractionsTickets;
  15493. MiscellaneousFees = dto.MiscellaneousFees;
  15494. ATip = dto.ATip;
  15495. TzHotelDesc = "";
  15496. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  15497. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  15498. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  15499. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  15500. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  15501. TzAirDesc = "";
  15502. TzZCost = dto.TzZCost;
  15503. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  15504. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  15505. var index = 1;
  15506. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  15507. foreach (var item in TzHotelDescArr)
  15508. {
  15509. if (AinfoArr != null)
  15510. {
  15511. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15512. if (Ainfo != null)
  15513. {
  15514. if (int.Parse(Ainfo.rs) <= 0)
  15515. {
  15516. continue;
  15517. }
  15518. var hotelText = string.Empty;
  15519. switch (item)
  15520. {
  15521. case "SGR":
  15522. hotelText = "单人间";
  15523. break;
  15524. case "JSES":
  15525. hotelText = "小套房";
  15526. break;
  15527. case "SUITE":
  15528. hotelText = "套房";
  15529. break;
  15530. case "TBR":
  15531. hotelText = "双人间";
  15532. break;
  15533. }
  15534. if (item != "TBR")
  15535. {
  15536. 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";
  15537. }
  15538. else
  15539. {
  15540. 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";
  15541. }
  15542. index++;
  15543. }
  15544. }
  15545. }
  15546. index = 1;
  15547. foreach (var item in TzAirDescArr)
  15548. {
  15549. if (AinfoArr != null)
  15550. {
  15551. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15552. if (Ainfo != null)
  15553. {
  15554. if (int.Parse(Ainfo.rs) <= 0)
  15555. {
  15556. continue;
  15557. }
  15558. 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";
  15559. index++;
  15560. }
  15561. }
  15562. }
  15563. if (dto.costType == "B")
  15564. {
  15565. if (BParameter == null)
  15566. {
  15567. return Ok(JsonView(false, "B段系数不存在!"));
  15568. }
  15569. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  15570. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  15571. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  15572. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  15573. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  15574. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  15575. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  15576. foreach (var item in TzHotelDescArr)
  15577. {
  15578. if (AinfoArr != null)
  15579. {
  15580. TzHotelDesc += "B段信息 \r\n";
  15581. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15582. if (Ainfo != null)
  15583. {
  15584. if (int.Parse(Ainfo.rs) <= 0)
  15585. {
  15586. continue;
  15587. }
  15588. var hotelText = string.Empty;
  15589. switch (item)
  15590. {
  15591. case "SGR":
  15592. hotelText = "单人间";
  15593. break;
  15594. case "JSES":
  15595. hotelText = "小套房";
  15596. break;
  15597. case "SUITE":
  15598. hotelText = "套房";
  15599. break;
  15600. case "TBR":
  15601. hotelText = "双人间";
  15602. break;
  15603. }
  15604. if (item != "TBR")
  15605. {
  15606. 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";
  15607. }
  15608. else
  15609. {
  15610. 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";
  15611. }
  15612. index++;
  15613. }
  15614. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  15615. }
  15616. }
  15617. index = 1;
  15618. foreach (var item in TzAirDescArr)
  15619. {
  15620. if (AinfoArr != null)
  15621. {
  15622. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  15623. if (Ainfo != null)
  15624. {
  15625. if (int.Parse(Ainfo.rs) <= 0)
  15626. {
  15627. continue;
  15628. }
  15629. 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";
  15630. index++;
  15631. }
  15632. }
  15633. }
  15634. }
  15635. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  15636. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  15637. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  15638. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  15639. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  15640. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  15641. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  15642. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  15643. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  15644. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  15645. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  15646. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  15647. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  15648. DickeyValue.Add("Visa", Visa); // 签证单人报价
  15649. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  15650. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  15651. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  15652. DickeyValue.Add("TzZCost", TzZCost);
  15653. foreach (var key in DickeyValue.Keys)
  15654. {
  15655. if (doc.Range.Bookmarks[key] != null)
  15656. {
  15657. Bookmark mark = doc.Range.Bookmarks[key];
  15658. mark.Text = DickeyValue[key];
  15659. }
  15660. }
  15661. byte[] bytes = null;
  15662. string strFileName = di.TeamName + "-客户报价.doc";
  15663. using (MemoryStream stream = new MemoryStream())
  15664. {
  15665. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15666. bytes = stream.ToArray();
  15667. }
  15668. return Ok(JsonView(true, "", new
  15669. {
  15670. Data = bytes,
  15671. strFileName,
  15672. }));
  15673. }
  15674. /// <summary>
  15675. /// 团组成本 各模块(酒店,地接,机票)成本提示
  15676. /// </summary>
  15677. /// <param name="dto"></param>
  15678. /// <returns></returns>
  15679. [HttpPost]
  15680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15681. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  15682. {
  15683. try
  15684. {
  15685. #region 参数验证
  15686. if (dto.DiId < 0)
  15687. {
  15688. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  15689. }
  15690. List<int> cTableIds = new List<int>() {
  15691. 76 ,//酒店预订
  15692. 77 ,//行程
  15693. 79 ,//车/导游地接
  15694. 80 ,//签证
  15695. 81 ,//邀请/公务活
  15696. 82 ,//团组客户保险
  15697. 85 ,//机票预订
  15698. 98 ,//其他款项
  15699. 285 ,//收款退还
  15700. 751 ,//酒店早餐
  15701. 1015 // 超支费用
  15702. };
  15703. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  15704. {
  15705. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  15706. }
  15707. #endregion
  15708. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  15709. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  15710. if (_GroupCostParameters.Count <= 0)
  15711. {
  15712. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  15713. }
  15714. if (_GroupCostParameters[0].IsShare == 0)
  15715. {
  15716. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  15717. }
  15718. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15719. //处理date为空问题
  15720. if (_GroupCosts.Count > 0)
  15721. {
  15722. for (int i = 0; i < _GroupCosts.Count; i++)
  15723. {
  15724. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  15725. {
  15726. if (i > 0)
  15727. {
  15728. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  15729. }
  15730. }
  15731. }
  15732. }
  15733. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  15734. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  15735. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  15736. string currCode = "";
  15737. #region currCode 验证
  15738. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  15739. if (isInt)
  15740. {
  15741. var currData = currDatas.Find(it => it.Id == intCurrency);
  15742. if (currData != null)
  15743. {
  15744. currCode = currData.Name;
  15745. }
  15746. }
  15747. else
  15748. {
  15749. currCode = _GroupCostParameters[0].Currency.Trim();
  15750. }
  15751. #endregion
  15752. //op,酒店单段模式存储
  15753. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  15754. {
  15755. CurrencyCode = currCode,
  15756. Rate = _GroupCostParameters[0].Rate,
  15757. CostType = _GroupCostParameters[0].CostType,
  15758. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  15759. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  15760. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  15761. };
  15762. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  15763. if (_GroupCostParameters.Count == 2)
  15764. {
  15765. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  15766. }
  15767. foreach (var item in _GroupCostParameters)
  15768. {
  15769. decimal _rate = 1;
  15770. decimal _rate1 = item.Rate;
  15771. decimal _scale = 1;
  15772. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  15773. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  15774. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  15775. //if (userInfo != null)
  15776. //{
  15777. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  15778. // {
  15779. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  15780. // {
  15781. // _scale = 1.00M;
  15782. // }
  15783. // }
  15784. //}
  15785. #endregion
  15786. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  15787. {
  15788. CurrencyCode = currCode,
  15789. Rate = _rate1,
  15790. CostType = item.CostType,
  15791. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  15792. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  15793. CostTypeNumber = item.CostTypenumber
  15794. };
  15795. if (_GroupCostParameters.Count > 1)
  15796. {
  15797. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  15798. }
  15799. else
  15800. {
  15801. modulePromptInfo.CostTypeNumber = item.LYJRS;
  15802. }
  15803. if (dto.CTable == 79)//
  15804. {
  15805. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  15806. modulePromptInfo.TotalCost = item.DJCB;
  15807. }
  15808. List<string> costTypes = new List<string>() { "A", "B" };
  15809. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  15810. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  15811. if (_GroupCostsDuplicates.Count() == 1)
  15812. {
  15813. _GroupCostsTypeData = _GroupCosts;
  15814. }
  15815. else
  15816. {
  15817. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  15818. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  15819. }
  15820. /*
  15821. * 76 酒店预订
  15822. * 77 行程
  15823. * 79 车/导游地接
  15824. * 80 签证
  15825. * 81 邀请/公务活动
  15826. * 82 团组客户保险
  15827. * 85 机票预订
  15828. * 98 其他款项
  15829. * 285 收款退还
  15830. * 751 酒店早餐
  15831. * 1015 超支费用
  15832. */
  15833. switch (dto.CTable)
  15834. {
  15835. case 76: // 酒店预订
  15836. _ModuleSubPromptInfo.AddRange(
  15837. _GroupCostsTypeData.Select(it => new
  15838. {
  15839. it.DAY,
  15840. it.Date,
  15841. it.ACCON,
  15842. it.ITIN,
  15843. it.SGR,
  15844. it.TBR,
  15845. it.JS_ES,
  15846. it.Suite
  15847. })
  15848. );
  15849. break;
  15850. case 79: // 车/导游地接
  15851. _ModuleSubPromptInfo.AddRange(
  15852. _GroupCostsTypeData.Select(it => new
  15853. {
  15854. Date = it.Date, //日期
  15855. CarFee = it.CarCost * _rate * _scale, //车费用
  15856. CarType = it.CarType, //车型
  15857. DriverFee = it.CFS * _rate * _scale, //司机工资
  15858. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  15859. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  15860. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  15861. GuideFee = it.TGS * _rate * _scale, //导游费用
  15862. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  15863. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  15864. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  15865. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  15866. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  15867. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  15868. Breakfast = it.B * _rate * _scale, //早餐费
  15869. Lunch = it.L * _rate * _scale, //午餐费
  15870. Dinner = it.D * _rate * _scale, //晚餐费
  15871. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  15872. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  15873. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  15874. TicketFee = it.EF * _rate * _scale, //门票费
  15875. TicketRemark = it.EFR, //门票费描述
  15876. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  15877. TravelSupplies = it.TE * _rate * _scale, //出行物资
  15878. SpentCash = it.PC * _rate * _scale, //零用金
  15879. LeadersFee = it.TLF * _rate * _scale, //领队费
  15880. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  15881. })
  15882. );
  15883. break;
  15884. case 85: // 机票
  15885. List<dynamic> datas = new List<dynamic>();
  15886. datas.Add(
  15887. new
  15888. {
  15889. AirType = "经济舱",
  15890. AirNum = item.JJCRS,
  15891. AirDRCB = item.JJCCB,
  15892. AirZCB = (item.JJCRS * item.JJCCB)
  15893. }
  15894. );
  15895. datas.Add(
  15896. new
  15897. {
  15898. AirType = "公务舱",
  15899. AirNum = item.GWCRS,
  15900. AirDRCB = item.GWCCB,
  15901. AirZCB = (item.GWCRS * item.GWCCB)
  15902. }
  15903. );
  15904. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  15905. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  15906. modulePromptInfo.Data = new
  15907. {
  15908. airFeeData = datas,
  15909. airInitData = initDatas
  15910. };
  15911. _ModulePromptInfos.Add(modulePromptInfo);
  15912. break;
  15913. default:
  15914. break;
  15915. }
  15916. }
  15917. if (dto.CTable != 85)
  15918. {
  15919. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  15920. _ModulePromptInfos.Add(_ModulePromptInfo);
  15921. }
  15922. _view.ModulePromptInfos = _ModulePromptInfos;
  15923. return Ok(JsonView(true, "操作成功!", _view));
  15924. }
  15925. catch (Exception ex)
  15926. {
  15927. return Ok(JsonView(false, ex.Message));
  15928. }
  15929. }
  15930. /// <summary>
  15931. /// 根据黑屏代码重新生成行程
  15932. /// </summary>
  15933. /// <param name="dto"></param>
  15934. /// <returns></returns>
  15935. [HttpPost]
  15936. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  15937. {
  15938. var jw = JsonView(false, "Error");
  15939. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  15940. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  15941. .Select(x => new
  15942. {
  15943. x.Id,
  15944. x.Title
  15945. })
  15946. .ToList();
  15947. if (Create.Any())
  15948. {
  15949. jw.Msg = "获取成功!";
  15950. jw.Code = 200;
  15951. jw.Data = new
  15952. {
  15953. BlackCodeListSelect = Create,
  15954. blackCodeIsTrue = true
  15955. };
  15956. }
  15957. else
  15958. {
  15959. jw.Code = 400;
  15960. jw.Data = new
  15961. {
  15962. BlackCodeListSelect = Create,
  15963. blackCodeIsTrue = false,
  15964. };
  15965. }
  15966. return Ok(jw);
  15967. }
  15968. /// <summary>
  15969. /// 根据黑屏代码Id重新生成行程
  15970. /// </summary>
  15971. /// <param name="dto"></param>
  15972. /// <returns></returns>
  15973. [HttpPost]
  15974. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  15975. {
  15976. var jw = JsonView(false, "Error");
  15977. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  15978. if (result.Code == 0)
  15979. {
  15980. jw.Msg = "获取成功!";
  15981. jw.Code = 200;
  15982. jw.Data = new
  15983. {
  15984. groupCost = result.Data,
  15985. blackCodeIsTrue = true
  15986. };
  15987. }
  15988. else
  15989. {
  15990. jw.Code = 400;
  15991. jw.Data = new
  15992. {
  15993. groupCost = result.Data,
  15994. blackCodeIsTrue = false,
  15995. };
  15996. }
  15997. return Ok(jw);
  15998. }
  15999. /// <summary>
  16000. /// 成本获取OP历史车费用
  16001. /// </summary>
  16002. /// <param name="dto"></param>
  16003. /// <returns></returns>
  16004. [HttpPost]
  16005. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  16006. {
  16007. var jw = JsonView(false);
  16008. try
  16009. {
  16010. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  16011. //获取现有所有车的数据
  16012. if (!dto.Param.IsNullOrWhiteSpace())
  16013. {
  16014. string sql = $@"
  16015. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  16016. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  16017. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  16018. 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
  16019. AND gctggr.ServiceEndTime is not NULL
  16020. ORDER by gctggrc.id DESC
  16021. ";
  16022. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  16023. var numeberResult = await Task.Run(() =>
  16024. {
  16025. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  16026. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  16027. return numberArr;
  16028. });
  16029. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  16030. foreach (var item in numeberResult)
  16031. {
  16032. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  16033. {
  16034. Country = "数据异常!",
  16035. City = string.Empty,
  16036. };
  16037. item.Area = find.Country + " " + find.City;
  16038. }
  16039. dbResult.AddRange(numeberResult);
  16040. if (dto.Param.Contains("、"))
  16041. {
  16042. var sp = dto.Param.Split("、");
  16043. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16044. .Where(x =>
  16045. {
  16046. return System.Array.Exists(sp, e =>
  16047. {
  16048. bool where = false;
  16049. if (x.Area != null)
  16050. {
  16051. where = x.Area.Contains(e);
  16052. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16053. {
  16054. return false;
  16055. }
  16056. }
  16057. if (x.PriceName != null && !where)
  16058. {
  16059. where = x.PriceName.Contains(e);
  16060. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16061. {
  16062. return false;
  16063. }
  16064. }
  16065. return where;
  16066. });
  16067. }).ToList();
  16068. }
  16069. else
  16070. {
  16071. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  16072. .Where(x =>
  16073. {
  16074. bool where = false;
  16075. if (x.Area != null)
  16076. {
  16077. where = x.Area.Contains(dto.Param);
  16078. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  16079. {
  16080. return false;
  16081. }
  16082. }
  16083. if (x.PriceName != null && !where)
  16084. {
  16085. where = x.PriceName.Contains(dto.Param);
  16086. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  16087. {
  16088. return false;
  16089. }
  16090. }
  16091. return where;
  16092. }
  16093. )
  16094. .ToList();
  16095. }
  16096. }
  16097. var view = dbResult.Select(x =>
  16098. {
  16099. decimal dp = 0.00M;
  16100. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  16101. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  16102. if (string.IsNullOrWhiteSpace(x.DatePrice))
  16103. {
  16104. if (startB && endB)
  16105. {
  16106. var timesp = endD.Subtract(startD);
  16107. if ((timesp.Days + 1) != 0)
  16108. {
  16109. dp = x.Price / (timesp.Days + 1);
  16110. }
  16111. }
  16112. }
  16113. else
  16114. {
  16115. dp = x.Price;
  16116. }
  16117. return new
  16118. {
  16119. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  16120. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  16121. x.Area,
  16122. x.id,
  16123. price = x.Price.ToString("F2"),
  16124. x.PriceName,
  16125. x.PriceContent,
  16126. x.TeamName,
  16127. x.DatePrice,
  16128. dayPrice = dp.ToString("F2"),
  16129. };
  16130. }).OrderByDescending(x => x.id).ToList();
  16131. jw = JsonView(true, "获取成功!", view);
  16132. }
  16133. catch (Exception e)
  16134. {
  16135. jw = JsonView(false, e.Message);
  16136. }
  16137. return Ok(jw);
  16138. }
  16139. [HttpPost]
  16140. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  16141. {
  16142. var jw = JsonView(true);
  16143. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  16144. if (string.IsNullOrWhiteSpace(dto.Keyword))
  16145. {
  16146. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16147. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16148. WHEN COUNT(*) >= 0 THEN 'True'
  16149. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16150. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  16151. ")
  16152. .ToList();
  16153. }
  16154. else
  16155. {
  16156. string likeKey = string.Empty;
  16157. foreach (var item in dto.Keyword)
  16158. {
  16159. likeKey += "%" + item;
  16160. }
  16161. likeKey += "%";
  16162. matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  16163. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  16164. WHEN COUNT(*) >= 0 THEN 'True'
  16165. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  16166. Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  16167. ")
  16168. .ToList();
  16169. }
  16170. if (matches.Any())
  16171. {
  16172. jw.Data = matches;
  16173. }
  16174. else
  16175. {
  16176. jw.Code = 201;
  16177. jw.Msg = "empty list";
  16178. jw.Data = new List<string>(1);
  16179. }
  16180. return Ok(jw);
  16181. }
  16182. /// <summary>
  16183. /// 报价Word下载
  16184. /// </summary>
  16185. /// <param name="dto"></param>
  16186. /// <returns></returns>
  16187. [HttpPost]
  16188. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  16189. {
  16190. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16191. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16192. if (di == null)
  16193. {
  16194. return Ok(JsonView(false, "团组不存在!"));
  16195. }
  16196. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16197. if (mainPrice == null || mainPrice.IsShare == 0)
  16198. {
  16199. return Ok(JsonView(false, "团组成本不存在!"));
  16200. }
  16201. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16202. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16203. if (costTypeHotelNumbers == null)
  16204. {
  16205. return Ok(JsonView(false, "团组成本不存在!"));
  16206. }
  16207. //文件名
  16208. string strFileName = di.TeamName + "-收款账单.doc";
  16209. //获取模板
  16210. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  16211. //载入模板
  16212. Document doc = new Document(tmppath);
  16213. decimal allPrice = 0.00M;
  16214. string itemStr = string.Empty;
  16215. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  16216. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  16217. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  16218. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  16219. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  16220. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  16221. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  16222. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  16223. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  16224. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  16225. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16226. {
  16227. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16228. ("BXRS", "BXCB", "BXXS", "bx"),
  16229. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16230. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16231. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  16232. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  16233. ("CPRS", "CPCB", "CPXS", "cp"),
  16234. ("HSRS", "HSCB", "HSXS", "hsjc"),
  16235. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  16236. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  16237. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  16238. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  16239. ("DJRS", "DJCB", "DJXS", "dj"),
  16240. ("GWRS", "GWCB", "GWXS", "gw"),
  16241. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  16242. };
  16243. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16244. var rightSum = 0.00M;
  16245. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16246. {
  16247. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16248. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16249. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16250. if (prefix == "tbr")
  16251. {
  16252. rsValue *= 2;
  16253. cbValue /= 2;
  16254. }
  16255. if (OtherCostPropertyBJ.Contains(prefix))
  16256. {
  16257. rightSum += cbValue * xsValue;
  16258. }
  16259. }
  16260. var hotelRooms = new Dictionary<string, int>
  16261. {
  16262. { "SGR", costTypeHotelNumbers.SGR },
  16263. { "TBR", costTypeHotelNumbers.TBR },
  16264. { "JSES", costTypeHotelNumbers.JSES },
  16265. { "SUITE", costTypeHotelNumbers.SUITE }
  16266. };
  16267. var flights = new Dictionary<string, int>
  16268. {
  16269. { "经济舱", mainPrice.JJCRS },
  16270. { "公务舱", mainPrice.GWCRS },
  16271. { "头等舱", mainPrice.TDCRS }
  16272. };
  16273. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16274. {
  16275. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16276. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16277. { "头等舱", new[] { "SUITE", "JSES" } }
  16278. };
  16279. var result = new Dictionary<string, int>();
  16280. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  16281. foreach (var flight in flights.Keys)
  16282. {
  16283. // 获取当前舱位的匹配规则
  16284. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16285. {
  16286. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16287. }
  16288. }
  16289. #region right计算
  16290. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16291. {
  16292. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16293. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16294. airHotelPriceList.Add(new
  16295. AirHotelPrice
  16296. {
  16297. Name = "经济舱TBR",
  16298. Price = rightSum + air + hotel,
  16299. Count = result["经济舱TBR"] * 2
  16300. });
  16301. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16302. }
  16303. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16304. {
  16305. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16306. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16307. airHotelPriceList.Add(new
  16308. AirHotelPrice
  16309. {
  16310. Name = "经济舱SGR",
  16311. Price = rightSum + air + hotel,
  16312. Count = result["经济舱SGR"]
  16313. });
  16314. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16315. }
  16316. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16317. {
  16318. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16319. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16320. airHotelPriceList.Add(new
  16321. AirHotelPrice
  16322. {
  16323. Name = "公务舱SGR",
  16324. Price = rightSum + air + hotel,
  16325. Count = result["公务舱SGR"]
  16326. });
  16327. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16328. }
  16329. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16330. {
  16331. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16332. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16333. airHotelPriceList.Add(new
  16334. AirHotelPrice
  16335. {
  16336. Name = "公务舱JSES",
  16337. Price = rightSum + air + hotel,
  16338. Count = result["公务舱JSES"]
  16339. });
  16340. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16341. }
  16342. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16343. {
  16344. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16345. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16346. airHotelPriceList.Add(new
  16347. AirHotelPrice
  16348. {
  16349. Name = "公务舱SUITE",
  16350. Price = rightSum + air + hotel,
  16351. Count = result["公务舱SUITE"]
  16352. });
  16353. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16354. }
  16355. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16356. {
  16357. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16358. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16359. airHotelPriceList.Add(new
  16360. AirHotelPrice
  16361. {
  16362. Name = "经济舱SUITE",
  16363. Price = rightSum + air + hotel,
  16364. Count = result["经济舱SUITE"]
  16365. });
  16366. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16367. }
  16368. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16369. {
  16370. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16371. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16372. airHotelPriceList.Add(new
  16373. AirHotelPrice
  16374. {
  16375. Name = "头等舱JSES",
  16376. Price = rightSum + air + hotel,
  16377. Count = result["头等舱JSES"]
  16378. });
  16379. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16380. }
  16381. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16382. {
  16383. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16384. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16385. airHotelPriceList.Add(new
  16386. AirHotelPrice
  16387. {
  16388. Name = "头等舱SUITE",
  16389. Price = rightSum + air + hotel,
  16390. Count = result["头等舱SUITE"]
  16391. });
  16392. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16393. }
  16394. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16395. {
  16396. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16397. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16398. airHotelPriceList.Add(new
  16399. AirHotelPrice
  16400. {
  16401. Name = "经济舱JSES",
  16402. Price = rightSum + air + hotel,
  16403. Count = result["经济舱JSES"]
  16404. });
  16405. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16406. }
  16407. #endregion
  16408. foreach (var item in airSouer.Keys)
  16409. {
  16410. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  16411. if (find != null && find.Count > 0)
  16412. {
  16413. if (item.Contains("TBR"))
  16414. {
  16415. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16416. }
  16417. else
  16418. {
  16419. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  16420. }
  16421. }
  16422. }
  16423. #region 替换Word模板书签内容
  16424. Dictionary<string, string> marks = new Dictionary<string, string>();
  16425. marks.Add("To", di.ClientUnit);//付款方
  16426. marks.Add("ToTel", di.TellPhone);//付款方电话
  16427. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  16428. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  16429. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  16430. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  16431. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  16432. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  16433. marks.Add("PayItemContent", itemStr);//详细信息
  16434. marks.Add("Total", allPrice.ToString("F2"));//合计
  16435. #endregion
  16436. foreach (var item in marks.Keys)
  16437. {
  16438. if (doc.Range.Bookmarks[item] != null)
  16439. {
  16440. Bookmark mark = doc.Range.Bookmarks[item];
  16441. mark.Text = marks[item];
  16442. }
  16443. }
  16444. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  16445. doc.Save(savePaht);
  16446. var jw = new JsonView();
  16447. jw.Msg = "生成成功!";
  16448. jw.Code = 200;
  16449. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  16450. return Ok(jw);
  16451. }
  16452. /// <summary>
  16453. /// 详细报价费用Excel下载
  16454. /// </summary>
  16455. /// <param name="dto"></param>
  16456. /// <returns></returns>
  16457. [HttpPost]
  16458. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  16459. {
  16460. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  16461. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  16462. if (di == null)
  16463. {
  16464. return Ok(JsonView(false, "团组不存在!"));
  16465. }
  16466. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  16467. if (mainPrice == null || mainPrice.IsShare == 0)
  16468. {
  16469. return Ok(JsonView(false, "团组成本不存在!"));
  16470. }
  16471. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  16472. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  16473. if (costTypeHotelNumbers == null)
  16474. {
  16475. return Ok(JsonView(false, "团组成本不存在!"));
  16476. }
  16477. WorkbookDesigner designer = new WorkbookDesigner();
  16478. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  16479. List<int> hideRowsList = new List<int>();
  16480. int conterStartIndex = 3;
  16481. int rowIndex = conterStartIndex;
  16482. designer.SetDataSource("GroupName", di.TeamName);
  16483. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  16484. {
  16485. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  16486. ("BXRS", "BXCB", "BXXS", "bx"),
  16487. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  16488. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  16489. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  16490. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  16491. ("CPRS", "CPCB", "CPXS", "cp") ,
  16492. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  16493. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  16494. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  16495. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  16496. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  16497. ("DJRS", "DJCB", "DJXS", "dj") ,
  16498. ("GWRS", "GWCB", "GWXS", "gw") ,
  16499. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  16500. };
  16501. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  16502. var rightSum = 0.00M;
  16503. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  16504. {
  16505. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  16506. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  16507. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  16508. if (prefix == "tbr")
  16509. {
  16510. rsValue *= 2;
  16511. cbValue /= 2;
  16512. }
  16513. if (OtherCostPropertyBJ.Contains(prefix))
  16514. {
  16515. rightSum += cbValue * xsValue;
  16516. }
  16517. if (rsValue == 0)
  16518. {
  16519. hideRowsList.Add(rowIndex);
  16520. }
  16521. else
  16522. {
  16523. designer.SetDataSource($"{prefix}rs", rsValue);
  16524. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  16525. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  16526. }
  16527. rowIndex += 2;
  16528. }
  16529. var hotelRooms = new Dictionary<string, int>
  16530. {
  16531. { "SGR", costTypeHotelNumbers.SGR },
  16532. { "TBR", costTypeHotelNumbers.TBR },
  16533. { "JSES", costTypeHotelNumbers.JSES },
  16534. { "SUITE", costTypeHotelNumbers.SUITE }
  16535. };
  16536. var flights = new Dictionary<string, int>
  16537. {
  16538. { "经济舱", mainPrice.JJCRS },
  16539. { "公务舱", mainPrice.GWCRS },
  16540. { "头等舱", mainPrice.TDCRS }
  16541. };
  16542. var flightRoomMatchingRules = new Dictionary<string, string[]>
  16543. {
  16544. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  16545. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  16546. { "头等舱", new[] { "SUITE", "JSES" } }
  16547. };
  16548. var result = new Dictionary<string, int>();
  16549. foreach (var flight in flights.Keys)
  16550. {
  16551. // 获取当前舱位的匹配规则
  16552. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  16553. {
  16554. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  16555. }
  16556. }
  16557. var allPrice = 0.00M;
  16558. #region right计算
  16559. int airRowIndex = 35;
  16560. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  16561. {
  16562. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16563. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  16564. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  16565. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  16566. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  16567. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  16568. }
  16569. else
  16570. {
  16571. hideRowsList.Add(airRowIndex);
  16572. }
  16573. airRowIndex += 2;
  16574. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  16575. {
  16576. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16577. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16578. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  16579. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  16580. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  16581. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  16582. }
  16583. else
  16584. {
  16585. hideRowsList.Add(airRowIndex);
  16586. }
  16587. airRowIndex += 2;
  16588. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  16589. {
  16590. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16591. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  16592. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  16593. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  16594. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  16595. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  16596. }
  16597. else
  16598. {
  16599. hideRowsList.Add(airRowIndex);
  16600. }
  16601. airRowIndex += 2;
  16602. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  16603. {
  16604. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16605. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16606. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  16607. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  16608. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  16609. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  16610. }
  16611. else
  16612. {
  16613. hideRowsList.Add(airRowIndex);
  16614. }
  16615. airRowIndex += 2;
  16616. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  16617. {
  16618. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  16619. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16620. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  16621. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  16622. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  16623. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  16624. }
  16625. else
  16626. {
  16627. hideRowsList.Add(airRowIndex);
  16628. }
  16629. airRowIndex += 2;
  16630. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  16631. {
  16632. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16633. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16634. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  16635. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  16636. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  16637. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  16638. }
  16639. else
  16640. {
  16641. hideRowsList.Add(airRowIndex);
  16642. }
  16643. airRowIndex += 2;
  16644. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  16645. {
  16646. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16647. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16648. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  16649. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  16650. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  16651. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  16652. }
  16653. else
  16654. {
  16655. hideRowsList.Add(airRowIndex);
  16656. }
  16657. airRowIndex += 2;
  16658. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  16659. {
  16660. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  16661. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  16662. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  16663. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  16664. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  16665. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  16666. }
  16667. else
  16668. {
  16669. hideRowsList.Add(airRowIndex);
  16670. }
  16671. airRowIndex += 2;
  16672. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  16673. {
  16674. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  16675. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  16676. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  16677. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  16678. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  16679. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  16680. }
  16681. else
  16682. {
  16683. hideRowsList.Add(airRowIndex);
  16684. }
  16685. #endregion
  16686. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  16687. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  16688. var ws = designer.Workbook.Worksheets[0];
  16689. foreach (var Rowindex in hideRowsList)
  16690. {
  16691. ws.Cells.HideRows(Rowindex, 2);
  16692. }
  16693. designer.Process();
  16694. designer.Workbook.Save(savePaht);
  16695. return Ok(JsonView(true, "生成成功!", new
  16696. {
  16697. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  16698. }));
  16699. }
  16700. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  16701. {
  16702. foreach (var roomType in roomTypes)
  16703. {
  16704. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  16705. {
  16706. hotelRooms[roomType]--;
  16707. flights[flightType]--;
  16708. if (roomType == "TBR")
  16709. {
  16710. flights[flightType]--; // 双人间在减少1
  16711. }
  16712. string key = flightType + roomType;
  16713. if (result.Keys.Contains(key))
  16714. {
  16715. result[key]++;
  16716. }
  16717. else
  16718. {
  16719. result.Add(key, 1);
  16720. }
  16721. }
  16722. }
  16723. }
  16724. private class AirHotelPrice
  16725. {
  16726. public string Name { get; set; }
  16727. public decimal Price { get; set; }
  16728. public int Count { get; set; }
  16729. }
  16730. #endregion
  16731. #region 酒店预订 New 2023-12-28 17:45
  16732. /// <summary>
  16733. /// 酒店预订
  16734. /// 酒店费用列表 根据团组Id查询
  16735. /// </summary>
  16736. /// <param name="_dto"></param>
  16737. /// <returns></returns>
  16738. [HttpPost]
  16739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16740. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  16741. {
  16742. #region 参数验证
  16743. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16744. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16745. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16746. #region 团组操作权限验证 76 酒店预定模块
  16747. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16748. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16749. #endregion
  16750. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16751. #region 页面操作权限验证
  16752. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16753. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16754. #endregion
  16755. #endregion
  16756. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  16757. }
  16758. /// <summary>
  16759. /// 酒店预订
  16760. /// 基础数据
  16761. /// </summary>
  16762. /// <param name="_dto"></param>
  16763. /// <returns></returns>
  16764. [HttpPost]
  16765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16766. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  16767. {
  16768. #region 参数验证
  16769. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16770. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16771. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16772. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16773. #region 页面操作权限验证
  16774. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16775. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16776. #endregion
  16777. #region 团组操作权限验证 76 酒店预定模块
  16778. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16779. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16780. #endregion
  16781. #endregion
  16782. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  16783. }
  16784. /// <summary>
  16785. /// 酒店预订
  16786. /// 创建 入住卷号码
  16787. /// </summary>
  16788. /// <param name="_dto"></param>
  16789. /// <returns></returns>
  16790. [HttpPost]
  16791. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16792. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  16793. {
  16794. #region 参数验证
  16795. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16796. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16797. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16798. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16799. #region 页面操作权限验证
  16800. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16801. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16802. #endregion
  16803. #region 团组操作权限验证 76 酒店预定模块
  16804. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16805. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16806. #endregion
  16807. #endregion
  16808. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  16809. if (data.Code != 0)
  16810. {
  16811. return Ok(JsonView(false, data.Msg));
  16812. }
  16813. return Ok(JsonView(true, data.Msg, data.Data));
  16814. }
  16815. /// <summary>
  16816. /// 酒店预订
  16817. /// 详情
  16818. /// </summary>
  16819. /// <param name="_dto"></param>
  16820. /// <returns></returns>
  16821. [HttpPost]
  16822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16823. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  16824. {
  16825. #region 参数验证
  16826. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  16827. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16828. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  16829. #region 团组操作权限验证 76 酒店预定模块
  16830. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16831. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16832. #endregion
  16833. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16834. #region 页面操作权限验证
  16835. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16836. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16837. #endregion
  16838. #endregion
  16839. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  16840. }
  16841. /// <summary>
  16842. /// 酒店预订
  16843. /// Add Or Edit
  16844. /// </summary>
  16845. /// <param name="_dto"></param>
  16846. /// <returns></returns>
  16847. [HttpPost]
  16848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16849. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  16850. {
  16851. #region 参数验证
  16852. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16853. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  16854. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  16855. #region 团组操作权限验证 76 酒店预定模块
  16856. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  16857. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  16858. #endregion
  16859. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16860. #region 页面操作权限验证
  16861. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16862. if (_dto.Id == 0) // Add
  16863. {
  16864. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16865. }
  16866. else if (_dto.Id > 1) // Edit
  16867. {
  16868. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16869. }
  16870. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  16871. #endregion
  16872. #endregion
  16873. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  16874. if (_view.Code != 200)
  16875. {
  16876. return Ok(_view);
  16877. }
  16878. #region 成本无酒店价格数据进入超支
  16879. _sqlSugar.BeginTran();
  16880. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  16881. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  16882. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  16883. for (int i = 0; i < groupCost.Count; i++)
  16884. {
  16885. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  16886. {
  16887. groupCost[i].Date = groupCost[i - 1].Date;
  16888. }
  16889. }
  16890. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  16891. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  16892. List<Fin_GroupExtraCostDto_OP>();
  16893. if (start_Bool && end_Bool)
  16894. {
  16895. while (start_Time < end_Time)
  16896. {
  16897. foreach (var item in groupCost_Grp)
  16898. {
  16899. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  16900. {
  16901. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  16902. {
  16903. extraCostList.Add(new
  16904. Fin_GroupExtraCostDto_OP
  16905. {
  16906. Area = _dto.AreaId,
  16907. coefficient = 1.5M,
  16908. createUser = _dto.UserId,
  16909. currency = _dto.CardPriceCurrency,
  16910. diId = _dto.DiId,
  16911. ManagerConfirm = 0,
  16912. SupervisorConfirm = 0,
  16913. SYsupervisorConfirm = 0,
  16914. editType = 1,
  16915. PortType = 1,
  16916. price = _dto.CardPrice,
  16917. PriceCount = 1,
  16918. priceType = 1027,
  16919. priceDetailType = 1044,
  16920. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  16921. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  16922. });
  16923. }
  16924. }
  16925. }
  16926. start_Time = start_Time.AddDays(1);
  16927. }
  16928. }
  16929. if (extraCostList.Any())
  16930. {
  16931. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  16932. }
  16933. _sqlSugar.CommitTran();
  16934. #endregion
  16935. #region 应用推送
  16936. try
  16937. {
  16938. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  16939. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  16940. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  16941. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  16942. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  16943. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  16944. var diId = _dto.DiId;
  16945. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16946. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16947. #region 操作记录
  16948. var opInfo = new Crm_TableOperationRecord()
  16949. {
  16950. TableName = "Grp_HotelReservations",
  16951. PortType = _dto.PortType,
  16952. DataId = hotelId,
  16953. CreateUserId = _dto.UserId
  16954. };
  16955. //var opStatus = OperationEnum.NoOperation;
  16956. if (_dto.Id < 1) //添加操作
  16957. {
  16958. opInfo.OperationItem = OperationEnum.Add;
  16959. }
  16960. else if (_dto.Id > 0)
  16961. {
  16962. opInfo.OperationItem = OperationEnum.Edit;
  16963. }
  16964. string opRemark = string.Empty;
  16965. if (ccpInfo != null)
  16966. {
  16967. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  16968. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  16969. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  16970. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  16971. }
  16972. opInfo.Remark = opRemark;
  16973. await _tableorRep.AddAsync(opInfo);
  16974. #endregion
  16975. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  16976. //2024-10-21 新增LZ UID
  16977. var userIds = new List<int>() { 21 };
  16978. string title = $"费用审核";
  16979. string content = "";
  16980. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16981. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  16982. try
  16983. {
  16984. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  16985. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  16986. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  16987. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  16988. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  16989. }
  16990. catch (Exception ex)
  16991. {
  16992. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  16993. }
  16994. }
  16995. catch (Exception ex)
  16996. {
  16997. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  16998. }
  16999. try
  17000. {
  17001. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  17002. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  17003. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  17004. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  17005. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  17006. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  17007. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  17008. //自动审核
  17009. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  17010. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  17011. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  17012. //2024-10-21 新增LZ UID
  17013. var userIds = new List<int>() { 21 };
  17014. string title = $"系统通知";
  17015. var diId = _dto.DiId;
  17016. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  17017. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  17018. string content = "";
  17019. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17020. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  17021. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  17022. }
  17023. catch (Exception ex)
  17024. {
  17025. }
  17026. #endregion
  17027. return Ok(_view);
  17028. }
  17029. /// <summary>
  17030. /// 酒店自动审核测试
  17031. /// Add Or Edit
  17032. /// </summary>
  17033. /// <param name="diid"></param>
  17034. /// <param name="dataId"></param>
  17035. /// <returns></returns>
  17036. [HttpPost]
  17037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17038. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  17039. {
  17040. #region 应用推送
  17041. try
  17042. {
  17043. //自动审核
  17044. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  17045. }
  17046. catch (Exception ex)
  17047. {
  17048. return Ok(JsonView(false, "操作失败"));
  17049. }
  17050. #endregion
  17051. return Ok(JsonView(false, "操作成功"));
  17052. }
  17053. /// <summary>
  17054. /// 酒店预订
  17055. /// Del
  17056. /// </summary>
  17057. /// <param name="_dto"></param>
  17058. /// <returns></returns>
  17059. [HttpPost]
  17060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17061. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  17062. {
  17063. #region 参数验证
  17064. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17065. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17066. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17067. #region 团组操作权限验证 76 酒店预定模块
  17068. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17069. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17070. #endregion
  17071. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17072. #region 页面操作权限验证
  17073. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17074. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  17075. #endregion
  17076. #endregion
  17077. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  17078. #region 操作记录
  17079. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  17080. {
  17081. TableName = "Grp_HotelReservations",
  17082. PortType = _dto.PortType,
  17083. OperationItem = OperationEnum.Del,
  17084. DataId = _dto.Id,
  17085. CreateUserId = _dto.UserId
  17086. });
  17087. #endregion
  17088. return Ok(data);
  17089. }
  17090. /// <summary>
  17091. /// 酒店预订
  17092. /// 生成VOUCHER
  17093. /// 2024.05.06 之前版本
  17094. /// </summary>
  17095. /// <param name="_dto"></param>
  17096. /// <returns></returns>
  17097. [HttpPost]
  17098. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17099. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  17100. {
  17101. try
  17102. {
  17103. #region 参数验证
  17104. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  17105. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17106. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  17107. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  17108. #region 团组操作权限验证 76 酒店预定模块
  17109. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17110. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  17111. #endregion
  17112. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17113. #region 页面操作权限验证
  17114. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17115. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17116. #endregion
  17117. #endregion
  17118. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  17119. //判断数据是否完整
  17120. if (hr != null)
  17121. {
  17122. if (!string.IsNullOrEmpty(hr.DetermineNo))
  17123. {
  17124. string strFileName = "HotelStatement/";
  17125. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17126. if (dele != null)
  17127. strFileName += dele.TourCode;
  17128. //载入模板
  17129. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  17130. Document doc = new Document(sss);
  17131. DocumentBuilder builder = new DocumentBuilder(doc);
  17132. #region 替换Word模板书签内容
  17133. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  17134. //入住卷预定号码
  17135. if (doc.Range.Bookmarks["VNO"] != null)
  17136. {
  17137. Bookmark mark = doc.Range.Bookmarks["VNO"];
  17138. mark.Text = hr.CheckNumber;
  17139. }
  17140. //酒店时间
  17141. if (doc.Range.Bookmarks["Date"] != null)
  17142. {
  17143. Bookmark mark = doc.Range.Bookmarks["Date"];
  17144. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17145. }
  17146. //团号
  17147. if (doc.Range.Bookmarks["TNo"] != null)
  17148. {
  17149. Bookmark mark = doc.Range.Bookmarks["TNo"];
  17150. mark.Text = dele.TourCode;
  17151. }
  17152. //预定号码
  17153. if (doc.Range.Bookmarks["BookingId"] != null)
  17154. {
  17155. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  17156. mark.Text = hr.ReservationsNo;
  17157. }
  17158. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  17159. {
  17160. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  17161. mark.Text = hr.DetermineNo;
  17162. }
  17163. //酒店城市
  17164. if (doc.Range.Bookmarks["City"] != null)
  17165. {
  17166. Bookmark mark = doc.Range.Bookmarks["City"];
  17167. mark.Text = hr.City;
  17168. }
  17169. //酒店名称
  17170. if (doc.Range.Bookmarks["HName"] != null)
  17171. {
  17172. Bookmark mark = doc.Range.Bookmarks["HName"];
  17173. mark.Text = hr.HotelName;
  17174. }
  17175. //酒店地址
  17176. if (doc.Range.Bookmarks["Address"] != null)
  17177. {
  17178. Bookmark mark = doc.Range.Bookmarks["Address"];
  17179. mark.Text = hr.HotelAddress;
  17180. }
  17181. //酒店电话
  17182. if (doc.Range.Bookmarks["Tel"] != null)
  17183. {
  17184. Bookmark mark = doc.Range.Bookmarks["Tel"];
  17185. mark.Text = hr.HotelTel;
  17186. }
  17187. //酒店传真
  17188. if (doc.Range.Bookmarks["Fax"] != null)
  17189. {
  17190. Bookmark mark = doc.Range.Bookmarks["Fax"];
  17191. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  17192. {
  17193. mark.Text = hr.HotelFax;
  17194. }
  17195. }
  17196. //入住时间
  17197. if (doc.Range.Bookmarks["CIn"] != null)
  17198. {
  17199. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17200. Bookmark mark = doc.Range.Bookmarks["CIn"];
  17201. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  17202. }
  17203. //退房时间
  17204. if (doc.Range.Bookmarks["COut"] != null)
  17205. {
  17206. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17207. Bookmark mark = doc.Range.Bookmarks["COut"];
  17208. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17209. }
  17210. //客户名称
  17211. if (doc.Range.Bookmarks["GName"] != null)
  17212. {
  17213. string guestName = "";
  17214. string[] clients = new string[] { };
  17215. if (hr.GuestName.Contains(","))
  17216. {
  17217. clients = hr.GuestName.Split(",");
  17218. }
  17219. else
  17220. {
  17221. clients = new string[] { hr.GuestName };
  17222. }
  17223. List<int> clientIds_int = new List<int>();
  17224. if (clients.Length > 0)
  17225. {
  17226. foreach (var item in clients)
  17227. {
  17228. if (item.IsNumeric())
  17229. {
  17230. clientIds_int.Add(int.Parse(item));
  17231. }
  17232. }
  17233. }
  17234. if (clientIds_int.Count > 0)
  17235. {
  17236. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  17237. foreach (var client in _clientDatas)
  17238. {
  17239. //男
  17240. if (client.Sex == 0) guestName += $"Mr.";
  17241. //女
  17242. else if (client.Sex == 1) guestName += $"Ms.";
  17243. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  17244. {
  17245. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  17246. }
  17247. //guestName += $"{client.Pinyin},";
  17248. }
  17249. if (guestName.Length > 0)
  17250. {
  17251. guestName = guestName.Substring(0, guestName.Length - 1);
  17252. }
  17253. }
  17254. else
  17255. {
  17256. guestName = hr.GuestName;
  17257. }
  17258. Bookmark mark = doc.Range.Bookmarks["GName"];
  17259. mark.Text = guestName;
  17260. }
  17261. //房间介绍
  17262. if (doc.Range.Bookmarks["ROOM"] != null)
  17263. {
  17264. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  17265. mark.Text = hr.RoomExplanation;
  17266. }
  17267. //报价描述
  17268. if (doc.Range.Bookmarks["NOTE"] != null)
  17269. {
  17270. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  17271. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  17272. if (ss != null)
  17273. mark.Text = ss.Name;
  17274. }
  17275. //入住时间
  17276. if (doc.Range.Bookmarks["CheckIn"] != null)
  17277. {
  17278. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  17279. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  17280. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17281. }
  17282. //退房时间
  17283. if (doc.Range.Bookmarks["CheckOut"] != null)
  17284. {
  17285. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  17286. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  17287. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  17288. }
  17289. //日期
  17290. if (doc.Range.Bookmarks["DT"] != null)
  17291. {
  17292. Bookmark mark = doc.Range.Bookmarks["DT"];
  17293. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  17294. }
  17295. //名称
  17296. if (doc.Range.Bookmarks["VName"] != null)
  17297. {
  17298. Bookmark mark = doc.Range.Bookmarks["VName"];
  17299. mark.Text = hr.HotelName;
  17300. }
  17301. //号码
  17302. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  17303. {
  17304. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  17305. mark.Text = hr.CheckNumber;
  17306. }
  17307. #endregion
  17308. strFileName += "VOUCHER.doc";
  17309. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17310. doc.Save(fileDir);
  17311. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17312. return Ok(JsonView(true, "操作成功!", Url));
  17313. }
  17314. else
  17315. {
  17316. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  17317. }
  17318. }
  17319. else
  17320. {
  17321. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  17322. }
  17323. }
  17324. catch (Exception ex)
  17325. {
  17326. return Ok(JsonView(false, ex.Message));
  17327. }
  17328. }
  17329. /// <summary>
  17330. /// 酒店预订
  17331. /// 生成VOUCHER
  17332. /// 2024.05.06 之后版本
  17333. /// </summary>
  17334. /// <param name="_dto"></param>
  17335. /// <returns></returns>
  17336. [HttpPost]
  17337. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17338. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  17339. {
  17340. #region 参数验证
  17341. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17342. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  17343. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17344. #region 团组操作权限验证 76 酒店预定模块
  17345. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17346. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17347. #endregion
  17348. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17349. #region 页面操作权限验证
  17350. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17351. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17352. #endregion
  17353. #endregion
  17354. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  17355. //判断数据是否完整
  17356. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17357. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  17358. string strFileName = "HotelStatement/";
  17359. string guestNames = ""; //格式Mr.xxx Ms.xxx
  17360. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  17361. #region 数据处理
  17362. List<int> guestIds = new List<int>();
  17363. //int index = 0;
  17364. foreach (var item in hrDtas)
  17365. {
  17366. if (item.GuestName.Contains(","))
  17367. {
  17368. string[] guestIdArr = item.GuestName.Split(',');
  17369. foreach (var guestIdStr in guestIdArr)
  17370. {
  17371. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  17372. if (guestBool)
  17373. {
  17374. guestIds.Add(guestId);
  17375. }
  17376. }
  17377. }
  17378. else guestNames += item.GuestName;
  17379. var voucherInfo = new HotelVoucherInfoView()
  17380. {
  17381. HotelName = item.HotelName,
  17382. CheckInDate = item.CheckInDate,
  17383. CheckOutDate = item.CheckOutDate,
  17384. ConfirmationNumber = item.DetermineNo.Trim(),
  17385. RoomType = item.RoomExplanation
  17386. };
  17387. vouchers.Add(voucherInfo);
  17388. }
  17389. if (guestIds.Count > 0)
  17390. {
  17391. guestIds = guestIds.Distinct().ToList();
  17392. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  17393. if (guestDatas.Count > 0)
  17394. {
  17395. guestNames = "";
  17396. foreach (var guest in guestDatas)
  17397. {
  17398. string guestName = "";
  17399. if (guest.Sex == 0) guestName += @"MR.";
  17400. else if (guest.Sex == 1) guestName += @"MS.";
  17401. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17402. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17403. guestNames += @$"{guestName.Trim()}、";
  17404. }
  17405. if (guestNames.Length > 0)
  17406. {
  17407. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17408. }
  17409. }
  17410. }
  17411. #endregion
  17412. //载入模板
  17413. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  17414. Document doc = new Document(sss);
  17415. DocumentBuilder builder = new DocumentBuilder(doc);
  17416. if (doc.Range.Bookmarks["GuestName"] != null)
  17417. {
  17418. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  17419. mark.Text = guestNames;
  17420. }
  17421. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17422. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  17423. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  17424. for (int i = 1; i <= vouchers.Count; i++)
  17425. {
  17426. HotelVoucherInfoView hviv = vouchers[i - 1];
  17427. builder.MoveToCell(0, i, 0, 0);
  17428. builder.Write(hviv.HotelName);
  17429. builder.MoveToCell(0, i, 1, 0);
  17430. builder.Write(hviv.CheckInDate);
  17431. builder.MoveToCell(0, i, 2, 0);
  17432. builder.Write(hviv.CheckOutDate);
  17433. builder.MoveToCell(0, i, 3, 0);
  17434. builder.Write(hviv.RoomType);
  17435. builder.MoveToCell(0, i, 4, 0);
  17436. builder.Write(hviv.ConfirmationNumber);
  17437. }
  17438. //删除多余行
  17439. int currRowIndex = vouchers.Count + 1;
  17440. int delRows = 21 - currRowIndex;
  17441. if (delRows > 0)
  17442. {
  17443. for (int i = 0; i < delRows; i++)
  17444. {
  17445. table.Rows.RemoveAt(currRowIndex);
  17446. //cultivateRowIndex++;
  17447. }
  17448. }
  17449. strFileName += "VOUCHER.docx";
  17450. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  17451. doc.Save(fileDir);
  17452. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  17453. return Ok(JsonView(true, "操作成功!", Url));
  17454. }
  17455. /// <summary>
  17456. /// 酒店预订
  17457. /// 生成VOUCHER 批量生成
  17458. /// New
  17459. /// </summary>
  17460. /// <param name="_dto"></param>
  17461. /// <returns></returns>
  17462. [HttpPost]
  17463. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17464. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  17465. {
  17466. #region 参数验证
  17467. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  17468. if (_dto.PageId < 1) _dto.PageId = 28;
  17469. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  17470. #region 团组操作权限验证 76 酒店预定模块
  17471. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  17472. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  17473. #endregion
  17474. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  17475. #region 页面操作权限验证
  17476. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  17477. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  17478. #endregion
  17479. #endregion
  17480. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  17481. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  17482. .OrderBy(x => x.CheckInDate)
  17483. .ToListAsync();
  17484. //判断数据是否完整
  17485. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  17486. string strFileName = "HotelStatement/";
  17487. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  17488. if (dele != null)
  17489. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  17490. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  17491. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  17492. .Where(it => it.IsDel == 0)
  17493. .ToListAsync();
  17494. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  17495. for (int i = 0; i < hrDtas.Count; i++)
  17496. {
  17497. string guestNames = string.Empty;
  17498. List<int> guestIds = new List<int>();
  17499. var item = hrDtas[i];
  17500. //处理客户姓名
  17501. if (item.GuestName.Contains(","))
  17502. {
  17503. string[] guestIdArr = item.GuestName.Split(',');
  17504. foreach (var guestIdStr in guestIdArr)
  17505. if (int.TryParse(guestIdStr, out int guestId))
  17506. guestIds.Add(guestId);
  17507. }
  17508. else
  17509. {
  17510. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  17511. if (guestIdBool)
  17512. {
  17513. guestIds.Add(guestId);
  17514. }
  17515. //NaN
  17516. if (item.GuestName.Contains("NaN"))
  17517. {
  17518. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  17519. }
  17520. }
  17521. if (guestIds.Count > 0)
  17522. {
  17523. guestIds = guestIds.Distinct().ToList();
  17524. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  17525. if (guestDatas1.Count > 0)
  17526. {
  17527. guestNames = "";
  17528. foreach (var guest in guestDatas1)
  17529. {
  17530. string guestName = "";
  17531. if (guest.Sex == 0) guestName += @"MR.";
  17532. else if (guest.Sex == 1) guestName += @"MS.";
  17533. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  17534. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  17535. guestNames += @$"{guestName.Trim()}、";
  17536. }
  17537. if (guestNames.Length > 0)
  17538. {
  17539. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  17540. }
  17541. }
  17542. }
  17543. //if (!string.IsNullOrEmpty(guestNames))
  17544. //{
  17545. hrDtas[i].GuestName = guestNames;
  17546. //}
  17547. }
  17548. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  17549. Document doc = new Document();
  17550. DocumentBuilder builder = new DocumentBuilder(doc);
  17551. try
  17552. {
  17553. builder.MoveToDocumentStart();
  17554. foreach (var item in hrDtas)
  17555. {
  17556. //标题
  17557. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17558. builder.ParagraphFormat.LineSpacing = 1;
  17559. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17560. builder.ParagraphFormat.Style.Font.Size = 9;
  17561. builder.ParagraphFormat.Style.Font.Bold = true;
  17562. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17563. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  17564. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  17565. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  17566. builder.ParagraphFormat.LineSpacing = 1;
  17567. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17568. builder.ParagraphFormat.Style.Font.Size = 9;
  17569. builder.ParagraphFormat.Style.Font.Bold = true;
  17570. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  17571. builder.StartTable();
  17572. // 设置边框颜色
  17573. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  17574. //设置边框样式
  17575. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  17576. //表格
  17577. #region 第一行
  17578. builder.InsertCell();
  17579. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17580. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17581. //builder.CellFormat.AllowAutoFit = false;
  17582. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17583. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17584. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17585. builder.CellFormat.WrapText = true; //自动换行
  17586. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17587. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  17588. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17589. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17590. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17591. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17592. builder.Write("TOUR NO:");
  17593. builder.InsertCell();
  17594. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17595. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17596. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17597. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17598. builder.ParagraphFormat.Style.Font.Bold = false;
  17599. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17600. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17601. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17602. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17603. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17604. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17605. builder.Write($"{dele?.TourCode ?? "-"}");
  17606. builder.InsertCell();
  17607. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17608. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17609. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17610. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17611. builder.ParagraphFormat.Style.Font.Bold = false;
  17612. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17613. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17614. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17615. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17616. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17617. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17618. builder.Write($"CITY:");
  17619. builder.InsertCell();
  17620. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17621. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17622. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17623. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17624. builder.ParagraphFormat.Style.Font.Bold = false;
  17625. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17626. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17627. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17628. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17629. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17630. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17631. builder.Write($"{item.City}");
  17632. builder.EndRow();
  17633. #endregion
  17634. #region 第二行
  17635. builder.InsertCell();
  17636. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17637. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17638. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17639. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17640. builder.ParagraphFormat.Style.Font.Bold = false;
  17641. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17642. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17643. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17644. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17645. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17646. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17647. builder.Write("CONFIRMATION NO:");
  17648. builder.InsertCell();
  17649. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17650. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17651. builder.ParagraphFormat.Style.Font.Size = 8;
  17652. builder.ParagraphFormat.Style.Font.Bold = false;
  17653. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17654. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17655. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17656. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17657. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17658. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17659. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17660. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17661. builder.Write($"{item.DetermineNo}");
  17662. builder.InsertCell();
  17663. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17664. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17665. builder.InsertCell();
  17666. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17667. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17668. builder.EndRow();
  17669. #endregion
  17670. #region 第三行
  17671. builder.InsertCell();
  17672. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17673. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17674. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17675. builder.ParagraphFormat.Style.Font.Bold = false;
  17676. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17677. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17678. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  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.Write($"HOTEL NAME:");
  17684. builder.InsertCell();
  17685. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17686. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17687. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17688. builder.ParagraphFormat.Style.Font.Bold = false;
  17689. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17690. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17691. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17692. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17693. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17694. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17695. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17696. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17697. builder.Write($"{item.HotelName}");
  17698. builder.InsertCell();
  17699. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17700. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17701. builder.InsertCell();
  17702. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17703. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17704. builder.EndRow();
  17705. #endregion
  17706. #region 第四行
  17707. builder.InsertCell();
  17708. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  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.Right;//对齐
  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.Write($"HOTEL ADDRESS:");
  17720. builder.InsertCell();
  17721. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17722. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17723. builder.ParagraphFormat.Style.Font.Size = 8;
  17724. builder.ParagraphFormat.Style.Font.Bold = false;
  17725. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17726. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17727. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17728. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17729. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17730. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17731. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17732. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17733. builder.Write($"{item.HotelAddress}");
  17734. builder.InsertCell();
  17735. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17736. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17737. builder.InsertCell();
  17738. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17739. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17740. builder.EndRow();
  17741. #endregion
  17742. #region 第五行
  17743. builder.InsertCell();
  17744. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17745. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17746. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17747. builder.ParagraphFormat.Style.Font.Bold = false;
  17748. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17749. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17750. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  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.Write("TEL:");
  17756. builder.InsertCell();
  17757. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17758. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17759. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17760. builder.ParagraphFormat.Style.Font.Bold = false;
  17761. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17762. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17763. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17764. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17765. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17766. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17767. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17768. builder.Write($"{item.HotelTel}");
  17769. builder.InsertCell();
  17770. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17771. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17772. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17773. builder.ParagraphFormat.Style.Font.Bold = false;
  17774. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17775. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17776. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17777. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17778. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17779. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17780. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17781. builder.Write($"FAX:");
  17782. builder.InsertCell();
  17783. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17784. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17785. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17786. builder.ParagraphFormat.Style.Font.Bold = false;
  17787. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17788. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17789. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17790. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17791. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17792. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17793. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17794. builder.Write($"{item.HotelFax}");
  17795. builder.EndRow();
  17796. #endregion
  17797. #region 第六行
  17798. builder.InsertCell();
  17799. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17800. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17801. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17802. builder.ParagraphFormat.Style.Font.Bold = false;
  17803. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17804. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17805. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17806. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17807. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17808. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17809. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17810. builder.Write("CHECK IN:");
  17811. builder.InsertCell();
  17812. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17813. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17814. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17815. builder.ParagraphFormat.Style.Font.Bold = false;
  17816. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17817. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17818. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17819. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17820. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17821. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17822. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17823. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  17824. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  17825. builder.Write($"{checkInStr}");
  17826. builder.InsertCell();
  17827. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17828. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17829. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17830. builder.ParagraphFormat.Style.Font.Bold = false;
  17831. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17832. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17833. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17834. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17835. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17836. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17837. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17838. builder.Write($"CHECK OUT:");
  17839. builder.InsertCell();
  17840. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17841. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17842. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17843. builder.ParagraphFormat.Style.Font.Bold = false;
  17844. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17845. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17846. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17847. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17848. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17849. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17850. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17851. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  17852. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  17853. builder.Write($"{checkOutStr}");
  17854. builder.EndRow();
  17855. #endregion
  17856. #region 第七行
  17857. builder.InsertCell();
  17858. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17859. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17860. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17861. builder.ParagraphFormat.Style.Font.Bold = false;
  17862. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17863. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17864. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  17865. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17866. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17867. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17868. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17869. builder.Write($"GUEST NAME:");
  17870. builder.InsertCell();
  17871. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17872. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17873. builder.ParagraphFormat.Style.Font.Size = 8;
  17874. builder.ParagraphFormat.Style.Font.Bold = false;
  17875. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17876. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17877. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17878. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17879. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17880. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17881. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17882. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17883. builder.Write($"{item.GuestName.Trim()}");
  17884. builder.InsertCell();
  17885. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17886. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17887. builder.InsertCell();
  17888. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17889. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17890. builder.EndRow();
  17891. #endregion
  17892. #region 第八行
  17893. builder.InsertCell();
  17894. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17895. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17896. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17897. builder.ParagraphFormat.Style.Font.Bold = false;
  17898. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17899. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17900. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  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.Write($"ROOM TYPE:");
  17906. builder.InsertCell();
  17907. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17908. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17909. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17910. builder.ParagraphFormat.Style.Font.Bold = false;
  17911. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17912. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17913. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17914. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  17915. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  17916. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  17917. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  17918. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17919. builder.Write($"{item.RoomExplanation}");
  17920. builder.InsertCell();
  17921. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17922. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17923. builder.InsertCell();
  17924. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17925. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17926. builder.EndRow();
  17927. #endregion
  17928. #region 第九行
  17929. builder.InsertCell();
  17930. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  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.Right;//对齐
  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.Write($"NOTE:");
  17942. builder.InsertCell();
  17943. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17944. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  17945. builder.ParagraphFormat.Style.Font.Size = 7.5;
  17946. builder.ParagraphFormat.Style.Font.Bold = false;
  17947. builder.CellFormat.HorizontalMerge = CellMerge.None;
  17948. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  17949. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  17950. builder.CellFormat.HorizontalMerge = CellMerge.First;
  17951. 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.");
  17952. builder.InsertCell();
  17953. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  17954. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17955. builder.InsertCell();
  17956. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  17957. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  17958. builder.EndRow();
  17959. #endregion
  17960. builder.EndTable();
  17961. //换行
  17962. builder.Writeln("");
  17963. builder.Writeln("");
  17964. }
  17965. #region 获取文档中的所有表格 设置文字自适应
  17966. // 获取文档中的所有表格。
  17967. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  17968. {
  17969. // 遍历表格中的所有行。
  17970. foreach (Aspose.Words.Tables.Row row in table.Rows)
  17971. {
  17972. foreach (Cell cell in row.Cells)
  17973. {
  17974. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  17975. cellFormat.Width = 0;
  17976. }
  17977. }
  17978. }
  17979. #endregion
  17980. #region 设置页眉
  17981. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  17982. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  17983. if (System.IO.File.Exists(voucherHeaderPath))
  17984. {
  17985. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  17986. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  17987. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  17988. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  17989. // 调整图片位置
  17990. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  17991. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  17992. shape.Top = 50; // 将图片距离页眉上边缘的距离
  17993. shape.Left = 0; // 将图片距离页面左边缘的距离
  17994. shape.Width = 81; // 设置图片宽度
  17995. shape.Height = 36; // 设置图片高度
  17996. }
  17997. //靠右
  17998. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  17999. //// 设置页脚上下边距
  18000. //builder.PageSetup.HeaderDistance = 42;
  18001. // 添加页眉线
  18002. Aspose.Words.Border borderHeader = null;
  18003. try
  18004. {
  18005. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  18006. }
  18007. catch (Exception e)
  18008. {
  18009. // TODO Auto-generated catch block
  18010. //e.printStackTrace();
  18011. }
  18012. borderHeader.Shadow = true;
  18013. borderHeader.DistanceFromText = 2;
  18014. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  18015. #endregion
  18016. }
  18017. catch (Exception ex)
  18018. {
  18019. }
  18020. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  18021. doc.Save(fileDir);
  18022. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  18023. return Ok(JsonView(true, "操作成功!", Url));
  18024. }
  18025. /// <summary>
  18026. /// 酒店预订
  18027. /// 生成 预定成本 Excel
  18028. /// </summary>
  18029. /// <param name="_dto"></param>
  18030. /// <returns></returns>
  18031. [HttpPost]
  18032. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18033. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  18034. {
  18035. #region 参数验证
  18036. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  18037. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  18038. if (!vadalitorRes.IsValid)
  18039. {
  18040. var errors = new StringBuilder();
  18041. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  18042. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  18043. }
  18044. #region 团组操作权限验证 76 酒店预定模块
  18045. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18046. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18047. #endregion
  18048. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18049. #region 页面操作权限验证
  18050. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18051. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18052. #endregion
  18053. #endregion
  18054. decimal _rate = 1.00M;
  18055. string _currency = string.Empty;
  18056. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  18057. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18058. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  18059. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  18060. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  18061. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  18062. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  18063. if (_GroupCostParameter == null)
  18064. {
  18065. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  18066. bool isIntType = int.TryParse(_currency, out int currId);
  18067. if (isIntType)
  18068. {
  18069. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18070. }
  18071. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18072. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18073. if (currInfo == null)
  18074. {
  18075. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18076. }
  18077. else _rate = currInfo.Rate;
  18078. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  18079. {
  18080. _rate = _GroupCostParameter.Rate;
  18081. }
  18082. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18083. //string strFileName = "HotelStatement/";
  18084. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18085. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18086. var rateDatas = new List<dynamic>();
  18087. #region 数据处理
  18088. foreach (var item in hrDtas)
  18089. {
  18090. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18091. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18092. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18093. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18094. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18095. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  18096. {
  18097. continue;
  18098. }
  18099. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18100. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  18101. string singleRoomFeeStr = string.Empty,
  18102. doubleRoomFeeStr = string.Empty,
  18103. suiteRoomFeeStr = string.Empty,
  18104. otherRoomFeeStr = string.Empty,
  18105. payMoneyStr = string.Empty,
  18106. cardPriceStr = string.Empty;
  18107. if (roomCurr.Equals("CNY"))
  18108. {
  18109. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  18110. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18111. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18112. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18113. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18114. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  18115. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  18116. }
  18117. else
  18118. {
  18119. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18120. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18121. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18122. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18123. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18124. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18125. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18126. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18127. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18128. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  18129. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  18130. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  18131. if (ccpPaymentCurrency.Equals("CNY"))
  18132. {
  18133. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  18134. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18135. }
  18136. else
  18137. {
  18138. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  18139. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  18140. }
  18141. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  18142. if (hotelcardPriceCurrency.Equals("CNY"))
  18143. {
  18144. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  18145. }
  18146. else
  18147. {
  18148. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  18149. }
  18150. }
  18151. string breakfastPriceStr = string.Empty,
  18152. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18153. governmentRentStr = string.Empty,
  18154. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18155. cityTaxStr = string.Empty,
  18156. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18157. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  18158. if (!string.IsNullOrEmpty(breakfastCurrency1))
  18159. {
  18160. if (breakfastCurrency1.Equals("CNY"))
  18161. {
  18162. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18163. }
  18164. else
  18165. {
  18166. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  18167. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  18168. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  18169. }
  18170. }
  18171. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  18172. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  18173. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  18174. {
  18175. if (governmentRentCurrency.Equals("CNY"))
  18176. {
  18177. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18178. }
  18179. else
  18180. {
  18181. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  18182. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  18183. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  18184. }
  18185. }
  18186. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  18187. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  18188. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  18189. {
  18190. if (cityTaxStrCurrency1.Equals("CNY"))
  18191. {
  18192. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18193. }
  18194. else
  18195. {
  18196. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  18197. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  18198. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  18199. }
  18200. }
  18201. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  18202. int payDId = roomInfo?.PayDId ?? 0;
  18203. pcfds.Add(new HotelReservations_PCFD_View()
  18204. {
  18205. City = item.City,
  18206. HotelName = item.HotelName,
  18207. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18208. // SingleRoomCount = item.SingleRoomCount,
  18209. SingleRoomPrice = singleRoomFeeStr,
  18210. // DoubleRoomCount = item.DoubleRoomCount,
  18211. DoubleRoomPrice = doubleRoomFeeStr,
  18212. //SuiteRoomCount = item.SuiteRoomCount,
  18213. SuiteRoomPrice = suiteRoomFeeStr,
  18214. OtherRoomPrice = otherRoomFeeStr,
  18215. //OtherRoomCount = item.OtherRoomCount,
  18216. BreakfastPrice = breakfastPriceStr,
  18217. GovernmentRent = governmentRentStr,
  18218. CityTax = cityTaxStr,
  18219. RoomExplanation = item.RoomExplanation,
  18220. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18221. PayTime = roomInfo?.ConsumptionDate,
  18222. BankNo = roomInfo?.BankNo,
  18223. PayMoney = payMoneyStr,
  18224. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18225. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18226. CardPrice = cardPriceStr,
  18227. Remark = ccpInfo.Remark
  18228. });
  18229. }
  18230. #endregion
  18231. //载入模板
  18232. WorkbookDesigner designer = new WorkbookDesigner();
  18233. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18234. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18235. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18236. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18237. var rateDatas1 = rateDatas.Distinct();
  18238. var rateStr = string.Empty;
  18239. foreach (var item in rateDatas1)
  18240. {
  18241. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  18242. }
  18243. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  18244. designer.SetDataSource("Opertor", userInfo.CnName);
  18245. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18246. dt.TableName = "ViewMyHotelReservations";
  18247. designer.SetDataSource(dt);
  18248. designer.Process();
  18249. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18250. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18251. designer.Workbook.Save(serverPath);
  18252. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18253. #region 删除指定行
  18254. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18255. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18256. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18257. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18258. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18259. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18260. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18261. cssIndex = dt.Columns["CityTax"].Ordinal,
  18262. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18263. remarkIndex = dt.Columns["Remark"].Ordinal;
  18264. //删除指定列
  18265. foreach (DataRow item in dt.Rows)
  18266. {
  18267. string singleStr = item["SingleRoomPrice"].ToString();
  18268. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18269. if (containsDigitButNotZero1) singleDel = false;
  18270. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18271. string doubleStr = item["DoubleRoomPrice"].ToString();
  18272. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18273. if (containsDigitButNotZero2) doubleDel = false;
  18274. string suiteStr = item["SuiteRoomPrice"].ToString();
  18275. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18276. if (containsDigitButNotZero3) suiteDel = false;
  18277. string otherStr = item["OtherRoomPrice"].ToString();
  18278. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18279. if (containsDigitButNotZero4) otherDel = false;
  18280. string zcStr = item["BreakfastPrice"].ToString();
  18281. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18282. if (containsDigitButNotZero5) zcDel = false;
  18283. string dsStr = item["GovernmentRent"].ToString();
  18284. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18285. if (containsDigitButNotZero6) dsDel = false;
  18286. string cssStr = item["CityTax"].ToString();
  18287. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18288. if (containsDigitButNotZero7) cssDel = false;
  18289. string cpStr = item["ConsumptionPatterns"].ToString();
  18290. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18291. string remarkStr = item["Remark"].ToString();
  18292. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18293. }
  18294. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18295. DeleteColumn(serverPath, cpIndex, cpDel);
  18296. DeleteColumn(serverPath, dsIndex, dsDel);
  18297. DeleteColumn(serverPath, cssIndex, cssDel);
  18298. DeleteColumn(serverPath, zcIndex, zcDel);
  18299. DeleteColumn(serverPath, otherIndex, otherDel);
  18300. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18301. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18302. DeleteColumn(serverPath, singleIndex, singleDel);
  18303. #endregion
  18304. //只保留第一个表格
  18305. DeleteSheet(serverPath);
  18306. return Ok(JsonView(true, "操作成功", url = rst));
  18307. }
  18308. else
  18309. {
  18310. _currency = _GroupCostParameter.Currency;
  18311. bool isIntType = int.TryParse(_currency, out int currId);
  18312. if (isIntType)
  18313. {
  18314. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  18315. }
  18316. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  18317. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  18318. if (currInfo == null)
  18319. {
  18320. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  18321. }
  18322. if (!_currency.ToUpper().Equals("CNY"))
  18323. {
  18324. _rate = _GroupCostParameter.Rate;
  18325. }
  18326. _rate = currInfo.Rate;
  18327. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  18328. //string strFileName = "HotelStatement/";
  18329. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  18330. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  18331. #region 数据处理
  18332. foreach (var item in hrDtas)
  18333. {
  18334. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  18335. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  18336. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  18337. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  18338. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  18339. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  18340. string singleRoomFeeStr = string.Empty,
  18341. doubleRoomFeeStr = string.Empty,
  18342. suiteRoomFeeStr = string.Empty,
  18343. otherRoomFeeStr = string.Empty,
  18344. payMoneyStr = string.Empty,
  18345. cardPriceStr = string.Empty;
  18346. if (roomCurr.Equals(_currency))
  18347. {
  18348. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  18349. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  18350. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  18351. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  18352. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  18353. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  18354. }
  18355. else
  18356. {
  18357. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  18358. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  18359. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  18360. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  18361. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  18362. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  18363. }
  18364. string breakfastPriceStr = string.Empty,
  18365. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  18366. governmentRentStr = string.Empty,
  18367. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  18368. cityTaxStrStr = string.Empty,
  18369. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  18370. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  18371. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  18372. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  18373. int payDId = roomInfo?.PayDId ?? 0;
  18374. pcfds.Add(new HotelReservations_PCFD_View()
  18375. {
  18376. City = item.City,
  18377. HotelName = item.HotelName,
  18378. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  18379. // SingleRoomCount = item.SingleRoomCount,
  18380. SingleRoomPrice = singleRoomFeeStr,
  18381. // DoubleRoomCount = item.DoubleRoomCount,
  18382. DoubleRoomPrice = doubleRoomFeeStr,
  18383. //SuiteRoomCount = item.SuiteRoomCount,
  18384. SuiteRoomPrice = suiteRoomFeeStr,
  18385. OtherRoomPrice = otherRoomFeeStr,
  18386. //OtherRoomCount = item.OtherRoomCount,
  18387. BreakfastPrice = breakfastPriceStr,
  18388. GovernmentRent = governmentRentStr,
  18389. CityTax = cityTaxStrStr,
  18390. RoomExplanation = item.RoomExplanation,
  18391. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  18392. PayTime = roomInfo?.ConsumptionDate,
  18393. BankNo = roomInfo?.BankNo,
  18394. PayMoney = payMoneyStr,
  18395. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  18396. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  18397. CardPrice = cardPriceStr,
  18398. Remark = ccpInfo.Remark
  18399. });
  18400. }
  18401. #endregion
  18402. //载入模板
  18403. WorkbookDesigner designer = new WorkbookDesigner();
  18404. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  18405. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  18406. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  18407. designer.SetDataSource("TourNo", groupInfo.TourCode);
  18408. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  18409. designer.SetDataSource("Opertor", userInfo.CnName);
  18410. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  18411. dt.TableName = "ViewMyHotelReservations";
  18412. designer.SetDataSource(dt);
  18413. designer.Process();
  18414. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  18415. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  18416. designer.Workbook.Save(serverPath);
  18417. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  18418. #region 删除指定行
  18419. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  18420. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  18421. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  18422. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  18423. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  18424. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  18425. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  18426. cssIndex = dt.Columns["CityTax"].Ordinal,
  18427. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  18428. remarkIndex = dt.Columns["Remark"].Ordinal;
  18429. //删除指定列
  18430. foreach (DataRow item in dt.Rows)
  18431. {
  18432. string singleStr = item["SingleRoomPrice"].ToString();
  18433. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  18434. if (containsDigitButNotZero1) singleDel = false;
  18435. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  18436. string doubleStr = item["DoubleRoomPrice"].ToString();
  18437. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18438. if (containsDigitButNotZero2) doubleDel = false;
  18439. string suiteStr = item["SuiteRoomPrice"].ToString();
  18440. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  18441. if (containsDigitButNotZero3) suiteDel = false;
  18442. string otherStr = item["OtherRoomPrice"].ToString();
  18443. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  18444. if (containsDigitButNotZero4) otherDel = false;
  18445. string zcStr = item["BreakfastPrice"].ToString();
  18446. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  18447. if (containsDigitButNotZero5) zcDel = false;
  18448. string dsStr = item["GovernmentRent"].ToString();
  18449. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  18450. if (containsDigitButNotZero6) dsDel = false;
  18451. string cssStr = item["CityTax"].ToString();
  18452. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  18453. if (containsDigitButNotZero7) cssDel = false;
  18454. string cpStr = item["ConsumptionPatterns"].ToString();
  18455. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  18456. string remarkStr = item["Remark"].ToString();
  18457. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  18458. }
  18459. DeleteColumn(serverPath, remarkIndex, remarkDel);
  18460. DeleteColumn(serverPath, cpIndex, cpDel);
  18461. DeleteColumn(serverPath, dsIndex, dsDel);
  18462. DeleteColumn(serverPath, cssIndex, cssDel);
  18463. DeleteColumn(serverPath, zcIndex, zcDel);
  18464. DeleteColumn(serverPath, otherIndex, otherDel);
  18465. DeleteColumn(serverPath, suiteIndex, suiteDel);
  18466. DeleteColumn(serverPath, doubleIndex, doubleDel);
  18467. DeleteColumn(serverPath, singleIndex, singleDel);
  18468. #endregion
  18469. //只保留第一个表格
  18470. DeleteSheet(serverPath);
  18471. return Ok(JsonView(true, "操作成功", url = rst));
  18472. }
  18473. //return Ok(JsonView(false));
  18474. }
  18475. /// <summary>
  18476. /// 删除指定列
  18477. /// </summary>
  18478. /// <param name="file"></param>
  18479. /// <param name="columnIndex"></param>
  18480. /// <param name="isDel"></param>
  18481. private void DeleteColumn(string file, int columnIndex, bool isDel)
  18482. {
  18483. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18484. //wb.Save(file);
  18485. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  18486. if (sheet1 != null)
  18487. {
  18488. if (isDel)
  18489. {
  18490. Cells cells = sheet1.Cells;
  18491. cells.DeleteColumn(columnIndex);
  18492. }
  18493. }
  18494. wb.Save(file);
  18495. }
  18496. /// <summary>
  18497. /// 删除sheet
  18498. /// </summary>
  18499. /// <param name="file"></param>
  18500. /// <param name="sheetName"></param>
  18501. private void DeleteSheet(string file, string sheetName = "")
  18502. {
  18503. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  18504. //wb.Save(file);
  18505. List<string> sheets = new List<string>();
  18506. foreach (var item in wb.Worksheets)
  18507. {
  18508. sheets.Add(item.Name);
  18509. }
  18510. if (sheets.Count > 0)
  18511. {
  18512. sheets.RemoveAt(0);//不删除第一个sheet
  18513. foreach (var item in sheets)
  18514. {
  18515. wb.Worksheets.RemoveAt(item);
  18516. }
  18517. }
  18518. wb.Save(file);
  18519. }
  18520. /// <summary>
  18521. /// 酒店预订
  18522. /// 确认单
  18523. /// </summary>
  18524. /// <param name="_dto"></param>
  18525. /// <returns></returns>
  18526. [HttpPost]
  18527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18528. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  18529. {
  18530. try
  18531. {
  18532. #region 参数验证
  18533. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  18534. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18535. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  18536. #region 团组操作权限验证 76 酒店预定模块
  18537. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18538. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  18539. #endregion
  18540. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18541. #region 页面操作权限验证
  18542. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18543. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18544. #endregion
  18545. #endregion
  18546. //团组信息
  18547. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  18548. //酒店数据
  18549. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  18550. if (listhoteldata.Count < 0)
  18551. {
  18552. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  18553. }
  18554. //利datatable存储
  18555. DataTable dt = new DataTable();
  18556. dt.Columns.Add("CheckInDate", typeof(string));
  18557. dt.Columns.Add("City", typeof(string));
  18558. dt.Columns.Add("Hotel", typeof(string));
  18559. dt.Columns.Add("Room", typeof(string));
  18560. for (int i = 0; i < listhoteldata.Count; i++)
  18561. {
  18562. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  18563. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  18564. while (dayStart < dayEnd)
  18565. {
  18566. string temp = "";
  18567. DataRow row = dt.NewRow();
  18568. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  18569. row["City"] = listhoteldata[i].City;
  18570. row["Hotel"] = listhoteldata[i].HotelName;
  18571. if (listhoteldata[i].SingleRoomCount > 0)
  18572. {
  18573. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  18574. }
  18575. if (listhoteldata[i].DoubleRoomCount > 0)
  18576. {
  18577. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  18578. }
  18579. if (listhoteldata[i].SuiteRoomCount > 0)
  18580. {
  18581. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  18582. }
  18583. if (listhoteldata[i].OtherRoomCount > 0)
  18584. {
  18585. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  18586. }
  18587. row["Room"] = temp;
  18588. dt.Rows.Add(row);
  18589. dayStart = dayStart.AddDays(1);
  18590. }
  18591. }
  18592. Dictionary<string, string> dic = new Dictionary<string, string>();
  18593. dic.Add("Dele", di.TeamName);
  18594. dic.Add("City", di.VisitCountry);
  18595. //模板路径
  18596. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  18597. //载入模板
  18598. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  18599. DocumentBuilder builder = new DocumentBuilder(doc);
  18600. foreach (var key in dic.Keys)
  18601. {
  18602. builder.MoveToBookmark(key);
  18603. builder.Write(dic[key]);
  18604. }
  18605. //获取word里所有表格
  18606. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  18607. //获取所填表格的序数
  18608. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  18609. var rowStart = tableOne.Rows[0]; //获取第1行
  18610. //循环赋值
  18611. for (int i = 0; i < dt.Rows.Count; i++)
  18612. {
  18613. builder.MoveToCell(0, i + 1, 0, 0);
  18614. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  18615. builder.MoveToCell(0, i + 1, 1, 0);
  18616. builder.Write(dt.Rows[i]["City"].ToString());
  18617. builder.MoveToCell(0, i + 1, 2, 0);
  18618. builder.Write(dt.Rows[i]["Hotel"].ToString());
  18619. builder.MoveToCell(0, i + 1, 3, 0);
  18620. builder.Write(dt.Rows[i]["Room"].ToString());
  18621. }
  18622. //删除多余行
  18623. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  18624. {
  18625. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  18626. }
  18627. string strFileName = di.TeamName + "酒店确认单.doc";
  18628. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  18629. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  18630. return Ok(JsonView(true, "成功", url));
  18631. }
  18632. catch (Exception ex)
  18633. {
  18634. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  18635. }
  18636. }
  18637. #endregion
  18638. #region 团组状态
  18639. /// <summary>
  18640. /// 团组状态列表 Page
  18641. /// </summary>
  18642. /// <param name="dto">团组列表请求dto</param>
  18643. /// <returns></returns>
  18644. [HttpPost]
  18645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18646. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  18647. {
  18648. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18649. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  18650. {
  18651. string sqlWhere = string.Empty;
  18652. if (dto.IsSure == 0) //未完成
  18653. {
  18654. sqlWhere += string.Format(@" And IsSure = 0");
  18655. }
  18656. else if (dto.IsSure == 1) //已完成
  18657. {
  18658. sqlWhere += string.Format(@" And IsSure = 1");
  18659. }
  18660. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  18661. {
  18662. string tj = dto.SearchCriteria;
  18663. 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}%')",
  18664. tj, tj, tj, tj, tj);
  18665. }
  18666. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  18667. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  18668. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  18669. From (
  18670. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  18671. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  18672. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  18673. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  18674. From Grp_DelegationInfo gdi
  18675. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  18676. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  18677. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  18678. Where gdi.IsDel = 0 {0}
  18679. ) temp ", sqlWhere);
  18680. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  18681. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  18682. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  18683. }
  18684. else
  18685. {
  18686. return Ok(JsonView(false, "查询失败"));
  18687. }
  18688. }
  18689. /// <summary>
  18690. /// 团组状态
  18691. /// 设置操作完成
  18692. /// </summary>
  18693. /// <param name="dto">团组列表请求dto</param>
  18694. /// <returns></returns>
  18695. [HttpPost]
  18696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18697. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  18698. {
  18699. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  18700. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  18701. {
  18702. Id = dto.Id,
  18703. IsSure = 1
  18704. };
  18705. var result = await _sqlSugar.Updateable(_DelegationInfo)
  18706. .UpdateColumns(it => new { it.IsSure })
  18707. .WhereColumns(it => new { it.Id })
  18708. .ExecuteCommandAsync();
  18709. if (result > 0)
  18710. {
  18711. return Ok(JsonView(true, "操作完成!"));
  18712. }
  18713. return Ok(JsonView(false, "操作失败!"));
  18714. }
  18715. #endregion
  18716. #region 保险费用录入
  18717. /// <summary>
  18718. /// 根据团组Id查询保险费用列表
  18719. /// </summary>
  18720. /// <param name="dto"></param>
  18721. /// <returns></returns>
  18722. [HttpPost]
  18723. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18724. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  18725. {
  18726. Result groupData = await _customersRep.CustomersByDiId(dto);
  18727. if (groupData.Code != 0)
  18728. {
  18729. return Ok(JsonView(false, groupData.Msg));
  18730. }
  18731. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18732. }
  18733. /// <summary>
  18734. /// 根据保险费用Id查询保险费用详细
  18735. /// </summary>
  18736. /// <param name="dto"></param>
  18737. /// <returns></returns>
  18738. [HttpPost]
  18739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18740. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  18741. {
  18742. try
  18743. {
  18744. Result groupData = await _customersRep.CustomersById(dto);
  18745. if (groupData.Code != 0)
  18746. {
  18747. return Ok(JsonView(false, groupData.Msg));
  18748. }
  18749. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18750. }
  18751. catch (Exception ex)
  18752. {
  18753. return Ok(JsonView(false, ex.Message));
  18754. }
  18755. }
  18756. /// <summary>
  18757. /// 保险费用录入页面初始化绑定
  18758. /// </summary>
  18759. /// <param name="dto"></param>
  18760. /// <returns></returns>
  18761. [HttpPost]
  18762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18763. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  18764. {
  18765. try
  18766. {
  18767. Result groupData = await _customersRep.CustomersInitialize(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. /// 保险费用操作(Status:1.新增,2.修改)
  18781. /// </summary>
  18782. /// <param name="dto"></param>
  18783. /// <returns></returns>
  18784. [HttpPost]
  18785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18786. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  18787. {
  18788. Result groupData = await _customersRep.OpCustomers(dto);
  18789. if (groupData.Code != 0)
  18790. {
  18791. return Ok(JsonView(false, groupData.Msg));
  18792. }
  18793. #region 应用推送
  18794. try
  18795. {
  18796. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  18797. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  18798. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  18799. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  18800. //自动审核
  18801. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  18802. //2024-10-21 新增LZ UID
  18803. var userIds = new List<int>() { 21 };
  18804. string title = $"系统通知";
  18805. var diId = dto.DiId;
  18806. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18807. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18808. string content = "";
  18809. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18810. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18811. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18812. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  18813. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  18814. }
  18815. catch (Exception ex)
  18816. {
  18817. }
  18818. #endregion
  18819. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  18820. }
  18821. /// <summary>
  18822. /// 保险文件上传
  18823. /// </summary>
  18824. /// <param name="file"></param>
  18825. /// <returns></returns>
  18826. [HttpPost]
  18827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18828. public async Task<IActionResult> UploadCus(IFormFile file)
  18829. {
  18830. try
  18831. {
  18832. if (file != null)
  18833. {
  18834. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18835. //文件名称
  18836. string projectFileName = file.FileName;
  18837. //上传的文件的路径
  18838. string filePath = "";
  18839. if (!Directory.Exists(fileDir))
  18840. {
  18841. Directory.CreateDirectory(fileDir);
  18842. }
  18843. //上传的文件的路径
  18844. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  18845. using (FileStream fs = System.IO.File.Create(filePath))
  18846. {
  18847. file.CopyTo(fs);
  18848. fs.Flush();
  18849. }
  18850. return Ok(JsonView(true, "上传成功!", projectFileName));
  18851. }
  18852. else
  18853. {
  18854. return Ok(JsonView(false, "上传失败!"));
  18855. }
  18856. }
  18857. catch (Exception ex)
  18858. {
  18859. return Ok(JsonView(false, "程序错误!"));
  18860. throw;
  18861. }
  18862. }
  18863. /// <summary>
  18864. /// 保险删除指定文件
  18865. /// </summary>
  18866. /// <param name="dto"></param>
  18867. /// <returns></returns>
  18868. [HttpPost]
  18869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18870. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  18871. {
  18872. try
  18873. {
  18874. string filePath = "";
  18875. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  18876. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  18877. //int id = 0;
  18878. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  18879. // 删除该文件
  18880. try
  18881. {
  18882. System.IO.File.Delete(filePath);
  18883. 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()
  18884. {
  18885. Attachment = "",
  18886. }).ExecuteCommandAsync();
  18887. if (result != 0)
  18888. {
  18889. return Ok(JsonView(true, "成功!"));
  18890. }
  18891. else
  18892. {
  18893. return Ok(JsonView(false, "失败!"));
  18894. }
  18895. }
  18896. catch (Exception)
  18897. {
  18898. 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()
  18899. {
  18900. Attachment = "",
  18901. }).ExecuteCommandAsync();
  18902. if (result != 0)
  18903. {
  18904. return Ok(JsonView(true, "成功!"));
  18905. }
  18906. else
  18907. {
  18908. return Ok(JsonView(false, "失败!"));
  18909. }
  18910. }
  18911. }
  18912. catch (Exception ex)
  18913. {
  18914. return Ok(JsonView(false, "程序错误!"));
  18915. throw;
  18916. }
  18917. }
  18918. /// <summary>
  18919. /// 保险费用操作(删除)
  18920. /// </summary>
  18921. /// <param name="dto"></param>
  18922. /// <returns></returns>
  18923. [HttpPost]
  18924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18925. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  18926. {
  18927. try
  18928. {
  18929. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  18930. if (!res)
  18931. {
  18932. return Ok(JsonView(false, "删除失败"));
  18933. }
  18934. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  18935. {
  18936. IsDel = 1,
  18937. DeleteUserId = dto.DeleteUserId,
  18938. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  18939. }).ExecuteCommandAsync();
  18940. return Ok(JsonView(true, "删除成功!"));
  18941. }
  18942. catch (Exception ex)
  18943. {
  18944. return Ok(JsonView(false, "程序错误!"));
  18945. throw;
  18946. }
  18947. }
  18948. #endregion
  18949. #region 接团客户名单 PageId 104
  18950. /// <summary>
  18951. /// 接团客户名单
  18952. /// 迁移数据(慎用!)
  18953. /// </summary>
  18954. /// <returns></returns>
  18955. [HttpPost]
  18956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18957. public async Task<IActionResult> PostTourClientListChange()
  18958. {
  18959. try
  18960. {
  18961. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  18962. //var groupClinetData1
  18963. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  18964. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  18965. int updateCount = 0;
  18966. if (oldOAClientList.Count > 0)
  18967. {
  18968. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  18969. _sqlSugar.BeginTran();
  18970. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  18971. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  18972. foreach (var item in oldOAClientList)
  18973. {
  18974. int comId = 0;
  18975. string format = "yyyy-MM-dd HH:mm:ss";
  18976. string data11 = "1990-01-01 00:00";
  18977. var data1 = IsValidDate(item.OPdate, format);
  18978. if (data1) data11 = item.OPdate;
  18979. //客户公司验证
  18980. if (!string.IsNullOrEmpty(item.Company))
  18981. {
  18982. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  18983. if (clientComInfo == null) // add
  18984. {
  18985. var addInfo = new Crm_CustomerCompany()
  18986. {
  18987. CompanyAbbreviation = "",
  18988. CompanyFullName = item.Company,
  18989. Address = "",
  18990. PostCodes = "",
  18991. LastedOpUserId = item.OPer,
  18992. LastedOpDt = Convert.ToDateTime(data11),
  18993. CreateUserId = item.OPer,
  18994. CreateTime = Convert.ToDateTime(data11),
  18995. IsDel = 0
  18996. };
  18997. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  18998. if (comId1 > 0) comId = comId1;
  18999. }
  19000. else comId = clientComInfo.Id;
  19001. }
  19002. //客户人员验证
  19003. int clientId = 0;
  19004. string name = item.LastName + item.Name;
  19005. if (!string.IsNullOrEmpty(name))
  19006. {
  19007. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  19008. if (clientInfo == null)
  19009. {
  19010. DateTime? dateTime = null;
  19011. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  19012. if (isDt) dateTime = birthDayDt;
  19013. var addInfo1 = new Crm_DeleClient()
  19014. {
  19015. CrmCompanyId = comId,
  19016. DiId = -1,
  19017. LastName = item.LastName,
  19018. FirstName = item.Name,
  19019. OldName = "",
  19020. Pinyin = item.Pinyin,
  19021. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  19022. Marriage = 0,
  19023. Phone = item.Phone,
  19024. Job = item.Job,
  19025. BirthDay = dateTime
  19026. };
  19027. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  19028. if (clientId1 > 0) clientId = clientId1;
  19029. }
  19030. else clientId = clientInfo.Id;
  19031. }
  19032. if (clientId < 1)
  19033. {
  19034. continue;
  19035. }
  19036. int airType = 0;
  19037. if (item.AirType == "超经舱") airType = 459;
  19038. else if (item.AirType == "公务舱") airType = 458;
  19039. else if (item.AirType == "经济舱") airType = 460;
  19040. else if (item.AirType == "其他") airType = 565;
  19041. else if (item.AirType == "头等舱") airType = 457;
  19042. var _TourClientListEntity = new Grp_TourClientList()
  19043. {
  19044. DiId = item.Diid,
  19045. ClientId = clientId,
  19046. CreateUserId = item.OPer,
  19047. CreateTime = Convert.ToDateTime(data11),
  19048. Remark = item.Remark,
  19049. IsDel = item.Isdel,
  19050. ShippingSpaceTypeId = airType,
  19051. ShippingSpaceSpecialNeeds = item.AirRemark,
  19052. HotelSpecialNeeds = item.RoomType
  19053. };
  19054. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  19055. if (_TourClientList > 0)
  19056. {
  19057. updateCount++;
  19058. }
  19059. }
  19060. _sqlSugar.CommitTran();
  19061. }
  19062. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  19063. }
  19064. catch (Exception ex)
  19065. {
  19066. _sqlSugar.RollbackTran();
  19067. return Ok(JsonView(false, ex.Message));
  19068. }
  19069. //return Ok(JsonView(true));
  19070. }
  19071. private bool IsValidDate(string dateString, string format)
  19072. {
  19073. DateTime dateValue;
  19074. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  19075. return valid;
  19076. }
  19077. /// <summary>
  19078. /// 接团客户名单
  19079. /// 根据团组Id查询List
  19080. /// </summary>
  19081. /// <param name="_dto"></param>
  19082. /// <returns></returns>
  19083. [HttpPost]
  19084. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19085. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  19086. {
  19087. #region 参数验证
  19088. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  19089. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  19090. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  19091. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19092. #region 页面操作权限验证
  19093. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19094. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19095. #endregion
  19096. #endregion
  19097. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  19098. if (viewData.Code != 0)
  19099. {
  19100. return Ok(JsonView(false, viewData.Msg));
  19101. }
  19102. return Ok(JsonView(viewData.Data));
  19103. }
  19104. /// <summary>
  19105. /// 接团客户名单
  19106. /// 基础数据 Init
  19107. /// </summary>
  19108. /// <param name="_dto"></param>
  19109. /// <returns></returns>
  19110. [HttpPost]
  19111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19112. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  19113. {
  19114. #region 参数验证
  19115. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19116. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19117. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19118. #region 页面操作权限验证
  19119. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19120. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19121. #endregion
  19122. #endregion
  19123. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  19124. }
  19125. /// <summary>
  19126. /// 接团客户名单
  19127. /// 根据 Id查询 Details
  19128. /// </summary>
  19129. /// <param name="_dto"></param>
  19130. /// <returns></returns>
  19131. [HttpPost]
  19132. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19133. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  19134. {
  19135. #region 参数验证
  19136. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19137. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19138. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19139. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19140. #region 页面操作权限验证
  19141. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19142. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  19143. #endregion
  19144. #endregion
  19145. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  19146. if (viewData.Code != 0)
  19147. {
  19148. return Ok(JsonView(false, viewData.Msg));
  19149. }
  19150. return Ok(JsonView(viewData.Data));
  19151. }
  19152. /// <summary>
  19153. /// 接团客户名单
  19154. /// Add Or Edit
  19155. /// </summary>
  19156. /// <param name="_dto"></param>
  19157. /// <returns></returns>
  19158. [HttpPost]
  19159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19160. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  19161. {
  19162. #region 参数验证
  19163. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19164. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19165. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  19166. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19167. #region 页面操作权限验证
  19168. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19169. if (_dto.Id == 0) //添加
  19170. {
  19171. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19172. }
  19173. else if (_dto.Id >= 0) //修改
  19174. {
  19175. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  19176. }
  19177. #endregion
  19178. #endregion
  19179. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  19180. if (viewData.Code != 0)
  19181. {
  19182. return Ok(JsonView(false, viewData.Msg));
  19183. }
  19184. return Ok(JsonView(true));
  19185. }
  19186. /// <summary>
  19187. /// 接团客户名单
  19188. /// json字符串 AddMultiple(添加多个)
  19189. /// </summary>
  19190. /// <param name="_dto"></param>
  19191. /// <returns></returns>
  19192. [HttpPost]
  19193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19194. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  19195. {
  19196. #region 参数验证
  19197. string jsonLabel = _dto.JsonLabel;
  19198. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19199. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19200. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19201. #region 页面操作权限验证
  19202. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19203. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19204. #endregion
  19205. #endregion
  19206. var request = new TourClientListAddMultipleDto();
  19207. request.DiId = _dto.DiId;
  19208. request.UserId = _dto.UserId;
  19209. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  19210. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  19211. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  19212. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  19213. var infos = new List<TourClientListInfo>();
  19214. foreach (var data in datas)
  19215. {
  19216. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  19217. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  19218. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  19219. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  19220. {
  19221. continue;
  19222. }
  19223. infos.Add(new TourClientListInfo()
  19224. {
  19225. IsAccompany = 1,
  19226. LastName = lastName,
  19227. FirstName = firstName,
  19228. Pinyin = lastNameEn + @"/" + firstNameEn,
  19229. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  19230. CompanyFullName = data.CompanyFullName,
  19231. Job = data.Job
  19232. });
  19233. }
  19234. if (infos.Any())
  19235. {
  19236. var viewData = await _tourClientListRep._AddMultiple(request);
  19237. if (viewData.Code != 0)
  19238. {
  19239. return Ok(JsonView(false, viewData.Msg));
  19240. }
  19241. return Ok(JsonView(true));
  19242. }
  19243. return Ok(JsonView(false));
  19244. }
  19245. /// <summary>
  19246. /// 接团客户名单
  19247. /// AddMultiple(添加多个)
  19248. /// </summary>
  19249. /// <param name="_dto"></param>
  19250. /// <returns></returns>
  19251. [HttpPost]
  19252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19253. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  19254. {
  19255. #region 参数验证
  19256. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19257. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19258. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19259. #region 页面操作权限验证
  19260. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19261. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  19262. #endregion
  19263. #endregion
  19264. var viewData = await _tourClientListRep._AddMultiple(_dto);
  19265. if (viewData.Code != 0)
  19266. {
  19267. return Ok(JsonView(false, viewData.Msg));
  19268. }
  19269. return Ok(JsonView(true));
  19270. }
  19271. /// <summary>
  19272. /// 接团客户名单
  19273. /// Del
  19274. /// </summary>
  19275. /// <param name="_dto"></param>
  19276. /// <returns></returns>
  19277. [HttpPost]
  19278. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19279. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  19280. {
  19281. #region 参数验证
  19282. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19283. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19284. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19285. #region 页面操作权限验证
  19286. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19287. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  19288. #endregion
  19289. #endregion
  19290. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  19291. if (viewData.Code != 0)
  19292. {
  19293. return Ok(JsonView(false, viewData.Msg));
  19294. }
  19295. return Ok(JsonView(true));
  19296. }
  19297. /// <summary>
  19298. /// 接团客户名单
  19299. /// 文件下载 客户名单
  19300. /// </summary>
  19301. /// <param name="_dto"></param>
  19302. /// <returns></returns>
  19303. [HttpPost]
  19304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19305. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  19306. {
  19307. #region 参数验证
  19308. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  19309. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  19310. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  19311. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19312. #region 页面操作权限验证
  19313. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19314. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19315. #endregion
  19316. #endregion
  19317. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  19318. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  19319. From Grp_TourClientList tcl
  19320. Left Join
  19321. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  19322. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  19323. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  19324. From Crm_DeleClient dc
  19325. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  19326. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  19327. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  19328. Where dc.IsDel = 0) temp
  19329. On temp.DcId =tcl.ClientId
  19330. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  19331. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  19332. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  19333. //载入模板
  19334. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  19335. if (_dto.Language == 1)
  19336. {
  19337. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  19338. }
  19339. //载入模板
  19340. var doc = new Document(tempPath);
  19341. DocumentBuilder builder = new DocumentBuilder(doc);
  19342. //获取word里所有表格
  19343. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19344. //获取所填表格的序数
  19345. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  19346. var rowStart = tableOne.Rows[0]; //获取第1行
  19347. if (_dto.Language == 0)
  19348. {
  19349. //循环赋值
  19350. for (int i = 0; i < DcList.Count; i++)
  19351. {
  19352. EncryptionProcessor.DecryptProperties(DcList[i]);
  19353. builder.MoveToCell(0, i + 1, 0, 0);
  19354. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  19355. builder.MoveToCell(0, i + 1, 1, 0);
  19356. int sex = DcList[i].Sex;
  19357. string sexStr = string.Empty;
  19358. if (sex == 0) sexStr = "男";
  19359. else if (sex == 1) sexStr = "女";
  19360. else sexStr = "未设置";
  19361. builder.Write(sexStr);
  19362. builder.MoveToCell(0, i + 1, 2, 0);
  19363. string birthDay = DcList[i].BirthDay;
  19364. string birthDayStr = string.Empty;
  19365. if (!string.IsNullOrEmpty(birthDay))
  19366. {
  19367. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  19368. }
  19369. builder.Write(birthDayStr);
  19370. builder.MoveToCell(0, i + 1, 3, 0);
  19371. string company = "";
  19372. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19373. {
  19374. company = DcList[i].CompanyFullName.ToString();
  19375. }
  19376. builder.Write(company);
  19377. builder.MoveToCell(0, i + 1, 4, 0);
  19378. builder.Write(DcList[i].Job);
  19379. }
  19380. }
  19381. else if (_dto.Language == 1)
  19382. {
  19383. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  19384. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  19385. List<string> transArrayStr = new List<string>();
  19386. string transStrRes1 = "";
  19387. for (int i = 0; i < DcList.Count; i++)
  19388. {
  19389. var dc = DcList[i];
  19390. EncryptionProcessor.DecryptProperties(dc);
  19391. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  19392. if (dc.Job.Equals("暂无")) dc.Job = "-";
  19393. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  19394. if (DcList.Count - 1 == i) transStrRes1 += str1;
  19395. else transStrRes1 += $"{str1}|";
  19396. }
  19397. #region AI转英文
  19398. string jsonValue = JsonConvert.SerializeObject(DcList);
  19399. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  19400. List<SeedMessages> messages = new List<SeedMessages>()
  19401. {
  19402. new SeedMessages
  19403. {
  19404. Role = KimiRole.user,
  19405. Content = jsonValue + text
  19406. }
  19407. };
  19408. KiMiApiClient client = new KiMiApiClient();
  19409. var kimiApiResult = await client.SeedMessage(messages);
  19410. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19411. string clients = kimiApiResult_JObject["content"].ToString();
  19412. string startStr = "```json", endStr = "```";
  19413. // 判断并清除开头部分
  19414. if (clients.StartsWith(startStr))
  19415. {
  19416. clients = clients.Remove(0, startStr.Length);
  19417. }
  19418. // 判断并清除结尾部分
  19419. if (clients.EndsWith(endStr))
  19420. {
  19421. clients = clients.Remove(clients.Length - endStr.Length);
  19422. }
  19423. var en_Json = JsonConvert.DeserializeObject<List<TourClientListDetailsView>>(clients);
  19424. //循环赋值
  19425. for (int i = 0; i < en_Json.Count; i++)
  19426. {
  19427. var dc = en_Json[i];
  19428. var dc1 = DcList.Find(x => x.Id == dc.Id);
  19429. string PYName = dc.FirstName + " " + dc.LastName;
  19430. builder.MoveToCell(0, i + 1, 0, 0);
  19431. builder.Write(PYName);
  19432. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  19433. builder.MoveToCell(0, i + 1, 1, 0);
  19434. builder.Write(sex);
  19435. DateTime birthDt;
  19436. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  19437. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19438. builder.MoveToCell(0, i + 1, 2, 0);
  19439. builder.Write(birthday);
  19440. string company = string.Empty, job = string.Empty;
  19441. company = dc.CompanyFullName;
  19442. job = dc.Job;
  19443. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  19444. {
  19445. //查询对照表
  19446. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  19447. if (tempCec != null)
  19448. {
  19449. company = tempCec.enName;
  19450. }
  19451. }
  19452. builder.MoveToCell(0, i + 1, 3, 0);
  19453. builder.Write(company);
  19454. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  19455. {
  19456. //查询对照表
  19457. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  19458. if (tempPec != null)
  19459. {
  19460. job = tempPec.enName;
  19461. }
  19462. }
  19463. builder.MoveToCell(0, i + 1, 4, 0);
  19464. builder.Write(job);
  19465. }
  19466. #endregion
  19467. #region 旧翻译英文处理
  19468. ////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";
  19469. //string transStrRes = "";
  19470. //if (transStrRes1.Length > 0)
  19471. //{
  19472. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  19473. //}
  19474. ////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
  19475. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  19476. ////List<string> transArray = new List<string> { };
  19477. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  19478. //if (transStrRes.Contains("|"))
  19479. //{
  19480. // string[] transArray1 = transStrRes.Split('|');
  19481. // if (transArray1.Length > 0)
  19482. // {
  19483. // foreach (var item in transArray1)
  19484. // {
  19485. // if (item.Contains("&"))
  19486. // {
  19487. // string[] transArray2 = item.Split('&');
  19488. // int index = 0;
  19489. // string companyName = "", job = "";
  19490. // if (transArray2.Length > 0)
  19491. // {
  19492. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  19493. // if (1 < transArray2.Length) companyName = transArray2[1];
  19494. // if (2 < transArray2.Length) job = transArray2[2];
  19495. // }
  19496. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  19497. // }
  19498. // }
  19499. // }
  19500. //}
  19501. ////循环赋值
  19502. //for (int i = 0; i < DcList.Count; i++)
  19503. //{
  19504. // string PYName = "";
  19505. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  19506. // {
  19507. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  19508. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  19509. // PYName = PY_First + " " + PY_Last;
  19510. // }
  19511. // else
  19512. // {
  19513. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  19514. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  19515. // PYName = PY_First + " " + PY_Last;
  19516. // }
  19517. // builder.MoveToCell(0, i + 1, 0, 0);
  19518. // builder.Write(PYName);
  19519. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  19520. // builder.MoveToCell(0, i + 1, 1, 0);
  19521. // builder.Write(sex);
  19522. // DateTime birthDt;
  19523. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  19524. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  19525. // builder.MoveToCell(0, i + 1, 2, 0);
  19526. // builder.Write(birthday);
  19527. // string company = string.Empty, job = string.Empty;
  19528. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  19529. // if (dcTransInfo != null)
  19530. // {
  19531. // company = dcTransInfo.CompanyName;
  19532. // job = dcTransInfo.Job;
  19533. // }
  19534. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  19535. // {
  19536. // //查询对照表
  19537. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  19538. // if (tempCec != null)
  19539. // {
  19540. // company = tempCec.enName;
  19541. // }
  19542. // //翻译
  19543. // else
  19544. // {
  19545. // }
  19546. // }
  19547. // builder.MoveToCell(0, i + 1, 3, 0);
  19548. // builder.Write(company);
  19549. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  19550. // {
  19551. // //查询对照表
  19552. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  19553. // if (tempPec != null)
  19554. // {
  19555. // job = tempPec.enName;
  19556. // }
  19557. // //翻译
  19558. // else
  19559. // {
  19560. // }
  19561. // }
  19562. // builder.MoveToCell(0, i + 1, 4, 0);
  19563. // builder.Write(job);
  19564. //}
  19565. #endregion
  19566. }
  19567. //删除多余行
  19568. while (tableOne.Rows.Count > DcList.Count + 1)
  19569. {
  19570. tableOne.Rows.RemoveAt(DcList.Count + 1);
  19571. }
  19572. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  19573. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  19574. doc.Save(fileDir);
  19575. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  19576. return Ok(JsonView(true, "操作成功!", Url));
  19577. }
  19578. private class TranslateInfo
  19579. {
  19580. public int Index { get; set; }
  19581. public string CompanyName { get; set; }
  19582. public string Job { get; set; }
  19583. }
  19584. [HttpPost]
  19585. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  19586. {
  19587. if (files.Count == 0)
  19588. {
  19589. return Ok(JsonView(false, "文件为空"));
  19590. }
  19591. KiMiApiClient KiMiApi = new KiMiApiClient();
  19592. var seedConter = await KiMiApi.UploadFilesAsync(files);
  19593. if (seedConter.Count == 0)
  19594. {
  19595. return Ok(JsonView(false, "上传结果为空!"));
  19596. }
  19597. var messages = new List<SeedMessages>
  19598. {
  19599. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  19600. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理,文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  19601. };
  19602. messages.InsertRange(1, seedConter);
  19603. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  19604. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  19605. string clients = kimiApiResult_JObject["content"].ToString();
  19606. string startStr = "```json", endStr = "```";
  19607. // 判断并清除开头部分
  19608. if (clients.StartsWith(startStr))
  19609. {
  19610. clients = clients.Remove(0, startStr.Length);
  19611. }
  19612. // 判断并清除结尾部分
  19613. if (clients.EndsWith(endStr))
  19614. {
  19615. clients = clients.Remove(clients.Length - endStr.Length);
  19616. }
  19617. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  19618. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  19619. {
  19620. {"姓", "LastName" },
  19621. {"名", "FirstName" },
  19622. {"姓名拼音", "Pinyin" },
  19623. {"性别", "Sex" },
  19624. {"单位", "CompanyFullName" },
  19625. {"职务", "Job" },
  19626. {"出生日期", "Birthday" },
  19627. };
  19628. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  19629. foreach (var item in clients_JObject)
  19630. {
  19631. BaiduClientOCRView cdc = new BaiduClientOCRView();
  19632. foreach (var field in clientFieldMap.Keys)
  19633. {
  19634. if (item.TryGetValue(field, out JToken value))
  19635. {
  19636. var getValue = value.ToString();
  19637. System.Type type = cdc.GetType();
  19638. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  19639. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  19640. propertyInfo.SetValue(cdc, propertyValue);
  19641. }
  19642. }
  19643. crmClients.Add(cdc);
  19644. }
  19645. return Ok(JsonView(new
  19646. {
  19647. fileCount = files.Count,
  19648. UploadCount = seedConter.Count,
  19649. ApiResult = clients,
  19650. CrmClients = crmClients
  19651. }));
  19652. }
  19653. #endregion
  19654. #region 团组倒推表
  19655. /// <summary>
  19656. /// 倒推表基础数据
  19657. /// Init
  19658. /// </summary>
  19659. /// <returns></returns>
  19660. [HttpPost]
  19661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19662. public async Task<IActionResult> PostInvertedListInit()
  19663. {
  19664. var viewData = await _invertedListRep._Init();
  19665. if (viewData.Code != 0)
  19666. {
  19667. return Ok(JsonView(false, viewData.Msg));
  19668. }
  19669. return Ok(JsonView(viewData.Data));
  19670. }
  19671. /// <summary>
  19672. /// 倒推表
  19673. /// Info
  19674. /// </summary>
  19675. /// <param name="dto"></param>
  19676. /// <returns></returns>
  19677. [HttpPost]
  19678. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19679. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  19680. {
  19681. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  19682. if (viewData.Code != 0)
  19683. {
  19684. return Ok(JsonView(false, viewData.Msg));
  19685. }
  19686. return Ok(JsonView(viewData.Data));
  19687. }
  19688. /// <summary>
  19689. /// 倒推表
  19690. /// Create
  19691. /// </summary>
  19692. /// <param name="dto"></param>
  19693. /// <returns></returns>
  19694. [HttpPost]
  19695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19696. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  19697. {
  19698. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  19699. if (viewData.Code != 0)
  19700. {
  19701. return Ok(JsonView(false, viewData.Msg));
  19702. }
  19703. return Ok(JsonView(viewData.Data));
  19704. }
  19705. /// <summary>
  19706. /// 倒推表
  19707. /// Update
  19708. /// </summary>
  19709. /// <param name="dto"></param>
  19710. /// <returns></returns>
  19711. [HttpPost]
  19712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19713. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  19714. {
  19715. var viewData = await _invertedListRep._Update(dto);
  19716. if (viewData.Code != 0)
  19717. {
  19718. return Ok(JsonView(false, viewData.Msg));
  19719. }
  19720. return Ok(JsonView(viewData.Data));
  19721. }
  19722. /// <summary>
  19723. /// 倒推表
  19724. /// File Download
  19725. /// </summary>
  19726. /// <param name="dto"></param>
  19727. /// <returns></returns>
  19728. [HttpPost]
  19729. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19730. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  19731. {
  19732. var info2 = await _invertedListRep._Info(1, dto.DiId);
  19733. if (info2.Code != 0)
  19734. {
  19735. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  19736. }
  19737. var info1 = info2.Data as InvertedListInfoView;
  19738. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  19739. string teamName = "";
  19740. if (info != null) teamName = info.TeamName;
  19741. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  19742. var doc = new Document();
  19743. var builder = new DocumentBuilder(doc);
  19744. #region old insert
  19745. ////载入模板
  19746. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  19747. //Document doc = new Document(tempPath);
  19748. //DocumentBuilder builder = new DocumentBuilder(doc);
  19749. //利用键值对存放数据
  19750. //Dictionary<string, string> dic = new Dictionary<string, string>();
  19751. //dic.Add("TeamName", teamName);
  19752. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  19753. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  19754. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  19755. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  19756. //dic.Add("SQRemark", info1.ApprovalRemark);
  19757. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  19758. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  19759. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  19760. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  19761. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  19762. //dic.Add("QZRemark", info1.VisaInformationRemark);
  19763. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  19764. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  19765. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  19766. //dic.Add("CQRemark", info1.IssueVisaRemark);
  19767. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  19768. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  19769. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  19770. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  19771. //#region 填充word模板书签内容
  19772. //foreach (var key in dic.Keys)
  19773. //{
  19774. // builder.MoveToBookmark(key);
  19775. // builder.Write(dic[key]);
  19776. //}
  19777. //#endregion
  19778. #endregion
  19779. #region New Insert
  19780. string titleFont = $"仿宋",
  19781. contentFont = $"仿宋";
  19782. var fontColor = Color.FromArgb(64, 64, 64);
  19783. //设置标题 团组名称
  19784. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19785. builder.Font.Name = titleFont;
  19786. builder.Font.Color = fontColor;
  19787. builder.Font.Size = 12;
  19788. builder.Font.Bold = true;
  19789. builder.Writeln(teamName);
  19790. //设置副标题 团组出访时间
  19791. builder.Font.Size = 12;
  19792. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  19793. builder.Writeln();
  19794. var backgroundColor = Color.FromArgb(199, 199, 199);
  19795. var table = builder.StartTable();
  19796. builder.InsertCell();
  19797. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  19798. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  19799. builder.CellFormat.Borders.LineWidth = 1;
  19800. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  19801. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  19802. builder.RowFormat.Height = 40;
  19803. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19804. builder.Font.Name = contentFont;
  19805. builder.Font.Size = 12;
  19806. builder.Font.Bold = true;
  19807. builder.Font.Color = fontColor;
  19808. builder.Write("时间");
  19809. builder.InsertCell();
  19810. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  19811. builder.Write("流程");
  19812. builder.InsertCell();
  19813. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  19814. builder.Write("说明");
  19815. builder.EndRow();
  19816. //报批资料准备
  19817. if (info1.IsSelectedAirportd)
  19818. {
  19819. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  19820. }
  19821. //报批/提供送签资料
  19822. if (info1.IsSelectedApprovalData)
  19823. {
  19824. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  19825. }
  19826. //出批件护照办理
  19827. if (info1.IsSelectedIssueApproval)
  19828. {
  19829. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  19830. }
  19831. //签证资料准备
  19832. if (info1.IsSelectedVisaInfo)
  19833. {
  19834. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  19835. }
  19836. //送签
  19837. if (info1.IsSelectedSendVisa)
  19838. {
  19839. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  19840. }
  19841. //出签
  19842. if (info1.IsSelectedIssueVisa)
  19843. {
  19844. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  19845. }
  19846. //机票
  19847. if (info1.IsSelectedAirTicket)
  19848. {
  19849. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  19850. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  19851. }
  19852. //酒店
  19853. if (info1.IsSelectedHotel)
  19854. {
  19855. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  19856. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  19857. }
  19858. //开行前会
  19859. if (info1.IsSelectedPreTripMeeting)
  19860. {
  19861. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  19862. }
  19863. //送机
  19864. if (info1.IsSelectedAirportdDropOff)
  19865. {
  19866. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  19867. }
  19868. builder.EndTable();
  19869. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  19870. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  19871. for (int i = 0; i < table.Rows.Count; i++)
  19872. {
  19873. var row = table.Rows[i];
  19874. //设置宽度
  19875. row.Cells[0].CellFormat.Width = 20.00;
  19876. row.Cells[1].CellFormat.Width = 30.00;
  19877. row.Cells[2].CellFormat.Width = 50.00;
  19878. if (i != 0)
  19879. {
  19880. //边框设置
  19881. InvertedListFileDownloadSetBorders(row.Cells, 0);
  19882. InvertedListFileDownloadSetBorders(row.Cells, 1);
  19883. InvertedListFileDownloadSetBorders(row.Cells, 2);
  19884. }
  19885. }
  19886. #region 页脚插入图片
  19887. // 创建页脚
  19888. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  19889. doc.FirstSection.HeadersFooters.Add(footer);
  19890. Paragraph para = new Paragraph(doc);
  19891. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  19892. footer.AppendChild(para);
  19893. builder.MoveTo(para);
  19894. string imagePath = "./Images/FMGJ_Log.png";
  19895. builder.InsertImage(imagePath);
  19896. #endregion
  19897. #endregion
  19898. var fileDir = AppSettingsHelper.Get("WordBasePath");
  19899. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  19900. string filePath = fileDir + $@"InvertedList/{fileName}";
  19901. doc.Save(filePath);
  19902. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  19903. return Ok(JsonView(true, "操作成功!", Url));
  19904. }
  19905. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  19906. {
  19907. var fontColor = Color.FromArgb(64, 64, 64);
  19908. builder.InsertCell();
  19909. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  19910. builder.RowFormat.Height = 40;
  19911. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19912. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19913. builder.Font.Name = fontName;
  19914. builder.Font.Size = 8;
  19915. builder.Font.Bold = true;
  19916. builder.Font.Color = fontColor;
  19917. builder.Write(dateTime);
  19918. builder.InsertCell();
  19919. builder.Font.Size = 9;
  19920. builder.Font.Bold = true;
  19921. builder.Font.Color = fontColor;
  19922. builder.Write(content);
  19923. builder.InsertCell();
  19924. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  19925. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  19926. builder.Font.Size = 9;
  19927. builder.Font.Bold = false;
  19928. builder.Font.Color = fontColor;
  19929. builder.Write(reamrk);
  19930. builder.EndRow();
  19931. }
  19932. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  19933. {
  19934. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  19935. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  19936. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  19937. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  19938. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  19939. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  19940. }
  19941. #endregion
  19942. #region 会务倒推表
  19943. /// <summary>
  19944. /// 会务倒推表
  19945. /// Init
  19946. /// </summary>
  19947. /// <returns></returns>
  19948. [HttpPost]
  19949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19950. public async Task<IActionResult> InforRetrogressTableInit()
  19951. {
  19952. var groupData = await _groupRepository.PostShareGroupInfos(1);
  19953. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  19954. return Ok(JsonView(false, groupData.Msg));
  19955. }
  19956. /// <summary>
  19957. /// 会务倒推表
  19958. /// ExcelDownload
  19959. /// </summary>
  19960. /// <param name="dto"></param>
  19961. /// <returns></returns>
  19962. [HttpPost]
  19963. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  19964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19965. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  19966. {
  19967. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  19968. var validatorRes = await validator.ValidateAsync(dto);
  19969. if (!validatorRes.IsValid)
  19970. {
  19971. StringBuilder sb = new StringBuilder();
  19972. foreach (var item in validatorRes.Errors)
  19973. {
  19974. sb.AppendLine(item.ErrorMessage);
  19975. }
  19976. return Ok(JsonView(false, sb.ToString()));
  19977. }
  19978. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  19979. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  19980. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  19981. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  19982. #region Excel
  19983. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  19984. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  19985. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  19986. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  19987. var fileNamePrefix = string.Empty;
  19988. if (days >= 30)
  19989. {
  19990. tempPath += $"会务工作倒推进度表(30天).xlsx";
  19991. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  19992. }
  19993. else if (days < 30 && days > 7)
  19994. {
  19995. tempPath += $"会务工作倒推进度表(15天).xlsx";
  19996. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  19997. }
  19998. else if (days <= 7)
  19999. {
  20000. tempPath += $"会务工作倒推进度表(7天).xlsx";
  20001. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  20002. }
  20003. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  20004. fileName = CommonFun.ValidFileName(fileName);
  20005. //载入模板
  20006. WorkbookDesigner designer = new WorkbookDesigner();
  20007. designer.Workbook = new Workbook(tempPath);
  20008. designer.Process();
  20009. if (!Directory.Exists(savePath))
  20010. {
  20011. Directory.CreateDirectory(savePath);
  20012. }
  20013. string serverPath = $"{savePath}{fileName}";
  20014. designer.Workbook.Save(serverPath);
  20015. string rst = $"{servicePath}{ftpPath}{fileName}";
  20016. #endregion
  20017. return Ok(JsonView(new { url = rst }));
  20018. }
  20019. #endregion
  20020. #region 三公签证费用(签证费、代办费)
  20021. /// <summary>
  20022. /// 三公签证费用(签证费、代办费)
  20023. /// List
  20024. /// </summary>
  20025. /// <returns></returns>
  20026. [HttpPost]
  20027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20028. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  20029. {
  20030. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  20031. if (_view.Code != 0)
  20032. {
  20033. return Ok(JsonView(false, _view.Msg));
  20034. }
  20035. return Ok(JsonView(true, "操作成功!", _view.Data));
  20036. }
  20037. /// <summary>
  20038. /// 三公签证费用(签证费、代办费)
  20039. /// Add Or Update
  20040. /// </summary>
  20041. /// <returns></returns>
  20042. [HttpPost]
  20043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20044. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  20045. {
  20046. var _view = await _visaFeeInfoRep._Update(_dto);
  20047. if (_view.Code != 0)
  20048. {
  20049. return Ok(JsonView(false, _view.Msg));
  20050. }
  20051. return Ok(JsonView(true, _view.Msg));
  20052. }
  20053. #endregion
  20054. #region 酒店询价
  20055. /// <summary>
  20056. /// 酒店询价
  20057. /// Init
  20058. /// </summary>
  20059. /// <returns></returns>
  20060. [HttpPost]
  20061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20062. public async Task<IActionResult> PostHotelInquiryInit()
  20063. {
  20064. var res = await _hotelInquiryRep._Init();
  20065. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20066. return Ok(JsonView(true, res.Msg, res.Data));
  20067. }
  20068. /// <summary>
  20069. /// 酒店询价
  20070. /// page Item
  20071. /// </summary>
  20072. /// <param name="_dto"></param>
  20073. /// <returns></returns>
  20074. [HttpPost]
  20075. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20076. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  20077. {
  20078. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  20079. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20080. var view = res.Data as PageDataViewBase;
  20081. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  20082. }
  20083. /// <summary>
  20084. /// 酒店询价
  20085. /// info
  20086. /// </summary>
  20087. /// <param name="_dto"></param>
  20088. /// <returns></returns>
  20089. [HttpPost]
  20090. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20091. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  20092. {
  20093. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  20094. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20095. return Ok(JsonView(true, res.Msg, res.Data));
  20096. }
  20097. /// <summary>
  20098. /// 酒店询价
  20099. /// Add Or Edit
  20100. /// </summary>
  20101. /// <param name="_dto"></param>
  20102. /// <returns></returns>
  20103. [HttpPost]
  20104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20105. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  20106. {
  20107. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  20108. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20109. return Ok(JsonView(true, res.Msg, res.Data));
  20110. }
  20111. /// <summary>
  20112. /// 酒店询价
  20113. /// Del
  20114. /// </summary>
  20115. /// <param name="_dto"></param>
  20116. /// <returns></returns>
  20117. [HttpPost]
  20118. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20119. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  20120. {
  20121. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  20122. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  20123. return Ok(JsonView(true, res.Msg, res.Data));
  20124. }
  20125. #endregion
  20126. #region 下载匹配op行程单
  20127. /// <summary>
  20128. /// 匹配op行程单
  20129. /// Init
  20130. /// </summary>
  20131. /// <param name="dto">团组列表请求dto</param>
  20132. /// <returns></returns>
  20133. [HttpPost]
  20134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20135. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  20136. {
  20137. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20138. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  20139. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  20140. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  20141. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  20142. .Where(it => it.IsDel == 0)
  20143. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  20144. .OrderByDescending(it => it.VisitStartDate)
  20145. .ToList();
  20146. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  20147. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20148. var diids = groupInfos.Select(it => it.Id).ToList();
  20149. List<string> countrys = new List<string>();
  20150. foreach (var item in country)
  20151. {
  20152. var data = _groupRepository.FormartTeamName(item);
  20153. var dataArray = _groupRepository.GroupSplitCountry(data);
  20154. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20155. }
  20156. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  20157. List<string> areaArray = new List<string>(); //GetGroupCityLine
  20158. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  20159. foreach (var item in areaItem)
  20160. {
  20161. string areaStr = item.Value;
  20162. if (!string.IsNullOrEmpty(areaStr))
  20163. {
  20164. string[] str1 = areaStr.Split("-");
  20165. if (str1.Length > 0)
  20166. {
  20167. areaArray.AddRange(str1);
  20168. }
  20169. }
  20170. }
  20171. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  20172. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  20173. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  20174. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  20175. .ToList();
  20176. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  20177. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  20178. .Where(it => countriesIds.Contains(it.Id))
  20179. .Select(it => new { it.Id, Name = it.Name_CN })
  20180. .ToList();
  20181. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  20182. .Select(it => it.TeamName).ToList();
  20183. stopwatch.Stop();
  20184. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  20185. }
  20186. ///// <summary>
  20187. ///// 匹配op行程单
  20188. ///// Init 查询区域数据
  20189. ///// </summary>
  20190. ///// <param name="dto">团组列表请求dto</param>
  20191. ///// <returns></returns>
  20192. //[HttpPost]
  20193. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20194. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  20195. //{
  20196. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  20197. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  20198. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  20199. // if (string.IsNullOrEmpty(countriesDataStr))
  20200. // {
  20201. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  20202. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  20203. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  20204. // }
  20205. // else
  20206. // {
  20207. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  20208. // }
  20209. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  20210. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  20211. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  20212. // List<dynamic> childList = new List<dynamic>();
  20213. // int parentId = dto.CountriesId;
  20214. // if (provinceData.Count > 1)
  20215. // {
  20216. // foreach (var item1 in provinceData)
  20217. // {
  20218. // List<dynamic> childList1 = new List<dynamic>();
  20219. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  20220. // foreach (var item2 in citiesData1)
  20221. // {
  20222. // List<dynamic> childList2 = new List<dynamic>();
  20223. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20224. // foreach (var item3 in countiesData1)
  20225. // {
  20226. // childList2.Add(new
  20227. // {
  20228. // id = item3.Id,
  20229. // parentId = item2.Id,
  20230. // level = "district",
  20231. // name = item3.Name_CN,
  20232. // });
  20233. // }
  20234. // childList1.Add(new
  20235. // {
  20236. // id = item2.Id,
  20237. // parentId = item1.Id,
  20238. // level = "city",
  20239. // name = item2.Name_CN,
  20240. // childList = childList2
  20241. // });
  20242. // }
  20243. // childList.Add(new
  20244. // {
  20245. // id = item1.Id,
  20246. // parentId = parentId,
  20247. // level = "province",
  20248. // name = item1.Name_CN,
  20249. // childList = childList1
  20250. // });
  20251. // }
  20252. // //城市
  20253. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  20254. // foreach (var item2 in citiesData2)
  20255. // {
  20256. // List<dynamic> childList22 = new List<dynamic>();
  20257. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20258. // foreach (var item3 in countiesData1)
  20259. // {
  20260. // childList22.Add(new
  20261. // {
  20262. // id = item3.Id,
  20263. // parentId = item2.Id,
  20264. // level = "district",
  20265. // name = item3.Name_CN,
  20266. // });
  20267. // }
  20268. // childList.Add(new
  20269. // {
  20270. // id = item2.Id,
  20271. // parentId = parentId,
  20272. // level = "city",
  20273. // name = item2.Name_CN,
  20274. // childList = childList22
  20275. // });
  20276. // }
  20277. // }
  20278. // else
  20279. // {
  20280. // foreach (var item2 in citiesData)
  20281. // {
  20282. // string cname = item2.Name_CN;
  20283. // List<dynamic> childList1 = new List<dynamic>();
  20284. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  20285. // foreach (var item3 in countiesData1)
  20286. // {
  20287. // childList1.Add(new
  20288. // {
  20289. // Id = item3.Id,
  20290. // parentId = item2.Id,
  20291. // level = "district",
  20292. // name = item3.Name_CN
  20293. // });
  20294. // }
  20295. // childList.Add(new
  20296. // {
  20297. // id = item2.Id,
  20298. // parentId = parentId,
  20299. // level = "city",
  20300. // name = item2.Name_CN,
  20301. // childList = childList1
  20302. // });
  20303. // }
  20304. // }
  20305. // stopwatch.Stop();
  20306. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  20307. //}
  20308. /// <summary>
  20309. /// 匹配op行程单
  20310. /// 接团信息列表 Page
  20311. /// </summary>
  20312. /// <param name="dto">团组列表请求dto</param>
  20313. /// <returns></returns>
  20314. [HttpPost]
  20315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20316. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  20317. {
  20318. var swatch = new Stopwatch();
  20319. swatch.Start();
  20320. #region 参数验证
  20321. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20322. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20323. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20324. #region 页面操作权限验证
  20325. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20326. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  20327. #endregion
  20328. #endregion
  20329. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20330. {
  20331. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  20332. //string sqlWhere = "";
  20333. if (!string.IsNullOrEmpty(dto.Country))
  20334. {
  20335. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  20336. }
  20337. if (!string.IsNullOrEmpty(dto.Area))
  20338. {
  20339. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  20340. }
  20341. if (!string.IsNullOrEmpty(dto.TeamName))
  20342. {
  20343. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  20344. }
  20345. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  20346. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  20347. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  20348. swatch.Stop();
  20349. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  20350. }
  20351. else
  20352. {
  20353. return Ok(JsonView(false, "查询失败"));
  20354. }
  20355. }
  20356. /// <summary>
  20357. /// 匹配op行程单
  20358. /// 行程单下载
  20359. /// </summary>
  20360. /// <param name="dto">团组列表请求dto</param>
  20361. /// <returns></returns>
  20362. [HttpPost]
  20363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20364. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  20365. {
  20366. #region 参数验证
  20367. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20368. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  20369. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20370. #region 页面操作权限验证
  20371. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  20372. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  20373. #endregion
  20374. #endregion
  20375. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  20376. {
  20377. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  20378. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  20379. }
  20380. else
  20381. {
  20382. return Ok(JsonView(false, "下载失败!"));
  20383. }
  20384. }
  20385. #endregion
  20386. #region 国家信息 数据 注释
  20387. //[HttpPost]
  20388. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  20389. //{
  20390. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  20391. // foreach (var item in dto)
  20392. // {
  20393. // infos.Add(new Grp_GroupsTaskAssignment()
  20394. // {
  20395. // DIId = item,
  20396. // CTId = 82,
  20397. // UId = 248,
  20398. // IsEnable = 1,
  20399. // CreateUserId = 233,
  20400. // CreateTime = DateTime.Now,
  20401. // IsDel = 0
  20402. // });
  20403. // infos.Add(new Grp_GroupsTaskAssignment()
  20404. // {
  20405. // DIId = item,
  20406. // CTId = 82,
  20407. // UId = 286,
  20408. // IsEnable = 1,
  20409. // CreateUserId = 233,
  20410. // CreateTime = DateTime.Now,
  20411. // IsDel = 0
  20412. // });
  20413. // }
  20414. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  20415. // return Ok("操作成功");
  20416. //}
  20417. //public class paramJsonDto
  20418. //{
  20419. // public List<CountriesInfo> str { get; set; }
  20420. //}
  20421. //[HttpPost]
  20422. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  20423. //{
  20424. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  20425. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  20426. // List<Sys_Cities> cities = new List<Sys_Cities>();
  20427. // List<Sys_Cities> districts = new List<Sys_Cities>();
  20428. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20429. // _sqlSugar.BeginTran();
  20430. // int countitiesIndex = 0;
  20431. // foreach (var item in dto.str)
  20432. // {
  20433. // dynamic data = item.c;
  20434. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  20435. // if (data != null)
  20436. // {
  20437. // countitiesIndex++;
  20438. // foreach (var item1 in data)
  20439. // {
  20440. // string cnname = item1.cn;
  20441. // string enname = item1.en;
  20442. // Sys_Cities provinceInfo = new Sys_Cities()
  20443. // {
  20444. // CountriesId = countriesId,
  20445. // Name_CN = cnname,
  20446. // Name_EN = enname,
  20447. // ParentId = 0,
  20448. // IsCapital = 1,
  20449. // CreateUserId = 208,
  20450. // CreateTime = DateTime.Now,
  20451. // IsDel = 0
  20452. // };
  20453. // if (item1.lv == "province") //省份
  20454. // {
  20455. // provinceInfo.Level = 1;
  20456. // int provinceId = 0;
  20457. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  20458. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  20459. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20460. // var data1 = item1.c;
  20461. // foreach (var item2 in data1)
  20462. // {
  20463. // if (item2.lv == "city")
  20464. // {
  20465. // string citycnname = item2.cn;
  20466. // string cityenname = item2.en;
  20467. // Sys_Cities cityInfo = new Sys_Cities()
  20468. // {
  20469. // CountriesId = countriesId,
  20470. // ParentId = provinceId,
  20471. // Level = 2,
  20472. // Name_CN = citycnname,
  20473. // Name_EN = cityenname,
  20474. // IsCapital = 1,
  20475. // CreateUserId = 208,
  20476. // CreateTime = DateTime.Now,
  20477. // IsDel = 0
  20478. // };
  20479. // if (item2.c != null)
  20480. // {
  20481. // int cityId = 0;
  20482. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  20483. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20484. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  20485. // foreach (var item3 in item2.c)
  20486. // {
  20487. // if (item3.lv == "district")
  20488. // {
  20489. // var districtInfo = new Sys_Cities()
  20490. // {
  20491. // CountriesId = countriesId,
  20492. // Name_CN = item3.cn,
  20493. // Name_EN = item3.en,
  20494. // Level = 3,
  20495. // ParentId = cityId,
  20496. // IsCapital = 1,
  20497. // CreateUserId = 208,
  20498. // CreateTime = DateTime.Now,
  20499. // IsDel = 0
  20500. // };
  20501. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20502. // //{
  20503. // districts.Add(districtInfo);
  20504. // //}
  20505. // }
  20506. // }
  20507. // }
  20508. // else
  20509. // {
  20510. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  20511. // //{
  20512. // cities.Add(cityInfo);
  20513. // //}
  20514. // }
  20515. // }
  20516. // }
  20517. // }
  20518. // else if (item1.lv == "city")//城市
  20519. // {
  20520. // provinceInfo.Level = 2;
  20521. // if (item1.c != null)
  20522. // {
  20523. // int cityId = 0;
  20524. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  20525. // if (citiesInfo != null) cityId = citiesInfo.Id;
  20526. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  20527. // foreach (var item3 in item1.c)
  20528. // {
  20529. // if (item3.lv == "district")
  20530. // {
  20531. // var districtInfo = new Sys_Cities()
  20532. // {
  20533. // CountriesId = countriesId,
  20534. // Name_CN = item3.cn,
  20535. // Name_EN = item3.en,
  20536. // Level = 3,
  20537. // ParentId = cityId,
  20538. // IsCapital = 1,
  20539. // CreateUserId = 208,
  20540. // CreateTime = DateTime.Now,
  20541. // IsDel = 0
  20542. // };
  20543. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  20544. // //{
  20545. // districts.Add(districtInfo);
  20546. // //}
  20547. // }
  20548. // }
  20549. // }
  20550. // else
  20551. // {
  20552. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  20553. // //{
  20554. // cities.Add(provinceInfo);
  20555. // //}
  20556. // }
  20557. // }
  20558. // }
  20559. // }
  20560. // }
  20561. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  20562. // cities = cities.Distinct().ToList();
  20563. // districts = districts.Distinct().ToList();
  20564. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  20565. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  20566. // cities.AddRange(districts);
  20567. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  20568. // //_sqlSugar.RollbackTran();
  20569. // _sqlSugar.CommitTran();
  20570. // return Ok(JsonView(false, "操作成功!"));
  20571. //}
  20572. //[HttpPost]
  20573. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  20574. //{
  20575. // List<CountitiesInfo> infos = dto.MyProperty;
  20576. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  20577. // _sqlSugar.BeginTran();
  20578. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  20579. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  20580. // foreach (var item in infos)
  20581. // {
  20582. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  20583. // if (countryInfo != null)
  20584. // {
  20585. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  20586. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  20587. // if (cityInfo1 != null)
  20588. // {
  20589. // cityInfo1.IsCapital = 0;
  20590. // cityInfos.Add(cityInfo1);
  20591. // }
  20592. // }
  20593. // }
  20594. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  20595. // .UpdateColumns(it => it.IsCapital)
  20596. // .WhereColumns(it => it.Id)
  20597. // .ExecuteCommand();
  20598. // //_sqlSugar.RollbackTran();
  20599. // _sqlSugar.CommitTran();
  20600. // return Ok(JsonView(false, "操作成功!"));
  20601. //}
  20602. //public class CounrtiesDto
  20603. //{
  20604. // public List<CountitiesInfo> MyProperty { get; set; }
  20605. //}
  20606. //public class CountitiesInfo
  20607. //{
  20608. // /// <summary>
  20609. // /// 圣约翰
  20610. // /// </summary>
  20611. // public string capital_name_chinese { get; set; }
  20612. // /// <summary>
  20613. // ///
  20614. // /// </summary>
  20615. // public string capital_name { get; set; }
  20616. // /// <summary>
  20617. // ///
  20618. // /// </summary>
  20619. // public string country_type { get; set; }
  20620. // /// <summary>
  20621. // /// 安提瓜和巴布达
  20622. // /// </summary>
  20623. // public string country_name_chinese { get; set; }
  20624. // /// <summary>
  20625. // /// 安提瓜和巴布达
  20626. // /// </summary>
  20627. // public string country_name_chinese_short { get; set; }
  20628. // /// <summary>
  20629. // /// 安提瓜和巴布达
  20630. // /// </summary>
  20631. // public string country_name_chinese_UN { get; set; }
  20632. // /// <summary>
  20633. // ///
  20634. // /// </summary>
  20635. // public string country_name_english_abbreviation { get; set; }
  20636. // /// <summary>
  20637. // ///
  20638. // /// </summary>
  20639. // public string country_name_english_formal { get; set; }
  20640. // /// <summary>
  20641. // ///
  20642. // /// </summary>
  20643. // public string country_name_english_UN { get; set; }
  20644. // /// <summary>
  20645. // ///
  20646. // /// </summary>
  20647. // public string continent_name { get; set; }
  20648. // /// <summary>
  20649. // ///
  20650. // /// </summary>
  20651. // public string subregion_name { get; set; }
  20652. // /// <summary>
  20653. // ///
  20654. // /// </summary>
  20655. // public string country_code2 { get; set; }
  20656. // /// <summary>
  20657. // ///
  20658. // /// </summary>
  20659. // public string country_code3 { get; set; }
  20660. // /// <summary>
  20661. // ///
  20662. // /// </summary>
  20663. // public string phone_code { get; set; }
  20664. //}
  20665. //public class CountriesInfo : BasicInfo
  20666. //{
  20667. // public List<CitiesInfo> c { get; set; }
  20668. //}
  20669. //public class CitiesInfo : BasicInfo
  20670. //{
  20671. // public List<AreaInfo> c { get; set; }
  20672. //}
  20673. //public class AreaInfo : BasicInfo
  20674. //{
  20675. // public List<AreaInfo> c { get; set; }
  20676. //}
  20677. //public class BasicInfo
  20678. //{
  20679. // public string code { get; set; }
  20680. // public string cn { get; set; }
  20681. // public string lv { get; set; }
  20682. // public string en { get; set; }
  20683. //}
  20684. #endregion
  20685. #region 查看邀请方
  20686. /// <summary>
  20687. /// 查看邀请方
  20688. /// 邀请方信息 Init
  20689. /// </summary>
  20690. /// <param name="dto"></param>
  20691. /// <returns></returns>
  20692. [HttpPost]
  20693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20694. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  20695. {
  20696. string sqlWhere = string.Empty;
  20697. if (!string.IsNullOrEmpty(dto.Search))
  20698. {
  20699. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  20700. }
  20701. string sql = string.Format($@"Select
  20702. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  20703. Id,
  20704. UnitName
  20705. From Res_InvitationOfficialActivityData
  20706. Where IsDel = 0
  20707. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  20708. RefAsync<int> total = 0;
  20709. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20710. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  20711. }
  20712. /// <summary>
  20713. /// 查看邀请方
  20714. /// 国家信息 Init
  20715. /// </summary>
  20716. /// <param name="dto"></param>
  20717. /// <returns></returns>
  20718. [HttpPost]
  20719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20720. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  20721. {
  20722. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  20723. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  20724. var diids = groupInfos.Select(it => it.Id).ToList();
  20725. List<string> countrys = new List<string>();
  20726. foreach (var item in country)
  20727. {
  20728. var data = _groupRepository.FormartTeamName(item);
  20729. var dataArray = _groupRepository.GroupSplitCountry(data);
  20730. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  20731. }
  20732. countrys = countrys.Distinct().ToList();
  20733. for (int i = 0; i < countrys.Count; i++)
  20734. {
  20735. string item = countrys[i];
  20736. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  20737. {
  20738. countrys.Remove(item);
  20739. i--;
  20740. }
  20741. }
  20742. RefAsync<int> total = 0;
  20743. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  20744. .Where(it => countrys.Contains(it.Name_CN))
  20745. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20746. .Select(it => new { id = it.Id, name = it.Name_CN })
  20747. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20748. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20749. }
  20750. /// <summary>
  20751. /// 查看邀请方
  20752. /// 城市信息 Init
  20753. /// </summary>
  20754. /// <param name="dto"></param>
  20755. /// <returns></returns>
  20756. [HttpPost]
  20757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20758. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  20759. {
  20760. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  20761. RefAsync<int> total = 0;
  20762. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  20763. .Where(it => it.CountriesId == dto.CountiesId)
  20764. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  20765. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  20766. .Select(it => new { id = it.Id, name = it.Name_CN })
  20767. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20768. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  20769. }
  20770. /// <summary>
  20771. /// 查看邀请方
  20772. /// 团组名称 Init
  20773. /// </summary>
  20774. /// <param name="dto"></param>
  20775. /// <returns></returns>
  20776. [HttpPost]
  20777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20778. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  20779. {
  20780. var watch = new Stopwatch();
  20781. watch.Start();
  20782. RefAsync<int> total = 0;
  20783. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  20784. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  20785. .Where((oa, di) => oa.IsDel == 0)
  20786. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  20787. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  20788. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  20789. .Distinct()
  20790. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20791. watch.Stop();
  20792. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  20793. }
  20794. /// <summary>
  20795. /// 查看邀请方
  20796. /// 团组 & 邀请方信息
  20797. /// </summary>
  20798. /// <param name="dto"></param>
  20799. /// <returns></returns>
  20800. [HttpPost]
  20801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20802. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  20803. {
  20804. var watch = new Stopwatch();
  20805. watch.Start();
  20806. RefAsync<int> total = 0;
  20807. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  20808. .AS("Grp_DelegationInfo")
  20809. .Includes(x => x.InvitingInfos)
  20810. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  20811. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  20812. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  20813. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  20814. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  20815. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  20816. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  20817. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  20818. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  20819. infos.ForEach(x =>
  20820. {
  20821. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  20822. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  20823. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  20824. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  20825. });
  20826. watch.Stop();
  20827. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  20828. }
  20829. #endregion
  20830. #region 报批行程
  20831. /// <summary>
  20832. /// 报批行程初始化
  20833. /// </summary>
  20834. /// <param name="dto"></param>
  20835. /// <returns></returns>
  20836. [HttpPost]
  20837. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  20838. {
  20839. const int chiNumber = 5;
  20840. var jw = JsonView(false);
  20841. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  20842. var group = groupList.First();
  20843. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  20844. group = groupList.First(x => x.Id == diid);
  20845. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20846. .Where(x => x.DiId == diid && x.IsDel == 0)
  20847. .ToArray();
  20848. var count = 1;
  20849. foreach (var item in blackCodeList)
  20850. {
  20851. if (string.IsNullOrWhiteSpace(item.Title))
  20852. {
  20853. item.Title = "未设置名称数据" + count;
  20854. }
  20855. count++;
  20856. }
  20857. ;
  20858. if (group == null)
  20859. {
  20860. jw.Msg = "暂无团组!";
  20861. return Ok(jw);
  20862. }
  20863. var data = new
  20864. {
  20865. groupList = groupList.Select(x => new
  20866. {
  20867. x.TeamName,
  20868. x.Id
  20869. }),
  20870. content = new ArrayList(),
  20871. groupInfo = new
  20872. {
  20873. group.VisitDays,
  20874. group.TourCode,
  20875. group.VisitPNumber,
  20876. group.TeamName,
  20877. group.Id,
  20878. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  20879. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  20880. group.ClientUnit
  20881. },
  20882. blackCodeList = blackCodeList.Select(x => new
  20883. {
  20884. x.Title,
  20885. x.Id
  20886. }),
  20887. FileTempList = new ArrayList()
  20888. {
  20889. new { Index = 1,FileName = "旧模板" },
  20890. new { Index = 2,FileName = "省外办" },
  20891. new { Index = 3,FileName = "市外办" },
  20892. }
  20893. };
  20894. var resultArr = new ArrayList();
  20895. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  20896. #region 默认不生成行程
  20897. //if (content.Count == 0)
  20898. //{
  20899. // var stay = "-";
  20900. // var cityPath = "-";
  20901. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  20902. // .Where(x => x.DiId == diid && x.IsDel == 0)
  20903. // .ToList();
  20904. // //添加城市路径以及住宿地
  20905. // //黑屏代码数据
  20906. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  20907. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  20908. // {
  20909. // jw = JsonView(true, "黑屏代码有误!", data);
  20910. // return Ok(jw);
  20911. // }
  20912. // data = data with
  20913. // {
  20914. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  20915. // {
  20916. // x.Title,
  20917. // x.Id,
  20918. // }).ToArray())
  20919. // };
  20920. // foreach (DataRow row in dtBlack.Rows)
  20921. // {
  20922. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  20923. // {
  20924. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  20925. // return Ok(jw);
  20926. // }
  20927. // }
  20928. // //黑屏代码获取时间区间
  20929. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  20930. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  20931. // _sqlSugar.BeginTran();
  20932. // for (int i = 0; i < timeArr.Count; i++)
  20933. // {
  20934. // stay = "-";
  20935. // cityPath = "-";
  20936. // DateTime NewData = DateTime.Parse(timeArr[i]);
  20937. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  20938. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  20939. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  20940. // if (tbSelect.Length > 0)
  20941. // {
  20942. // List<string> threeCodeStr = new List<string>();
  20943. // foreach (var item in tbSelect)
  20944. // {
  20945. // var threeCode = item["Three"].ToString() ?? "";
  20946. // if (threeCode.Length == 6)
  20947. // {
  20948. // var start = threeCode.Substring(0, 3);
  20949. // var end = threeCode.Substring(3, 3);
  20950. // if (threeCodeStr.Count == 0)
  20951. // {
  20952. // threeCodeStr.Add(start);
  20953. // threeCodeStr.Add(end);
  20954. // }
  20955. // else
  20956. // {
  20957. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  20958. // {
  20959. // threeCodeStr.Add(end);
  20960. // }
  20961. // else
  20962. // {
  20963. // threeCodeStr.Add(start);
  20964. // threeCodeStr.Add(end);
  20965. // }
  20966. // }
  20967. // }
  20968. // }
  20969. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  20970. // var last = threeCodeStr.Last();
  20971. // foreach (var item in threeCodeStr)
  20972. // {
  20973. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  20974. // if (item.Equals(last))
  20975. // {
  20976. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  20977. // }
  20978. // }
  20979. // cityPath = cityPath.Trim('-');
  20980. // }
  20981. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  20982. // appro.Diid = diid ?? -1;
  20983. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  20984. // appro.Id = thisId;
  20985. // appro.CreateUserId = dto.UserId;
  20986. // appro.CreateTime = DateTime.Now;
  20987. // content.Add(appro);
  20988. // }
  20989. // _sqlSugar.CommitTran();
  20990. //}
  20991. #endregion
  20992. foreach (var x in content)
  20993. {
  20994. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  20995. if (chiList.Count < chiNumber)
  20996. {
  20997. for (int i = chiList.Count; i < chiNumber; i++)
  20998. {
  20999. chiList.Add(new Grp_ApprovalTravelDetails());
  21000. }
  21001. }
  21002. resultArr.Add(new
  21003. {
  21004. x.Id,
  21005. x.Date,
  21006. x.Diid,
  21007. chiList = chiList.Select(x1 => new
  21008. {
  21009. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21010. x1.Details,
  21011. x1.ParentId,
  21012. x1.Id
  21013. })
  21014. });
  21015. }
  21016. data = data with
  21017. {
  21018. content = resultArr,
  21019. };
  21020. jw = JsonView(true, "获取成功!", data);
  21021. return Ok(jw);
  21022. }
  21023. /// <summary>
  21024. /// 报批行程删除
  21025. /// </summary>
  21026. /// <param name="dto"></param>
  21027. /// <returns></returns>
  21028. [HttpPost]
  21029. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  21030. {
  21031. var jw = JsonView(false);
  21032. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21033. if (group == null)
  21034. {
  21035. jw.Msg = "团组参数有误!";
  21036. return Ok(jw);
  21037. }
  21038. try
  21039. {
  21040. _sqlSugar.BeginTran();
  21041. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  21042. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  21043. {
  21044. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21045. DeleteUserId = dto.uesrId,
  21046. IsDel = 1
  21047. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  21048. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  21049. {
  21050. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21051. DeleteUserId = dto.uesrId,
  21052. IsDel = 1
  21053. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  21054. _sqlSugar.CommitTran();
  21055. jw = JsonView(true, "删除成功");
  21056. }
  21057. catch (Exception ex)
  21058. {
  21059. jw = JsonView(false, ex.Message);
  21060. }
  21061. return Ok(jw);
  21062. }
  21063. /// <summary>
  21064. /// 报批行程保存
  21065. /// </summary>
  21066. /// <param name="dto"></param>
  21067. /// <returns></returns>
  21068. [HttpPost]
  21069. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  21070. {
  21071. var jw = JsonView(false);
  21072. var Find = dto.Arr.Find(x => x.id == 0);
  21073. if (Find != null)
  21074. {
  21075. jw.Msg = "生成的ID为0!";
  21076. return Ok(jw);
  21077. }
  21078. foreach (var item in dto.Arr)
  21079. {
  21080. foreach (var chi in item.chiList)
  21081. {
  21082. if (chi.parentId == 0)
  21083. {
  21084. chi.parentId = item.id;
  21085. }
  21086. }
  21087. }
  21088. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  21089. _sqlSugar.BeginTran();
  21090. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  21091. {
  21092. var parentIds = dto.Arr.Select(x => x.id).ToList();
  21093. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  21094. {
  21095. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  21096. DeleteUserId = dto.UserId,
  21097. IsDel = 1
  21098. }).ExecuteCommand();
  21099. }
  21100. try
  21101. {
  21102. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  21103. {
  21104. CreateTime = DateTime.Now,
  21105. CreateUserId = dto.UserId,
  21106. Details = x.details,
  21107. ParentId = x.parentId,
  21108. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21109. Remark = "",
  21110. IsDel = 0
  21111. }).ToList()).ExecuteCommand();
  21112. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  21113. {
  21114. Id = x.id,
  21115. Details = x.details,
  21116. ParentId = x.parentId,
  21117. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  21118. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  21119. {
  21120. Details = x.Details,
  21121. ParentId = x.ParentId,
  21122. Time = x.Time
  21123. }).ExecuteCommand();
  21124. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  21125. {
  21126. Id = x.id,
  21127. Date = x.date,
  21128. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  21129. {
  21130. Date = x.Date
  21131. }).ExecuteCommand();
  21132. _sqlSugar.CommitTran();
  21133. jw = JsonView(true, "保存成功!");
  21134. }
  21135. catch (Exception ex)
  21136. {
  21137. _sqlSugar.RollbackTran();
  21138. jw = JsonView(false, "保存失败!" + ex.Message);
  21139. }
  21140. return Ok(jw);
  21141. }
  21142. /// <summary>
  21143. /// 报批行程生成
  21144. /// </summary>
  21145. /// <param name="dto"></param>
  21146. /// <returns></returns>
  21147. [HttpPost]
  21148. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  21149. {
  21150. var jw = JsonView(false);
  21151. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21152. if (group == null)
  21153. {
  21154. jw.Msg = "暂无该团组!";
  21155. return Ok(jw);
  21156. }
  21157. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  21158. //黑屏代码数据
  21159. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  21160. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  21161. {
  21162. jw.Msg = "黑屏代码有误!";
  21163. return Ok(jw);
  21164. }
  21165. foreach (DataRow row in dtBlack.Rows)
  21166. {
  21167. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  21168. {
  21169. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  21170. return Ok(jw);
  21171. }
  21172. }
  21173. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  21174. var resultArr = new ArrayList();
  21175. //if (officialActivitiesArr.Count == 0)
  21176. //{
  21177. // jw.Msg = "暂无公务出访信息!";
  21178. // return Ok(jw);
  21179. //}
  21180. try
  21181. {
  21182. _sqlSugar.BeginTran();
  21183. DeleteApprovalJourney(new
  21184. Domain.Dtos.Groups.DeleteApprovalJourney
  21185. {
  21186. Diid = dto.Diid,
  21187. uesrId = dto.Userid
  21188. });
  21189. var stay = "-";
  21190. var cityPath = "-";
  21191. var arriveCountry = string.Empty;
  21192. //添加城市路径以及住宿地
  21193. //黑屏代码获取时间区间
  21194. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  21195. var empty = "【未收入该三字码!请机票同事录入】";
  21196. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  21197. #region 配置公务活动时间
  21198. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  21199. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  21200. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  21201. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  21202. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  21203. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21204. {
  21205. 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" }),
  21206. 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"}),
  21207. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21208. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  21209. };
  21210. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  21211. {
  21212. 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" }),
  21213. 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"}),
  21214. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  21215. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  21216. };
  21217. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  21218. {
  21219. 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" }),
  21220. 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"}),
  21221. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  21222. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  21223. };
  21224. #endregion
  21225. var nextDayNum = 0;
  21226. for (int i = 0; i < timeArr.Count; i++)
  21227. {
  21228. stay = "-";
  21229. cityPath = "-";
  21230. var chiarr = new List<Grp_ApprovalTravelDetails>();
  21231. DateTime NewData = DateTime.Parse(timeArr[i]);
  21232. //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();
  21233. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  21234. if (nextDayNum > 0)
  21235. {
  21236. nextDayNum--;
  21237. }
  21238. if (tbSelect.Length > 0)
  21239. {
  21240. List<string> threeCodeStr = new List<string>();
  21241. bool isTrade = false;
  21242. string trip = string.Empty;
  21243. foreach (var item in tbSelect)
  21244. {
  21245. if (nextDayNum == 0)
  21246. {
  21247. nextDayNum = Convert.ToInt32(item["Sign"]);
  21248. }
  21249. var airStartTime = item["StartTime"].ToString() ?? "0000";
  21250. var airEndTime = item["EndTime"].ToString() ?? "0000";
  21251. var takeOffTime = DateTime.Parse(timeArr[i]);
  21252. var fallToTime = DateTime.Parse(timeArr[i]);
  21253. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  21254. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  21255. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  21256. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  21257. if (nextDayNum > 0)
  21258. {
  21259. fallToTime = fallToTime.AddDays(nextDayNum);
  21260. }
  21261. trip = string.Empty;
  21262. var start = string.Empty;
  21263. var end = string.Empty;
  21264. var threeCode = item["Three"].ToString() ?? "";
  21265. if (threeCode.Length == 6)
  21266. {
  21267. start = threeCode.Substring(0, 3);
  21268. end = threeCode.Substring(3, 3);
  21269. if (threeCodeStr.Count == 0)
  21270. {
  21271. threeCodeStr.Add(start);
  21272. threeCodeStr.Add(end);
  21273. }
  21274. else
  21275. {
  21276. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  21277. {
  21278. threeCodeStr.Add(end);
  21279. }
  21280. else
  21281. {
  21282. threeCodeStr.Add(start);
  21283. threeCodeStr.Add(end);
  21284. }
  21285. }
  21286. }
  21287. //处理机票信息
  21288. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  21289. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  21290. if (start_Object == null)
  21291. {
  21292. start_Object = new Res_ThreeCode()
  21293. {
  21294. AirPort = empty,
  21295. AirPort_En = empty,
  21296. City = empty,
  21297. Country = empty,
  21298. Four = empty,
  21299. Three = empty,
  21300. };
  21301. }
  21302. if (end_Object == null)
  21303. {
  21304. end_Object = new Res_ThreeCode()
  21305. {
  21306. AirPort = empty,
  21307. AirPort_En = empty,
  21308. City = empty,
  21309. Country = empty,
  21310. Four = empty,
  21311. Three = empty,
  21312. };
  21313. }
  21314. //机型判断
  21315. string airModel = item["AirModel"].ToString();
  21316. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  21317. string flightTime = item["FlightTime"].ToString();
  21318. flightTime = ParseBlackTime(flightTime);
  21319. //航班号
  21320. string flightcode = item["Fliagtcode"].ToString();
  21321. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  21322. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  21323. if (aircompany == null)
  21324. {
  21325. aircompany = new Res_AirCompany
  21326. {
  21327. CnName = hsEmpty,
  21328. EnName = hsEmpty,
  21329. ShortCode = hsEmpty,
  21330. };
  21331. }
  21332. //航班前公务安排
  21333. if (tbSelect.First().Equals(item) && i != 0)
  21334. {
  21335. foreach (var takeoff in takeoffTimes)
  21336. {
  21337. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  21338. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  21339. {
  21340. foreach (var addTime in takeoff.Item2)
  21341. {
  21342. chiarr.Add(new Grp_ApprovalTravelDetails
  21343. {
  21344. Time = addTime,
  21345. CreateTime = DateTime.Now,
  21346. CreateUserId = dto.Userid,
  21347. ParentId = 0,
  21348. Details = "公务活动"
  21349. });
  21350. }
  21351. break;
  21352. }
  21353. }
  21354. }
  21355. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  21356. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  21357. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  21358. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  21359. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  21360. if (isTrade)
  21361. {
  21362. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  21363. trip += "(转机不出机场)。";
  21364. }
  21365. //else
  21366. //{
  21367. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  21368. //}
  21369. chiarr.Add(new Grp_ApprovalTravelDetails
  21370. {
  21371. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  21372. CreateTime = DateTime.Now,
  21373. CreateUserId = dto.Userid,
  21374. ParentId = 0,
  21375. Details = trip
  21376. });
  21377. //最后一条到达的时间安排公务
  21378. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  21379. {
  21380. bool isCheckCountry = false;
  21381. if (end_Object.Country != arriveCountry)
  21382. {
  21383. arriveCountry = end_Object.Country;
  21384. isCheckCountry = true;
  21385. }
  21386. if (nextDayNum == 0)
  21387. {
  21388. //需要入境的情况
  21389. if (isCheckCountry)
  21390. {
  21391. foreach (var fallTime in fallTimesCheckCountry)
  21392. {
  21393. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21394. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21395. {
  21396. foreach (var addTime in fallTime.Item2)
  21397. {
  21398. chiarr.Add(new Grp_ApprovalTravelDetails
  21399. {
  21400. Time = addTime,
  21401. CreateTime = DateTime.Now,
  21402. CreateUserId = dto.Userid,
  21403. ParentId = 0,
  21404. Details = "公务活动"
  21405. });
  21406. }
  21407. break;
  21408. }
  21409. }
  21410. }
  21411. else
  21412. {
  21413. foreach (var fallTime in fallTimesNotCheckCountry)
  21414. {
  21415. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  21416. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  21417. {
  21418. foreach (var addTime in fallTime.Item2)
  21419. {
  21420. chiarr.Add(new Grp_ApprovalTravelDetails
  21421. {
  21422. Time = addTime,
  21423. CreateTime = DateTime.Now,
  21424. CreateUserId = dto.Userid,
  21425. ParentId = 0,
  21426. Details = "公务活动"
  21427. });
  21428. }
  21429. break;
  21430. }
  21431. }
  21432. }
  21433. }
  21434. }
  21435. }
  21436. //添加乘车语句
  21437. //chiarr.Add(new Grp_ApprovalTravelDetails
  21438. //{
  21439. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  21440. // CreateTime = DateTime.Now,
  21441. // CreateUserId = dto.Userid,
  21442. // ParentId = 0,
  21443. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  21444. //});
  21445. //if (i != timeArr.Count - 1)
  21446. //{
  21447. // fallToTime = fallToTime.AddHours(2.5);
  21448. // foreach (var item in Times)
  21449. // {
  21450. // //排列公务时间
  21451. // if (fallToTime.Hour < item.Item1)
  21452. // {
  21453. // chiarr.Add(new Grp_ApprovalTravelDetails
  21454. // {
  21455. // Time = $"{item.Item2} - {item.Item3}",
  21456. // CreateTime = DateTime.Now,
  21457. // CreateUserId = dto.Userid,
  21458. // ParentId = 0,
  21459. // Details = "公务活动"
  21460. // });
  21461. // }
  21462. // }
  21463. //}
  21464. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  21465. var last = threeCodeStr.Last();
  21466. foreach (var item in threeCodeStr)
  21467. {
  21468. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  21469. if (item.Equals(last))
  21470. {
  21471. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  21472. }
  21473. }
  21474. cityPath = cityPath.Trim('-');
  21475. }
  21476. else
  21477. {
  21478. foreach (var item in Times)
  21479. {
  21480. chiarr.Add(new Grp_ApprovalTravelDetails
  21481. {
  21482. Time = $"{item.Item2} - {item.Item3}",
  21483. CreateTime = DateTime.Now,
  21484. CreateUserId = dto.Userid,
  21485. ParentId = 0,
  21486. Details = "公务活动"
  21487. });
  21488. }
  21489. }
  21490. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  21491. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  21492. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  21493. appro.Diid = dto.Diid;
  21494. appro.CreateUserId = dto.Userid;
  21495. appro.CreateTime = DateTime.Now;
  21496. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  21497. appro.Id = thisId;
  21498. //foreach (var item in gwinfo)
  21499. //{
  21500. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  21501. // chi.Details = "拜访" + item.Client;
  21502. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  21503. // {
  21504. // chi.Details += "," + item.ReqSample;
  21505. // }
  21506. // chi.ParentId = thisId;
  21507. // chi.Time = item.Time;
  21508. // chiarr.Add(chi);
  21509. //}
  21510. if (chiarr.Count < 6)
  21511. {
  21512. for (int j = chiarr.Count; j < 6; j++)
  21513. {
  21514. chiarr.Add(new
  21515. Grp_ApprovalTravelDetails());
  21516. }
  21517. }
  21518. resultArr.Add(new
  21519. {
  21520. appro.Id,
  21521. appro.Date,
  21522. appro.Diid,
  21523. chiList = chiarr.Select(x1 => new
  21524. {
  21525. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  21526. x1.Details,
  21527. x1.ParentId,
  21528. x1.Id
  21529. })
  21530. });
  21531. }
  21532. _sqlSugar.CommitTran();
  21533. jw = JsonView(true, "生成成功!", resultArr);
  21534. }
  21535. catch (Exception ex)
  21536. {
  21537. jw.Code = 400;
  21538. jw.Msg = "生成失败!" + ex.Message;
  21539. }
  21540. return Ok(jw);
  21541. }
  21542. /// <summary>
  21543. /// 报批行程word导出
  21544. /// </summary>
  21545. /// <param name="dto"></param>
  21546. /// <returns></returns>
  21547. [HttpPost]
  21548. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  21549. {
  21550. var jw = JsonView(false);
  21551. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  21552. if (group == null)
  21553. {
  21554. jw.Msg = "暂无该团组!";
  21555. return Ok(jw);
  21556. }
  21557. //模板路径
  21558. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  21559. var fileName = string.Empty;
  21560. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  21561. bool bold = false;
  21562. if (dto.FileIndex == 1)
  21563. {
  21564. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  21565. }
  21566. else if (dto.FileIndex == 2)
  21567. {
  21568. fileName = "省外办-报批.docx";
  21569. bold = false;
  21570. titleFont = "方正黑体简体";
  21571. timeFont = "Times New Roman";
  21572. contentFont = "方正仿宋_GBK";
  21573. }
  21574. else if (dto.FileIndex == 3)
  21575. {
  21576. fileName = "市外办-报批.docx";
  21577. titleFont = "方正黑体简体";
  21578. timeFont = "Times New Roman";
  21579. contentFont = "方正仿宋简体";
  21580. }
  21581. tempPath = tempPath + fileName;
  21582. //载入模板
  21583. Document doc = new Document(tempPath);
  21584. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21585. //获取所填表格的序数
  21586. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21587. Aspose.Words.Tables.Row titleRowClone = null;
  21588. Aspose.Words.Tables.Row CenterRowClone = null;
  21589. int index = 0;
  21590. int indexChi = 0;
  21591. int SetIndex = 0;
  21592. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  21593. //获取数据,放到datatable
  21594. foreach (var item in ApprovalTravelArr)
  21595. {
  21596. if (index > 0)
  21597. {
  21598. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  21599. tableOne.AppendChild(titleRowClone);
  21600. }
  21601. var textTime = item.Date;
  21602. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  21603. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  21604. SetIndex++;
  21605. if (ChiRep.Count > 0)
  21606. {
  21607. foreach (var itemChi in ChiRep)
  21608. {
  21609. var txtTime = itemChi.Time;
  21610. var txtDetail = itemChi.Details;
  21611. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  21612. {
  21613. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  21614. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21615. //indexChi++;
  21616. //SetIndex++;
  21617. break;
  21618. }
  21619. if (indexChi > 0)
  21620. {
  21621. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21622. tableOne.AppendChild(CenterRowClone);
  21623. }
  21624. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  21625. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  21626. indexChi++;
  21627. SetIndex++;
  21628. }
  21629. }
  21630. //else
  21631. //{
  21632. // if (indexChi > 0)
  21633. // {
  21634. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  21635. // tableOne.AppendChild(CenterRowClone);
  21636. // }
  21637. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  21638. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  21639. // indexChi++;
  21640. // SetIndex++;
  21641. //}
  21642. index++;
  21643. }
  21644. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  21645. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21646. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  21647. jw.Code = 200;
  21648. jw.Msg = "";
  21649. return Ok(jw);
  21650. }
  21651. private string ParseBlackTime(string time)
  21652. {
  21653. // 匹配可能只有分钟的情况
  21654. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  21655. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  21656. if (match.Success)
  21657. {
  21658. string hours = match.Groups[1].Value;
  21659. string minutes = match.Groups[2].Value;
  21660. // 如果小时部分为空,则只显示分钟
  21661. if (string.IsNullOrEmpty(hours))
  21662. {
  21663. return $"{minutes}分钟";
  21664. }
  21665. // 如果分钟部分为空,则只显示小时
  21666. else if (string.IsNullOrEmpty(minutes))
  21667. {
  21668. return $"{hours}小时";
  21669. }
  21670. // 否则显示完整格式
  21671. else
  21672. {
  21673. return $"{hours}小时{minutes}分钟";
  21674. }
  21675. }
  21676. else
  21677. {
  21678. return "未知时长";
  21679. }
  21680. }
  21681. private string intToString(int numberVal)
  21682. {
  21683. string numberval = numberVal.ToString();
  21684. Dictionary<char, string> Number = new Dictionary<char, string>();
  21685. Number.Add('1', "一");
  21686. Number.Add('2', "二");
  21687. Number.Add('3', "三");
  21688. Number.Add('4', "四");
  21689. Number.Add('5', "五");
  21690. Number.Add('6', "六");
  21691. Number.Add('7', "七");
  21692. Number.Add('8', "八");
  21693. Number.Add('9', "九");
  21694. string stringNumberVal = string.Empty;
  21695. for (int i = 0; i < numberval.Length; i++)
  21696. {
  21697. if (i == 0)
  21698. {
  21699. stringNumberVal += Number[numberval[i]];
  21700. }
  21701. else if (i >= 1)
  21702. {
  21703. if (numberval[i] == '0')
  21704. {
  21705. stringNumberVal = "十";
  21706. }
  21707. else
  21708. {
  21709. stringNumberVal += "十" + Number[numberval[i]];
  21710. }
  21711. }
  21712. }
  21713. return stringNumberVal;
  21714. }
  21715. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  21716. {
  21717. //获取table中的某个单元格,从0开始
  21718. Cell lshCell = table.Rows[rows].Cells[cells];
  21719. //将单元格中段落移除
  21720. foreach (Paragraph item in lshCell.Paragraphs)
  21721. {
  21722. lshCell.Paragraphs.Remove(item);
  21723. }
  21724. if (val.Contains("\r\n"))
  21725. {
  21726. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  21727. foreach (var item in spArr)
  21728. {
  21729. //新建一个段落
  21730. Paragraph p = new Paragraph(doc);
  21731. var r = new Run(doc, item);
  21732. //设置字体
  21733. if (!string.IsNullOrEmpty(font))
  21734. {
  21735. r.Font.Name = font;
  21736. }
  21737. r.Font.Bold = bold;
  21738. //把设置的值赋给之前新建的段落
  21739. p.AppendChild(r);
  21740. //将此段落加到单元格内
  21741. lshCell.AppendChild(p);
  21742. }
  21743. }
  21744. else
  21745. {
  21746. //新建一个段落
  21747. Paragraph p = new Paragraph(doc);
  21748. var r = new Run(doc, val);
  21749. //设置字体
  21750. if (!string.IsNullOrEmpty(font))
  21751. {
  21752. r.Font.Name = font;
  21753. }
  21754. r.Font.Bold = bold;
  21755. //把设置的值赋给之前新建的段落
  21756. p.AppendChild(r);
  21757. //将此段落加到单元格内
  21758. lshCell.AppendChild(p);
  21759. }
  21760. }
  21761. /// <summary>
  21762. /// 报批行程AI续写
  21763. /// </summary>
  21764. /// <returns></returns>
  21765. [HttpPost]
  21766. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  21767. {
  21768. var jw = JsonView(false);
  21769. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  21770. {
  21771. jw.Msg = "参数有误!";
  21772. return Ok(jw);
  21773. }
  21774. KiMiApiClient kiMi = new KiMiApiClient();
  21775. List<SeedMessages> messages = new List<SeedMessages>() {
  21776. new SeedMessages
  21777. {
  21778. Role = KimiRole.system,
  21779. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  21780. },
  21781. new SeedMessages
  21782. {
  21783. Role = KimiRole.user,
  21784. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  21785. }
  21786. };
  21787. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  21788. string data = kimi_result.Choices[0]?.Message.Content;
  21789. if (string.IsNullOrWhiteSpace(data))
  21790. {
  21791. jw.Data = "Ai续写失败!";
  21792. }
  21793. else
  21794. {
  21795. jw = JsonView(true, "success!", data);
  21796. }
  21797. return Ok(jw);
  21798. }
  21799. #endregion
  21800. #region 团组接待意见调查
  21801. /// <summary>
  21802. /// 团组接待意见调查 - 信息管理
  21803. /// 基础数据(团组)
  21804. /// </summary>
  21805. /// <returns></returns>
  21806. [HttpGet]
  21807. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21808. public async Task<IActionResult> OpinionaireInit()
  21809. {
  21810. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  21811. .Select(x => new
  21812. {
  21813. x.Id,
  21814. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  21815. })
  21816. .OrderByDescending(x => x.Id)
  21817. .ToListAsync();
  21818. return Ok(JsonView(groupData, groupData.Count));
  21819. }
  21820. /// <summary>
  21821. /// 团组接待意见调查 - 信息管理
  21822. /// 列表
  21823. /// </summary>
  21824. /// <param name="groupId"></param>
  21825. /// <returns></returns>
  21826. [HttpGet("{groupId}")]
  21827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21828. public async Task<IActionResult> OpinionaireManageList(int groupId)
  21829. {
  21830. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21831. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  21832. .Select(x => new
  21833. {
  21834. x.Id,
  21835. x.TourGuideName,
  21836. x.CityName,
  21837. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  21838. x.CreateTime
  21839. })
  21840. .OrderBy(x => x.Id)
  21841. .ToListAsync();
  21842. return Ok(JsonView(data));
  21843. }
  21844. /// <summary>
  21845. /// 团组接待意见调查 - 信息管理
  21846. /// 保存
  21847. /// </summary>
  21848. /// <param name="dto"></param>
  21849. /// <returns></returns>
  21850. [HttpPost]
  21851. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21852. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  21853. {
  21854. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21855. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21856. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21857. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  21858. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  21859. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  21860. _opinionaireRep.BeginTran();
  21861. if (addData != null && addData.Count > 0)
  21862. {
  21863. foreach (var item in addData)
  21864. {
  21865. item.CreateUserId = currUserInfo.UserId;
  21866. item.DiId = dto.DiId;
  21867. }
  21868. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  21869. }
  21870. if (updData != null && updData.Count > 0)
  21871. {
  21872. var upd = await _opinionaireRep._sqlSugar
  21873. .Updateable(updData)
  21874. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  21875. .WhereColumns(x => new { x.Id })
  21876. .ExecuteCommandAsync();
  21877. }
  21878. _opinionaireRep.CommitTran();
  21879. return Ok(JsonView("操作成功!"));
  21880. }
  21881. /// <summary>
  21882. /// 团组接待意见调查 - 信息管理
  21883. /// 删除
  21884. /// </summary>
  21885. /// <param name="id"></param>
  21886. /// <returns></returns>
  21887. [HttpDelete("{id}")]
  21888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21889. public async Task<IActionResult> OpinionaireManageDel(int id)
  21890. {
  21891. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  21892. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  21893. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  21894. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  21895. if (!del) return Ok(JsonView("操作失败!"));
  21896. return Ok(JsonView("操作成功!"));
  21897. }
  21898. /// <summary>
  21899. /// 团组接待意见调查 - 用户
  21900. /// 列表
  21901. /// </summary>
  21902. /// <param name="diId"></param>
  21903. /// <returns></returns>
  21904. [HttpGet("{diId}")]
  21905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21906. public async Task<IActionResult> OpinionaireUserList(int diId)
  21907. {
  21908. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  21909. var sql = string.Format(@"
  21910. SELECT
  21911. o.Id,
  21912. o.DiId,
  21913. di.TeamName AS 'GroupName',
  21914. di.VisitPNumber AS 'PeopleNumber',
  21915. di.ClientName AS 'LeadGroup',
  21916. di.VisitCountry AS 'Travel',
  21917. di.VisitDays AS 'Days',
  21918. o.CityName,
  21919. o.TourGuideName,
  21920. o.Catering,
  21921. o.CateringReason,
  21922. o.Stay,
  21923. o.StayReason,
  21924. o.[Route],
  21925. o.RouteReason,
  21926. o.OfficialActivity,
  21927. o.OfficialActivityReason,
  21928. o.TourGuide,
  21929. o.TourGuideReason,
  21930. o.[Translate],
  21931. o.TranslateReason,
  21932. o.Trip,
  21933. o.TripReason,
  21934. o.ESFileName,
  21935. o.SignatureDate,
  21936. o.Remark
  21937. FROM
  21938. Grp_Opinionaire o
  21939. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  21940. WHERE
  21941. o.IsDel = 0
  21942. AND o.DiId = {0}
  21943. ORDER BY
  21944. o.Id ASC", diId);
  21945. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  21946. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  21947. return Ok(JsonView(data));
  21948. }
  21949. /// <summary>
  21950. /// 团组接待意见调查 - 用户
  21951. /// 保存
  21952. /// </summary>
  21953. /// <param name="dto"></param>
  21954. /// <returns></returns>
  21955. [HttpPost]
  21956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21957. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  21958. {
  21959. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  21960. foreach (var item in dto)
  21961. {
  21962. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  21963. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  21964. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  21965. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  21966. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  21967. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  21968. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  21969. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  21970. }
  21971. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  21972. if (!Directory.Exists(filePathBase))
  21973. {
  21974. Directory.CreateDirectory(filePathBase);
  21975. }
  21976. #region 上传文件
  21977. var filePaths = new List<string>();
  21978. foreach (var item in dto)
  21979. {
  21980. var file = item.File;
  21981. // 将文件保存到指定位置
  21982. var filePath = Path.Combine(filePathBase, file.FileName);
  21983. using (var stream = new FileStream(filePath, FileMode.Create))
  21984. {
  21985. await file.CopyToAsync(stream);
  21986. }
  21987. //验证文件是否上传成功
  21988. if (!System.IO.File.Exists(filePath))
  21989. {
  21990. foreach (var filePathStr in filePaths)
  21991. {
  21992. System.IO.File.Delete(filePathStr);
  21993. }
  21994. return Ok(JsonView(false, "文件上传失败!"));
  21995. }
  21996. item.ESFileName = file.FileName;
  21997. }
  21998. #endregion
  21999. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  22000. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  22001. .UpdateColumns(x => new
  22002. {
  22003. x.Catering,
  22004. x.CateringReason,
  22005. x.Stay,
  22006. x.StayReason,
  22007. x.Route,
  22008. x.RouteReason,
  22009. x.OfficialActivity,
  22010. x.OfficialActivityReason,
  22011. x.TourGuide,
  22012. x.TourGuideReason,
  22013. x.Translate,
  22014. x.TranslateReason,
  22015. x.Trip,
  22016. x.TripReason,
  22017. x.ESFileName,
  22018. x.SignatureDate,
  22019. x.Remark
  22020. })
  22021. .WhereColumns(x => new { x.Id })
  22022. .ExecuteCommandAsync();
  22023. if (upd < 1)
  22024. {
  22025. foreach (var filePathStr in filePaths)
  22026. {
  22027. System.IO.File.Delete(filePathStr);
  22028. }
  22029. return Ok(JsonView(false));
  22030. }
  22031. return Ok(JsonView(true));
  22032. }
  22033. #endregion
  22034. #region 团组餐厅相关信息
  22035. /// <summary>
  22036. /// 团组相关餐厅信息
  22037. /// 基础数据(团组)
  22038. /// </summary>
  22039. /// <returns></returns>
  22040. [HttpGet]
  22041. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22042. public async Task<IActionResult> RestaurantInit()
  22043. {
  22044. return Ok(await _restaurantRep.InitAsync());
  22045. }
  22046. /// <summary>
  22047. /// 团组相关餐厅信息
  22048. /// Item
  22049. /// </summary>
  22050. /// <param name="dto"></param>
  22051. /// <returns></returns>
  22052. [HttpPost]
  22053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22054. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  22055. {
  22056. int portType = dto.PortType,
  22057. groupId = dto.GroupId;
  22058. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22059. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22060. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  22061. }
  22062. /// <summary>
  22063. /// 团组相关餐厅信息
  22064. /// List
  22065. /// </summary>
  22066. /// <param name="dto"></param>
  22067. /// <returns></returns>
  22068. [HttpPost]
  22069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22070. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  22071. {
  22072. int portType = dto.PortType,
  22073. groupId = dto.GroupId;
  22074. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22075. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22076. var sql = string.Format(@" SELECT
  22077. ri.Id,
  22078. ri.GroupId,
  22079. ri.Date,
  22080. ri.StartTime,
  22081. ri.EndTime,
  22082. CASE WHEN ri.Type = 1 THEN '早餐'
  22083. WHEN ri.Type = 2 THEN '午餐'
  22084. WHEN ri.Type = 3 THEN '晚餐'
  22085. ELSE '其他'
  22086. END AS 'Type',
  22087. ri.Name,
  22088. ri.Address,
  22089. ri.Tel,
  22090. ri.Remark,
  22091. ri.CreateTime,
  22092. u.CnName AS CreateUserName
  22093. FROM
  22094. Grp_RestaurantInfo ri
  22095. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  22096. WHERE
  22097. ri.IsDel = 0
  22098. AND ri.GroupId = {0}
  22099. ORDER BY
  22100. ri.Date ASC
  22101. ", groupId);
  22102. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  22103. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  22104. return Ok(JsonView(infos));
  22105. }
  22106. /// <summary>
  22107. /// 团组相关餐厅信息
  22108. /// Info
  22109. /// </summary>
  22110. /// <param name="dto"></param>
  22111. /// <returns></returns>
  22112. [HttpPost]
  22113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22114. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  22115. {
  22116. int portType = dto.PortType,
  22117. id = dto.Id;
  22118. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  22119. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22120. return Ok(await _restaurantRep.InfoAsync(portType, id));
  22121. }
  22122. /// <summary>
  22123. /// 团组相关餐厅信息
  22124. /// Op
  22125. /// </summary>
  22126. /// <param name="dto"></param>
  22127. /// <returns></returns>
  22128. [HttpPost]
  22129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22130. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  22131. {
  22132. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22133. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  22134. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  22135. return Ok(await _restaurantRep.OpAsync(dto));
  22136. }
  22137. /// <summary>
  22138. /// 团组相关餐厅信息
  22139. /// Del
  22140. /// </summary>
  22141. /// <param name="dto"></param>
  22142. /// <returns></returns>
  22143. [HttpPost]
  22144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22145. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  22146. {
  22147. int userId = dto.DeleteUserId;
  22148. var id = dto.Id;
  22149. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  22150. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  22151. return Ok(await _restaurantRep.DelAsync(dto));
  22152. }
  22153. #endregion
  22154. /// <summary>
  22155. /// 123132123
  22156. /// </summary>
  22157. /// <param name="_dto"></param>
  22158. /// <returns></returns>
  22159. [HttpPost]
  22160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22161. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  22162. {
  22163. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  22164. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  22165. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  22166. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  22167. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  22168. dicDetail.Add(789, 1034);
  22169. dicDetail.Add(790, 1035);
  22170. dicDetail.Add(791, 1036);
  22171. dicDetail.Add(792, 1037);
  22172. dicDetail.Add(793, 1038);
  22173. dicDetail.Add(794, 1039);
  22174. dicDetail.Add(795, 1040);
  22175. dicDetail.Add(796, 1041);
  22176. dicDetail.Add(797, 1042);
  22177. dicDetail.Add(798, 1043);
  22178. dicDetail.Add(801, 1044);
  22179. dicDetail.Add(802, 1045);
  22180. dicDetail.Add(803, 1046);
  22181. Dictionary<int, int> dic = new Dictionary<int, int>();
  22182. dic.Add(806, 1027);
  22183. dic.Add(807, 1028);
  22184. dic.Add(808, 1029);
  22185. dic.Add(809, 1030);
  22186. dic.Add(810, 1031);
  22187. dic.Add(811, 1032);
  22188. dic.Add(812, 1033);
  22189. foreach (var item in list_visa)
  22190. {
  22191. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  22192. temp.Coefficient = item.coefficient;
  22193. DateTime dtCrt;
  22194. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  22195. if (b1)
  22196. {
  22197. temp.CreateTime = dtCrt;
  22198. }
  22199. else
  22200. {
  22201. temp.CreateTime = DateTime.Now;
  22202. }
  22203. temp.CreateUserId = item.Operators;
  22204. temp.DeleteTime = "";
  22205. temp.DeleteUserId = 0;
  22206. temp.DiId = int.Parse(item.DIID);
  22207. temp.FilePath = item.FilePath;
  22208. temp.IsDel = item.IsDel;
  22209. temp.Price = item.Price;
  22210. temp.PriceCount = 1;
  22211. temp.PriceCurrency = item.Currency;
  22212. int detailId = 0;
  22213. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  22214. {
  22215. detailId = dicDetail[item.PriceTypeDetail];
  22216. }
  22217. temp.PriceDetailType = detailId;
  22218. temp.PriceDt = DateTime.Now;
  22219. temp.PriceName = item.PriceName;
  22220. temp.PriceSum = item.Price;
  22221. int tid = 0;
  22222. if (dic.ContainsKey(item.PriceType))
  22223. {
  22224. tid = dic[item.PriceType];
  22225. }
  22226. temp.PriceType = tid;
  22227. temp.Remark = item.Remark;
  22228. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  22229. }
  22230. return Ok(JsonView(true, "操作成功!"));
  22231. }
  22232. [HttpPost]
  22233. public IActionResult TimeTest()
  22234. {
  22235. var jw = JsonView(false, "error");
  22236. _sqlSugar.BeginTran();
  22237. try
  22238. {
  22239. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  22240. .Select(x => new Crm_NewClientData
  22241. {
  22242. Id = x.Id,
  22243. Client = x.Client,
  22244. Contact = x.Contact,
  22245. Location = x.Location,
  22246. })
  22247. .ToList();
  22248. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  22249. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  22250. Stopwatch stopwatch = new Stopwatch();
  22251. // 开始计时
  22252. stopwatch.Start();
  22253. foreach (var item in clientList)
  22254. {
  22255. EncryptionProcessor.DecryptProperties(item);
  22256. }
  22257. stopwatch.Stop();
  22258. jw.Code = 200;
  22259. jw.Data = stopwatch.ElapsedMilliseconds;
  22260. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  22261. }
  22262. catch (Exception ex)
  22263. {
  22264. jw.Code = 400;
  22265. jw.Msg = ex.Message;
  22266. }
  22267. return Ok(jw);
  22268. }
  22269. }
  22270. }