GroupsController.cs 831 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914
  1. using Aspose.Cells;
  2. using Aspose.Cells.Charts;
  3. using Aspose.Words;
  4. using Aspose.Words.Drawing;
  5. using Aspose.Words.Tables;
  6. using EyeSoft.Collections.Generic;
  7. using EyeSoft.IO;
  8. using Google.Protobuf.WellKnownTypes;
  9. using Microsoft.AspNetCore.SignalR;
  10. using MySqlX.XDevAPI.Relational;
  11. using NetUV.Core.Handles;
  12. using NPOI.HSSF.UserModel;
  13. using NPOI.POIFS.Crypt.Dsig;
  14. using NPOI.SS.Format;
  15. using NPOI.SS.Formula.Functions;
  16. using NPOI.SS.UserModel;
  17. using NPOI.SS.Util;
  18. using NPOI.XSSF.UserModel;
  19. using OASystem.API.OAMethodLib;
  20. using OASystem.API.OAMethodLib.APNs;
  21. using OASystem.API.OAMethodLib.File;
  22. using OASystem.API.OAMethodLib.Hub.HubClients;
  23. using OASystem.API.OAMethodLib.Hub.Hubs;
  24. using OASystem.API.OAMethodLib.JuHeAPI;
  25. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  26. using OASystem.Domain.AesEncryption;
  27. using OASystem.Domain.Dtos.CRM;
  28. using OASystem.Domain.Dtos.FileDto;
  29. using OASystem.Domain.Dtos.Financial;
  30. using OASystem.Domain.Dtos.Groups;
  31. using OASystem.Domain.Entities.Customer;
  32. using OASystem.Domain.Entities.Financial;
  33. using OASystem.Domain.Entities.Groups;
  34. using OASystem.Domain.ViewModels;
  35. using OASystem.Domain.ViewModels.Financial;
  36. using OASystem.Domain.ViewModels.Groups;
  37. using OASystem.Domain.ViewModels.Statistics;
  38. using OASystem.Infrastructure.Repositories.CRM;
  39. using OASystem.Infrastructure.Repositories.Financial;
  40. using OASystem.Infrastructure.Repositories.Groups;
  41. using OfficeOpenXml;
  42. using Org.BouncyCastle.Asn1.Ocsp;
  43. using Quartz.Util;
  44. using SqlSugar;
  45. using SqlSugar.Extensions;
  46. using System.Collections;
  47. using System.Data;
  48. using System.Data.OleDb;
  49. using System.Diagnostics;
  50. using System.Globalization;
  51. using System.IO;
  52. using System.IO.Compression;
  53. using System.Net.Http;
  54. using System.Reflection.PortableExecutable;
  55. using System.Security.Cryptography;
  56. using Ubiety.Dns.Core;
  57. using static NPOI.POIFS.Crypt.CryptoFunctions;
  58. using static OASystem.API.OAMethodLib.JWTHelper;
  59. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  60. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  61. using Bookmark = Aspose.Words.Bookmark;
  62. using Cell = Aspose.Words.Tables.Cell;
  63. using Table = Aspose.Words.Tables.Table;
  64. namespace OASystem.API.Controllers
  65. {
  66. /// <summary>
  67. /// 团组相关
  68. /// </summary>
  69. //[Authorize]
  70. [Route("api/[controller]/[action]")]
  71. public class GroupsController : ControllerBase
  72. {
  73. private readonly ILogger<GroupsController> _logger;
  74. private readonly GrpScheduleRepository _grpScheduleRep;
  75. private readonly IMapper _mapper;
  76. private readonly DelegationInfoRepository _groupRepository;
  77. private readonly TaskAssignmentRepository _taskAssignmentRep;
  78. private readonly AirTicketResRepository _airTicketResRep;
  79. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  80. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  81. private readonly DelegationEnDataRepository _delegationEnDataRep;
  82. private readonly DelegationVisaRepository _delegationVisaRep;
  83. private readonly VisaPriceRepository _visaPriceRep;
  84. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  85. private readonly HotelPriceRepository _hotelPriceRep;
  86. private readonly CustomersRepository _customersRep;
  87. private readonly MessageRepository _message;
  88. private readonly SqlSugarClient _sqlSugar;
  89. private readonly TourClientListRepository _tourClientListRep;
  90. private readonly TeamRateRepository _teamRateRep;
  91. #region 成本相关
  92. private readonly CheckBoxsRepository _checkBoxs;
  93. private readonly GroupCostRepository _GroupCostRepository;
  94. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  95. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  96. #endregion
  97. private readonly SetDataRepository _setDataRep;
  98. private string url;
  99. private string path;
  100. private readonly EnterExitCostRepository _enterExitCostRep;
  101. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  102. private readonly UsersRepository _usersRep;
  103. private readonly IJuHeApiService _juHeApi;
  104. private readonly InvertedListRepository _invertedListRep;
  105. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  106. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  107. private readonly ThreeCodeRepository _threeCodeRepository;
  108. private readonly HotelInquiryRepository _hotelInquiryRep;
  109. private readonly FeeAuditRepository _feeAuditRep;
  110. private readonly VisaCommissionRepository _visaCommissionRep;
  111. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  112. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  113. private readonly List<CurrencyInfo> _currencyInit;
  114. private readonly List<int> _portTypeData;
  115. private readonly TableOperationRecordRepository _tableorRep;
  116. public GroupsController(
  117. ILogger<GroupsController> logger,
  118. IMapper mapper,
  119. IHubContext<ChatHub, IChatClient> hubContext,
  120. SqlSugarClient sqlSugar,
  121. GrpScheduleRepository grpScheduleRep,
  122. DelegationInfoRepository groupRepository,
  123. TaskAssignmentRepository taskAssignmentRep,
  124. AirTicketResRepository airTicketResRep,
  125. DecreasePaymentsRepository decreasePaymentsRep,
  126. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  127. DelegationEnDataRepository delegationEnDataRep,
  128. EnterExitCostRepository enterExitCostRep,
  129. DelegationVisaRepository delegationVisaRep,
  130. MessageRepository message,
  131. VisaPriceRepository visaPriceRep,
  132. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  133. CheckBoxsRepository checkBoxs,
  134. GroupCostRepository GroupCostRepository,
  135. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  136. GroupCostParameterRepository GroupCostParameterRepository,
  137. HotelPriceRepository hotelPriceRep,
  138. CustomersRepository customersRep,
  139. SetDataRepository setDataRep,
  140. TourClientListRepository tourClientListRep,
  141. TeamRateRepository teamRateRep,
  142. UsersRepository usersRep, IJuHeApiService juHeApi,
  143. InvertedListRepository invertedListRep,
  144. VisaFeeInfoRepository visaFeeInfoRep,
  145. TicketBlackCodeRepository ticketBlackCodeRep,
  146. HotelInquiryRepository hotelInquiryRep,
  147. ThreeCodeRepository threeCodeRepository,
  148. FeeAuditRepository feeAuditRep,
  149. VisaCommissionRepository visaCommissionRep,
  150. ForeignReceivablesRepository ffrRep,
  151. OpinionaireRepository opinionaireRep,
  152. TableOperationRecordRepository tableorRep
  153. )
  154. {
  155. _logger = logger;
  156. _mapper = mapper;
  157. _grpScheduleRep = grpScheduleRep;
  158. _groupRepository = groupRepository;
  159. _taskAssignmentRep = taskAssignmentRep;
  160. _airTicketResRep = airTicketResRep;
  161. _sqlSugar = sqlSugar;
  162. url = AppSettingsHelper.Get("ExcelBaseUrl");
  163. path = AppSettingsHelper.Get("ExcelBasePath");
  164. if (!System.IO.Directory.Exists(path))
  165. {
  166. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  167. }
  168. _decreasePaymentsRep = decreasePaymentsRep;
  169. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  170. _delegationEnDataRep = delegationEnDataRep;
  171. _enterExitCostRep = enterExitCostRep;
  172. _delegationVisaRep = delegationVisaRep;
  173. _message = message;
  174. _visaPriceRep = visaPriceRep;
  175. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  176. _checkBoxs = checkBoxs;
  177. _GroupCostRepository = GroupCostRepository;
  178. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  179. _GroupCostParameterRepository = GroupCostParameterRepository;
  180. _hotelPriceRep = hotelPriceRep;
  181. _customersRep = customersRep;
  182. _setDataRep = setDataRep;
  183. _tourClientListRep = tourClientListRep;
  184. _teamRateRep = teamRateRep;
  185. _hubContext = hubContext;
  186. _usersRep = usersRep;
  187. _juHeApi = juHeApi;
  188. _invertedListRep = invertedListRep;
  189. _visaFeeInfoRep = visaFeeInfoRep;
  190. _ticketBlackCodeRep = ticketBlackCodeRep;
  191. _hotelInquiryRep = hotelInquiryRep;
  192. _threeCodeRepository = threeCodeRepository;
  193. _feeAuditRep = feeAuditRep;
  194. _visaCommissionRep = visaCommissionRep;
  195. _ffrRep = ffrRep;
  196. _opinionaireRep = opinionaireRep;
  197. _currencyInit = new List<CurrencyInfo>()
  198. {
  199. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  200. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  201. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  202. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  203. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  204. };
  205. _portTypeData = new List<int>() { 2, 3 };
  206. _tableorRep = tableorRep;
  207. }
  208. #region 流程管控
  209. /// <summary>
  210. /// 获取团组流程管控信息
  211. /// </summary>
  212. /// <param name="paras">参数Json字符串</param>
  213. /// <returns></returns>
  214. [HttpPost]
  215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  216. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  217. {
  218. if (string.IsNullOrEmpty(_jsonDto.Paras))
  219. {
  220. return Ok(JsonView(false, "参数为空"));
  221. }
  222. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  223. if (_ScheduleDto != null)
  224. {
  225. if (_ScheduleDto.SearchType == 2)//获取列表
  226. {
  227. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  228. return Ok(JsonView(_grpScheduleViewList));
  229. }
  230. else//获取对象
  231. {
  232. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  233. if (_grpScheduleView != null)
  234. {
  235. return Ok(JsonView(_grpScheduleView));
  236. }
  237. }
  238. }
  239. else
  240. {
  241. return Ok(JsonView(false, "参数反序列化失败"));
  242. }
  243. return Ok(JsonView(false, "暂无数据!"));
  244. }
  245. /// <summary>
  246. /// 修改团组流程管控详细表数据
  247. /// </summary>
  248. /// <param name="paras"></param>
  249. /// <returns></returns>
  250. [HttpPost]
  251. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  252. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  253. {
  254. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  255. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  256. .SetColumns(it => it.Duty == _detail.Duty)
  257. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  258. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  259. .SetColumns(it => it.JobContent == _detail.JobContent)
  260. .SetColumns(it => it.Remark == _detail.Remark)
  261. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  262. .Where(s => s.Id == dto.Id)
  263. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  264. .ExecuteCommandAsync();
  265. if (result > 0)
  266. {
  267. return Ok(JsonView(true, "保存成功!"));
  268. }
  269. return Ok(JsonView(false, "保存失败!"));
  270. }
  271. /// <summary>
  272. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  273. /// </summary>
  274. /// <param name="dto"></param>
  275. /// <returns></returns>
  276. [HttpPost]
  277. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  278. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  279. {
  280. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  281. _detail.IsDel = 1;
  282. _detail.DeleteUserId = dto.Duty;
  283. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  284. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  285. .SetColumns(it => it.IsDel == _detail.IsDel)
  286. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  287. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  288. .Where(it => it.Id == dto.Id)
  289. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  290. //.WhereColumns(s => s.Id == dto.Id)
  291. .ExecuteCommandAsync();
  292. if (result > 0)
  293. {
  294. return Ok(JsonView(true, "删除成功!"));
  295. }
  296. return Ok(JsonView(false, "删除失败!"));
  297. }
  298. /// <summary>
  299. /// 增加团组流程管控详细表数据
  300. /// </summary>
  301. /// <param name="dto"></param>
  302. /// <returns></returns>
  303. [HttpPost]
  304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  305. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  306. {
  307. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  308. if (DateTime.Now < _detail.ExpectBeginDt)
  309. {
  310. _detail.StepStatus = 0;
  311. }
  312. else
  313. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  314. _detail.StepStatus = 1;
  315. }
  316. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  317. if (result > 0)
  318. {
  319. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  320. return Ok(JsonView(true, "添加成功!", _result));
  321. }
  322. return Ok(JsonView(false, "添加失败!"));
  323. }
  324. #endregion
  325. #region 团组基本信息
  326. /// <summary>
  327. /// 接团信息列表
  328. /// </summary>
  329. /// <param name="dto">团组列表请求dto</param>
  330. /// <returns></returns>
  331. [HttpPost]
  332. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  333. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  334. {
  335. var groupData = await _groupRepository.GetGroupList(dto);
  336. if (groupData.Code != 0)
  337. {
  338. return Ok(JsonView(false, groupData.Msg));
  339. }
  340. return Ok(JsonView(groupData.Data));
  341. }
  342. /// <summary>
  343. /// 分页查询团组列表
  344. /// </summary>
  345. /// <param name="dto"></param>
  346. /// <returns></returns>
  347. [HttpPost]
  348. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  349. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  350. {
  351. var watch = new Stopwatch();
  352. watch.Start();
  353. RefAsync<int> total = 0;
  354. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  355. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  356. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  357. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  358. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  359. .Distinct()
  360. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  361. watch.Stop();
  362. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  363. }
  364. /// <summary>
  365. /// 接团信息列表 Page
  366. /// </summary>
  367. /// <param name="dto">团组列表请求dto</param>
  368. /// <returns></returns>
  369. [HttpPost]
  370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  371. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  372. {
  373. #region 参数验证
  374. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  375. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  376. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  377. #region 页面操作权限验证
  378. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  379. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  380. #endregion
  381. #endregion
  382. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  383. {
  384. string sqlWhere = string.Empty;
  385. if (dto.IsSure == 0) //未完成
  386. {
  387. sqlWhere += string.Format(@" And IsSure = 0");
  388. }
  389. else if (dto.IsSure == 1) //已完成
  390. {
  391. sqlWhere += string.Format(@" And IsSure = 1");
  392. }
  393. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  394. {
  395. string tj = dto.SearchCriteria;
  396. 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}%')",
  397. tj, tj, tj, tj, tj);
  398. }
  399. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  400. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  401. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  402. JietuanOperator,IsSure,CreateTime,IsBid
  403. From (
  404. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  405. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  406. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  407. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  408. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  409. From Grp_DelegationInfo gdi
  410. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  411. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  412. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  413. Where gdi.IsDel = 0 {0}
  414. ) temp", sqlWhere);
  415. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  416. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  417. #region 处理所属部门
  418. /*
  419. * 1.sq 和 gyy 等显示 市场部
  420. * 2.王鸽和主管及张总还有管理员号统一国交部
  421. * 2-1. 4 管理员 ,21 张海麟
  422. */
  423. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  424. List<int> userIds1 = new List<int>() { 4, 21 };
  425. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  426. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  427. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  428. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  429. .ToList();
  430. foreach (var item in _DelegationList)
  431. {
  432. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  433. }
  434. #endregion
  435. var _view = new
  436. {
  437. PageFuncAuth = pageFunAuthView,
  438. Data = _DelegationList
  439. };
  440. return Ok(JsonView(true, "查询成功!", _view, total));
  441. }
  442. else
  443. {
  444. return Ok(JsonView(false, "查询失败"));
  445. }
  446. }
  447. /// <summary>
  448. /// 团组列表
  449. /// </summary>
  450. /// <returns></returns>
  451. [HttpPost]
  452. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  453. {
  454. #region 参数验证
  455. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  456. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  457. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  458. #region 页面操作权限验证
  459. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  460. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  461. #endregion
  462. #endregion
  463. if (dto.PortType != 1 && dto.PortType != 2)
  464. {
  465. return Ok(JsonView(false, "查询失败!"));
  466. }
  467. string orderbyStr = "order by gdi.CreateTime Desc";
  468. string sqlWhere = string.Empty;
  469. if (dto.IsSure == 0) //未完成
  470. {
  471. sqlWhere += string.Format(@" And IsSure = 0");
  472. }
  473. else if (dto.IsSure == 1) //已完成
  474. {
  475. sqlWhere += string.Format(@" And IsSure = 1");
  476. }
  477. //团组类型
  478. if (dto.TeamDid > 0)
  479. {
  480. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  481. }
  482. //团组名称
  483. if (!string.IsNullOrEmpty(dto.TeamName))
  484. {
  485. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  486. }
  487. //客户名称
  488. if (!string.IsNullOrEmpty(dto.ClientName))
  489. {
  490. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  491. }
  492. //客户单位
  493. if (!string.IsNullOrEmpty(dto.ClientUnit))
  494. {
  495. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  496. }
  497. //出访时间
  498. if (!string.IsNullOrEmpty(dto.visitDataTime))
  499. {
  500. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  501. orderbyStr = "order by gdi.VisitDate";
  502. }
  503. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  504. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  505. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  506. JietuanOperator,IsSure,CreateTime
  507. From (
  508. Select row_number() over({0}) as Row_Number,
  509. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  510. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  511. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  512. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  513. From Grp_DelegationInfo gdi
  514. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  515. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  516. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  517. Where gdi.IsDel = 0 {1}
  518. ) temp ", orderbyStr, sqlWhere);
  519. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  520. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  521. #region 处理所属部门
  522. /*
  523. * 1.sq 和 gyy 等显示 市场部
  524. * 2.王鸽和主管及张总还有管理员号统一国交部
  525. * 2-1. 4 管理员 ,21 张海麟
  526. */
  527. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  528. List<int> userIds1 = new List<int>() { 4, 21 };
  529. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  530. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  531. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  532. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  533. .ToList();
  534. foreach (var item in _DelegationList)
  535. {
  536. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  537. }
  538. #endregion
  539. var _view = new
  540. {
  541. PageFuncAuth = pageFunAuthView,
  542. Data = _DelegationList
  543. };
  544. return Ok(JsonView(true, "查询成功!", _view, total));
  545. }
  546. /// <summary>
  547. /// 接团信息详情
  548. /// </summary>
  549. /// <param name="dto">团组info请求dto</param>
  550. /// <returns></returns>
  551. [HttpPost]
  552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  553. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  554. {
  555. var groupData = await _groupRepository.GetGroupInfo(dto);
  556. if (groupData.Code != 0)
  557. {
  558. return Ok(JsonView(false, groupData.Msg));
  559. }
  560. return Ok(JsonView(groupData.Data));
  561. }
  562. /// <summary>
  563. /// 接团信息 编辑添加
  564. /// 基础信息数据源
  565. /// </summary>
  566. /// <param name="dto"></param>
  567. /// <returns></returns>
  568. [HttpPost]
  569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  570. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  571. {
  572. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  573. if (groupData.Code != 0)
  574. {
  575. return Ok(JsonView(false, groupData.Msg));
  576. }
  577. return Ok(JsonView(groupData.Data));
  578. }
  579. /// <summary>
  580. /// 接团信息 操作(增改)
  581. /// </summary>
  582. /// <param name="dto"></param>
  583. /// <returns></returns>
  584. [HttpPost]
  585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  586. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  587. {
  588. try
  589. {
  590. decimal ffrPrice = 0.00M;
  591. DateTime? visitDt = null;
  592. if (dto.Status == 2)
  593. {
  594. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  595. if (groupInfo != null)
  596. {
  597. ffrPrice = groupInfo.PaymentMoney;
  598. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  599. }
  600. }
  601. var groupData = await _groupRepository.GroupOperation(dto);
  602. if (groupData.Code != 0)
  603. {
  604. return Ok(JsonView(false, groupData.Msg));
  605. }
  606. int diId = 0;
  607. //添加时 默认加入团组汇率
  608. if (dto.Status == 1) //添加
  609. {
  610. diId = groupData.Data;
  611. //添加默认币种
  612. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  613. //默认分配权限
  614. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  615. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  616. var _managerIds = new List<int>() { 22, 32, 21 };
  617. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  618. if (userIds.Count > 0)
  619. {
  620. userIds.Add(208);
  621. //创建团组管控
  622. GroupStepForDelegation.CreateWorkStep(diId);
  623. //发送消息
  624. string groupName = dto.TeamName;
  625. string createGroupUser = string.Empty;
  626. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  627. if (userInfo != null) createGroupUser = userInfo.CnName;
  628. string title = $"系统通知";
  629. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  630. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  631. }
  632. //默认创建倒推表
  633. await _invertedListRep._Create(dto.UserId, diId);
  634. }
  635. else if (dto.Status == 2)
  636. {
  637. diId = dto.Id;
  638. }
  639. #region 签证人员团组时间通知
  640. #region 计算出访起止时间
  641. var startTime = new DateTime();
  642. var endTime = new DateTime();
  643. if (DateTime.TryParse(dto.VisitDate, out startTime))
  644. {
  645. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  646. }
  647. #endregion
  648. if (diId > 0)
  649. {
  650. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  651. }
  652. #endregion
  653. #region 团组操作默认添加/修改收款账单
  654. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  655. {
  656. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  657. .Where(x => x.IsDel == 0 &&
  658. x.Diid == diId &&
  659. x.Remark.Equals("预付款")
  660. )
  661. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  662. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  663. .FirstAsync();
  664. ffrInfo = new Fin_ForeignReceivables()
  665. {
  666. Diid = diId,
  667. PriceName = dto.ClientUnit,
  668. Price = dto.PaymentMoney,
  669. Count = 1,
  670. Unit = $"元",
  671. ItemSumPrice = dto.PaymentMoney,
  672. Rate = 1.0000M,
  673. Currency = 836,
  674. AddingWay = 0,
  675. CreateUserId = dto.UserId,
  676. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  677. Remark = $"预付款"
  678. };
  679. if (ffrInfo == null) //Add
  680. {
  681. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  682. }
  683. else //修改
  684. {
  685. await _sqlSugar.Updateable(ffrInfo)
  686. .UpdateColumns(x => new
  687. {
  688. x.PriceName,
  689. x.Price,
  690. x.ItemSumPrice,
  691. x.CreateTime,
  692. x.CreateUserId
  693. })
  694. .WhereColumns(x => x.Id)
  695. .ExecuteCommandAsync();
  696. }
  697. }
  698. #endregion
  699. return Ok(JsonView(true, "操作成功!", diId));
  700. }
  701. catch (Exception ex)
  702. {
  703. Logs("[response]" + JsonConvert.SerializeObject(dto));
  704. Logs(ex.Message);
  705. return Ok(JsonView(false, ex.Message));
  706. }
  707. }
  708. /// <summary>
  709. /// 接团流程操作(增改)
  710. /// 安卓端使用 建团时添加客户名单
  711. /// </summary>
  712. /// <param name="dto"></param>
  713. /// <returns></returns>
  714. [HttpPost]
  715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  716. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  717. {
  718. try
  719. {
  720. #region 参数验证
  721. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  722. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  723. #region 页面操作权限验证
  724. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  725. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  726. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  727. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  728. #endregion
  729. #endregion
  730. _sqlSugar.BeginTran();
  731. decimal ffrPrice = 0.00M;
  732. DateTime? visitDt = null;
  733. if (dto.Status == 2)
  734. {
  735. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  736. if (groupInfo != null)
  737. {
  738. ffrPrice = groupInfo.PaymentMoney;
  739. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  740. }
  741. }
  742. var _dto = new GroupOperationDto();
  743. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  744. var groupData = await _groupRepository.GroupOperation(_dto);
  745. if (groupData.Code != 0)
  746. {
  747. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  748. }
  749. int diId = 0;
  750. //添加时 默认加入团组汇率
  751. if (dto.Status == 1) //添加
  752. {
  753. diId = groupData.Data;
  754. //添加默认币种
  755. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  756. //默认分配权限
  757. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  758. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  759. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  760. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  761. if (userIds.Count > 0)
  762. {
  763. userIds.Add(208);
  764. //创建团组管控
  765. GroupStepForDelegation.CreateWorkStep(diId);
  766. //发送消息
  767. string groupName = dto.TeamName;
  768. string createGroupUser = string.Empty;
  769. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  770. if (userInfo != null) createGroupUser = userInfo.CnName;
  771. string title = $"系统通知";
  772. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  773. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  774. }
  775. #region 应用推送
  776. try
  777. {
  778. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  779. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  780. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  781. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  782. {
  783. List<string> userList = new List<string>() { users.QiyeChatUserId };
  784. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  785. }
  786. }
  787. catch (Exception ex)
  788. {
  789. }
  790. #endregion
  791. //默认创建倒推表
  792. await _invertedListRep._Create(dto.UserId, diId);
  793. }
  794. if (dto.Status == 2)
  795. {
  796. diId = dto.Id;
  797. if (diId == 0)
  798. {
  799. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  800. }
  801. }
  802. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  803. if (viewData.Code != 0)
  804. {
  805. _sqlSugar.RollbackTran();
  806. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  807. }
  808. #region 团组操作默认添加/修改收款账单
  809. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  810. {
  811. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  812. .Where(x => x.IsDel == 0 &&
  813. x.Diid == diId &&
  814. x.Remark.Equals("预付款")
  815. )
  816. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  817. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  818. .FirstAsync();
  819. ffrInfo = new Fin_ForeignReceivables()
  820. {
  821. Diid = diId,
  822. PriceName = dto.ClientUnit,
  823. Price = dto.PaymentMoney,
  824. Count = 1,
  825. Unit = $"元",
  826. ItemSumPrice = dto.PaymentMoney,
  827. Rate = 1.0000M,
  828. Currency = 836,
  829. AddingWay = 0,
  830. CreateUserId = dto.UserId,
  831. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  832. Remark = $"预付款"
  833. };
  834. if (ffrInfo == null) //Add
  835. {
  836. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  837. }
  838. else //修改
  839. {
  840. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  841. .UpdateColumns(x => new
  842. {
  843. x.PriceName,
  844. x.Price,
  845. x.ItemSumPrice,
  846. x.CreateTime,
  847. x.CreateUserId
  848. })
  849. .WhereColumns(x => x.Id)
  850. .ExecuteCommandAsync();
  851. }
  852. }
  853. #endregion
  854. #region 签证人员团组时间通知
  855. #region 计算出访起止时间
  856. var startTime = new DateTime();
  857. var endTime = new DateTime();
  858. if (DateTime.TryParse(dto.VisitDate, out startTime))
  859. {
  860. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  861. }
  862. #endregion
  863. if (diId > 0)
  864. {
  865. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  866. }
  867. #endregion
  868. _sqlSugar.CommitTran();
  869. return Ok(JsonView(true, "添加成功"));
  870. }
  871. catch (Exception ex)
  872. {
  873. _sqlSugar.RollbackTran();
  874. return Ok(JsonView(false, ex.Message));
  875. }
  876. }
  877. /// <summary>
  878. /// 接团信息 操作(删除)
  879. /// </summary>
  880. /// <param name="dto"></param>
  881. /// <returns></returns>
  882. [HttpPost]
  883. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  884. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  885. {
  886. var diId = dto.Id;
  887. if (diId < 1) return Ok(JsonView(false,MsgTips.Id));
  888. #region 删除 验证 (费用录入、出入境费用、收款账单)
  889. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  890. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  891. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  892. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  893. #endregion
  894. var groupData = await _groupRepository.GroupDel(dto);
  895. if (groupData.Code != 0)
  896. {
  897. return Ok(JsonView(false, groupData.Msg));
  898. }
  899. return Ok(JsonView(true));
  900. }
  901. /// <summary>
  902. /// 获取团组销售报价号
  903. /// 团组添加时 使用
  904. /// </summary>
  905. /// <returns></returns>
  906. [HttpPost]
  907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  908. public async Task<IActionResult> GetGroupSalesQuoteNo()
  909. {
  910. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  911. if (groupData.Code != 0)
  912. {
  913. return Ok(JsonView(false, groupData.Msg));
  914. }
  915. object salesQuoteNo = new
  916. {
  917. SalesQuoteNo = groupData.Data
  918. };
  919. return Ok(JsonView(salesQuoteNo));
  920. }
  921. /// <summary>
  922. /// 设置确认出团
  923. /// </summary>
  924. /// <param name="dto"></param>
  925. /// <returns></returns>
  926. [HttpPost]
  927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  928. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  929. {
  930. var groupData = await _groupRepository.ConfirmationGroup(dto);
  931. if (groupData.Code != 0)
  932. {
  933. return Ok(JsonView(false, groupData.Msg));
  934. }
  935. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  936. #region OA消息推送
  937. try
  938. {
  939. string groupName = groupInfo.TeamName;
  940. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  941. string title = $"系统通知";
  942. string content = $"团组[{groupName}]已确认出团!";
  943. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  944. }
  945. catch (Exception ex)
  946. {
  947. }
  948. #endregion
  949. #region 应用推送
  950. try
  951. {
  952. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  953. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  954. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  955. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  956. {
  957. List<string> userList = new List<string>() { users.QiyeChatUserId };
  958. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  959. }
  960. }
  961. catch (Exception ex)
  962. {
  963. }
  964. #endregion
  965. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  966. return Ok(JsonView(true, "操作成功!", groupData.Data));
  967. }
  968. /// <summary>
  969. /// 获取团组名称data And 签证国别Data
  970. /// </summary>
  971. /// <param name="dto"></param>
  972. /// <returns></returns>
  973. [HttpPost]
  974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  975. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  976. {
  977. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  978. if (groupData.Code != 0)
  979. {
  980. return Ok(JsonView(false, groupData.Msg));
  981. }
  982. return Ok(JsonView(groupData.Data));
  983. }
  984. /// <summary>
  985. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  986. /// </summary>
  987. /// <returns></returns>
  988. [HttpPost]
  989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  990. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  991. {
  992. try
  993. {
  994. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  995. if (groupData.Code != 0)
  996. {
  997. return Ok(JsonView(false, groupData.Msg));
  998. }
  999. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1000. }
  1001. catch (Exception ex)
  1002. {
  1003. return Ok(JsonView(false, "程序错误!"));
  1004. throw;
  1005. }
  1006. }
  1007. /// <summary>
  1008. /// 团组清单 Excel
  1009. /// </summary>
  1010. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1011. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1012. /// <returns></returns>
  1013. [HttpGet]
  1014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1015. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1016. {
  1017. DateTime _beginDt, _endDt;
  1018. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1019. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1020. if (!beginBool && !endBool)
  1021. {
  1022. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1023. }
  1024. string sql = string.Format(@"
  1025. SELECT
  1026. ROW_NUMBER,
  1027. Id,
  1028. SalesQuoteNo,
  1029. TourCode,
  1030. TeamTypeId,
  1031. TeamType,
  1032. TeamLevId,
  1033. TeamLev,
  1034. TeamName,
  1035. ClientName,
  1036. ClientUnit,
  1037. VisitDate,
  1038. VisitDays,
  1039. VisitPNumber,
  1040. JietuanOperatorId,
  1041. JietuanOperator,
  1042. IsSure,
  1043. CreateTime,
  1044. IsBid
  1045. FROM
  1046. (
  1047. SELECT
  1048. ROW_NUMBER() OVER(
  1049. ORDER BY
  1050. gdi.CreateTime Desc
  1051. ) AS ROW_NUMBER,
  1052. gdi.Id,
  1053. SalesQuoteNo,
  1054. TourCode,
  1055. ssd.Id TeamTypeId,
  1056. ssd.Name TeamType,
  1057. ssd1.Id TeamLevId,
  1058. ssd1.Name TeamLev,
  1059. TeamName,
  1060. ClientName,
  1061. ClientUnit,
  1062. VisitDate,
  1063. VisitDays,
  1064. VisitPNumber,
  1065. JietuanOperator JietuanOperatorId,
  1066. su.CnName JietuanOperator,
  1067. IsSure,
  1068. gdi.CreateTime,
  1069. gdi.IsBid
  1070. FROM
  1071. Grp_DelegationInfo gdi
  1072. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1073. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1074. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1075. WHERE
  1076. gdi.IsDel = 0
  1077. AND gdi.IsBid = 0
  1078. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1079. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1080. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1081. #region 处理所属部门
  1082. /*
  1083. * 1.sq 和 gyy 等显示 市场部
  1084. * 2.王鸽和主管及张总还有管理员号统一国交部
  1085. * 2-1. 4 管理员 ,21 张海麟
  1086. */
  1087. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1088. List<int> userIds1 = new List<int>() { 4, 21 };
  1089. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1090. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1091. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1092. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1093. .ToListAsync();
  1094. foreach (var item in groupList)
  1095. {
  1096. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1097. }
  1098. #endregion
  1099. #region Excel
  1100. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1101. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1102. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1103. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1104. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1105. //载入模板
  1106. WorkbookDesigner designer = new WorkbookDesigner();
  1107. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1108. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1109. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1110. dt.TableName = "GroupList";
  1111. designer.SetDataSource(dt);
  1112. designer.Process();
  1113. if (!Directory.Exists(savePath))
  1114. {
  1115. Directory.CreateDirectory(savePath);
  1116. }
  1117. string serverPath = $"{savePath}{fileName}";
  1118. designer.Workbook.Save(serverPath);
  1119. string rst = $"{servicePath}{ftpPath}{fileName}";
  1120. #endregion
  1121. return Ok(JsonView(true, "操作成功!", rst));
  1122. }
  1123. #endregion
  1124. #region 团组&签证
  1125. /// <summary>
  1126. /// 根据团组Id获取签证客户信息List
  1127. /// </summary>
  1128. /// <param name="dto">请求dto</param>
  1129. /// <returns></returns>
  1130. [HttpPost]
  1131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1132. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1133. {
  1134. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1135. if (groupData.Code != 0)
  1136. {
  1137. return Ok(JsonView(false, groupData.Msg));
  1138. }
  1139. return Ok(JsonView(groupData.Data));
  1140. }
  1141. /// <summary>
  1142. /// IOS获取团组签证拍照上传进度01(团组列表)
  1143. /// </summary>
  1144. /// <param name="dto">请求dto</param>
  1145. /// <returns></returns>
  1146. [HttpPost]
  1147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1148. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1149. {
  1150. if (dto == null)
  1151. {
  1152. return Ok(JsonView(false, "参数为空"));
  1153. }
  1154. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1155. return Ok(JsonView(visaList));
  1156. }
  1157. /// <summary>
  1158. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1159. /// </summary>
  1160. /// <returns></returns>
  1161. [HttpPost]
  1162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1163. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1164. {
  1165. if (dto == null)
  1166. {
  1167. return Ok(JsonView(false, "请求错误:"));
  1168. }
  1169. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1170. return Ok(JsonView(list));
  1171. }
  1172. /// <summary>
  1173. /// IOS获取团组签证拍照上传进度03(相册)
  1174. /// </summary>
  1175. /// <returns></returns>
  1176. [HttpPost]
  1177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1178. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1179. {
  1180. if (dto == null)
  1181. {
  1182. return Ok(JsonView(false, "请求错误:"));
  1183. }
  1184. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1185. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1186. list.ForEach(s => s.url = url);
  1187. return Ok(JsonView(list));
  1188. }
  1189. /// <summary>
  1190. /// IOS获取团组签证拍照上传进度04(图片上传)
  1191. /// </summary>
  1192. /// <param name="dto"></param>
  1193. /// <returns></returns>
  1194. [HttpPost]
  1195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1196. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1197. {
  1198. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1199. //if (!string.IsNullOrEmpty(result))
  1200. //{
  1201. //}
  1202. //else {
  1203. // return Ok(JsonView(false, "上传失败"));
  1204. //}
  1205. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1206. int sucNum = 0;
  1207. try
  1208. {
  1209. foreach (var item in dto.base64DataList)
  1210. {
  1211. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1212. string result = decodeBase64ToImage(item, imageName);
  1213. if (!string.IsNullOrEmpty(result))
  1214. {
  1215. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1216. pic.CreateUserId = dto.CreateUserId;
  1217. pic.PicName = imageName;
  1218. pic.PicPath = result;
  1219. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1220. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1221. if (insertResult > 0)
  1222. {
  1223. sucNum++;
  1224. }
  1225. }
  1226. }
  1227. }
  1228. catch (Exception ex)
  1229. {
  1230. return Ok(JsonView(false, ex.Message));
  1231. }
  1232. string msg = string.Format(@"成功上传{0}张", sucNum);
  1233. return Ok(JsonView(true, msg));
  1234. }
  1235. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1236. {
  1237. string filename = "";//声明一个string类型的相对路径
  1238. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1239. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1240. try//会有异常抛出,try,catch一下
  1241. {
  1242. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1243. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1244. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1245. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1246. //文件名称
  1247. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1248. //上传的文件的路径
  1249. string filePath = "";
  1250. if (!Directory.Exists(fileDir))
  1251. {
  1252. Directory.CreateDirectory(fileDir);
  1253. }
  1254. //上传的文件的路径
  1255. filePath = fileDir + filename;
  1256. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1257. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1258. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1259. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1260. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1261. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1262. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1263. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1264. bitmap.Dispose();
  1265. }
  1266. catch (Exception e)
  1267. {
  1268. string massage = e.Message;
  1269. Logs("IOS图片上传Error:" + massage);
  1270. //filename = e.Message;
  1271. }
  1272. return filename;//返回相对路径
  1273. }
  1274. /// <summary>
  1275. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1276. /// </summary>
  1277. /// <param name="dto"></param>
  1278. /// <returns></returns>
  1279. [HttpPost]
  1280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1281. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1282. {
  1283. if (dto == null)
  1284. {
  1285. return Ok(JsonView(false, "请求错误:"));
  1286. }
  1287. string msg = "参数错误";
  1288. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1289. {
  1290. try
  1291. {
  1292. //_delegationVisaRep.BeginTran();
  1293. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1294. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1295. .Where(s => s.Id == dto.visaProgressCustomerId)
  1296. .ExecuteCommandAsync();
  1297. if (updCount > 0 && dto.publishCode == 1)
  1298. {
  1299. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1300. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1301. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1302. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1303. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1304. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1305. if (groupData == null)
  1306. {
  1307. _delegationVisaRep.RollbackTran();
  1308. }
  1309. string title = string.Format(@"[签证进度更新]");
  1310. string content = string.Format(@"测试文本");
  1311. bool rst = await _message.AddMsg(new MessageDto()
  1312. {
  1313. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1314. IssuerId = dto.publisher,
  1315. Title = title,
  1316. Content = content,
  1317. ReleaseTime = DateTime.Now,
  1318. UIdList = new List<int> {
  1319. 234
  1320. }
  1321. });
  1322. if (rst)
  1323. {
  1324. return Ok(JsonView(true, "发送通知成功"));
  1325. }
  1326. }
  1327. //_delegationVisaRep.CommitTran();
  1328. }
  1329. catch (Exception)
  1330. {
  1331. //_delegationVisaRep.RollbackTran();
  1332. }
  1333. }
  1334. return Ok(JsonView(true, msg));
  1335. }
  1336. #endregion
  1337. #region 团组任务分配
  1338. /// <summary>
  1339. /// 团组任务分配初始化
  1340. /// </summary>
  1341. /// <param name="dto"></param>
  1342. /// <returns></returns>
  1343. [HttpPost]
  1344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1345. public async Task<IActionResult> GetTaskAssignmen()
  1346. {
  1347. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1348. if (groupData.Code != 0)
  1349. {
  1350. return Ok(JsonView(false, groupData.Msg));
  1351. }
  1352. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1353. }
  1354. /// <summary>
  1355. /// 团组任务分配查询
  1356. /// </summary>
  1357. /// <param name="dto"></param>
  1358. /// <returns></returns>
  1359. [HttpPost]
  1360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1361. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1362. {
  1363. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1364. if (groupData.Code != 0)
  1365. {
  1366. return Ok(JsonView(false, groupData.Msg));
  1367. }
  1368. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1369. }
  1370. /// <summary>
  1371. /// 团组任务分配操作
  1372. /// </summary>
  1373. /// <param name="dto"></param>
  1374. /// <returns></returns>
  1375. [HttpPost]
  1376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1377. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1378. {
  1379. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1380. if (groupData.Code != 0)
  1381. {
  1382. return Ok(JsonView(false, groupData.Msg));
  1383. }
  1384. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1385. }
  1386. /// <summary>
  1387. /// 团组任务分配
  1388. /// 批量分配
  1389. /// 查询团组
  1390. /// </summary>
  1391. /// <param name="dto"></param>
  1392. /// <returns></returns>
  1393. [HttpPost]
  1394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1395. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1396. {
  1397. //参数验证
  1398. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1399. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1400. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1401. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1402. }
  1403. /// <summary>
  1404. /// 团组任务分配
  1405. /// 批量分配
  1406. /// </summary>
  1407. /// <param name="dto"></param>
  1408. /// <returns></returns>
  1409. [HttpPost]
  1410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1411. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1412. {
  1413. //参数验证
  1414. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1415. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1416. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1417. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1418. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1419. }
  1420. #endregion
  1421. #region 团组费用审核
  1422. /// <summary>
  1423. /// 费用审核
  1424. /// 团组列表 Page
  1425. /// </summary>
  1426. /// <param name="_dto">团组列表请求dto</param>
  1427. /// <returns></returns>
  1428. [HttpPost]
  1429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1430. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1431. {
  1432. #region 参数验证
  1433. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1434. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1435. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1436. #region 页面操作权限验证
  1437. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1438. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1439. #endregion
  1440. #endregion
  1441. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1442. {
  1443. string sqlWhere = string.Empty;
  1444. if (_dto.IsSure == 0) //未完成
  1445. {
  1446. sqlWhere += string.Format(@" And IsSure = 0");
  1447. }
  1448. else if (_dto.IsSure == 1) //已完成
  1449. {
  1450. sqlWhere += string.Format(@" And IsSure = 1");
  1451. }
  1452. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1453. {
  1454. string tj = _dto.SearchCriteria;
  1455. 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}%')",
  1456. tj, tj, tj, tj, tj);
  1457. }
  1458. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1459. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1460. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1461. From (
  1462. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1463. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1464. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1465. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1466. From Grp_DelegationInfo gdi
  1467. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1468. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1469. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1470. Where gdi.IsDel = 0 {0}
  1471. ) temp ", sqlWhere);
  1472. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1473. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1474. var _view = new
  1475. {
  1476. PageFuncAuth = pageFunAuthView,
  1477. Data = _DelegationList
  1478. };
  1479. return Ok(JsonView(true, "查询成功!", _view, total));
  1480. }
  1481. else
  1482. {
  1483. return Ok(JsonView(false, "查询失败"));
  1484. }
  1485. }
  1486. /// <summary>
  1487. /// 获取团组费用审核
  1488. /// </summary>
  1489. /// <param name="paras">参数Json字符串</param>
  1490. /// <returns></returns>
  1491. [HttpPost]
  1492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1493. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1494. {
  1495. try
  1496. {
  1497. #region 参数验证
  1498. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1499. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1500. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1501. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1502. #region 页面操作权限验证
  1503. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1504. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1505. #endregion
  1506. #endregion
  1507. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1508. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1509. #region 费用清单
  1510. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1511. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1512. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1513. List<Grp_CreditCardPayment> entityList = _groupRepository
  1514. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1515. .Where(exp.ToExpression())
  1516. .ToList();
  1517. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1518. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1519. /*
  1520. * 76://酒店预订
  1521. */
  1522. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1523. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1524. .ToListAsync();
  1525. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1526. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1527. .ToListAsync();
  1528. /*
  1529. * 79://车/导游地接
  1530. */
  1531. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1532. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1533. .ToListAsync();
  1534. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1535. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1536. .ToListAsync();
  1537. /*
  1538. * 80: //签证
  1539. */
  1540. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1541. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1542. .ToListAsync();
  1543. /*
  1544. *81: //邀请/公务活动
  1545. */
  1546. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1547. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1548. .ToListAsync();
  1549. /*
  1550. * 82: //团组客户保险
  1551. */
  1552. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1553. /*
  1554. * Lable = 85 机票预订
  1555. */
  1556. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1557. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1558. .ToListAsync();
  1559. /*
  1560. * 85 机票预定
  1561. */
  1562. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1563. /*
  1564. * 98 其他款项
  1565. */
  1566. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1567. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1568. .ToListAsync();
  1569. /*
  1570. * 285:收款退还
  1571. */
  1572. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1573. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1574. .ToListAsync();
  1575. /*
  1576. * 1015: //超支费用
  1577. */
  1578. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1579. /*
  1580. * 币种信息
  1581. */
  1582. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1583. /*
  1584. * 车/导游地接 费用类型
  1585. */
  1586. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1587. /*
  1588. * 车/导游地接 费用类型
  1589. */
  1590. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1591. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1592. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1593. /*
  1594. * 用户信息
  1595. */
  1596. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1597. /*
  1598. * 费用模块
  1599. */
  1600. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1601. string priceModule = string.Empty;
  1602. if (sdPriceName != null)
  1603. {
  1604. priceModule = sdPriceName.Name;
  1605. }
  1606. /*
  1607. * 成本信息
  1608. */
  1609. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1610. decimal _groupRate = 0.0000M;
  1611. string _groupCurrencyCode = "-";
  1612. if (groupCost != null)
  1613. {
  1614. _groupRate = groupCost.Rate;
  1615. if (int.TryParse(groupCost.Currency, out int _currency))
  1616. {
  1617. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1618. }
  1619. else _groupCurrencyCode = groupCost.Currency;
  1620. }
  1621. string costContentSql = $"Select * From Grp_GroupCost";
  1622. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1623. //处理日期为空的天数
  1624. for (int i = 0; i < groupCostDetails.Count; i++)
  1625. if (i != 0)
  1626. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1627. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1628. /*
  1629. * 处理详情数据
  1630. */
  1631. foreach (var entity in entityList)
  1632. {
  1633. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1634. _detail.Id = entity.Id;
  1635. _detail.PriceName = priceModule;
  1636. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1637. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1638. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1639. //处理金额
  1640. if (entity.CTable == 1015)
  1641. {
  1642. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1643. if (czInfo != null)
  1644. {
  1645. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1646. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1647. }
  1648. }
  1649. /*
  1650. * 应付款金额
  1651. */
  1652. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1653. string PaymentCurrency_WaitPay = "Unknown";
  1654. string hotelCurrncyCode = "Unknown";
  1655. string hotelCurrncyName = "Unknown";
  1656. if (sdPaymentCurrency_WaitPay != null)
  1657. {
  1658. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1659. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1660. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1661. if (hotelCurrncyCode.Equals("CNY"))
  1662. {
  1663. entity.DayRate = 1.0000M;
  1664. }
  1665. }
  1666. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1667. /*
  1668. * 此次付款金额
  1669. */
  1670. decimal CurrPayStr = 0.00M,
  1671. OriginalCurrPay = 0.00M;
  1672. if (entity.PayPercentage == 0)
  1673. {
  1674. if (entity.PayThenMoney != 0)
  1675. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1676. }
  1677. else
  1678. {
  1679. if (entity.PayMoney != 0)
  1680. {
  1681. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1682. }
  1683. }
  1684. if (_dto.Label == 79)
  1685. {
  1686. string original = string.Empty;
  1687. if (hotelCurrncyCode.Equals("CNY"))
  1688. {
  1689. OriginalCurrPay = CurrPayStr;
  1690. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1691. }
  1692. else
  1693. {
  1694. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1695. //760 EUR(7600.00 CNY)
  1696. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1697. }
  1698. }
  1699. else
  1700. {
  1701. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1702. }
  1703. /*
  1704. * 剩余尾款
  1705. */
  1706. decimal BalanceStr = 0;
  1707. if (CurrPayStr != 0)
  1708. {
  1709. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1710. BalanceStr = 0;
  1711. else
  1712. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1713. }
  1714. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1715. /*
  1716. * Bus名称
  1717. */
  1718. _detail.BusName = "待增加";
  1719. /*
  1720. *费用所属
  1721. */
  1722. switch (entity.CTable)
  1723. {
  1724. case 76://酒店预订
  1725. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1726. if (hotelReservations != null)
  1727. {
  1728. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1729. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1730. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1731. string roomFeeStr = "", roomFeestr1 = "";
  1732. //是否比较房型价格
  1733. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1734. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1735. roomFeeStr += $"<br/>";
  1736. if (hotelReservations.SingleRoomPrice > 0)
  1737. {
  1738. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚<br/>";
  1739. __isSingle = true;
  1740. }
  1741. if (hotelReservations.DoubleRoomPrice > 0)
  1742. {
  1743. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚<br/>";
  1744. __isDouble = true;
  1745. }
  1746. if (hotelReservations.SuiteRoomPrice > 0)
  1747. {
  1748. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚<br/>";
  1749. __isSuite = true;
  1750. }
  1751. if (hotelReservations.OtherRoomPrice > 0)
  1752. {
  1753. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚)";
  1754. __isOther = true;
  1755. }
  1756. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1757. else roomFeeStr += " 0.00 * 0";
  1758. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1759. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1760. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1761. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1762. /*
  1763. * 费用类型
  1764. * 1:房费
  1765. * 2:早餐
  1766. * 3:地税
  1767. * 4:城市税
  1768. * </summary>
  1769. */
  1770. //地税
  1771. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1772. if (governmentRentData != null)
  1773. {
  1774. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1775. governmentRentFee = governmentRentData.Price;
  1776. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1777. if (governmentRentCurrData != null)
  1778. {
  1779. governmentRentCode = governmentRentCurrData.Name;
  1780. governmentRentName = $"({governmentRentCurrData.Remark})";
  1781. }
  1782. }
  1783. //城市税
  1784. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1785. if (cityTaxData != null)
  1786. {
  1787. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1788. cityTaxFee = cityTaxData.Price;
  1789. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1790. if (cityTaxCurrData != null)
  1791. {
  1792. cityTaxCode = cityTaxCurrData.Name;
  1793. cityTaxName = $"({cityTaxCurrData.Remark})";
  1794. }
  1795. }
  1796. //酒店早餐
  1797. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1798. if (breakfastData != null)
  1799. {
  1800. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1801. breakfastFee = breakfastData.Price;
  1802. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1803. if (breakfastCurrData != null)
  1804. {
  1805. breakfastCode = breakfastCurrData.Name;
  1806. breakfastName = $"({breakfastCurrData.Remark})";
  1807. }
  1808. }
  1809. //房间费用
  1810. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1811. if (roomData != null)
  1812. {
  1813. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1814. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1815. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1816. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1817. roomFee = roomData.Price;
  1818. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1819. if (roomCurrData != null)
  1820. {
  1821. roomCode = roomCurrData.Name;
  1822. roomName = $"({roomCurrData.Remark})";
  1823. }
  1824. }
  1825. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1826. string hotelCostStr = "";
  1827. decimal hotelCsotTotal = 0.00M;
  1828. if (groupCost != null)
  1829. {
  1830. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1831. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1832. }
  1833. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1834. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1835. string hotelCost_day = "";
  1836. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1837. foreach (var item in hotelCostDetails1)
  1838. {
  1839. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1840. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1841. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1842. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1843. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1844. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1845. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1846. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1847. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1848. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1849. hotelCost_day += @$"<br/>";
  1850. }
  1851. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1852. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  1853. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  1854. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  1855. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1856. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1857. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1858. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1859. $"房间说明: {hotelReservations.Remark} <br/>" +
  1860. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接或其他人代付:{roomBool}<br/><br/>" +
  1861. $"{hotelBreakfastStr}" +
  1862. $"{hotelGovernmentRentStr}" +
  1863. $"{hotelCityTaxStr}";
  1864. _detail.PriceNameContent = hotelReservations.HotelName;
  1865. }
  1866. break;
  1867. case 79://车/导游地接
  1868. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1869. if (touristGuideGroundReservations != null)
  1870. {
  1871. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1872. {
  1873. _detail.BusName = touristGuideGroundReservations.BusName;
  1874. }
  1875. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1876. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1877. //if (isInt)
  1878. //{
  1879. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1880. // if (cityInfo != null)
  1881. // {
  1882. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1883. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1884. // if (carFeeItem != null)
  1885. // {
  1886. // nameContent += $@"({carFeeItem.Name})";
  1887. // }
  1888. // _detail.PriceNameContent = nameContent;
  1889. // }
  1890. //}
  1891. //else
  1892. //{
  1893. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1894. //}
  1895. var touristGuideGroundReservationsContents =
  1896. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1897. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1898. foreach (var item in touristGuideGroundReservationsContents)
  1899. {
  1900. string typeName = "Unknown";
  1901. string carCurrencyCode = "Unknown";
  1902. string carCurrencyName = "Unknown";
  1903. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1904. if (carTypeData != null) typeName = carTypeData.Name;
  1905. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1906. if (currencyData != null)
  1907. {
  1908. carCurrencyCode = currencyData.Name;
  1909. carCurrencyName = currencyData.Remark;
  1910. }
  1911. //op、成本 币种是否一致
  1912. bool IsCurrencyAgreement = false;
  1913. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1914. string opCostStr = string.Empty;
  1915. decimal opCostTypePrice = 0.00M;
  1916. #region 处理成本各项费用
  1917. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1918. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1919. if (opCost.Count > 0)
  1920. {
  1921. switch (item.SId)
  1922. {
  1923. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1924. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1925. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1926. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1927. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1928. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1929. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1930. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1931. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1932. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1933. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1934. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1935. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1936. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1937. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1938. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1939. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1940. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1941. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1942. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1943. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1944. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1945. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1946. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1947. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1948. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1949. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1950. }
  1951. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1952. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1953. }
  1954. #endregion
  1955. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  1956. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1957. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1958. $"{opTypeStr} {opCostStr}<br/>" +
  1959. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1960. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1961. }
  1962. _detail.PriceMsgContent = priceMsg;
  1963. }
  1964. break;
  1965. case 80: //签证
  1966. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1967. if (visaInfo != null)
  1968. {
  1969. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1970. _detail.PriceNameContent = visaInfo.VisaDescription;
  1971. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1972. }
  1973. break;
  1974. case 81: //邀请/公务活动
  1975. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1976. if (_ioa != null)
  1977. {
  1978. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1979. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1980. sendCurrName = "Unknown", //快递费用币种 Name
  1981. sendCurrCode = "Unknown", //快递费用币种 Code
  1982. eventsCurrName = "Unknown", //公务活动费币种 Name
  1983. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1984. translateCurrName = "Unknown", //公务翻译费 Name
  1985. translateCurrCode = "Unknown"; //公务翻译费 Code
  1986. #region 处理费用币种
  1987. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1988. if (inviteCurrData != null)
  1989. {
  1990. inviteCurrName = inviteCurrData.Remark;
  1991. inviteCurrCode = inviteCurrData.Name;
  1992. }
  1993. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1994. if (sendCurrData != null)
  1995. {
  1996. sendCurrName = sendCurrData.Remark;
  1997. sendCurrCode = sendCurrData.Name;
  1998. }
  1999. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2000. if (eventsCurrData != null)
  2001. {
  2002. eventsCurrName = eventsCurrData.Remark;
  2003. eventsCurrCode = eventsCurrData.Name;
  2004. }
  2005. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2006. if (translateCurrData != null)
  2007. {
  2008. translateCurrName = translateCurrData.Remark;
  2009. translateCurrCode = translateCurrData.Name;
  2010. }
  2011. #endregion
  2012. _detail.PriceNameContent = _ioa.InviterArea;
  2013. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2014. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2015. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2016. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2017. $@"备注:" + _ioa.Remark + "<br/>";
  2018. }
  2019. break;
  2020. case 82: //团组客户保险
  2021. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2022. if (customers != null)
  2023. {
  2024. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2025. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2026. }
  2027. break;
  2028. case 85: //机票预订
  2029. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2030. if (jpRes != null)
  2031. {
  2032. string FlightsDescription = jpRes.FlightsDescription;
  2033. string PriceDescription = jpRes.PriceDescription;
  2034. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2035. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2036. }
  2037. break;
  2038. case 98://其他款项
  2039. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2040. if (gdpRes != null)
  2041. {
  2042. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2043. _detail.PriceNameContent = gdpRes.PriceName;
  2044. }
  2045. break;
  2046. case 285://收款退还
  2047. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2048. if (refundAndOtherMoney != null)
  2049. {
  2050. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2051. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2052. }
  2053. break;
  2054. case 751://酒店早餐
  2055. break;
  2056. case 1015://超支费用
  2057. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2058. if (groupExtraCost != null)
  2059. {
  2060. _detail.PriceNameContent = groupExtraCost.PriceName;
  2061. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2062. }
  2063. break;
  2064. default:
  2065. break;
  2066. }
  2067. /*
  2068. * 申请人
  2069. */
  2070. string operatorName = " - ";
  2071. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2072. if (_opUser != null)
  2073. {
  2074. operatorName = _opUser.CnName;
  2075. }
  2076. _detail.OperatorName = operatorName;
  2077. /*
  2078. * 审核人
  2079. */
  2080. string auditOperatorName = "Unknown";
  2081. if (entity.AuditGMOperate == 0)
  2082. auditOperatorName = " - ";
  2083. else if (entity.AuditGMOperate == 4)
  2084. auditOperatorName = "自动审核";
  2085. else
  2086. {
  2087. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2088. if (_adUser != null)
  2089. {
  2090. auditOperatorName = _adUser.CnName;
  2091. }
  2092. }
  2093. _detail.AuditOperatorName = auditOperatorName;
  2094. /*
  2095. * 超预算比例
  2096. */
  2097. string overBudgetStr = "";
  2098. if (entity.ExceedBudget == -1)
  2099. overBudgetStr = sdPriceName.Name + "尚无预算";
  2100. else if (entity.ExceedBudget == 0)
  2101. {
  2102. if (entity.CTable == 76 || entity.CTable == 79)
  2103. {
  2104. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2105. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2106. }
  2107. else
  2108. {
  2109. overBudgetStr = "未超预算";
  2110. }
  2111. }
  2112. else
  2113. overBudgetStr = entity.ExceedBudget.ToString("P");
  2114. _detail.OverBudget = overBudgetStr;
  2115. /*
  2116. * 已审核金额
  2117. */
  2118. decimal auditFee = 0.00M;
  2119. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  2120. /*
  2121. * 费用总计
  2122. */
  2123. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2124. {
  2125. CurrencyId = entity.PaymentCurrency,
  2126. CurrencyName = PaymentCurrency_WaitPay,
  2127. AmountPayable = entity.PayMoney,
  2128. ThisPayment = OriginalCurrPay,
  2129. BalancePayment = BalanceStr,
  2130. AuditedFunds = auditFee
  2131. });
  2132. _detail.IsAuditGM = entity.IsAuditGM;
  2133. detailList.Add(_detail);
  2134. }
  2135. #endregion
  2136. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2137. /*
  2138. * 下方描述处理
  2139. */
  2140. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2141. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2142. if (ccpCurrencyPrice != null)
  2143. {
  2144. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2145. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2146. }
  2147. else
  2148. {
  2149. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2150. }
  2151. string amountPayableStr = string.Format(@"应付款总金额: ");
  2152. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2153. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2154. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2155. foreach (var item in nonDuplicat)
  2156. {
  2157. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2158. if (strs.Count > 0)
  2159. {
  2160. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2161. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2162. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2163. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  2164. //单独处理此次付款金额
  2165. if (item.CurrencyId == 836) //人民币
  2166. {
  2167. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2168. }
  2169. else
  2170. {
  2171. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  2172. }
  2173. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  2174. //单独处理已审核费用
  2175. if (item.CurrencyId == 836) //人民币
  2176. {
  2177. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2178. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  2179. }
  2180. else
  2181. {
  2182. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  2183. }
  2184. }
  2185. }
  2186. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2187. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2188. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2189. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  2190. var _view1 = new
  2191. {
  2192. PageFuncAuth = pageFunAuthView,
  2193. Data = _view
  2194. };
  2195. return Ok(JsonView(_view1));
  2196. }
  2197. catch (Exception ex)
  2198. {
  2199. return Ok(JsonView(false, ex.Message));
  2200. }
  2201. }
  2202. /// <summary>
  2203. /// 费用审核
  2204. /// 修改团组费用审核状态
  2205. /// </summary>
  2206. /// <param name="_dto">参数Json字符串</param>
  2207. /// <returns></returns>
  2208. [HttpPost]
  2209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2210. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2211. {
  2212. #region 参数验证
  2213. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2214. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2215. #endregion
  2216. #region 页面操作权限验证
  2217. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2218. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2219. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2220. #endregion
  2221. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2222. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2223. DateTime dtNow = DateTime.Now;
  2224. _groupRepository.BeginTran();
  2225. int rst = 0;
  2226. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2227. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2228. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2229. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2230. List<dynamic> msgDatas = new List<dynamic>();
  2231. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2232. foreach (var item in idList)
  2233. {
  2234. int CreditId = int.Parse(item);
  2235. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2236. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2237. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2238. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2239. .Where(s => s.Id == CreditId)
  2240. .ExecuteCommandAsync();
  2241. if (result < 1)
  2242. {
  2243. rst = -1;
  2244. _groupRepository.RollbackTran();
  2245. return Ok(JsonView(false, "操作失败并回滚!"));
  2246. }
  2247. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2248. if (creditData != null)
  2249. {
  2250. #region 应用通知配置
  2251. try
  2252. {
  2253. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2254. }
  2255. catch (Exception ex)
  2256. {
  2257. }
  2258. #endregion
  2259. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2260. string groupNameStr = string.Empty;
  2261. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2262. if (groupData != null) groupNameStr = groupData.TeamName;
  2263. string creditTypeStr = string.Empty;
  2264. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2265. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2266. string creditCurrency = string.Empty;
  2267. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2268. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2269. if (creditCurrency.Equals("CNY"))
  2270. {
  2271. creditData.DayRate = 1.0000M;
  2272. }
  2273. if (creditData.PayPercentage == 0.00M)
  2274. {
  2275. creditData.PayPercentage = 100M;
  2276. }
  2277. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2278. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2279. string msgContent = "";
  2280. if (creditCurrency.Equals("CNY"))
  2281. {
  2282. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2283. }
  2284. else
  2285. {
  2286. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2287. }
  2288. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2289. }
  2290. }
  2291. if (rst == 0)
  2292. {
  2293. _groupRepository.CommitTran();
  2294. foreach (var item in msgDatas)
  2295. {
  2296. //发送消息
  2297. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2298. }
  2299. #region 应用推送
  2300. try
  2301. {
  2302. foreach (var ccpId in dic_ccp_user.Keys)
  2303. {
  2304. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2305. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2306. }
  2307. }
  2308. catch (Exception)
  2309. {
  2310. }
  2311. #endregion
  2312. return Ok(JsonView(true, "操作成功!"));
  2313. }
  2314. return Ok(JsonView(false, "操作失败!"));
  2315. }
  2316. #endregion
  2317. #region 机票费用录入
  2318. /// <summary>
  2319. /// 机票录入当前登录人可操作团组
  2320. /// </summary>
  2321. /// <param name="dto"></param>
  2322. /// <returns></returns>
  2323. [HttpPost]
  2324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2325. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2326. {
  2327. try
  2328. {
  2329. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2330. if (groupData.Code != 0)
  2331. {
  2332. return Ok(JsonView(false, groupData.Msg));
  2333. }
  2334. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2335. }
  2336. catch (Exception ex)
  2337. {
  2338. return Ok(JsonView(false, "程序错误!"));
  2339. throw;
  2340. }
  2341. }
  2342. /// <summary>
  2343. /// 机票费用录入列表
  2344. /// </summary>
  2345. /// <param name="dto"></param>
  2346. /// <returns></returns>
  2347. [HttpPost]
  2348. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2349. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2350. {
  2351. try
  2352. {
  2353. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2354. if (groupData.Code != 0)
  2355. {
  2356. return Ok(JsonView(false, groupData.Msg));
  2357. }
  2358. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2359. }
  2360. catch (Exception ex)
  2361. {
  2362. return Ok(JsonView(false, ex.Message));
  2363. throw;
  2364. }
  2365. }
  2366. /// <summary>
  2367. /// 根据id查询费用录入信息
  2368. /// </summary>
  2369. /// <param name="dto"></param>
  2370. /// <returns></returns>
  2371. [HttpPost]
  2372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2373. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2374. {
  2375. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2376. if (groupData.Code != 0)
  2377. {
  2378. return Ok(JsonView(false, groupData.Msg));
  2379. }
  2380. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2381. }
  2382. /// <summary>
  2383. /// 机票费用录入操作(Status:1.新增,2.修改)
  2384. /// </summary>
  2385. /// <param name="dto"></param>
  2386. /// <returns></returns>
  2387. [HttpPost]
  2388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2389. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2390. {
  2391. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2392. if (groupData.Code != 0)
  2393. {
  2394. return Ok(JsonView(false, groupData.Msg));
  2395. }
  2396. #region 应用推送
  2397. try
  2398. {
  2399. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2400. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2401. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2402. //2024-10-21 新增LZ UID
  2403. var userIds = new List<int>() { 21 };
  2404. string title = $"系统通知";
  2405. string content = "";
  2406. var diId = dto.AirTicketResOpData.DiId;
  2407. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2408. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2409. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2410. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2411. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2412. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2413. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2414. }
  2415. catch (Exception ex)
  2416. {
  2417. }
  2418. #endregion
  2419. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2420. }
  2421. /// <summary>
  2422. /// 根据舱位类型查询接团客户名单信息
  2423. /// </summary>
  2424. /// <param name="dto"></param>
  2425. /// <returns></returns>
  2426. [HttpPost]
  2427. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2428. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2429. {
  2430. try
  2431. {
  2432. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2433. if (crm_Groups.Count != 0)
  2434. {
  2435. List<dynamic> Customer = new List<dynamic>();
  2436. foreach (var item in crm_Groups)
  2437. {
  2438. var data = new
  2439. {
  2440. Id = item.Id,
  2441. Pinyin = item.Pinyin,
  2442. Name = item.LastName + item.FirstName
  2443. };
  2444. Customer.Add(data);
  2445. }
  2446. return Ok(JsonView(true, "查询成功!", Customer));
  2447. }
  2448. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2449. }
  2450. catch (Exception ex)
  2451. {
  2452. return Ok(JsonView(false, "程序错误!"));
  2453. throw;
  2454. }
  2455. }
  2456. /// <summary>
  2457. /// 根据团号获取客户信息
  2458. /// </summary>
  2459. /// <param name="dto"></param>
  2460. /// <returns></returns>
  2461. [HttpPost]
  2462. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2463. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2464. {
  2465. var jw = JsonView(false);
  2466. if (dto.DIID < 1)
  2467. {
  2468. jw.Msg += "请输入正确的diid";
  2469. return Ok(jw);
  2470. }
  2471. var arr = getSimplClientList(dto.DIID);
  2472. jw = JsonView(true, "获取成功!", arr);
  2473. return Ok(jw);
  2474. }
  2475. private List<SimplClientInfo> getSimplClientList(int diId)
  2476. {
  2477. 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);
  2478. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2479. foreach (var item in arr)
  2480. {
  2481. EncryptionProcessor.DecryptProperties(item);
  2482. }
  2483. return arr;
  2484. }
  2485. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2486. {
  2487. string result = origin;
  2488. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2489. {
  2490. string[] temparr = origin.Split(',');
  2491. string fistrStr = temparr[0];
  2492. int count = temparr.Count();
  2493. int tempId;
  2494. bool success = int.TryParse(fistrStr, out tempId);
  2495. if (success)
  2496. {
  2497. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2498. if (tempInfo != null)
  2499. {
  2500. if (count > 1)
  2501. {
  2502. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2503. }
  2504. else
  2505. {
  2506. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2507. }
  2508. }
  2509. }
  2510. }
  2511. return result;
  2512. }
  2513. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2514. {
  2515. string result = origin;
  2516. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2517. {
  2518. string[] temparr = origin.Split(',');
  2519. result = "";
  2520. foreach (var item in temparr)
  2521. {
  2522. int tempId;
  2523. bool success = int.TryParse(item, out tempId);
  2524. if (success)
  2525. {
  2526. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2527. if (tempInfo != null)
  2528. {
  2529. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2530. }
  2531. }
  2532. }
  2533. }
  2534. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2535. return result;
  2536. }
  2537. /// <summary>
  2538. /// 机票费用录入,删除
  2539. /// </summary>
  2540. /// <param name="dto"></param>
  2541. /// <returns></returns>
  2542. [HttpPost]
  2543. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2544. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2545. {
  2546. try
  2547. {
  2548. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2549. if (res)
  2550. {
  2551. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2552. {
  2553. IsDel = 1,
  2554. DeleteUserId = dto.DeleteUserId,
  2555. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2556. }).ExecuteCommandAsync();
  2557. return Ok(JsonView(true, "删除成功!"));
  2558. }
  2559. return Ok(JsonView(false, "删除失败!"));
  2560. }
  2561. catch (Exception ex)
  2562. {
  2563. return Ok(JsonView(false, "程序错误!"));
  2564. throw;
  2565. }
  2566. }
  2567. /// <summary>
  2568. /// 导出机票录入报表
  2569. /// </summary>
  2570. /// <param name="dto"></param>
  2571. /// <returns></returns>
  2572. [HttpPost]
  2573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2574. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2575. {
  2576. try
  2577. {
  2578. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2579. if (groupData.Code != 0)
  2580. {
  2581. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2582. }
  2583. else
  2584. {
  2585. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2586. if (AirTicketReservations.Count != 0)
  2587. {
  2588. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2589. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2590. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2591. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2592. WorkbookDesigner designer = new WorkbookDesigner();
  2593. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2594. decimal countCost = 0;
  2595. foreach (var item in AirTicketReservations)
  2596. {
  2597. #region 处理客人姓名
  2598. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2599. item.ClientName = clientNames;
  2600. #endregion
  2601. if (item.BankType == "其他")
  2602. {
  2603. item.BankNo = "--";
  2604. }
  2605. else
  2606. {
  2607. if (!string.IsNullOrEmpty(item.BankType))
  2608. {
  2609. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2610. }
  2611. }
  2612. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2613. item.Price = System.Decimal.Round(item.Price, 2);
  2614. countCost += Convert.ToDecimal(item.Price);
  2615. }
  2616. designer.SetDataSource("Export", AirTicketReservations);
  2617. designer.SetDataSource("ExportDiCode", diCode);
  2618. designer.SetDataSource("ExportDiName", diName);
  2619. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2620. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2621. designer.Process();
  2622. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2623. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2624. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2625. return Ok(JsonView(true, "成功", url = rst));
  2626. }
  2627. else
  2628. {
  2629. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2630. }
  2631. }
  2632. }
  2633. catch (Exception ex)
  2634. {
  2635. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2636. throw;
  2637. }
  2638. }
  2639. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2640. /// <summary>
  2641. /// 行程单导出
  2642. /// </summary>
  2643. /// <param name="dto"></param>
  2644. /// <returns></returns>
  2645. [HttpPost]
  2646. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2647. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2648. {
  2649. try
  2650. {
  2651. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2652. if (groupData.Code != 0)
  2653. {
  2654. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2655. }
  2656. else
  2657. {
  2658. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2659. if (dto.Language == "CN")
  2660. {
  2661. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2662. DocumentBuilder builder = new DocumentBuilder(doc);
  2663. int tableIndex = 0;//表格索引
  2664. //得到文档中的第一个表格
  2665. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2666. foreach (var item in _AirTicketReservations)
  2667. {
  2668. #region 处理固定数据
  2669. string[] FlightsCode = item.FlightsCode.Split('/');
  2670. if (FlightsCode.Length != 0)
  2671. {
  2672. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2673. if (_AirCompany != null)
  2674. {
  2675. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2676. }
  2677. else
  2678. {
  2679. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2680. }
  2681. }
  2682. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2683. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2684. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2685. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2686. string name = "";
  2687. foreach (string clientName in nameArray)
  2688. {
  2689. if (!name.Contains(clientName))
  2690. {
  2691. name += clientName + ",";
  2692. }
  2693. }
  2694. if (!string.IsNullOrWhiteSpace(name))
  2695. {
  2696. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2697. }
  2698. else
  2699. {
  2700. table.Range.Bookmarks["ClientName"].Text = "--";
  2701. }
  2702. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2703. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2704. table.Range.Bookmarks["JointTicket"].Text = "--";
  2705. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2706. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2707. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2708. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2709. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2710. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2711. #endregion
  2712. #region 循环数据处理
  2713. List<AirInfo> airs = new List<AirInfo>();
  2714. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2715. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2716. for (int i = 0; i < FlightsCode.Length; i++)
  2717. {
  2718. AirInfo air = new AirInfo();
  2719. string[] tempstr = DayArray[i]
  2720. .Replace("\r\n", string.Empty)
  2721. .Replace("\\r\\n", string.Empty)
  2722. .TrimStart().TrimEnd()
  2723. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2724. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2725. string starCity = "";
  2726. if (star_Three != null)
  2727. {
  2728. starCity = star_Three.AirPort;
  2729. }
  2730. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2731. string EndCity = "";
  2732. if (End_Three != null)
  2733. {
  2734. EndCity = End_Three.AirPort;
  2735. }
  2736. air.Destination = starCity + "/" + EndCity;
  2737. air.Flight = FlightsCode[i];
  2738. air.SeatingClass = item.CTypeName;
  2739. string dateTime = tempstr[2];
  2740. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2741. air.FlightDate = DateTemp;
  2742. air.DepartureTime = tempstr[5];
  2743. air.LandingTime = tempstr[6];
  2744. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2745. air.TicketStatus = "--";
  2746. air.Luggage = "--";
  2747. air.DepartureTerminal = "--";
  2748. air.LandingTerminal = "--";
  2749. airs.Add(air);
  2750. }
  2751. int row = 13;
  2752. for (int i = 0; i < airs.Count; i++)
  2753. {
  2754. if (airs.Count > 2)
  2755. {
  2756. for (int j = 0; j < airs.Count - 2; j++)
  2757. {
  2758. var CopyRow = table.Rows[12].Clone(true);
  2759. table.Rows.Add(CopyRow);
  2760. }
  2761. }
  2762. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2763. int index = 0;
  2764. foreach (PropertyInfo property in properties)
  2765. {
  2766. string value = property.GetValue(airs[i]).ToString();
  2767. Cell ishcel0 = table.Rows[row].Cells[index];
  2768. Paragraph p = new Paragraph(doc);
  2769. string s = value;
  2770. p.AppendChild(new Run(doc, s));
  2771. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2772. ishcel0.AppendChild(p);
  2773. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2774. index++;
  2775. }
  2776. row++;
  2777. }
  2778. #endregion
  2779. Paragraph lastParagraph = new Paragraph(doc);
  2780. //第一个表格末尾加段落
  2781. table.ParentNode.InsertAfter(lastParagraph, table);
  2782. //复制第一个表格
  2783. Table cloneTable = (Table)table.Clone(true);
  2784. //在文档末尾段落后面加入复制的表格
  2785. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2786. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2787. {
  2788. int rownewsIndex = 13;
  2789. for (int i = 0; i < 2; i++)
  2790. {
  2791. var CopyRow = table.Rows[12].Clone(true);
  2792. table.Rows.RemoveAt(13);
  2793. table.Rows.Add(CopyRow);
  2794. rownewsIndex++;
  2795. }
  2796. }
  2797. else
  2798. {
  2799. table.Rows.RemoveAt(12);
  2800. }
  2801. cloneTable.Rows.RemoveAt(12);
  2802. }
  2803. if (_AirTicketReservations.Count != 0)
  2804. {
  2805. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2806. if (FlightsCode.Length != 0)
  2807. {
  2808. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2809. if (_AirCompany != null)
  2810. {
  2811. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2812. }
  2813. else
  2814. {
  2815. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2816. }
  2817. }
  2818. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2819. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2820. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2821. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2822. string name = "";
  2823. foreach (string clientName in nameArray)
  2824. {
  2825. if (!name.Contains(clientName))
  2826. {
  2827. name += clientName + ",";
  2828. }
  2829. }
  2830. if (!string.IsNullOrWhiteSpace(name))
  2831. {
  2832. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2833. }
  2834. else
  2835. {
  2836. table.Range.Bookmarks["ClientName"].Text = "--";
  2837. }
  2838. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2839. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2840. table.Range.Bookmarks["JointTicket"].Text = "--";
  2841. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2842. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2843. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2844. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2845. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2846. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2847. }
  2848. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2849. //保存合并后的文档
  2850. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2851. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2852. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2853. return Ok(JsonView(true, "成功!", rst));
  2854. }
  2855. else
  2856. {
  2857. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2858. DocumentBuilder builder = new DocumentBuilder(doc);
  2859. int tableIndex = 0;//表格索引
  2860. //得到文档中的第一个表格
  2861. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2862. List<string> texts = new List<string>();
  2863. foreach (var item in _AirTicketReservations)
  2864. {
  2865. string[] FlightsCode = item.FlightsCode.Split('/');
  2866. if (FlightsCode.Length != 0)
  2867. {
  2868. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2869. if (_AirCompany != null)
  2870. {
  2871. if (!transDic.ContainsKey(_AirCompany.CnName))
  2872. {
  2873. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2874. }
  2875. }
  2876. else
  2877. {
  2878. if (!transDic.ContainsKey("--"))
  2879. {
  2880. transDic.Add("--", "--");
  2881. }
  2882. }
  2883. }
  2884. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2885. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2886. string name = "";
  2887. foreach (string clientName in nameArray)
  2888. {
  2889. name += clientName + ",";
  2890. }
  2891. if (!texts.Contains(name))
  2892. {
  2893. texts.Add(name);
  2894. }
  2895. List<AirInfo> airs = new List<AirInfo>();
  2896. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2897. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2898. for (int i = 0; i < FlightsCode.Length; i++)
  2899. {
  2900. AirInfo air = new AirInfo();
  2901. string[] tempstr = DayArray[i]
  2902. .Replace("\r\n", string.Empty)
  2903. .Replace("\\r\\n", string.Empty)
  2904. .TrimStart().TrimEnd()
  2905. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2906. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2907. if (star_Three != null)
  2908. {
  2909. if (!transDic.ContainsKey(star_Three.AirPort))
  2910. {
  2911. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2912. }
  2913. }
  2914. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2915. if (End_Three != null)
  2916. {
  2917. if (!transDic.ContainsKey(End_Three.AirPort))
  2918. {
  2919. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2920. }
  2921. }
  2922. if (!texts.Contains(item.CTypeName))
  2923. {
  2924. texts.Add(item.CTypeName);
  2925. }
  2926. }
  2927. }
  2928. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2929. if (transData.Count > 0)
  2930. {
  2931. foreach (TranslateResult item in transData)
  2932. {
  2933. if (!transDic.ContainsKey(item.Query))
  2934. {
  2935. transDic.Add(item.Query, item.Translation);
  2936. }
  2937. }
  2938. }
  2939. foreach (var item in _AirTicketReservations)
  2940. {
  2941. #region 处理固定数据
  2942. string[] FlightsCode = item.FlightsCode.Split('/');
  2943. if (FlightsCode.Length != 0)
  2944. {
  2945. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2946. if (_AirCompany != null)
  2947. {
  2948. string str = "--";
  2949. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2950. if (!string.IsNullOrEmpty(translateResult))
  2951. {
  2952. str = translateResult;
  2953. str = _airTicketResRep.Processing(str);
  2954. }
  2955. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2956. }
  2957. else
  2958. {
  2959. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2960. }
  2961. }
  2962. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2963. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2964. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2965. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2966. string names = "";
  2967. foreach (string clientName in nameArray)
  2968. {
  2969. names += clientName + ",";
  2970. }
  2971. if (!string.IsNullOrWhiteSpace(names))
  2972. {
  2973. string str = "--";
  2974. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2975. if (!string.IsNullOrEmpty(translateResult))
  2976. {
  2977. str = translateResult;
  2978. str = _airTicketResRep.Processing(str);
  2979. }
  2980. table.Range.Bookmarks["ClientName"].Text = str;
  2981. }
  2982. else
  2983. {
  2984. table.Range.Bookmarks["ClientName"].Text = "--";
  2985. }
  2986. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2987. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2988. table.Range.Bookmarks["JointTicket"].Text = "--";
  2989. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2990. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2991. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2992. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2993. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2994. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2995. #endregion
  2996. #region 循环数据处理
  2997. List<AirInfo> airs = new List<AirInfo>();
  2998. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2999. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3000. for (int i = 0; i < FlightsCode.Length; i++)
  3001. {
  3002. AirInfo air = new AirInfo();
  3003. string[] tempstr = DayArray[i]
  3004. .Replace("\r\n", string.Empty)
  3005. .Replace("\\r\\n", string.Empty)
  3006. .TrimStart().TrimEnd()
  3007. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3008. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3009. string starCity = "";
  3010. if (star_Three != null)
  3011. {
  3012. string str2 = "--";
  3013. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3014. if (!string.IsNullOrEmpty(translateResult2))
  3015. {
  3016. str2 = translateResult2;
  3017. str2 = _airTicketResRep.Processing(str2);
  3018. }
  3019. starCity = str2;
  3020. }
  3021. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3022. string EndCity = "";
  3023. if (End_Three != null)
  3024. {
  3025. string str1 = "--";
  3026. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3027. if (!string.IsNullOrEmpty(translateResult1))
  3028. {
  3029. str1 = translateResult1;
  3030. str1 = _airTicketResRep.Processing(str1);
  3031. }
  3032. EndCity = str1;
  3033. }
  3034. air.Destination = starCity + "/" + EndCity;
  3035. air.Flight = FlightsCode[i];
  3036. string str = "--";
  3037. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3038. if (!string.IsNullOrEmpty(translateResult))
  3039. {
  3040. str = translateResult;
  3041. str = _airTicketResRep.Processing(str);
  3042. }
  3043. air.SeatingClass = str;
  3044. string dateTime = tempstr[2];
  3045. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3046. air.FlightDate = DateTemp;
  3047. air.DepartureTime = tempstr[5];
  3048. air.LandingTime = tempstr[6];
  3049. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3050. air.TicketStatus = "--";
  3051. air.Luggage = "--";
  3052. air.DepartureTerminal = "--";
  3053. air.LandingTerminal = "--";
  3054. airs.Add(air);
  3055. }
  3056. int row = 13;
  3057. for (int i = 0; i < airs.Count; i++)
  3058. {
  3059. if (airs.Count > 2)
  3060. {
  3061. for (int j = 0; j < airs.Count - 2; j++)
  3062. {
  3063. var CopyRow = table.Rows[12].Clone(true);
  3064. table.Rows.Add(CopyRow);
  3065. }
  3066. }
  3067. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3068. int index = 0;
  3069. foreach (PropertyInfo property in properties)
  3070. {
  3071. string value = property.GetValue(airs[i]).ToString();
  3072. Cell ishcel0 = table.Rows[row].Cells[index];
  3073. Paragraph p = new Paragraph(doc);
  3074. string s = value;
  3075. p.AppendChild(new Run(doc, s));
  3076. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3077. ishcel0.AppendChild(p);
  3078. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3079. //ishcel0.CellFormat.VerticalAlignment=
  3080. index++;
  3081. }
  3082. row++;
  3083. }
  3084. #endregion
  3085. Paragraph lastParagraph = new Paragraph(doc);
  3086. //第一个表格末尾加段落
  3087. table.ParentNode.InsertAfter(lastParagraph, table);
  3088. //复制第一个表格
  3089. Table cloneTable = (Table)table.Clone(true);
  3090. //在文档末尾段落后面加入复制的表格
  3091. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3092. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3093. {
  3094. int rownewsIndex = 13;
  3095. for (int i = 0; i < 2; i++)
  3096. {
  3097. var CopyRow = table.Rows[12].Clone(true);
  3098. table.Rows.RemoveAt(13);
  3099. table.Rows.Add(CopyRow);
  3100. rownewsIndex++;
  3101. }
  3102. }
  3103. else
  3104. {
  3105. table.Rows.RemoveAt(12);
  3106. }
  3107. cloneTable.Rows.RemoveAt(12);
  3108. }
  3109. if (_AirTicketReservations.Count != 0)
  3110. {
  3111. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3112. if (FlightsCode.Length != 0)
  3113. {
  3114. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3115. if (_AirCompany != null)
  3116. {
  3117. string str = "--";
  3118. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3119. if (!string.IsNullOrEmpty(translateResult))
  3120. {
  3121. str = translateResult;
  3122. str = _airTicketResRep.Processing(str);
  3123. }
  3124. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3125. }
  3126. else
  3127. {
  3128. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3129. }
  3130. }
  3131. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3132. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3133. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3134. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3135. string names = "";
  3136. foreach (string clientName in nameArray)
  3137. {
  3138. names += clientName + ",";
  3139. }
  3140. if (!string.IsNullOrWhiteSpace(names))
  3141. {
  3142. string str = "--";
  3143. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3144. if (!string.IsNullOrEmpty(translateResult))
  3145. {
  3146. str = translateResult;
  3147. str = _airTicketResRep.Processing(str);
  3148. }
  3149. table.Range.Bookmarks["ClientName"].Text = str;
  3150. }
  3151. else
  3152. {
  3153. table.Range.Bookmarks["ClientName"].Text = "--";
  3154. }
  3155. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3156. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3157. table.Range.Bookmarks["JointTicket"].Text = "--";
  3158. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3159. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3160. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3161. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3162. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3163. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3164. }
  3165. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3166. //保存合并后的文档
  3167. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3168. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3169. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3170. return Ok(JsonView(true, "成功!", rst));
  3171. }
  3172. }
  3173. }
  3174. catch (Exception ex)
  3175. {
  3176. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3177. throw;
  3178. }
  3179. }
  3180. #endregion
  3181. #region 团组增减款项 --> 其他款项
  3182. /// <summary>
  3183. /// 团组增减款项下拉框绑定
  3184. /// </summary>
  3185. /// <param name="dto"></param>
  3186. /// <returns></returns>
  3187. [HttpPost]
  3188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3189. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3190. {
  3191. #region 参数验证
  3192. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3193. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3194. #endregion
  3195. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3196. }
  3197. /// <summary>
  3198. /// 根据团组Id查询团组增减款项
  3199. /// </summary>
  3200. /// <param name="dto"></param>
  3201. /// <returns></returns>
  3202. [HttpPost]
  3203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3204. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3205. {
  3206. #region 参数验证
  3207. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3208. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3209. #endregion
  3210. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3211. }
  3212. /// <summary>
  3213. /// 团组增减款项操作(Status:1.新增,2.修改)
  3214. /// </summary>
  3215. /// <param name="dto"></param>
  3216. /// <returns></returns>
  3217. [HttpPost]
  3218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3219. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3220. {
  3221. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3222. if (groupData.Code != 200)
  3223. {
  3224. return Ok(JsonView(false, groupData.Msg));
  3225. }
  3226. #region 应用推送
  3227. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3228. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3229. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3230. //自动审核
  3231. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3232. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3233. //2024-10-21 新增LZ UID
  3234. var userIds = new List<int>() { 21 };
  3235. string title = $"系统通知";
  3236. string content = "";
  3237. var diId = dto.DiId;
  3238. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3239. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3240. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3241. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3242. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3243. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3244. #endregion
  3245. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3246. }
  3247. /// <summary>
  3248. /// 团组增减款项操作 删除
  3249. /// </summary>
  3250. /// <param name="dto"></param>
  3251. /// <returns></returns>
  3252. [HttpPost]
  3253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3254. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3255. {
  3256. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3257. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3258. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3259. if (res.Code == 0)
  3260. {
  3261. return Ok(JsonView(true, "删除成功!"));
  3262. }
  3263. return Ok(JsonView(false, "删除失败!"));
  3264. }
  3265. /// <summary>
  3266. /// 根据团组增减款项Id查询
  3267. /// </summary>
  3268. /// <param name="dto"></param>
  3269. /// <returns></returns>
  3270. [HttpPost]
  3271. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3272. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3273. {
  3274. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3275. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3276. }
  3277. /// <summary>
  3278. /// 查询供应商名称
  3279. /// </summary>
  3280. /// <param name="dto"></param>
  3281. /// <returns></returns>
  3282. [HttpPost]
  3283. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3284. {
  3285. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3286. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3287. ?? new List<Grp_DecreasePayments>();
  3288. dbResult = dbResult.Distinct(new
  3289. ProductComparer()).ToList();
  3290. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3291. {
  3292. x.Id,
  3293. x.SupplierAddress,
  3294. x.SupplierArea,
  3295. x.SupplierContact,
  3296. x.SupplierContactNumber,
  3297. x.SupplierEmail,
  3298. x.SupplierName,
  3299. x.SupplierSocialAccount,
  3300. x.SupplierTypeId,
  3301. }).ToList());
  3302. return Ok(jw);
  3303. }
  3304. /// <summary>
  3305. /// 团组增减款项 OTA匹配
  3306. /// </summary>
  3307. /// <param name="file"></param>
  3308. /// <returns></returns>
  3309. [HttpPost]
  3310. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3311. {
  3312. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3313. string fileName = file.FileName;
  3314. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3315. {
  3316. return Ok(JsonView(false, "请上传Excel文件!"));
  3317. }
  3318. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3319. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3320. if (!Directory.Exists(path))
  3321. {
  3322. Directory.CreateDirectory(path);
  3323. }
  3324. var filePath = @$"{path}/{fileName}";
  3325. //保存文件
  3326. using (FileStream fs = System.IO.File.Create(filePath))
  3327. {
  3328. file.CopyTo(fs);
  3329. fs.Flush();
  3330. }
  3331. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3332. //读取ExcelFile
  3333. DataTable dt = ConvertExcelToDataTable(filePath);
  3334. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3335. dt.TableName = "TB";
  3336. //修改table列名
  3337. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3338. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3339. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3340. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3341. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3342. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3343. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3344. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3345. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3346. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3347. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3348. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3349. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3350. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3351. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3352. var otaOrderNos = new List<string>();
  3353. foreach (DataRow item in dt.Rows)
  3354. {
  3355. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3356. }
  3357. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3358. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3359. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3360. .Select((dp, di) => new
  3361. {
  3362. dp.PriceName,
  3363. dp.OTAOrderNo,
  3364. dp.FeeTotal,
  3365. di.TeamName,
  3366. })
  3367. .ToListAsync();
  3368. foreach (DataRow item in dt.Rows)
  3369. {
  3370. var otaOrderNo = item["OTAOrderNo"].ToString();
  3371. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3372. if (oaData == null) continue;
  3373. item["GroupName"] = oaData.TeamName;
  3374. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3375. }
  3376. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3377. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3378. List<DataTable> datas = new List<DataTable>();
  3379. datas.Add(dt);
  3380. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3381. return Ok(JsonView(true, "操作成功", new { url = url }));
  3382. }
  3383. #region
  3384. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3385. {
  3386. // 创建Workbook对象
  3387. Workbook workbook = new Workbook(excelFilePath);
  3388. // 获取第一个工作表
  3389. Worksheet worksheet = workbook.Worksheets[0];
  3390. // 将工作表转换为DataTable
  3391. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3392. return dataTable;
  3393. }
  3394. #endregion
  3395. #endregion
  3396. #region 文件上传、删除
  3397. /// <summary>
  3398. /// region 文件上传 可以带参数
  3399. /// </summary>
  3400. /// <param name="file"></param>
  3401. /// <returns></returns>
  3402. [HttpPost]
  3403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3404. public async Task<IActionResult> UploadProject(IFormFile file)
  3405. {
  3406. //var TypeName = Request.Headers["TypeName"].ToString();
  3407. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3408. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3409. ////文件名称
  3410. //string projectFileName = file.FileName;
  3411. ////上传的文件的路径
  3412. //string filePath = $"{fileDir}/{projectFileName}";
  3413. //if (TypeName == "A")//A代表团组增减款项
  3414. //{
  3415. // filePath = fileDir + $@"\团组增减款项相关文件";
  3416. // if (!Directory.Exists(filePath))
  3417. // {
  3418. // Directory.CreateDirectory(filePath);
  3419. // }
  3420. // //上传的文件的路径
  3421. // filePath += $@"\{projectFileName}";
  3422. //}
  3423. //else if (TypeName == "B")//B代表商邀相关文件
  3424. //{
  3425. // //上传的文件的路径
  3426. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3427. // if (!Directory.Exists(filePath))
  3428. // {
  3429. // Directory.CreateDirectory(filePath);
  3430. // }
  3431. // //上传的文件的路径
  3432. // filePath = $@"\{projectFileName}";
  3433. //}
  3434. //try
  3435. //{
  3436. // using (FileStream fs = System.IO.File.Create(filePath))
  3437. // {
  3438. // file.CopyTo(fs);
  3439. // fs.Flush();
  3440. // }
  3441. //}
  3442. //catch (Exception ex)
  3443. //{
  3444. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3445. //}
  3446. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3447. try
  3448. {
  3449. var TypeName = Request.Headers["TypeName"].ToString();
  3450. if (file != null)
  3451. {
  3452. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3453. //文件名称
  3454. string projectFileName = file.FileName;
  3455. //上传的文件的路径
  3456. string filePath = $"{fileDir}/{projectFileName}";
  3457. if (TypeName == "A")//A代表团组增减款项
  3458. {
  3459. if (!Directory.Exists(fileDir))
  3460. {
  3461. Directory.CreateDirectory(fileDir);
  3462. }
  3463. //上传的文件的路径
  3464. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3465. }
  3466. else if (TypeName == "B")//B代表商邀相关文件
  3467. {
  3468. if (!Directory.Exists(fileDir))
  3469. {
  3470. Directory.CreateDirectory(fileDir);
  3471. }
  3472. //上传的文件的路径
  3473. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3474. }
  3475. using (FileStream fs = System.IO.File.Create(filePath))
  3476. {
  3477. file.CopyTo(fs);
  3478. fs.Flush();
  3479. }
  3480. return Ok(JsonView(true, "上传成功!", projectFileName));
  3481. }
  3482. else
  3483. {
  3484. return Ok(JsonView(false, "上传失败!"));
  3485. }
  3486. }
  3487. catch (Exception ex)
  3488. {
  3489. return Ok(JsonView(false, "程序错误!"));
  3490. }
  3491. }
  3492. /// <summary>
  3493. /// 删除指定文件
  3494. /// </summary>
  3495. /// <param name="dto"></param>
  3496. /// <returns></returns>
  3497. [HttpPost]
  3498. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3499. public async Task<IActionResult> DelFile(DelFileDto dto)
  3500. {
  3501. try
  3502. {
  3503. var TypeName = Request.Headers["TypeName"].ToString();
  3504. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3505. string filePath = "";
  3506. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3507. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3508. int id = 0;
  3509. if (TypeName == "A")
  3510. {
  3511. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3512. // 删除该文件
  3513. System.IO.File.Delete(filePath);
  3514. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3515. .Where(a => a.Id == dto.Id)
  3516. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3517. .ExecuteCommandAsync();
  3518. }
  3519. else if (TypeName == "B")
  3520. {
  3521. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3522. // 删除该文件
  3523. System.IO.File.Delete(filePath);
  3524. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3525. if (info != null)
  3526. {
  3527. string[] files = new string[] { };
  3528. if (!string.IsNullOrEmpty(info.Attachment))
  3529. {
  3530. try
  3531. {
  3532. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3533. }
  3534. catch (Exception)
  3535. {
  3536. files = new List<string>() { info.Attachment }.ToArray();
  3537. }
  3538. }
  3539. if (files.Length > 0)
  3540. {
  3541. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3542. string filePath2 = string.Empty;
  3543. if (files1.Length > 0)
  3544. {
  3545. filePath2 = JsonConvert.SerializeObject(files1);
  3546. }
  3547. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3548. .Where(a => a.Id == dto.Id)
  3549. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3550. .ExecuteCommandAsync();
  3551. }
  3552. }
  3553. }
  3554. if (id != 0)
  3555. {
  3556. return Ok(JsonView(true, "成功!"));
  3557. }
  3558. else
  3559. {
  3560. return Ok(JsonView(false, "失败!"));
  3561. }
  3562. }
  3563. catch (Exception ex)
  3564. {
  3565. return Ok(JsonView(false, "程序错误!"));
  3566. throw;
  3567. }
  3568. }
  3569. /// <summary>
  3570. /// 文件上传多个文件 可以带参数
  3571. /// </summary>
  3572. /// <param name="file"></param>
  3573. /// <returns></returns>
  3574. [HttpPost]
  3575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3576. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3577. {
  3578. try
  3579. {
  3580. var TypeName = Request.Headers["TypeName"].ToString();
  3581. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3582. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3583. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3584. var filePahts = new List<string>();
  3585. foreach (var file in files)
  3586. {
  3587. //文件名称
  3588. string projectFileName = file.FileName;
  3589. //上传的文件的路径
  3590. string filePath = $"{fileDir}/{projectFileName}";
  3591. if (TypeName == "A")//A代表团组增减款项
  3592. {
  3593. if (!Directory.Exists(fileDir))
  3594. {
  3595. Directory.CreateDirectory(fileDir);
  3596. }
  3597. //上传的文件的路径
  3598. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3599. }
  3600. else if (TypeName == "B")//B代表商邀相关文件
  3601. {
  3602. if (!Directory.Exists(fileDir))
  3603. {
  3604. Directory.CreateDirectory(fileDir);
  3605. }
  3606. //上传的文件的路径
  3607. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3608. }
  3609. using (FileStream fs = System.IO.File.Create(filePath))
  3610. {
  3611. file.CopyTo(fs);
  3612. fs.Flush();
  3613. }
  3614. filePahts.Add(projectFileName);
  3615. }
  3616. return Ok(JsonView(true, "上传成功!", filePahts));
  3617. }
  3618. catch (Exception ex)
  3619. {
  3620. return Ok(JsonView(false, "程序错误!"));
  3621. }
  3622. }
  3623. #endregion
  3624. #region 商邀费用录入
  3625. /// <summary>
  3626. /// 根据团组Id查询商邀费用列表
  3627. /// </summary>
  3628. /// <param name="dto"></param>
  3629. /// <returns></returns>
  3630. [HttpPost]
  3631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3632. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3633. {
  3634. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3635. if (groupData.Code != 0)
  3636. {
  3637. return Ok(JsonView(false, groupData.Msg));
  3638. }
  3639. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3640. }
  3641. /// <summary>
  3642. /// 商邀费用列表
  3643. /// 下载文件
  3644. /// </summary>
  3645. /// <param name="dto"></param>
  3646. /// <returns></returns>
  3647. [HttpGet("{id}")]
  3648. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3649. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3650. {
  3651. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3652. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3653. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3654. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3655. var filePaths = new List<string>();
  3656. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3657. try
  3658. {
  3659. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3660. }
  3661. catch (Exception ex)
  3662. {
  3663. filePaths.Add(info.Attachment);
  3664. }
  3665. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3666. for (int i = 0; i < filePaths.Count; i++)
  3667. {
  3668. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3669. }
  3670. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3671. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3672. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3673. {
  3674. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3675. {
  3676. foreach (string filePath in filePaths)
  3677. {
  3678. if (System.IO.File.Exists(filePath))
  3679. {
  3680. // 获取文件名
  3681. string fileName = Path.GetFileName(filePath);
  3682. // 将文件添加到ZIP归档中
  3683. zipArchive.CreateEntryFromFile(filePath, fileName);
  3684. }
  3685. }
  3686. }
  3687. }
  3688. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3689. }
  3690. /// <summary>
  3691. /// 商邀费用 Info Page 基础数据源
  3692. /// </summary>
  3693. /// <param name="dto"></param>
  3694. /// <returns></returns>
  3695. [HttpPost]
  3696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3697. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3698. {
  3699. try
  3700. {
  3701. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3702. if (groupData.Code != 0)
  3703. {
  3704. return Ok(JsonView(false, groupData.Msg));
  3705. }
  3706. return Ok(JsonView(true, "操作成功", groupData.Data));
  3707. }
  3708. catch (Exception ex)
  3709. {
  3710. return Ok(JsonView(false, ex.Message));
  3711. throw;
  3712. }
  3713. }
  3714. /// <summary>
  3715. /// 根据商邀费用ID查询C表和商邀费用数据
  3716. /// </summary>
  3717. /// <param name="dto"></param>
  3718. /// <returns></returns>
  3719. [HttpPost]
  3720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3721. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3722. {
  3723. try
  3724. {
  3725. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3726. if (groupData.Code != 0)
  3727. {
  3728. return Ok(JsonView(false, groupData.Msg));
  3729. }
  3730. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3731. }
  3732. catch (Exception ex)
  3733. {
  3734. return Ok(JsonView(false, ex.Message));
  3735. throw;
  3736. }
  3737. }
  3738. /// <summary>
  3739. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3740. /// </summary>
  3741. /// <param name="dto"></param>
  3742. /// <returns></returns>
  3743. [HttpPost]
  3744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3745. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3746. {
  3747. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3748. if (groupData.Code != 0)
  3749. {
  3750. return Ok(JsonView(false, groupData.Msg));
  3751. }
  3752. #region 应用推送
  3753. try
  3754. {
  3755. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3756. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3757. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3758. //2024-10-21 新增LZ UID
  3759. var userIds = new List<int>() { 21 };
  3760. string title = $"系统通知";
  3761. string content = "";
  3762. var diId = dto.DiId;
  3763. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3764. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3765. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3766. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3767. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3768. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  3769. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  3770. }
  3771. catch (Exception ex)
  3772. {
  3773. }
  3774. #endregion
  3775. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3776. }
  3777. /// <summary>
  3778. /// 商邀删除
  3779. /// </summary>
  3780. /// <param name="dto"></param>
  3781. /// <returns></returns>
  3782. [HttpPost]
  3783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3784. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3785. {
  3786. try
  3787. {
  3788. _sqlSugar.BeginTran();
  3789. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3790. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3791. {
  3792. IsDel = 1,
  3793. DeleteUserId = dto.DeleteUserId,
  3794. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3795. })
  3796. .Where(it => it.Id == dto.Id)
  3797. .ExecuteCommand();
  3798. if (res1 > 0)
  3799. {
  3800. int _diId = 0;
  3801. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3802. if (_ioaInfo != null)
  3803. {
  3804. _diId = _ioaInfo.DiId;
  3805. }
  3806. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3807. .SetColumns(a => new Grp_CreditCardPayment()
  3808. {
  3809. IsDel = 1,
  3810. DeleteUserId = dto.DeleteUserId,
  3811. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3812. })
  3813. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3814. .ExecuteCommand();
  3815. if (res2 > 0)
  3816. {
  3817. _sqlSugar.CommitTran();
  3818. return Ok(JsonView(true, "删除成功!"));
  3819. }
  3820. }
  3821. _sqlSugar.RollbackTran();
  3822. return Ok(JsonView(false, "删除失败"));
  3823. }
  3824. catch (Exception ex)
  3825. {
  3826. _sqlSugar.RollbackTran();
  3827. return Ok(JsonView(false, ex.Message));
  3828. }
  3829. }
  3830. /// <summary>
  3831. /// 团组模块文件上传
  3832. /// </summary>
  3833. /// <param name="dto"></param>
  3834. /// <returns></returns>
  3835. [HttpPost]
  3836. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3837. {
  3838. var jw = JsonView(false);
  3839. long M = 1024 * 1024;
  3840. if (dto.Files == null || dto.Files.Count == 0)
  3841. {
  3842. jw.Msg = "无文件信息!";
  3843. return Ok(jw);
  3844. }
  3845. if (dto.Files.Sum(x => x.Length) > 20 * M)
  3846. {
  3847. jw.Msg = "文件大小超过20M!";
  3848. return Ok(jw);
  3849. }
  3850. //var nameSp = dto.File.FileName.Split(".");
  3851. //if (nameSp.Length < 2)
  3852. //{
  3853. // jw.Msg = "拓展名称有误!";
  3854. // return Ok(jw);
  3855. //}
  3856. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3857. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3858. //{
  3859. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3860. // return Ok(jw);
  3861. //}
  3862. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3863. if (Ctable == null)
  3864. {
  3865. jw.Msg = "Ctable指向有误!";
  3866. return Ok(jw);
  3867. }
  3868. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3869. if (groupInfo == null)
  3870. {
  3871. jw.Msg = "团组信息不存在!";
  3872. return Ok(jw);
  3873. }
  3874. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3875. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3876. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3877. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3878. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3879. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3880. try
  3881. {
  3882. if (!Directory.Exists(fileBase))
  3883. {
  3884. Directory.CreateDirectory(fileBase);
  3885. }
  3886. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3887. foreach (var fileStream in dto.Files)
  3888. {
  3889. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3890. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3891. {
  3892. Cid = dto.Cid,
  3893. CreateTime = DateTime.Now,
  3894. CreateUserId = dto.Userid,
  3895. Ctable = dto.Ctable,
  3896. Diid = dto.Diid,
  3897. IsDel = 0,
  3898. FilePath = saveFilePath,
  3899. FileName = fileStream.FileName
  3900. };
  3901. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3902. {
  3903. fileStream.CopyTo(fs);
  3904. fs.Flush();
  3905. }
  3906. saveArr.Add(file);
  3907. }
  3908. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3909. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3910. jw = JsonView(true, "保存成功!", new
  3911. {
  3912. count = addResult,
  3913. filesName = saveArr.Select(x => x.FileName)
  3914. });
  3915. }
  3916. catch (Exception ex)
  3917. {
  3918. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3919. {
  3920. count = 0,
  3921. filesName = new string[0],
  3922. });
  3923. }
  3924. return Ok(jw);
  3925. }
  3926. /// <summary>
  3927. /// 查询各模块已保存文件
  3928. /// </summary>
  3929. /// <param name="dto"></param>
  3930. /// <returns></returns>
  3931. [HttpPost]
  3932. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3933. {
  3934. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3935. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  3936. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  3937. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3938. {
  3939. expression = Expressionable.Create<Grp_GroupModelFile>()
  3940. .And(x => visaIds.Contains(x.CreateUserId));
  3941. }
  3942. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3943. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3944. .Where(expression.ToExpression())
  3945. .ToList();
  3946. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3947. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3948. {
  3949. x.FileName,
  3950. x.Id,
  3951. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3952. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3953. })));
  3954. }
  3955. /// <summary>
  3956. /// 下载该团组下的所有文件
  3957. /// </summary>
  3958. /// <param name="dto"></param>
  3959. /// <returns></returns>
  3960. [HttpPost]
  3961. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3962. {
  3963. var jw = JsonView(false);
  3964. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3965. if (groupInfo == null)
  3966. {
  3967. jw.Msg = "团组信息不存在!";
  3968. return Ok(jw);
  3969. }
  3970. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3971. var isModule = Convert.ToBoolean(dto.isModule);
  3972. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3973. IOOperatorHelper io = new IOOperatorHelper();
  3974. if (isModule)
  3975. {
  3976. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3977. foreach (var moduleArr in moduleGroup)
  3978. {
  3979. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3980. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3981. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3982. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3983. foreach (var item in moduleArr)
  3984. {
  3985. if (System.IO.File.Exists(item.FilePath))
  3986. {
  3987. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3988. {
  3989. byte[] bytes = new byte[fileStream.Length];
  3990. fileStream.Read(bytes, 0, bytes.Length);
  3991. fileStream.Close();
  3992. Stream stream = new MemoryStream(bytes);
  3993. chiZips.Add(item.FileName, stream);
  3994. }
  3995. }
  3996. }
  3997. if (chiZips.Count > 0)
  3998. {
  3999. var byts = io.ConvertZipStream(chiZips);
  4000. Stream stream = new MemoryStream(byts);
  4001. Zips.Add(key.Name + "_.zip", stream);
  4002. }
  4003. }
  4004. }
  4005. else
  4006. {
  4007. foreach (var item in dbQuery)
  4008. {
  4009. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4010. {
  4011. byte[] bytes = new byte[fileStream.Length];
  4012. fileStream.Read(bytes, 0, bytes.Length);
  4013. fileStream.Close();
  4014. Stream stream = new MemoryStream(bytes);
  4015. while (Zips.Keys.Contains(item.FileName))
  4016. {
  4017. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4018. }
  4019. Zips.Add(item.FileName, stream);
  4020. }
  4021. }
  4022. }
  4023. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4024. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4025. if (Zips.Count > 0)
  4026. {
  4027. var byts = io.ConvertZipStream(Zips);
  4028. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4029. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4030. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4031. }
  4032. else
  4033. {
  4034. jw.Msg = "暂无生成文件!";
  4035. }
  4036. return Ok(jw);
  4037. }
  4038. /// <summary>
  4039. /// 下载该团组下此模块的所有文件
  4040. /// </summary>
  4041. /// <param name="dto"></param>
  4042. /// <returns></returns>
  4043. [HttpPost]
  4044. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4045. {
  4046. var jw = JsonView(false);
  4047. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4048. if (groupInfo == null)
  4049. {
  4050. jw.Msg = "团组信息不存在!";
  4051. return Ok(jw);
  4052. }
  4053. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4054. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4055. && x.IsDel == 0);
  4056. if (key == null)
  4057. {
  4058. jw.Msg = "Ctable指向错误!";
  4059. return Ok(jw);
  4060. }
  4061. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4062. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4063. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4064. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4065. IOOperatorHelper io = new IOOperatorHelper();
  4066. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4067. foreach (var item in dbQuery)
  4068. {
  4069. if (System.IO.File.Exists(item.FilePath))
  4070. {
  4071. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4072. {
  4073. byte[] bytes = new byte[fileStream.Length];
  4074. fileStream.Read(bytes, 0, bytes.Length);
  4075. fileStream.Close();
  4076. Stream stream = new MemoryStream(bytes);
  4077. while (Zips.Keys.Contains(item.FileName))
  4078. {
  4079. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4080. }
  4081. Zips.Add(item.FileName, stream);
  4082. }
  4083. }
  4084. }
  4085. if (Zips.Count > 0)
  4086. {
  4087. var byts = io.ConvertZipStream(Zips);
  4088. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4089. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4090. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4091. }
  4092. else
  4093. {
  4094. jw.Msg = "暂无生成文件!";
  4095. }
  4096. return Ok(jw);
  4097. }
  4098. /// <summary>
  4099. /// 删除该团组下的指定文件
  4100. /// </summary>
  4101. /// <param name="dto"></param>
  4102. /// <returns></returns>
  4103. [HttpPost]
  4104. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4105. {
  4106. var jw = JsonView(false);
  4107. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4108. if (sing == null)
  4109. {
  4110. jw.Msg = "暂无";
  4111. return Ok(jw);
  4112. }
  4113. if (System.IO.File.Exists(sing.FilePath))
  4114. {
  4115. try
  4116. {
  4117. System.IO.File.Delete(sing.FilePath);
  4118. }
  4119. catch (Exception ex)
  4120. {
  4121. jw.Msg = "删除失败!" + ex.Message;
  4122. return Ok(jw);
  4123. }
  4124. }
  4125. sing.IsDel = 1;
  4126. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4127. sing.DeleteUserId = dto.UserId;
  4128. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4129. jw = JsonView(true, "删除成功!");
  4130. return Ok(jw);
  4131. }
  4132. #endregion
  4133. #region 团组英文资料
  4134. /// <summary>
  4135. /// 查询团组英文所有资料
  4136. /// </summary>
  4137. /// <param name="dto"></param>
  4138. /// <returns></returns>
  4139. [HttpPost]
  4140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4141. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4142. {
  4143. try
  4144. {
  4145. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4146. if (groupData.Code != 0)
  4147. {
  4148. return Ok(JsonView(false, groupData.Msg));
  4149. }
  4150. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4151. }
  4152. catch (Exception ex)
  4153. {
  4154. return Ok(JsonView(false, "程序错误!"));
  4155. throw;
  4156. }
  4157. }
  4158. /// <summary>
  4159. /// 团组英文资料操作(Status:1.新增,2.修改)
  4160. /// </summary>
  4161. /// <param name="dto"></param>
  4162. /// <returns></returns>
  4163. [HttpPost]
  4164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4165. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4166. {
  4167. try
  4168. {
  4169. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4170. if (groupData.Code != 0)
  4171. {
  4172. return Ok(JsonView(false, groupData.Msg));
  4173. }
  4174. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4175. }
  4176. catch (Exception ex)
  4177. {
  4178. return Ok(JsonView(false, "程序错误!"));
  4179. throw;
  4180. }
  4181. }
  4182. /// <summary>
  4183. /// 团组英文资料Id查询数据
  4184. /// </summary>
  4185. /// <param name="dto"></param>
  4186. /// <returns></returns>
  4187. [HttpPost]
  4188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4189. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4190. {
  4191. try
  4192. {
  4193. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4194. if (_DelegationEnData != null)
  4195. {
  4196. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4197. }
  4198. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4199. }
  4200. catch (Exception ex)
  4201. {
  4202. return Ok(JsonView(false, "程序错误!"));
  4203. throw;
  4204. }
  4205. }
  4206. /// <summary>
  4207. /// 团组英文资料删除
  4208. /// </summary>
  4209. /// <param name="dto"></param>
  4210. /// <returns></returns>
  4211. [HttpPost]
  4212. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4213. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4214. {
  4215. try
  4216. {
  4217. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4218. if (!res)
  4219. {
  4220. return Ok(JsonView(false, "删除失败"));
  4221. }
  4222. return Ok(JsonView(true, "删除成功!"));
  4223. }
  4224. catch (Exception ex)
  4225. {
  4226. return Ok(JsonView(false, "程序错误!"));
  4227. throw;
  4228. }
  4229. }
  4230. #endregion
  4231. #region 导出邀请函
  4232. /// <summary>
  4233. /// 导出邀请函页面初始化
  4234. /// </summary>
  4235. /// <param name="dto"></param>
  4236. /// <returns></returns>
  4237. [HttpPost]
  4238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4239. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4240. {
  4241. try
  4242. {
  4243. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4244. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4245. if (dto.DiId == 0)
  4246. {
  4247. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4248. }
  4249. else
  4250. {
  4251. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4252. }
  4253. return Ok(JsonView(true, "查询成功!", new
  4254. {
  4255. deleClient = crm_Deles,
  4256. delegations = grp_Delegations
  4257. }));
  4258. }
  4259. catch (Exception ex)
  4260. {
  4261. return Ok(JsonView(false, "程序错误!"));
  4262. throw;
  4263. }
  4264. }
  4265. /// <summary>
  4266. /// 导出邀请函
  4267. /// </summary>
  4268. /// <param name="dto"></param>
  4269. /// <returns></returns>
  4270. [HttpPost]
  4271. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4272. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4273. {
  4274. #region 参数验证
  4275. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4276. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4277. #endregion
  4278. try
  4279. {
  4280. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4281. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4282. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4283. From Grp_TourClientList tcl
  4284. Left Join
  4285. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4286. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4287. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4288. From Crm_DeleClient dc
  4289. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4290. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4291. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4292. Where dc.IsDel = 0) temp
  4293. On temp.DcId =tcl.ClientId
  4294. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4295. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4296. List<string> texts = new List<string>();
  4297. if (datas.Count != 0)
  4298. {
  4299. foreach (TourClientListDetailsView item in datas)
  4300. {
  4301. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4302. {
  4303. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4304. }
  4305. else
  4306. {
  4307. string name = item.LastName + item.FirstName;
  4308. texts.Add(name);
  4309. }
  4310. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4311. {
  4312. if (!transDic.ContainsKey(item.Job))
  4313. {
  4314. texts.Add(item.Job);
  4315. }
  4316. }
  4317. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4318. {
  4319. texts.Add(item.CompanyFullName);
  4320. }
  4321. }
  4322. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4323. if (transData.Count > 0)
  4324. {
  4325. foreach (TranslateResult item in transData)
  4326. {
  4327. if (!transDic.ContainsKey(item.Query))
  4328. {
  4329. transDic.Add(item.Query, item.Translation);
  4330. }
  4331. }
  4332. }
  4333. List<GuestList> list = new List<GuestList>();
  4334. foreach (TourClientListDetailsView dele in datas)
  4335. {
  4336. GuestList guestList = new GuestList();
  4337. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4338. {
  4339. guestList.Name = dele.Pinyin;
  4340. }
  4341. else
  4342. {
  4343. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4344. guestList.Name = Name;
  4345. }
  4346. if (dele.Sex == 0)
  4347. {
  4348. guestList.Sex = "Male";
  4349. }
  4350. else if (dele.Sex == 1)
  4351. {
  4352. guestList.Sex = "Female";
  4353. }
  4354. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4355. if (!string.IsNullOrEmpty(dele.Job))
  4356. {
  4357. guestList.Job = dele.Job;
  4358. }
  4359. list.Add(guestList);
  4360. }
  4361. //载入模板
  4362. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4363. DocumentBuilder builder = new DocumentBuilder(doc);
  4364. //获取word里所有表格
  4365. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4366. //获取所填表格的序数
  4367. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4368. var rowStart = tableOne.Rows[0]; //获取第1行
  4369. //循环赋值
  4370. for (int i = 0; i < list.Count; i++)
  4371. {
  4372. builder.MoveToCell(0, i + 1, 0, 0);
  4373. builder.Write(list[i].Name.ToString());
  4374. builder.MoveToCell(0, i + 1, 1, 0);
  4375. builder.Write(list[i].Sex.ToString());
  4376. builder.MoveToCell(0, i + 1, 2, 0);
  4377. builder.Write(list[i].DOB.ToString());
  4378. builder.MoveToCell(0, i + 1, 3, 0);
  4379. builder.Write(list[i].Job.ToString());
  4380. }
  4381. //删除多余行
  4382. while (tableOne.Rows.Count > list.Count + 1)
  4383. {
  4384. tableOne.Rows.RemoveAt(list.Count + 1);
  4385. }
  4386. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4387. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4388. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4389. doc.Save(filePath);
  4390. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4391. return Ok(JsonView(true, "操作成功!", Url));
  4392. }
  4393. else
  4394. {
  4395. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4396. }
  4397. }
  4398. catch (Exception ex)
  4399. {
  4400. return Ok(JsonView(false, ex.Message));
  4401. throw;
  4402. }
  4403. }
  4404. #endregion
  4405. #region 团组经理模块 出入境费用
  4406. /// <summary>
  4407. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4408. /// </summary>
  4409. /// <returns></returns>
  4410. [HttpPost]
  4411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4412. public async Task<IActionResult> SetDayAndCostAreaChange()
  4413. {
  4414. try
  4415. {
  4416. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4417. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4418. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4419. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4420. foreach (var item in unite) //处理交集数据
  4421. {
  4422. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4423. }
  4424. foreach (var item in merge) //处理差集数据
  4425. {
  4426. int nationalTravelFeeId = 0;
  4427. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4428. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4429. else
  4430. {
  4431. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4432. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4433. }
  4434. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4435. }
  4436. //只更新dayAndCost 的 nationalTravelFeeId;
  4437. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4438. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4439. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4440. }
  4441. catch (Exception ex)
  4442. {
  4443. return Ok(JsonView(false, ex.Message));
  4444. throw;
  4445. }
  4446. }
  4447. /// <summary>
  4448. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4449. /// </summary>
  4450. /// <returns></returns>
  4451. [HttpPost]
  4452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4453. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4454. {
  4455. try
  4456. {
  4457. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  4458. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4459. //SetDataInfoView
  4460. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4461. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4462. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4463. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4464. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4465. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4466. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4467. //默认币种显示
  4468. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4469. {
  4470. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4471. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4472. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4473. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4474. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4475. };
  4476. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4477. if (_currencyRate.Count > 0)
  4478. {
  4479. foreach (var item in _currencyInfos)
  4480. {
  4481. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4482. if (rateInfo != null)
  4483. {
  4484. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4485. rate1 *= 1.035M;
  4486. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4487. }
  4488. }
  4489. }
  4490. return Ok(JsonView(true, "查询成功!", new
  4491. {
  4492. GroupNameData = groupNameData.Data,
  4493. CurrencyData = _CurrencyData,
  4494. WordTypeData = _WordTypeData,
  4495. ExcelTypeData = _ExcelTypeData,
  4496. CurrencyInit = _currencyInfos
  4497. }));
  4498. }
  4499. catch (Exception ex)
  4500. {
  4501. return Ok(JsonView(false, ex.Message));
  4502. throw;
  4503. }
  4504. }
  4505. /// <summary>
  4506. /// 团组模块 - 出入境费用
  4507. /// 实时汇率 tips
  4508. /// 签证费用 tips
  4509. /// 机票费用 tips
  4510. /// </summary>
  4511. /// <returns></returns>
  4512. [HttpPost]
  4513. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4514. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4515. {
  4516. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4517. //默认币种显示
  4518. var _currencyInfos = _currencyInit;
  4519. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4520. List<dynamic> reteInfos = new List<dynamic>();
  4521. if (_currencyRate.Count > 0)
  4522. {
  4523. foreach (var item in _currencyInfos)
  4524. {
  4525. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4526. if (rateInfo != null)
  4527. {
  4528. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4529. decimal rate1 = item.Rate;
  4530. rate1 *= 1.03M;
  4531. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4532. reteInfos.Add(new
  4533. {
  4534. currCode = item.CurrencyCode,
  4535. currName = item.CurrencyName,
  4536. rate = rate2,
  4537. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4538. });
  4539. }
  4540. }
  4541. }
  4542. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4543. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4544. return Ok(JsonView(true, "查询成功!", new
  4545. {
  4546. //GroupNameData = groupNameData.Data,
  4547. visaData = visaData.Data,
  4548. airData = airData.Data,
  4549. reteInfos = reteInfos
  4550. }));
  4551. }
  4552. /// <summary>
  4553. /// 团组模块 - 出入境费用 - Info
  4554. /// </summary>
  4555. /// <returns></returns>
  4556. [HttpPost]
  4557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4558. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4559. {
  4560. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4561. }
  4562. /// <summary>
  4563. /// 团组模块 - 出入境费用 - Add And Update
  4564. /// </summary>
  4565. /// <returns></returns>
  4566. [HttpPost]
  4567. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4568. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4569. {
  4570. try
  4571. {
  4572. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4573. if (dto.DayOtherPriceData.Any())
  4574. {
  4575. var inserList = dto.DayOtherPriceData
  4576. .Where(x => x.Id == 0)
  4577. .Select(x => new Grp_DayOtherPrice
  4578. {
  4579. Cost = x.Cost,
  4580. Id = x.Id,
  4581. CreateTime = DateTime.Now,
  4582. CreateUserId = dto.UserId,
  4583. Currency = x.Currency,
  4584. Diid = x.DiId,
  4585. Index = x.Index,
  4586. IsDel = 0,
  4587. SetDataId = x.SetDataId,
  4588. SubTotal = x.SubTotal,
  4589. Remark = x.Remark
  4590. })
  4591. .ToList();
  4592. var updateList = dto.DayOtherPriceData
  4593. .Where(x => x.Id != 0)
  4594. .Select(x => new Grp_DayOtherPrice
  4595. {
  4596. Cost = x.Cost,
  4597. Id = x.Id,
  4598. CreateTime = DateTime.Now,
  4599. CreateUserId = dto.UserId,
  4600. Currency = x.Currency,
  4601. Diid = x.DiId,
  4602. Index = x.Index,
  4603. IsDel = 0,
  4604. SetDataId = x.SetDataId,
  4605. SubTotal = x.SubTotal,
  4606. Remark = x.Remark
  4607. })
  4608. .ToList();
  4609. //添加
  4610. _sqlSugar.BeginTran();
  4611. if (inserList.Any())
  4612. {
  4613. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4614. }
  4615. if (updateList.Any())
  4616. {
  4617. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4618. }
  4619. _sqlSugar.CommitTran();
  4620. }
  4621. if (data.Code != 0)
  4622. {
  4623. return Ok(JsonView(false, data.Msg));
  4624. }
  4625. //生成默认文件pdf并且通知人员
  4626. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4627. {
  4628. DiId = dto.DiId,
  4629. ExportType = 1,
  4630. SubTypeId = 1005
  4631. }, "pdf");
  4632. //发送通知
  4633. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4634. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4635. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4636. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4637. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4638. //汇率信息记录
  4639. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4640. return Ok(JsonView(true, data.Msg, data.Data));
  4641. }
  4642. catch (Exception ex)
  4643. {
  4644. return Ok(JsonView(false, ex.Message));
  4645. }
  4646. }
  4647. /// <summary>
  4648. /// 团组模块 - 出入境费用 - Confirm 费用
  4649. /// </summary>
  4650. /// <returns></returns>
  4651. [HttpPost]
  4652. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4653. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4654. {
  4655. //TODO:测试完毕需把对应的用户ID更改
  4656. //1、数据表添加字段
  4657. //2、更改字段接口()
  4658. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4659. //3、确认成功 给财务发送消息
  4660. if (_view.Code == 200)
  4661. {
  4662. if (dto.Type == 1)
  4663. {
  4664. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4665. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4666. }
  4667. }
  4668. return Ok(_view);
  4669. }
  4670. /// <summary>
  4671. /// 团组模块 - 出入境费用 - File downlaod
  4672. /// </summary>
  4673. /// <param name="dto"></param>
  4674. /// <returns></returns>
  4675. [HttpPost]
  4676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4677. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4678. {
  4679. try
  4680. {
  4681. if (dto.DiId < 1)
  4682. {
  4683. return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4684. }
  4685. if (dto.ExportType < 1)
  4686. {
  4687. return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4688. }
  4689. if (dto.SubTypeId < 1)
  4690. {
  4691. return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4692. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4693. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4694. 3 团组成员名单 1 团组成员名单", ""));
  4695. }
  4696. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4697. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4698. if (_EnterExitCosts == null)
  4699. {
  4700. return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4701. }
  4702. //数据源
  4703. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4704. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4705. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4706. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4707. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4708. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4709. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  4710. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4711. .Select((x, a, b) => new
  4712. {
  4713. x.Index,
  4714. itemName = a.Name,
  4715. CurrencyStr = b.Name,
  4716. x.Cost,
  4717. x.SubTotal,
  4718. x.Remark
  4719. })
  4720. .OrderBy((x) => x.Index)
  4721. .ToList(); //其他款项费用
  4722. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4723. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4724. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4725. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4726. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4727. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4728. .Select((tcl, dc, cc) => new ClientInfo
  4729. {
  4730. LastName = dc.LastName,
  4731. FirstName = dc.FirstName,
  4732. Sex = dc.Sex,
  4733. Birthday = dc.BirthDay,
  4734. Company = cc.CompanyFullName,
  4735. Job = dc.Job
  4736. })
  4737. .ToList();
  4738. foreach (var item in DeleClientList)
  4739. {
  4740. EncryptionProcessor.DecryptProperties(item);
  4741. }
  4742. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4743. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4744. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4745. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4746. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4747. if (dto.ExportType == 1) //明细表
  4748. {
  4749. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4750. {
  4751. //获取模板
  4752. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4753. //载入模板
  4754. Document doc = new Document(tempPath);
  4755. DocumentBuilder builder = new DocumentBuilder(doc);
  4756. //利用键值对存放数据
  4757. Dictionary<string, string> dic = new Dictionary<string, string>();
  4758. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4759. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4760. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4761. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4762. decimal otherPriceTotal = dac5.Sum(x => x.SubTotal); //其他费用
  4763. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4764. //境内费用(其他费用)
  4765. if (_EnterExitCosts.ChoiceOne == 1)
  4766. {
  4767. string row1_1 = "";
  4768. if (_EnterExitCosts.Visa > 0)
  4769. {
  4770. //insidePayTotal += _EnterExitCosts.Visa;
  4771. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4772. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4773. {
  4774. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4775. }
  4776. }
  4777. string row1_2 = "";
  4778. if (_EnterExitCosts.YiMiao > 0)
  4779. {
  4780. //insidePayTotal += _EnterExitCosts.YiMiao;
  4781. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4782. }
  4783. if (_EnterExitCosts.HeSuan > 0)
  4784. {
  4785. //insidePayTotal += _EnterExitCosts.HeSuan;
  4786. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4787. }
  4788. if (_EnterExitCosts.Service > 0)
  4789. {
  4790. //insidePayTotal += _EnterExitCosts.Service;
  4791. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4792. }
  4793. string row1_3 = "";
  4794. if (_EnterExitCosts.Safe > 0)
  4795. {
  4796. //insidePayTotal += _EnterExitCosts.Safe;
  4797. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4798. }
  4799. if (_EnterExitCosts.Ticket > 0)
  4800. {
  4801. //insidePayTotal += _EnterExitCosts.Ticket;
  4802. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4803. }
  4804. string row1 = "";
  4805. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4806. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4807. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4808. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4809. dic.Add("Row1Str", row1);
  4810. }
  4811. string airTotalStr = string.Empty,
  4812. airPriceStr = string.Empty;
  4813. //经济舱
  4814. if (_EnterExitCosts.SumJJC == 1)
  4815. {
  4816. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4817. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4818. }
  4819. //公务舱
  4820. if (_EnterExitCosts.SumGWC == 1)
  4821. {
  4822. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4823. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4824. }
  4825. //头等舱
  4826. if (_EnterExitCosts.SumTDC == 1)
  4827. {
  4828. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4829. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4830. }
  4831. dic.Add("AirTotalStr", airTotalStr);
  4832. dic.Add("AirPriceStr", airPriceStr);
  4833. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4834. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4835. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4836. int table1Row = 0,
  4837. table2Row = 0,
  4838. table3Row = 0,
  4839. table4Row = 0,
  4840. table5Row = 0;
  4841. //住宿费
  4842. if (_EnterExitCosts.ChoiceThree == 1)
  4843. {
  4844. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4845. table1Row = dac1.Count;
  4846. #region 填充word表格内容
  4847. for (int i = 0; i < dac1.Count; i++)
  4848. {
  4849. Grp_DayAndCost dac = dac1[i];
  4850. if (dac == null) continue;
  4851. builder.MoveToCell(0, i, 0, 0);
  4852. builder.Write("第" + dac.Days.ToString() + "晚:");
  4853. builder.MoveToCell(0, i, 1, 0);
  4854. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4855. //builder.Write(dac.Place == null ? "" : dac.Place);
  4856. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4857. builder.MoveToCell(0, i, 2, 0);
  4858. builder.Write("费用标准:");
  4859. string curr = "";
  4860. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4861. if (currData != null)
  4862. {
  4863. curr = currData.Name;
  4864. }
  4865. builder.MoveToCell(0, i, 3, 0);
  4866. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4867. builder.MoveToCell(0, i, 4, 0);
  4868. builder.Write("费用小计:");
  4869. builder.MoveToCell(0, i, 5, 0);
  4870. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4871. }
  4872. #endregion
  4873. }
  4874. else dic.Add("SubZS", "0.00");
  4875. //删除多余行
  4876. while (table1.Rows.Count > table1Row)
  4877. {
  4878. table1.Rows.RemoveAt(table1Row);
  4879. }
  4880. //伙食费
  4881. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4882. if (_EnterExitCosts.ChoiceFour == 1)
  4883. {
  4884. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4885. table2Row = dac2.Count;
  4886. #region 填充word表格内容
  4887. for (int i = 0; i < dac2.Count; i++)
  4888. {
  4889. Grp_DayAndCost dac = dac2[i];
  4890. if (dac == null) continue;
  4891. builder.MoveToCell(1, i, 0, 0);
  4892. builder.Write("第" + dac.Days.ToString() + "天:");
  4893. builder.MoveToCell(1, i, 1, 0);
  4894. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4895. builder.MoveToCell(1, i, 2, 0);
  4896. builder.Write("费用标准:");
  4897. string curr = "";
  4898. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4899. if (currData != null)
  4900. {
  4901. curr = currData.Name;
  4902. }
  4903. builder.MoveToCell(1, i, 3, 0);
  4904. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4905. builder.MoveToCell(1, i, 4, 0);
  4906. builder.Write("费用小计:");
  4907. builder.MoveToCell(1, i, 5, 0);
  4908. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4909. }
  4910. #endregion
  4911. }
  4912. else dic.Add("SubHS", "0.00");
  4913. //删除多余行
  4914. while (table2.Rows.Count > table2Row)
  4915. {
  4916. table2.Rows.RemoveAt(table2Row);
  4917. }
  4918. //公杂费
  4919. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4920. if (_EnterExitCosts.ChoiceFive == 1)
  4921. {
  4922. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4923. table3Row = dac3.Count;
  4924. #region 填充word表格内容
  4925. for (int i = 0; i < dac3.Count; i++)
  4926. {
  4927. Grp_DayAndCost dac = dac3[i];
  4928. if (dac == null) continue;
  4929. builder.MoveToCell(2, i, 0, 0);
  4930. builder.Write("第" + dac.Days.ToString() + "天:");
  4931. builder.MoveToCell(2, i, 1, 0);
  4932. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4933. builder.MoveToCell(2, i, 2, 0);
  4934. builder.Write("费用标准:");
  4935. string curr = "";
  4936. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4937. if (currData != null)
  4938. {
  4939. curr = currData.Name;
  4940. }
  4941. builder.MoveToCell(2, i, 3, 0);
  4942. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4943. builder.MoveToCell(2, i, 4, 0);
  4944. builder.Write("费用小计:");
  4945. builder.MoveToCell(2, i, 5, 0);
  4946. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4947. }
  4948. //删除多余行
  4949. while (table3.Rows.Count > table3Row)
  4950. {
  4951. table3.Rows.RemoveAt(table3Row);
  4952. }
  4953. #endregion
  4954. }
  4955. else dic.Add("SubGZF", "0.00");
  4956. //删除多余行
  4957. while (table3.Rows.Count > table3Row)
  4958. {
  4959. table3.Rows.RemoveAt(table3Row);
  4960. }
  4961. //培训费
  4962. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4963. if (_EnterExitCosts.ChoiceSix == 1)
  4964. {
  4965. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4966. dic.Add("SubPX", pxStr);
  4967. table4Row = dac4.Count;
  4968. #region 填充word表格内容
  4969. for (int i = 0; i < dac4.Count; i++)
  4970. {
  4971. Grp_DayAndCost dac = dac4[i];
  4972. if (dac == null) continue;
  4973. builder.MoveToCell(3, i, 0, 0);
  4974. builder.Write("第" + dac.Days.ToString() + "天:");
  4975. builder.MoveToCell(3, i, 1, 0);
  4976. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4977. builder.MoveToCell(3, i, 2, 0);
  4978. builder.Write("费用标准:");
  4979. string curr = "";
  4980. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4981. if (currData != null)
  4982. {
  4983. curr = currData.Name;
  4984. }
  4985. builder.MoveToCell(3, i, 3, 0);
  4986. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4987. builder.MoveToCell(3, i, 4, 0);
  4988. builder.Write("费用小计:");
  4989. builder.MoveToCell(3, i, 5, 0);
  4990. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4991. }
  4992. #endregion
  4993. }
  4994. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  4995. //删除多余行
  4996. while (table4.Rows.Count > table4Row)
  4997. {
  4998. table4.Rows.RemoveAt(table4Row);
  4999. }
  5000. //其他费用
  5001. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5002. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5003. {
  5004. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5005. dic.Add("titleQi", qtStr);
  5006. table5Row = dac5.Count;
  5007. #region 填充word表格内容
  5008. for (int i = 0; i < dac5.Count; i++)
  5009. {
  5010. var dac = dac5[i];
  5011. if (dac == null) continue;
  5012. builder.MoveToCell(4, i, 0, 0);
  5013. builder.Write("第" + dac.Index.ToString() + "项:");
  5014. builder.MoveToCell(4, i, 1, 0);
  5015. builder.Write(dac.itemName);
  5016. builder.MoveToCell(4, i, 2, 0);
  5017. builder.Write("费用标准:");
  5018. builder.MoveToCell(4, i, 3, 0);
  5019. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5020. builder.MoveToCell(4, i, 4, 0);
  5021. builder.Write("费用小计:");
  5022. builder.MoveToCell(4, i, 5, 0);
  5023. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5024. builder.MoveToCell(4, i, 6, 0);
  5025. builder.Write("备注:");
  5026. builder.MoveToCell(4, i, 7, 0);
  5027. builder.Write(dac.Remark);
  5028. }
  5029. #endregion
  5030. }
  5031. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5032. //删除多余行
  5033. while (table5.Rows.Count > table5Row)
  5034. {
  5035. table5.Rows.RemoveAt(table5Row);
  5036. }
  5037. //加上其他费用
  5038. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5039. decimal subJJC = 0.00M,
  5040. subGWC = 0.00M,
  5041. subTDC = 0.00M;
  5042. //经济舱
  5043. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5044. //公务舱
  5045. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5046. //头等舱
  5047. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5048. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5049. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5050. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5051. #region 填充word模板书签内容
  5052. foreach (var key in dic.Keys)
  5053. {
  5054. Bookmark bookmark = doc.Range.Bookmarks[key];
  5055. if (bookmark != null)
  5056. {
  5057. builder.MoveToBookmark(key);
  5058. builder.Write(dic[key]);
  5059. }
  5060. }
  5061. #endregion
  5062. //文件名
  5063. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5064. AsposeHelper.removewatermark_v2180();
  5065. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5066. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5067. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5068. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5069. }
  5070. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5071. {
  5072. //获取模板
  5073. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5074. //载入模板
  5075. Document doc = new Document(tempPath);
  5076. DocumentBuilder builder = new DocumentBuilder(doc);
  5077. Dictionary<string, string> dic = new Dictionary<string, string>();
  5078. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5079. {
  5080. List<string> list = new List<string>();
  5081. try
  5082. {
  5083. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5084. foreach (var item in spilitArr)
  5085. {
  5086. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5087. var depCode = spDotandEmpty[2].Substring(0, 3);
  5088. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5089. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5090. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5091. list.Add(depName);
  5092. list.Add(arrName);
  5093. }
  5094. list = list.Distinct().ToList();
  5095. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5096. }
  5097. catch (Exception)
  5098. {
  5099. dic.Add("ReturnCode", "行程录入不正确!");
  5100. }
  5101. }
  5102. else
  5103. {
  5104. dic.Add("ReturnCode", "未录入行程!");
  5105. }
  5106. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5107. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5108. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5109. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5110. {
  5111. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5112. dic.Add("Day", sp.Days.ToString());
  5113. }
  5114. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5115. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5116. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5117. //dic.Add("Names", Names);
  5118. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5119. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5120. decimal dac1totalPrice = 0.00M;
  5121. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5122. foreach (var dac in dac1)
  5123. {
  5124. if (dac.SubTotal == 0.00M)
  5125. {
  5126. continue;
  5127. }
  5128. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5129. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5130. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5131. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5132. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5133. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5134. builder.Write(currency);//币种
  5135. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5136. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5137. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5138. builder.Write("");//人数
  5139. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5140. builder.Write("");//天数
  5141. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5142. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5143. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5144. decimal rate = 0.00M;
  5145. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5146. builder.Write(rate.ToString("#0.0000"));//汇率
  5147. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5148. decimal rbmPrice = dac.SubTotal;
  5149. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5150. accommodationStartIndex++;
  5151. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5152. }
  5153. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5154. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5155. {
  5156. table1.Rows.RemoveAt(i - 1);
  5157. foodandotherStartIndex--;
  5158. }
  5159. if (dac2.Count == dac3.Count)//国家 币种 金额
  5160. {
  5161. for (int i = 0; i < dac2.Count; i++)
  5162. {
  5163. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5164. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5165. }
  5166. }
  5167. decimal dac2totalPrice = 0.00M;
  5168. foreach (var dac in dac2)
  5169. {
  5170. if (dac.SubTotal == 0)
  5171. {
  5172. continue;
  5173. }
  5174. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5175. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5176. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5177. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5178. builder.Write(currency);//币种
  5179. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5180. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5181. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5182. builder.Write("");//人数
  5183. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5184. builder.Write("");//天数
  5185. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5186. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5187. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5188. decimal rate = 0.00M;
  5189. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5190. builder.Write(rate.ToString("#0.0000"));//汇率
  5191. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5192. decimal rbmPrice = dac.SubTotal;
  5193. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5194. foodandotherStartIndex++;
  5195. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5196. }
  5197. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5198. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5199. {
  5200. table1.Rows.RemoveAt(i - 1);
  5201. }
  5202. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5203. string otherFeeStr = "";
  5204. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5205. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5206. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5207. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5208. foreach (var otherInfo in dac5)
  5209. {
  5210. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5211. }
  5212. #endregion
  5213. if (otherFeeStr.Length > 0)
  5214. {
  5215. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5216. otherFeeStr = $"({otherFeeStr})";
  5217. dic.Add("OtherFeeStr", otherFeeStr);
  5218. }
  5219. //总计
  5220. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5221. //国际旅费
  5222. string outsideAir = string.Empty;
  5223. string allPriceAir = string.Empty;
  5224. if (_EnterExitCosts.SumJJC == 1)
  5225. {
  5226. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5227. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5228. }
  5229. if (_EnterExitCosts.SumGWC == 1)
  5230. {
  5231. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5232. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5233. }
  5234. if (_EnterExitCosts.SumTDC == 1)
  5235. {
  5236. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5237. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5238. }
  5239. dic.Add("InTravelPrice", $"({outsideAir})");
  5240. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5241. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5242. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5243. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5244. foreach (var key in dic.Keys)
  5245. {
  5246. builder.MoveToBookmark(key);
  5247. builder.Write(dic[key]);
  5248. }
  5249. //模板文件名
  5250. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5251. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5252. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5253. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5254. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5255. }
  5256. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5257. {
  5258. //获取模板
  5259. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5260. //载入模板
  5261. WorkbookDesigner designer = new WorkbookDesigner();
  5262. designer.Workbook = new Workbook(tempPath);
  5263. Dictionary<string, string> dic = new Dictionary<string, string>();
  5264. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5265. {
  5266. List<string> list = new List<string>();
  5267. try
  5268. {
  5269. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5270. foreach (var item in spilitArr)
  5271. {
  5272. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5273. var depCode = spDotandEmpty[2].Substring(0, 3);
  5274. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5275. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5276. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5277. list.Add(depName);
  5278. list.Add(arrName);
  5279. }
  5280. list = list.Distinct().ToList();
  5281. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5282. }
  5283. catch (Exception)
  5284. {
  5285. dic.Add("ReturnCode", "行程录入不正确!");
  5286. }
  5287. }
  5288. else
  5289. {
  5290. dic.Add("ReturnCode", "未录入行程!");
  5291. }
  5292. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5293. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5294. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5295. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5296. {
  5297. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5298. dic.Add("Day", sp.Days.ToString());
  5299. }
  5300. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5301. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5302. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5303. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5304. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5305. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5306. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5307. designer.SetDataSource("Name", Names);
  5308. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5309. designer.SetDataSource("Day", dic["Day"] + "天");
  5310. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5311. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5312. int startIndex = 10;
  5313. const int startIndexcopy = 10;
  5314. if (dac2.Count == dac3.Count)//国家 币种 金额
  5315. {
  5316. for (int i = 0; i < dac2.Count; i++)
  5317. {
  5318. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5319. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5320. }
  5321. }
  5322. DataTable dtdac1 = new DataTable();
  5323. List<string> place = new List<string>();
  5324. dtdac1.Columns.AddRange(new DataColumn[] {
  5325. new DataColumn(){ ColumnName = "city"},
  5326. new DataColumn(){ ColumnName = "curr"},
  5327. new DataColumn(){ ColumnName = "criterion"},
  5328. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5329. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5330. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5331. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5332. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5333. });
  5334. DataTable dtdac2 = new DataTable();
  5335. dtdac2.Columns.AddRange(new DataColumn[] {
  5336. new DataColumn(){ ColumnName = "city"},
  5337. new DataColumn(){ ColumnName = "curr"},
  5338. new DataColumn(){ ColumnName = "criterion"},
  5339. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5340. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5341. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5342. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5343. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5344. });
  5345. dtdac1.TableName = "tb1";
  5346. dtdac2.TableName = "tb2";
  5347. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5348. foreach (var item in dac1)
  5349. {
  5350. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5351. if (place.Contains(item.Place))
  5352. {
  5353. continue;
  5354. }
  5355. DataRow row = dtdac1.NewRow();
  5356. row["city"] = item.Place;
  5357. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5358. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5359. row["curr"] = currency;
  5360. row["rate"] = rate.ToString("#0.0000");
  5361. row["criterion"] = item.Cost.ToString("#0.00");
  5362. row["number"] = 1;
  5363. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5364. //row["costRMB"] = rbmPrice;
  5365. dtdac1.Rows.Add(row);
  5366. place.Add(item.Place);
  5367. }
  5368. place = new List<string>();
  5369. foreach (var item in dac2)
  5370. {
  5371. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5372. if (place.Contains(item.Place))
  5373. {
  5374. continue;
  5375. }
  5376. DataRow row = dtdac2.NewRow();
  5377. row["city"] = item.Place;
  5378. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5379. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5380. row["curr"] = currency;
  5381. row["rate"] = rate.ToString("#0.0000");
  5382. row["criterion"] = item.Cost.ToString("#0.00");
  5383. row["number"] = 1;
  5384. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5385. //row["cost"] = item.SubTotal;
  5386. //row["costRMB"] = rbmPrice;
  5387. dtdac2.Rows.Add(row);
  5388. place.Add(item.Place);
  5389. //dac2totalPrice += rbmPrice;
  5390. }
  5391. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5392. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5393. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5394. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5395. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5396. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5397. string cell4Str1 = string.Empty;
  5398. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5399. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5400. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5401. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5402. string cellStr = $" 5.其他费用(";
  5403. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5404. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5405. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5406. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5407. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5408. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5409. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5410. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5411. foreach (var otherInfo in dac5)
  5412. {
  5413. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5414. }
  5415. #endregion
  5416. if (cellStr.Length > 8)
  5417. {
  5418. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5419. }
  5420. cellStr += ")";
  5421. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5422. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5423. decimal pxFee = dac4.Sum(it => it.Cost);
  5424. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5425. string celllastStr1 = "";
  5426. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5427. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5428. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5429. celllastStr1 += $",国际旅费 元";
  5430. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5431. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5432. designer.SetDataSource("cell4Str", cell4Str);
  5433. designer.SetDataSource("cellStr", cellStr);
  5434. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5435. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5436. designer.SetDataSource("celllastStr", celllastStr);
  5437. Workbook wb = designer.Workbook;
  5438. var sheet = wb.Worksheets[0];
  5439. //绑定datatable数据集
  5440. designer.SetDataSource(dtdac1);
  5441. designer.SetDataSource(dtdac2);
  5442. designer.Process();
  5443. var rowStart = dtdac1.Rows.Count;
  5444. while (rowStart > 0)
  5445. {
  5446. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5447. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5448. startIndex++;
  5449. rowStart--;
  5450. }
  5451. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5452. startIndex += 1; //总计行
  5453. rowStart = dtdac2.Rows.Count;
  5454. while (rowStart > 0)
  5455. {
  5456. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5457. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5458. startIndex++;
  5459. rowStart--;
  5460. }
  5461. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5462. wb.CalculateFormula(true);
  5463. //模板文件名
  5464. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5465. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5466. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5467. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5468. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5469. }
  5470. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5471. {
  5472. //获取模板
  5473. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5474. //载入模板
  5475. Document doc = new Document(tempPath);
  5476. DocumentBuilder builder = new DocumentBuilder(doc);
  5477. Dictionary<string, string> dic = new Dictionary<string, string>();
  5478. dic.Add("GroupName", _DelegationInfo.TeamName);
  5479. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5480. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5481. string missionLeaderJob = "";//负责人job
  5482. int groupNumber = 0; //团人数
  5483. if (DeleClientList.Count > 0)
  5484. {
  5485. missionLeader = DeleClientList[0]?.Name ?? "";
  5486. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5487. }
  5488. dic.Add("MissionLeader", missionLeader); //团负责人
  5489. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5490. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5491. #region MyRegion
  5492. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5493. //{
  5494. // List<string> list = new List<string>();
  5495. // try
  5496. // {
  5497. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5498. // foreach (var item in spilitArr)
  5499. // {
  5500. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5501. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5502. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5503. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5504. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5505. // list.Add(depName);
  5506. // list.Add(arrName);
  5507. // }
  5508. // list = list.Distinct().ToList();
  5509. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5510. // }
  5511. // catch (Exception)
  5512. // {
  5513. // dic.Add("ReturnCode", "行程录入不正确!");
  5514. // }
  5515. //}
  5516. //else
  5517. //{
  5518. // dic.Add("ReturnCode", "未录入行程!");
  5519. //}
  5520. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5521. dic.Add("ReturnCode", string.Join("、", countrys));
  5522. #endregion
  5523. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5524. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5525. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5526. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5527. //{
  5528. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5529. // dic.Add("Day", sp.Days.ToString());
  5530. //}
  5531. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5532. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5533. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5534. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5535. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5536. //培训人员名单
  5537. int cultivateRowIndex = 7;
  5538. foreach (var item in DeleClientList)
  5539. {
  5540. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5541. builder.Write(item.Name);
  5542. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5543. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5544. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5545. string birthDay = "";
  5546. if (item.Birthday != null)
  5547. {
  5548. DateTime dt = Convert.ToDateTime(item.Birthday);
  5549. birthDay = $"{dt.Year}.{dt.Month}";
  5550. }
  5551. builder.Write(birthDay);
  5552. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5553. builder.Write(item.Company);
  5554. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5555. builder.Write(item.Job);
  5556. cultivateRowIndex++;
  5557. }
  5558. //删除多余行
  5559. //cultivateRowIndex -= 2;
  5560. int delRows = 10 + 7 - cultivateRowIndex;
  5561. if (delRows > 0)
  5562. {
  5563. for (int i = 0; i < delRows; i++)
  5564. {
  5565. table1.Rows.RemoveAt(cultivateRowIndex);
  5566. //cultivateRowIndex++;
  5567. }
  5568. }
  5569. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5570. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5571. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5572. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5573. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5574. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5575. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5576. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5577. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5578. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5579. //其他费用
  5580. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5581. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5582. //其他费用合计
  5583. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5584. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5585. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5586. //公务舱合计
  5587. //国际旅费
  5588. string outsideJJ = "";
  5589. string allPriceJJ = "";
  5590. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5591. {
  5592. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5593. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5594. }
  5595. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5596. {
  5597. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5598. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5599. }
  5600. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5601. {
  5602. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5603. dic.Add("AirFeeTotal", airFeeTotalStr);
  5604. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5605. dic.Add("FeeTotal", feeTotalStr);
  5606. }
  5607. foreach (var key in dic.Keys)
  5608. {
  5609. builder.MoveToBookmark(key);
  5610. builder.Write(dic[key]);
  5611. }
  5612. //模板文件名
  5613. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5614. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5615. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5616. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5617. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5618. }
  5619. }
  5620. else if (dto.ExportType == 2) //表格
  5621. {
  5622. //利用键值对存放数据
  5623. Dictionary<string, string> dic = new Dictionary<string, string>();
  5624. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5625. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5626. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5627. dic.Add("Day", sp.Days.ToString());
  5628. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5629. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5630. {
  5631. //获取模板
  5632. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5633. //载入模板
  5634. Document doc = new Document(tempPath);
  5635. DocumentBuilder builder = new DocumentBuilder(doc);
  5636. dic.Add("TeamName", _DelegationInfo.TeamName);
  5637. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5638. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5639. string missionLeaderName = "",
  5640. missionLeaderJob = "";
  5641. if (DeleClientList.Count > 0)
  5642. {
  5643. missionLeaderName = DeleClientList[0].Name;
  5644. missionLeaderJob = DeleClientList[0].Job;
  5645. }
  5646. dic.Add("MissionLeaderName", missionLeaderName);
  5647. dic.Add("MissionLeaderJob", missionLeaderJob);
  5648. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5649. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5650. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5651. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5652. int rowCount = 10;//总人数行
  5653. int startRowIndex = 7; //起始行
  5654. for (int i = 0; i < DeleClientList.Count; i++)
  5655. {
  5656. builder.MoveToCell(0, startRowIndex, 0, 0);
  5657. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5658. builder.MoveToCell(0, startRowIndex, 1, 0);
  5659. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5660. builder.Write(sex);//性别
  5661. builder.MoveToCell(0, startRowIndex, 2, 0);
  5662. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5663. builder.MoveToCell(0, startRowIndex, 3, 0);
  5664. builder.Write(DeleClientList[i].Company);//工作单位
  5665. builder.MoveToCell(0, startRowIndex, 4, 0);
  5666. builder.Write(DeleClientList[i].Job);//职务及级别
  5667. builder.MoveToCell(0, startRowIndex, 5, 0);
  5668. builder.Write("");//人员属性
  5669. builder.MoveToCell(0, startRowIndex, 6, 0);
  5670. builder.Write("");//上次出国时间
  5671. startRowIndex++;
  5672. }
  5673. int nullRow = rowCount - DeleClientList.Count;//空行
  5674. for (int i = 0; i < nullRow; i++)
  5675. {
  5676. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5677. }
  5678. foreach (var key in dic.Keys)
  5679. {
  5680. builder.MoveToBookmark(key);
  5681. builder.Write(dic[key]);
  5682. }
  5683. //模板文件名
  5684. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5685. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5686. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5687. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5688. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5689. }
  5690. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5691. {
  5692. //获取模板
  5693. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5694. //载入模板
  5695. Document doc = new Document(tempPath);
  5696. DocumentBuilder builder = new DocumentBuilder(doc);
  5697. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  5698. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  5699. dic.Add("Names", Names);
  5700. int accommodationRows = 12, foodandotherRows = 12;
  5701. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5702. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  5703. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5704. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5705. int accommodationStartIndex = 6;
  5706. decimal dac1totalPrice = 0.00M;
  5707. foreach (var dac in dac1)
  5708. {
  5709. if (dac.SubTotal == 0)
  5710. {
  5711. continue;
  5712. }
  5713. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5714. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5715. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5716. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5717. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5718. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5719. builder.Write(currency);//币种
  5720. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5721. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5722. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5723. builder.Write("");//人数
  5724. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5725. builder.Write("");//天数
  5726. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5727. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5728. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5729. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5730. builder.Write(rate.ToString("#0.0000"));//汇率
  5731. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5732. decimal rbmPrice = rate * dac.SubTotal;
  5733. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5734. accommodationStartIndex++;
  5735. dac1totalPrice += rbmPrice;
  5736. }
  5737. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5738. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5739. builder.Write("小计");
  5740. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5741. builder.Write(dac1totalPrice.ToString("#0.00"));
  5742. accommodationStartIndex++;
  5743. int nullRow = accommodationRows - dac1.Count;
  5744. //删除空行
  5745. //if (nullRow > 0)
  5746. //{
  5747. // int rowIndex = accommodationStartIndex;
  5748. // for (int i = 0; i < nullRow; i++)
  5749. // {
  5750. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5751. // row.Remove();
  5752. // rowIndex++;
  5753. // }
  5754. //}
  5755. if (dac2.Count == dac3.Count)//国家 币种 金额
  5756. {
  5757. for (int i = 0; i < dac2.Count; i++)
  5758. {
  5759. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5760. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5761. }
  5762. }
  5763. int foodandotherStartIndex = 19;//
  5764. decimal dac2totalPrice = 0.00M;
  5765. foreach (var dac in dac2)
  5766. {
  5767. if (dac.SubTotal == 0)
  5768. {
  5769. continue;
  5770. }
  5771. //foodandotherStartIndex = 12;
  5772. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5773. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5774. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5775. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5776. builder.Write(currency);//币种
  5777. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5778. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5779. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5780. builder.Write("");//人数
  5781. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5782. builder.Write("");//天数
  5783. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5784. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5785. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5786. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5787. builder.Write(rate.ToString("#0.0000"));//汇率
  5788. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5789. decimal rbmPrice = rate * dac.SubTotal;
  5790. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5791. foodandotherStartIndex++;
  5792. dac2totalPrice += rbmPrice;
  5793. }
  5794. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5795. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5796. //删除空行
  5797. //if (dac2.Count < foodandotherRows)
  5798. //{
  5799. // while (table2.Rows.Count > dac2.Count)
  5800. // {
  5801. // table2.Rows.RemoveAt(dac2.Count);
  5802. // }
  5803. //}
  5804. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5805. string otherFeeStr = "";
  5806. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5807. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5808. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5809. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5810. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5811. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5812. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5813. foreach (var otherInfo in dac5)
  5814. {
  5815. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5816. }
  5817. #endregion
  5818. if (otherFeeStr.Length > 0)
  5819. {
  5820. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5821. otherFeeStr = $"({otherFeeStr})";
  5822. dic.Add("OtherFeeStr", otherFeeStr);
  5823. }
  5824. foreach (var key in dic.Keys)
  5825. {
  5826. builder.MoveToBookmark(key);
  5827. builder.Write(dic[key]);
  5828. }
  5829. //模板文件名
  5830. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5831. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5832. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5833. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5834. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5835. }
  5836. }
  5837. else if (dto.ExportType == 3)
  5838. {
  5839. if (dto.SubTypeId == 1) //团组成员名单
  5840. {
  5841. if (DeleClientList.Count < 1)
  5842. {
  5843. return Ok(JsonView(false, "团组成员暂未录入!!!", ""));
  5844. }
  5845. //获取模板
  5846. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5847. //载入模板
  5848. Document doc = new Document(tempPath);
  5849. DocumentBuilder builder = new DocumentBuilder(doc);
  5850. //获取word里所有表格
  5851. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5852. //获取所填表格的序数
  5853. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5854. var rowStart = tableOne.Rows[0]; //获取第1行
  5855. //循环赋值
  5856. for (int i = 0; i < DeleClientList.Count; i++)
  5857. {
  5858. builder.MoveToCell(0, i + 1, 0, 0);
  5859. builder.Write(DeleClientList[i].Name);
  5860. builder.MoveToCell(0, i + 1, 1, 0);
  5861. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5862. builder.Write(sex);
  5863. builder.MoveToCell(0, i + 1, 2, 0);
  5864. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5865. builder.MoveToCell(0, i + 1, 3, 0);
  5866. builder.Write(DeleClientList[i].Company);
  5867. builder.MoveToCell(0, i + 1, 4, 0);
  5868. builder.Write(DeleClientList[i].Job);
  5869. }
  5870. //删除多余行
  5871. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5872. {
  5873. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5874. }
  5875. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5876. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5877. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5878. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5879. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5880. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5881. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5882. }
  5883. }
  5884. return Ok(JsonView(400, "操作失败!", ""));
  5885. }
  5886. catch (Exception ex)
  5887. {
  5888. return Ok(JsonView(400, ex.Message, ""));
  5889. }
  5890. }
  5891. /// <summary>
  5892. /// 获取三公费用标准city
  5893. /// </summary>
  5894. /// <param name="placeData"></param>
  5895. /// <param name="nationalTravelFeeId"></param>
  5896. /// <returns></returns>
  5897. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5898. {
  5899. string _city = string.Empty;
  5900. if (placeData.Count < 1) return _city;
  5901. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5902. if (data == null) return _city;
  5903. string country = data.Country;
  5904. string city = data.City;
  5905. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5906. else _city = city;
  5907. return _city;
  5908. }
  5909. /// <summary>
  5910. /// 团组模块 - 出入境费用 - 明细表导出
  5911. /// </summary>
  5912. /// <returns></returns>
  5913. [HttpPost]
  5914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5915. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5916. {
  5917. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5918. if (data.Code != 0)
  5919. {
  5920. return Ok(JsonView(false, data.Msg));
  5921. }
  5922. return Ok(JsonView(true, data.Msg, data.Data));
  5923. }
  5924. /// <summary>
  5925. /// 团组模块 - 出入境费用 - 一键清空
  5926. /// </summary>
  5927. /// <returns></returns>
  5928. [HttpPost]
  5929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5930. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5931. {
  5932. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5933. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5934. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5935. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5936. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  5937. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  5938. .SetColumns(x => new Grp_DayOtherPrice
  5939. {
  5940. IsDel = 1,
  5941. DeleteUserId = dto.UserId,
  5942. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5943. })
  5944. .ExecuteCommandAsync();
  5945. if (_view.Code == 0)
  5946. {
  5947. return Ok(JsonView(true, "操作成功"));
  5948. }
  5949. return Ok(JsonView(false, "操作失败"));
  5950. }
  5951. /// <summary>
  5952. /// 团组模块 - 出入境费用 - 子项删除
  5953. /// </summary>
  5954. /// <returns></returns>
  5955. [HttpPost]
  5956. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5957. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5958. {
  5959. try
  5960. {
  5961. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5962. if (data.Code != 0)
  5963. {
  5964. return Ok(JsonView(false, data.Msg));
  5965. }
  5966. return Ok(JsonView(true, "操作成功!", data.Data));
  5967. }
  5968. catch (Exception ex)
  5969. {
  5970. return Ok(JsonView(false, ex.Message));
  5971. }
  5972. }
  5973. /// <summary>
  5974. /// 删除三公其他费用
  5975. /// </summary>
  5976. /// <param name="dto"></param>
  5977. /// <returns></returns>
  5978. [HttpPost]
  5979. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  5980. {
  5981. var jw = JsonView(false,"删除失败!");
  5982. var data = new Grp_DayOtherPrice()
  5983. {
  5984. Id = dto.Id,
  5985. IsDel = 1,
  5986. DeleteUserId = dto.DeleteUserId,
  5987. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  5988. };
  5989. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  5990. if (del > 0)
  5991. {
  5992. jw.Code = 200;
  5993. jw.Msg = "删除成功!";
  5994. }
  5995. return Ok(jw);
  5996. }
  5997. /// <summary>
  5998. /// 团组模块 - 出入境国家费用标准 List
  5999. /// </summary>
  6000. /// <returns></returns>
  6001. [HttpPost]
  6002. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6003. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6004. {
  6005. try
  6006. {
  6007. Stopwatch sw = new Stopwatch();
  6008. sw.Start();
  6009. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6010. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6011. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6012. Where gntf.Isdel = 0");
  6013. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6014. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6015. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6016. //foreach (var item in nationalTravel)
  6017. //{
  6018. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6019. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6020. // if (otherData != null)
  6021. // {
  6022. // cityData.Remove(otherData);
  6023. // cityData.Add(otherData);
  6024. // }
  6025. // nationalTravelFeeData1.Add(new
  6026. // {
  6027. // Country = item.Country,
  6028. // CityData = cityData
  6029. // });
  6030. //}
  6031. sw.Stop();
  6032. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6033. }
  6034. catch (Exception ex)
  6035. {
  6036. return Ok(JsonView(false, ex.Message));
  6037. throw;
  6038. }
  6039. }
  6040. /// <summary>
  6041. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6042. /// </summary>
  6043. /// <returns></returns>
  6044. [HttpPost]
  6045. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6046. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6047. {
  6048. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6049. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6050. List<string> countryData = new List<string>();
  6051. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6052. countryData = countryData.Distinct().ToList();
  6053. List<dynamic> dataSource = new List<dynamic>();
  6054. foreach (var item in countryData)
  6055. {
  6056. List<string> cityData1 = new List<string>();
  6057. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6058. var countryData2 = new
  6059. {
  6060. CountryName = item,
  6061. CityData = cityData1
  6062. };
  6063. dataSource.Add(countryData2);
  6064. }
  6065. return Ok(JsonView(true, "查询成功!", dataSource));
  6066. }
  6067. /// <summary>
  6068. /// 团组模块 - 出入境国家费用标准 Page List
  6069. /// </summary>
  6070. /// <returns></returns>
  6071. [HttpPost]
  6072. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6073. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6074. {
  6075. int portId = dto.PortType;
  6076. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6077. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6078. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6079. string whereSql = string.Empty;
  6080. if (!string.IsNullOrEmpty(dto.Country))
  6081. {
  6082. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6083. }
  6084. if (!string.IsNullOrEmpty(dto.City))
  6085. {
  6086. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6087. }
  6088. string pageSql = string.Format(@"Select * From (
  6089. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6090. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6091. From Grp_NationalTravelFee gntf
  6092. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6093. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6094. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6095. RefAsync<int> total = 0;
  6096. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6097. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6098. }
  6099. /// <summary>
  6100. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6101. /// </summary>
  6102. /// <returns></returns>
  6103. [HttpPost]
  6104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6105. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6106. {
  6107. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6108. int portId = dto.PortType;
  6109. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6110. string whereSql = string.Empty;
  6111. if (!string.IsNullOrEmpty(dto.Country))
  6112. {
  6113. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6114. }
  6115. if (!string.IsNullOrEmpty(dto.City))
  6116. {
  6117. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6118. }
  6119. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6120. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6121. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6122. From Grp_NationalTravelFee gntf
  6123. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6124. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6125. Where gntf.Isdel = 0 {0} ", whereSql);
  6126. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6127. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6128. }
  6129. /// <summary>
  6130. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6131. /// </summary>
  6132. /// <returns></returns>
  6133. [HttpPost]
  6134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6135. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6136. {
  6137. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6138. if (data.Code != 0)
  6139. {
  6140. return Ok(JsonView(false, data.Msg));
  6141. }
  6142. return Ok(JsonView(true, "操作成功!", data.Data));
  6143. }
  6144. /// <summary>
  6145. /// 团组模块 - 出入境国家费用标准 - Del
  6146. /// </summary>
  6147. /// <returns></returns>
  6148. [HttpPost]
  6149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6150. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6151. {
  6152. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6153. {
  6154. Id = dto.Id,
  6155. DeleteUserId = dto.DeleteUserId,
  6156. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6157. IsDel = 1
  6158. };
  6159. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6160. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6161. .WhereColumns(it => new { it.Id })
  6162. .ExecuteCommandAsync();
  6163. if (delStatus <= 0)
  6164. {
  6165. return Ok(JsonView(false, "删除失败!"));
  6166. }
  6167. return Ok(JsonView(true, "操作成功!"));
  6168. }
  6169. /// <summary>
  6170. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6171. /// 注:Get 请求Headers 加 Token
  6172. /// </summary>
  6173. /// <param name="groupId"></param>
  6174. /// <returns></returns>
  6175. [HttpGet("{groupId}")]
  6176. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6177. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6178. {
  6179. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6180. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6181. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6182. data.ForEach(x =>
  6183. {
  6184. x.CreateUserId = _currUserInfo.UserId;
  6185. });
  6186. if (data.Count > 0)
  6187. {
  6188. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6189. if (add > 0)
  6190. {
  6191. return Ok(JsonView(true, "操作成功!"));
  6192. }
  6193. }
  6194. return Ok(JsonView(false, "未操作!"));
  6195. }
  6196. #endregion
  6197. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  6198. /// <summary>
  6199. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  6200. /// </summary>
  6201. /// <returns></returns>
  6202. [HttpPost]
  6203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6204. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  6205. {
  6206. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6207. //SetDataInfoView
  6208. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6209. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6210. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6211. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6212. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6213. //默认币种显示
  6214. var _currencyInfos = _currencyInit;
  6215. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6216. if (_currencyRate.Count > 0)
  6217. {
  6218. foreach (var item in _currencyInfos)
  6219. {
  6220. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6221. if (rateInfo != null)
  6222. {
  6223. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6224. rate1 *= 1.035M;
  6225. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6226. }
  6227. }
  6228. }
  6229. return Ok(JsonView(true, "查询成功!", new
  6230. {
  6231. WordTypeData = _WordTypeData,
  6232. ExcelTypeData = _ExcelTypeData,
  6233. CurrencyInit = _currencyInfos
  6234. }));
  6235. }
  6236. /// <summary>
  6237. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  6238. /// </summary>
  6239. /// <returns></returns>
  6240. [HttpPost]
  6241. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6242. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  6243. {
  6244. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6245. RefAsync<int> total = 0;
  6246. int diId = 0;
  6247. var status = int.TryParse(dto.GroupName, out diId);
  6248. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  6249. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  6250. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  6251. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  6252. .Select(x => new
  6253. {
  6254. Id = x.Id,
  6255. GroupName = x.TeamName
  6256. })
  6257. .OrderByDescending(x => x.Id)
  6258. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6259. return Ok(JsonView(true, "查询成功!", data, total));
  6260. }
  6261. /// <summary>
  6262. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  6263. /// </summary>
  6264. /// <returns></returns>
  6265. [HttpPost]
  6266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6267. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  6268. {
  6269. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6270. RefAsync<int> total = 0;
  6271. var data = await _sqlSugar.Queryable<Sys_SetData>()
  6272. .Where(x => x.IsDel == 0 && x.STid == 66)
  6273. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  6274. .Select(x => new
  6275. {
  6276. id = x.Id,
  6277. name = x.Name,
  6278. remark = x.Remark,
  6279. })
  6280. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6281. return Ok(JsonView(true, "查询成功!", data, total));
  6282. }
  6283. /// <summary>
  6284. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  6285. /// </summary>
  6286. /// <returns></returns>
  6287. [HttpPost]
  6288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6289. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  6290. {
  6291. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6292. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6293. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  6294. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  6295. var groupOtherRateData = groupRateData.TeamRates;
  6296. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6297. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  6298. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  6299. groupOtherRateData = groupOtherRateData
  6300. .Select(x => new TeamRateDescAddCurrencyIdView {
  6301. CurrencyId = x.CurrencyId,
  6302. CurrencyName = x.CurrencyName,
  6303. CurrencyCode = x.CurrencyCode,
  6304. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  6305. }).ToList();
  6306. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  6307. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData= groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  6308. }
  6309. /// <summary>
  6310. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  6311. /// </summary>
  6312. /// <returns></returns>
  6313. [HttpPost]
  6314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6315. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  6316. {
  6317. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6318. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6319. var tipsData = new List<int>() {1,2,3 };
  6320. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  6321. if (dto.TipsType == 1)
  6322. {
  6323. //默认币种显示
  6324. var _currencyInfos = _currencyInit;
  6325. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6326. List<dynamic> reteInfos = new List<dynamic>();
  6327. if (_currencyRate.Count > 0)
  6328. {
  6329. foreach (var item in _currencyInfos)
  6330. {
  6331. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6332. if (rateInfo != null)
  6333. {
  6334. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6335. decimal rate1 = item.Rate;
  6336. rate1 *= 1.03M;
  6337. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6338. reteInfos.Add(new
  6339. {
  6340. currCode = item.CurrencyCode,
  6341. currName = item.CurrencyName,
  6342. rate = rate2,
  6343. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6344. });
  6345. }
  6346. }
  6347. }
  6348. return Ok(JsonView(true, "查询成功!", reteInfos));
  6349. }
  6350. else if (dto.TipsType == 2)
  6351. {
  6352. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  6353. return Ok(JsonView(true, "查询成功!", visaData.Data));
  6354. }
  6355. else if (dto.TipsType == 3)
  6356. {
  6357. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  6358. return Ok(JsonView(true, "查询成功!", airData.Data));
  6359. }
  6360. return Ok(JsonView(false));
  6361. }
  6362. /// <summary>
  6363. /// 团组模块 - 出入境国家费用标准-移动端 List
  6364. /// </summary>
  6365. /// <returns></returns>
  6366. [HttpPost]
  6367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6368. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  6369. {
  6370. Stopwatch sw = new Stopwatch();
  6371. sw.Start();
  6372. RefAsync<int> total = 0;
  6373. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  6374. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  6375. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  6376. .Where((ntf, sd, u) => ntf.IsDel == 0)
  6377. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  6378. .Select((ntf, sd, u) => new
  6379. {
  6380. Id = ntf.Id,
  6381. Area = $"{ntf.Country}-{ntf.City}",
  6382. Currency = ntf.Currency,
  6383. CurrencyCode = sd.Name,
  6384. CurrencyName = sd.Remark,
  6385. RoomCost = ntf.RoomCost,
  6386. FoodCost = ntf.FoodCost,
  6387. PublicCost = ntf.PublicCost,
  6388. LastUpdateUserId = ntf.LastUpdateUserId,
  6389. LastUpdateUserName = u.CnName,
  6390. LastUpdateTime = ntf.LastUpdateTime,
  6391. })
  6392. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6393. sw.Stop();
  6394. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  6395. }
  6396. /// <summary>
  6397. /// 团组模块 - 出入境费用-移动端 - Info
  6398. /// </summary>
  6399. /// <returns></returns>
  6400. [HttpPost]
  6401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6402. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  6403. {
  6404. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6405. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6406. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  6407. return Ok(data);
  6408. }
  6409. /// <summary>
  6410. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  6411. /// </summary>
  6412. /// <returns></returns>
  6413. [HttpPost]
  6414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6415. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  6416. {
  6417. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6418. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6419. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6420. var mobileInfo = new EnterExitCostMobileParentInfoView();
  6421. if (eecInfo == null) return Ok(mobileInfo);
  6422. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  6423. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  6424. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6425. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6426. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  6427. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6428. {
  6429. SubId = dac.Id,
  6430. DiId = dac.DiId,
  6431. Type = dac.Type,
  6432. Days = dac.Days,
  6433. NationalTravelFeeId = dac.NationalTravelFeeId,
  6434. Arae = $"{ntf.Country}-{ntf.City}",
  6435. Cost = dac.Cost,
  6436. Currency = dac.Currency,
  6437. CurrencyName = sd.Name,
  6438. SubTotal = dac.SubTotal,
  6439. })
  6440. .ToList();
  6441. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  6442. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  6443. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  6444. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  6445. mobileInfo.Currencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark);
  6446. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  6447. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  6448. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  6449. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  6450. //其他款项
  6451. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6452. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  6453. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  6454. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6455. .OrderBy((dop, sd1, sd2) => dop.Index)
  6456. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  6457. {
  6458. SubId = dop.Id,
  6459. DiId = dop.Diid,
  6460. Index = dop.Index,
  6461. SetDataId = dop.SetDataId,
  6462. SetDataName = sd1.Name,
  6463. Cost = dop.Cost,
  6464. Currency = dop.Currency,
  6465. CurrencyName = sd2.Remark,
  6466. SubTotal = dop.SubTotal,
  6467. Remark = dop.Remark,
  6468. })
  6469. .ToArray();
  6470. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  6471. return Ok(mobileInfo);
  6472. }
  6473. /// <summary>
  6474. /// 团组模块 - 出入境费用-移动端 - SubInfo
  6475. /// </summary>
  6476. /// <returns></returns>
  6477. [HttpPost]
  6478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6479. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  6480. {
  6481. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6482. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6483. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  6484. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  6485. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  6486. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  6487. var subType = dto.SubType;
  6488. if (subType == 1) //1:境内费用
  6489. {
  6490. var oneData = new ChoiceOneMobileSubInfoView()
  6491. {
  6492. Id = eecInfo.Id,
  6493. ChoiceOne = eecInfo.ChoiceOne,
  6494. ChoiceOneTotalCost = eecInfo.InsidePay,
  6495. Visa = eecInfo.Visa,
  6496. VisaRemark = eecInfo.VisaRemark,
  6497. YiMiao = eecInfo.YiMiao,
  6498. HeSuan = eecInfo.HeSuan,
  6499. Service = eecInfo.Service,
  6500. Ticket = eecInfo.Ticket,
  6501. Safe = eecInfo.Safe,
  6502. };
  6503. return Ok(JsonView(oneData));
  6504. }
  6505. else if (subType == 2) //2:国际旅费
  6506. {
  6507. var twoData = new ChoiceTwoMobileSubInfoView() {
  6508. Id = eecInfo.Id,
  6509. ChoiceTwoJJ = eecInfo.SumJJC,
  6510. OutsideJJPay = eecInfo.OutsideJJPay,
  6511. ChoiceTwoGW = eecInfo.SumGWC,
  6512. OutsideGWPay = eecInfo.OutsideGWPay,
  6513. ChoiceTwoTD = eecInfo.SumTDC,
  6514. OutsideTDPay = eecInfo.OutsideTDPay,
  6515. AirJJ = eecInfo.AirJJ,
  6516. AirGW = eecInfo.AirGW,
  6517. AirTD = eecInfo.AirTD,
  6518. CityTranffic = eecInfo.CityTranffic
  6519. };
  6520. return Ok(JsonView(twoData));
  6521. }
  6522. else if (subType == 3) //3:住宿费
  6523. {
  6524. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6525. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6526. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6527. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  6528. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6529. {
  6530. SubId = dac.Id,
  6531. DiId = dac.DiId,
  6532. Type = dac.Type,
  6533. Days = dac.Days,
  6534. NationalTravelFeeId = dac.NationalTravelFeeId,
  6535. Arae = $"{ntf.Country}-{ntf.City}",
  6536. Cost = dac.Cost,
  6537. Currency = dac.Currency,
  6538. CurrencyName = sd.Name,
  6539. SubTotal = dac.SubTotal,
  6540. })
  6541. .ToArray();
  6542. var data = new ChoiceMobileSubInfo3To6View() {
  6543. ParentId = eecInfo.Id,
  6544. Choice = eecInfo.ChoiceThree,
  6545. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6546. Details = dayAndCostDatas
  6547. };
  6548. return Ok(JsonView(data));
  6549. }
  6550. else if (subType == 4) //4:伙食费
  6551. {
  6552. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6553. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6554. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6555. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  6556. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6557. {
  6558. SubId = dac.Id,
  6559. DiId = dac.DiId,
  6560. Type = dac.Type,
  6561. Days = dac.Days,
  6562. NationalTravelFeeId = dac.NationalTravelFeeId,
  6563. Arae = $"{ntf.Country}-{ntf.City}",
  6564. Cost = dac.Cost,
  6565. Currency = dac.Currency,
  6566. CurrencyName = sd.Name,
  6567. SubTotal = dac.SubTotal,
  6568. })
  6569. .ToArray();
  6570. var data = new ChoiceMobileSubInfo3To6View()
  6571. {
  6572. ParentId = eecInfo.Id,
  6573. Choice = eecInfo.ChoiceFour,
  6574. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6575. Details = dayAndCostDatas
  6576. };
  6577. return Ok(JsonView(data));
  6578. }
  6579. else if (subType == 5) //5:公杂费
  6580. {
  6581. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6582. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6583. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6584. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  6585. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6586. {
  6587. SubId = dac.Id,
  6588. DiId = dac.DiId,
  6589. Type = dac.Type,
  6590. Days = dac.Days,
  6591. NationalTravelFeeId = dac.NationalTravelFeeId,
  6592. Arae = $"{ntf.Country}-{ntf.City}",
  6593. Cost = dac.Cost,
  6594. Currency = dac.Currency,
  6595. CurrencyName = sd.Name,
  6596. SubTotal = dac.SubTotal,
  6597. })
  6598. .ToArray();
  6599. var data = new ChoiceMobileSubInfo3To6View()
  6600. {
  6601. ParentId = eecInfo.Id,
  6602. Choice = eecInfo.ChoiceFive,
  6603. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6604. Details = dayAndCostDatas
  6605. };
  6606. return Ok(JsonView(data));
  6607. }
  6608. else if (subType == 6) //6:培训费
  6609. {
  6610. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  6611. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  6612. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  6613. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  6614. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  6615. {
  6616. SubId = dac.Id,
  6617. DiId = dac.DiId,
  6618. Type = dac.Type,
  6619. Days = dac.Days,
  6620. NationalTravelFeeId = dac.NationalTravelFeeId,
  6621. Arae = $"{ntf.Country}-{ntf.City}",
  6622. Cost = dac.Cost,
  6623. Currency = dac.Currency,
  6624. CurrencyName = sd.Name,
  6625. SubTotal = dac.SubTotal,
  6626. })
  6627. .ToArray();
  6628. var data = new ChoiceMobileSubInfo3To6View()
  6629. {
  6630. ParentId = eecInfo.Id,
  6631. Choice = eecInfo.ChoiceSix,
  6632. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  6633. Details = dayAndCostDatas
  6634. };
  6635. return Ok(JsonView(data));
  6636. }
  6637. else if (subType == 7) //7:其他
  6638. {
  6639. //其他款项
  6640. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6641. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  6642. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  6643. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6644. .OrderBy((dop, sd1, sd2) => dop.Index)
  6645. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  6646. {
  6647. SubId = dop.Id,
  6648. DiId = dop.Diid,
  6649. Index = dop.Index,
  6650. SetDataId = dop.SetDataId,
  6651. SetDataName = sd1.Name,
  6652. Cost = dop.Cost,
  6653. Currency = dop.Currency,
  6654. CurrencyName = sd2.Name,
  6655. SubTotal = dop.SubTotal,
  6656. Remark = dop.Remark,
  6657. })
  6658. .ToArray();
  6659. var data = new ChoiceSevenMobileSubInfoView()
  6660. {
  6661. ParentId = eecInfo.Id,
  6662. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  6663. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  6664. Details = otherData
  6665. };
  6666. return Ok(JsonView(data));
  6667. }
  6668. return Ok(JsonView(false));
  6669. }
  6670. #region op
  6671. /// <summary>
  6672. /// 移动端更新费用消息通知
  6673. /// </summary>
  6674. /// <param name="diid"></param>
  6675. /// <param name="id"></param>
  6676. /// <param name="currUserId"></param>
  6677. private async Task EnterExitCostMobileOpNotice(int diid, int id,int currUserId)
  6678. {
  6679. try
  6680. {
  6681. ////生成默认文件pdf并且通知人员
  6682. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  6683. //{
  6684. // DiId = diid,
  6685. // ExportType = 1,
  6686. // SubTypeId = 1005
  6687. //}, "pdf");
  6688. ////发送通知
  6689. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  6690. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  6691. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  6692. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  6693. ////汇率信息记录
  6694. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  6695. }
  6696. catch (Exception ex)
  6697. {
  6698. //记录日志
  6699. throw;
  6700. }
  6701. }
  6702. /// <summary>
  6703. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  6704. /// </summary>
  6705. /// <returns></returns>
  6706. [HttpPost]
  6707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6708. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  6709. {
  6710. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6711. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6712. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6713. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  6714. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  6715. int id = dto.Id;
  6716. if (id <= 0) //add
  6717. {
  6718. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  6719. if (add < 1) return Ok(JsonView(false));
  6720. id = add;
  6721. }
  6722. else //update
  6723. {
  6724. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  6725. if (upd < 1) return Ok(JsonView(false));
  6726. }
  6727. #region 汇率变更时更改币种相关费用
  6728. var opDayCosts = new List<Grp_DayAndCost>();
  6729. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  6730. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  6731. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  6732. .LeftJoin<Sys_SetData>((dac,sd) => dac.Currency == sd.Id)
  6733. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  6734. .Select((dac, sd) => new {
  6735. dac.Id,
  6736. dac.DiId,
  6737. CurrencyCode = sd.Name,
  6738. dac.Cost
  6739. })
  6740. .ToList();
  6741. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  6742. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  6743. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  6744. .Select((dop, sd) => new {
  6745. dop.Id,
  6746. dop.Diid,
  6747. CurrencyCode = sd.Name,
  6748. dop.Cost
  6749. })
  6750. .ToList();
  6751. if (dayCosts.Count > 0)
  6752. {
  6753. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  6754. foreach (var dc in new_dayCosts)
  6755. {
  6756. var thisCurrency = dc.Key.ToUpper();
  6757. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  6758. if (thisRate == 0.00M) continue;
  6759. foreach (var dcSub in dc)
  6760. {
  6761. opDayCosts.Add(new Grp_DayAndCost() {
  6762. Id = dcSub.Id,
  6763. DiId = dcSub.DiId,
  6764. Cost = dcSub.Cost,
  6765. SubTotal = dcSub.Cost * thisRate,
  6766. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  6767. });
  6768. }
  6769. }
  6770. if (opDayCosts.Count > 0)
  6771. {
  6772. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  6773. }
  6774. }
  6775. if (dayOtherCosts.Count > 0)
  6776. {
  6777. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  6778. foreach (var dc in new_dayOtherCosts)
  6779. {
  6780. var thisCurrency = dc.Key.ToUpper();
  6781. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  6782. if (thisRate == 0.00M) continue;
  6783. foreach (var dcSub in dc)
  6784. {
  6785. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  6786. {
  6787. Id = dcSub.Id,
  6788. Diid = dcSub.Diid,
  6789. Cost = dcSub.Cost,
  6790. SubTotal = dcSub.Cost * thisRate,
  6791. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  6792. });
  6793. }
  6794. }
  6795. if (opDayOtherCosts.Count > 0)
  6796. {
  6797. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  6798. }
  6799. }
  6800. #endregion
  6801. //消息通知
  6802. await EnterExitCostMobileOpNotice(dto.DiId, id,dto.CurrUserId);
  6803. //汇率信息记录
  6804. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  6805. return Ok(JsonView(true));
  6806. }
  6807. /// <summary>
  6808. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  6809. /// </summary>
  6810. /// <returns></returns>
  6811. [HttpPost]
  6812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6813. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  6814. {
  6815. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6816. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6817. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6818. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  6819. int id = dto.Id;
  6820. if (id <= 0) //add
  6821. {
  6822. checkboxInfo.CreateUserId = dto.CurrUserId;
  6823. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  6824. if (add < 1) return Ok(JsonView(false));
  6825. }
  6826. else //update
  6827. {
  6828. var upd = await _sqlSugar.Updateable(checkboxInfo)
  6829. .UpdateColumns(x => new {
  6830. x.ChoiceOne,
  6831. x.ChoiceTwo,
  6832. x.SumJJC,
  6833. x.SumGWC,
  6834. x.SumTDC,
  6835. x.ChoiceThree,
  6836. x.ChoiceFour,
  6837. x.ChoiceFive,
  6838. x.ChoiceSix,
  6839. x.OtherExpenses_Checked
  6840. })
  6841. .Where(x => x.Id == id)
  6842. .ExecuteCommandAsync();
  6843. if (upd < 1) return Ok(JsonView(false));
  6844. }
  6845. return Ok(JsonView(true));
  6846. }
  6847. /// <summary>
  6848. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  6849. /// </summary>
  6850. /// <returns></returns>
  6851. [HttpPost]
  6852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6853. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  6854. {
  6855. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId,isSelected = dto.IsSelected;
  6856. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  6857. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6858. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6859. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6860. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  6861. var checkboxInfo = new Grp_EnterExitCost() {
  6862. Id = id,
  6863. DiId = diId,
  6864. CreateUserId = currUserId
  6865. };
  6866. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  6867. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  6868. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  6869. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  6870. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  6871. if (id <= 0) //add
  6872. {
  6873. checkboxInfo.CreateUserId = dto.CurrUserId;
  6874. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  6875. if (add < 1) return Ok(JsonView(false));
  6876. }
  6877. else //update
  6878. {
  6879. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  6880. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  6881. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  6882. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  6883. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  6884. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  6885. .Where(x => x.Id == id)
  6886. .ExecuteCommandAsync();
  6887. if (upd < 1) return Ok(JsonView(false));
  6888. }
  6889. return Ok(JsonView(true));
  6890. }
  6891. /// <summary>
  6892. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  6893. /// </summary>
  6894. /// <returns></returns>
  6895. [HttpPost]
  6896. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6897. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  6898. {
  6899. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6900. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6901. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6902. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  6903. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  6904. int id = dto.Id;
  6905. if (id <= 0) //add
  6906. {
  6907. info.CreateUserId = dto.CurrUserId;
  6908. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  6909. if (add < 1) return Ok(JsonView(false));
  6910. id = add;
  6911. }
  6912. else //update
  6913. {
  6914. var upd = await _sqlSugar.Updateable(info)
  6915. .UpdateColumns(x => new {
  6916. x.ChoiceOne,
  6917. x.InsidePay,
  6918. x.VisaRemark,
  6919. x.Visa,
  6920. x.Service,
  6921. x.Safe,
  6922. x.Ticket,
  6923. x.HeSuan,
  6924. x.YiMiao,
  6925. })
  6926. .Where(x => x.Id == id)
  6927. .ExecuteCommandAsync();
  6928. if (upd < 1) return Ok(JsonView(false));
  6929. }
  6930. //消息通知
  6931. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  6932. return Ok(JsonView(new { itemTotal = info.InsidePay }));
  6933. }
  6934. /// <summary>
  6935. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  6936. /// </summary>
  6937. /// <returns></returns>
  6938. [HttpPost]
  6939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6940. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  6941. {
  6942. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  6943. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  6944. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6945. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  6946. info.AirJJC_Checked = dto.ChoiceTwoJJ;
  6947. info.AirGWC_Checked = dto.ChoiceTwoGW;
  6948. info.AirTDC_Checked = dto.ChoiceTwoTD;
  6949. int id = dto.Id;
  6950. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  6951. if (id <= 0) //add
  6952. {
  6953. info.CreateUserId = dto.CurrUserId;
  6954. var addInfo = await _sqlSugar.Insertable(info).ExecuteReturnEntityAsync();
  6955. if (addInfo == null) return Ok(JsonView(false));
  6956. id = addInfo.Id;
  6957. }
  6958. else //update
  6959. {
  6960. var upd = await _sqlSugar.Updateable(info)
  6961. .UpdateColumns(x => new {
  6962. x.AirJJC_Checked,
  6963. x.OutsideJJPay,
  6964. x.AirGWC_Checked,
  6965. x.OutsideGWPay,
  6966. x.AirTDC_Checked,
  6967. x.OutsideTDPay,
  6968. x.AirJJ,
  6969. x.AirGW,
  6970. x.AirTD,
  6971. x.CityTranffic
  6972. })
  6973. .Where(x => x.Id == id)
  6974. .ExecuteCommandAsync();
  6975. if (upd <1) return Ok(JsonView(false));
  6976. }
  6977. jjcItemTotal = info.AirJJ + info.CityTranffic;
  6978. gwcItemTotal = info.AirGW + info.CityTranffic;
  6979. tdcItemTotal = info.AirTD + info.CityTranffic;
  6980. //消息通知
  6981. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  6982. return Ok(JsonView(new
  6983. {
  6984. choiceTwoJJ = dto.ChoiceTwoJJ,
  6985. jjcItemTotal = jjcItemTotal,
  6986. choiceTwoGW = dto.ChoiceTwoGW,
  6987. gwcItemTotal = gwcItemTotal,
  6988. choiceTwoTD = dto.ChoiceTwoTD,
  6989. tdcItemTotal = tdcItemTotal
  6990. }));
  6991. }
  6992. /// <summary>
  6993. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  6994. /// </summary>
  6995. /// <returns></returns>
  6996. [HttpPost]
  6997. [ApiExplorerSettings(IgnoreApi = true)]
  6998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6999. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  7000. {
  7001. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7002. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7003. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7004. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  7005. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  7006. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  7007. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  7008. var infos = infos1.Select(x => new Grp_DayAndCost
  7009. {
  7010. Id = x.Id,
  7011. DiId = dto.DiId,
  7012. Type = dto.FeeType,
  7013. Days = x.Days,
  7014. NationalTravelFeeId = x.NationalTravelFeeId,
  7015. Cost = x.Cost,
  7016. Currency = x.Currency,
  7017. SubTotal = x.SubTotal,
  7018. CreateUserId = dto.CurrUserId
  7019. })
  7020. .ToList();
  7021. var adds = infos.Where(x => x.Id <= 0).ToList();
  7022. var upds = infos.Where(x => x.Id > 0).ToList();
  7023. if (adds.Count > 0)
  7024. {
  7025. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  7026. if (add < 1) return Ok(JsonView(false));
  7027. }
  7028. if (upds.Count > 0)
  7029. {
  7030. var upd = await _sqlSugar.Updateable(adds)
  7031. .UpdateColumns(x => new
  7032. {
  7033. x.Days,
  7034. x.NationalTravelFeeId,
  7035. x.Cost,
  7036. x.Currency,
  7037. x.SubTotal
  7038. })
  7039. .WhereColumns(x => new { x.Id })
  7040. .ExecuteCommandAsync();
  7041. if (upd < 1) return Ok(JsonView(false));
  7042. }
  7043. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  7044. //消息通知
  7045. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  7046. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  7047. return Ok(JsonView(new { itemTotal = itemTotal }));
  7048. }
  7049. /// <summary>
  7050. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  7051. /// </summary>
  7052. /// <returns></returns>
  7053. [HttpPost]
  7054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7055. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  7056. {
  7057. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  7058. int subId = dto.SubId, feeType = dto.FeeType;
  7059. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7060. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7061. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7062. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  7063. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  7064. subInfo.Id = subId;
  7065. subInfo.DiId = dto.DiId;
  7066. if (feeType == 3) subInfo.Type = 1;
  7067. else if (feeType == 4) subInfo.Type = 1;
  7068. else if (feeType == 5) subInfo.Type = 1;
  7069. else if (feeType == 6) subInfo.Type = 1;
  7070. subInfo.CreateUserId = dto.CurrUserId;
  7071. //子表op
  7072. if (subId < 1)
  7073. {
  7074. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  7075. if (subAdd < 1) return Ok(JsonView(false));
  7076. }
  7077. else
  7078. {
  7079. var subUpd = await _sqlSugar.Updateable(subInfo)
  7080. .UpdateColumns(x => new
  7081. {
  7082. x.Days,
  7083. x.NationalTravelFeeId,
  7084. x.Cost,
  7085. x.Currency,
  7086. x.SubTotal
  7087. })
  7088. .WhereColumns(x => new { x.Id })
  7089. .ExecuteCommandAsync();
  7090. if (subUpd < 1) return Ok(JsonView(false));
  7091. }
  7092. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  7093. //消息通知
  7094. var parentId = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First().Id;
  7095. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  7096. return Ok(JsonView(new { itemTotal = itemTotal }));
  7097. }
  7098. /// <summary>
  7099. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  7100. /// </summary>
  7101. /// <returns></returns>
  7102. [HttpPost]
  7103. [ApiExplorerSettings(IgnoreApi = true)]
  7104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7105. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  7106. {
  7107. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7108. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7109. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7110. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  7111. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  7112. {
  7113. Id = x.Id,
  7114. Diid = dto.DiId,
  7115. SetDataId = x.SetDataId,
  7116. Index = x.Index,
  7117. Cost = x.Cost,
  7118. Currency = x.Currency,
  7119. SubTotal = x.SubTotal,
  7120. CreateUserId = dto.CurrUserId,
  7121. Remark = x.Remark
  7122. }).ToList();
  7123. var adds = infos.Where(x => x.Id <= 0).ToList();
  7124. var upds = infos.Where(x => x.Id > 0).ToList();
  7125. if (adds.Count > 0)
  7126. {
  7127. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  7128. if (add < 1) return Ok(JsonView(false));
  7129. }
  7130. if (upds.Count > 0)
  7131. {
  7132. var upd = await _sqlSugar.Updateable(adds)
  7133. .UpdateColumns(x => new
  7134. {
  7135. x.Index,
  7136. x.SetDataId,
  7137. x.Cost,
  7138. x.Currency,
  7139. x.SubTotal,
  7140. x.Remark
  7141. })
  7142. .WhereColumns(x => new { x.Id })
  7143. .ExecuteCommandAsync();
  7144. if (upd < 1) return Ok(JsonView(false));
  7145. }
  7146. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  7147. //消息通知
  7148. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  7149. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  7150. return Ok(JsonView(new { itemTotal = itemTotal }));
  7151. }
  7152. /// <summary>
  7153. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  7154. /// </summary>
  7155. /// <returns></returns>
  7156. [HttpPost]
  7157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7158. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  7159. {
  7160. int subId = dto.SubId;
  7161. int diId = dto.Diid;
  7162. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7163. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7164. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7165. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  7166. subInfo.Id = subId;
  7167. subInfo.Diid = dto.Diid;
  7168. subInfo.CreateUserId = dto.CurrUserId;
  7169. #region 子表op
  7170. if (subId < 1)//add
  7171. {
  7172. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  7173. if (subAdd < 1) return Ok(JsonView(false));
  7174. }
  7175. else //upd
  7176. {
  7177. var subUpd = await _sqlSugar.Updateable(subInfo)
  7178. .UpdateColumns(x => new
  7179. {
  7180. x.Index,
  7181. x.SetDataId,
  7182. x.Cost,
  7183. x.Currency,
  7184. x.SubTotal,
  7185. x.Remark
  7186. })
  7187. .WhereColumns(x => new { x.Id })
  7188. .ExecuteCommandAsync();
  7189. if (subUpd < 1) return Ok(JsonView(false));
  7190. }
  7191. #endregion
  7192. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  7193. //消息通知
  7194. var parentId = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).First().Id;
  7195. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  7196. return Ok(JsonView(new { itemTotal = itemTotal }));
  7197. }
  7198. /// <summary>
  7199. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  7200. /// </summary>
  7201. /// <returns></returns>
  7202. [HttpPost]
  7203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7204. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  7205. {
  7206. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  7207. if (data.Code != 0)
  7208. {
  7209. return Ok(JsonView(false, data.Msg));
  7210. }
  7211. return Ok(JsonView(true, "操作成功!", data.Data));
  7212. }
  7213. /// <summary>
  7214. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  7215. /// </summary>
  7216. /// <param name="dto"></param>
  7217. /// <returns></returns>
  7218. [HttpPost]
  7219. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  7220. {
  7221. var data = new Grp_DayOtherPrice()
  7222. {
  7223. Id = dto.Id,
  7224. IsDel = 1,
  7225. DeleteUserId = dto.DeleteUserId,
  7226. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7227. };
  7228. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7229. if (del > 0) return Ok(JsonView(true,"删除成功!"));
  7230. return Ok(JsonView(false,"删除失败!"));
  7231. }
  7232. #endregion
  7233. #endregion
  7234. #region 签证费用录入
  7235. /// <summary>
  7236. /// 根据diid查询签证费用列表
  7237. /// </summary>
  7238. /// <param name="dto"></param>
  7239. /// <returns></returns>
  7240. [HttpPost]
  7241. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7242. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  7243. {
  7244. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  7245. if (groupData.Code != 0)
  7246. {
  7247. return Ok(JsonView(false, groupData.Msg));
  7248. }
  7249. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7250. }
  7251. /// <summary>
  7252. /// 根据签证费用Id查询单条数据及c表数据
  7253. /// </summary>
  7254. /// <param name="dto"></param>
  7255. /// <returns></returns>
  7256. [HttpPost]
  7257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7258. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  7259. {
  7260. Result groupData = await _visaPriceRep.PostVisaById(dto);
  7261. if (groupData.Code != 0)
  7262. {
  7263. return Ok(JsonView(false, groupData.Msg));
  7264. }
  7265. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7266. }
  7267. /// <summary>
  7268. /// 签证费用删除
  7269. /// </summary>
  7270. /// <param name="dto"></param>
  7271. /// <returns></returns>
  7272. [HttpPost]
  7273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7274. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  7275. {
  7276. _sqlSugar.BeginTran();
  7277. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  7278. if (!res)
  7279. {
  7280. _sqlSugar.RollbackTran();
  7281. return Ok(JsonView(false, "删除失败"));
  7282. }
  7283. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  7284. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  7285. .SetColumns(a => new Grp_CreditCardPayment()
  7286. {
  7287. IsDel = 1,
  7288. DeleteUserId = dto.DeleteUserId,
  7289. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7290. })
  7291. .ExecuteCommand();
  7292. if (resSub < 1)
  7293. {
  7294. _sqlSugar.RollbackTran();
  7295. return Ok(JsonView(false, "删除失败"));
  7296. }
  7297. _sqlSugar.CommitTran();
  7298. return Ok(JsonView(true, "删除成功!"));
  7299. }
  7300. /// <summary>
  7301. /// 签证费用录入下拉框初始化
  7302. /// </summary>
  7303. /// <returns></returns>
  7304. [HttpPost]
  7305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7306. public async Task<IActionResult> VisaPriceAddSelect()
  7307. {
  7308. //支付方式
  7309. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  7310. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  7311. //币种
  7312. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  7313. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  7314. //乘客类型
  7315. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  7316. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  7317. //卡类型
  7318. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  7319. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  7320. //代办费类型
  7321. var agencyFeeTypeData = new List<dynamic>() {
  7322. new { id = 0 , Text = "未选择" },
  7323. new { id = 1 , Text = "小公务" },
  7324. new { id = 2 , Text = "大公务" },
  7325. };
  7326. //签证费用标准国家Data
  7327. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  7328. var data = new
  7329. {
  7330. Payment = _Payment,
  7331. CurrencyList = _CurrencyList,
  7332. PassengerType = _PassengerType,
  7333. BankCard = _BankCard,
  7334. AgencyFeeType = agencyFeeTypeData,
  7335. CountryFeeData = visaCountryFeeData
  7336. };
  7337. return Ok(JsonView(true, "查询成功!", data));
  7338. }
  7339. /// <summary>
  7340. /// 签证费用录入操作(Status:1.新增,2.修改)
  7341. /// </summary>
  7342. /// <param name="dto"></param>
  7343. /// <returns></returns>
  7344. [HttpPost]
  7345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7346. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  7347. {
  7348. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  7349. if (groupData.Code != 0)
  7350. {
  7351. return Ok(JsonView(false, groupData.Msg));
  7352. }
  7353. #region 应用推送
  7354. try
  7355. {
  7356. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  7357. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  7358. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  7359. //2024-10-21 新增LZ UID
  7360. var userIds = new List<int>() { 21 };
  7361. string title = $"系统通知";
  7362. string content = "";
  7363. var diId = dto.DiId;
  7364. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  7365. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  7366. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7367. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7368. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  7369. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  7370. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  7371. }
  7372. catch (Exception ex)
  7373. {
  7374. }
  7375. #endregion
  7376. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7377. }
  7378. #endregion
  7379. #region 签证提成录入
  7380. /// <summary>
  7381. /// 签证提成录入
  7382. /// 基础数据
  7383. /// </summary>
  7384. /// <param name="_dto"></param>
  7385. /// <returns></returns>
  7386. [HttpGet]
  7387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7388. public async Task<IActionResult> VisaCommissionInit()
  7389. {
  7390. return Ok(await _visaCommissionRep.Init());
  7391. }
  7392. /// <summary>
  7393. /// 签证提成录入
  7394. /// Item
  7395. /// </summary>
  7396. /// <param name="_dto"></param>
  7397. /// <returns></returns>
  7398. [HttpPost]
  7399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7400. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  7401. {
  7402. var validator = new VisaCommissionItemDtoValidator();
  7403. var validatorRes = await validator.ValidateAsync(_dto);
  7404. if (!validatorRes.IsValid)
  7405. {
  7406. StringBuilder sb = new StringBuilder();
  7407. foreach (var item in validatorRes.Errors)
  7408. {
  7409. sb.AppendLine(item.ErrorMessage);
  7410. }
  7411. return Ok(JsonView(false, sb.ToString()));
  7412. }
  7413. return Ok(await _visaCommissionRep.Item(_dto));
  7414. }
  7415. /// <summary>
  7416. /// 签证提成录入
  7417. /// Save
  7418. /// </summary>
  7419. /// <param name="_dto"></param>
  7420. /// <returns></returns>
  7421. [HttpPost]
  7422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7423. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  7424. {
  7425. //参数验证
  7426. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  7427. foreach (var item in _dto.Items)
  7428. {
  7429. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  7430. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  7431. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  7432. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  7433. }
  7434. return Ok(await _visaCommissionRep.Save(_dto));
  7435. }
  7436. /// <summary>
  7437. /// 签证提成录入
  7438. /// Create
  7439. /// </summary>
  7440. /// <param name="_dto"></param>
  7441. /// <returns></returns>
  7442. [HttpPost]
  7443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7444. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  7445. {
  7446. var validator = new VisaCommissionCreateDtoValidator();
  7447. var validatorRes = await validator.ValidateAsync(_dto);
  7448. if (!validatorRes.IsValid)
  7449. {
  7450. StringBuilder sb = new StringBuilder();
  7451. foreach (var item in validatorRes.Errors)
  7452. {
  7453. sb.AppendLine(item.ErrorMessage);
  7454. }
  7455. return Ok(JsonView(false, sb.ToString()));
  7456. }
  7457. return Ok(await _visaCommissionRep.Create(_dto));
  7458. }
  7459. /// <summary>
  7460. /// 签证提成录入
  7461. /// Put(编辑)
  7462. /// </summary>
  7463. /// <param name="id"></param>
  7464. /// <param name="_dto"></param>
  7465. /// <returns></returns>
  7466. [HttpPut]
  7467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7468. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  7469. {
  7470. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  7471. var validator = new VisaCommissionCreateDtoValidator();
  7472. var validatorRes = await validator.ValidateAsync(_dto);
  7473. if (!validatorRes.IsValid)
  7474. {
  7475. StringBuilder sb = new StringBuilder();
  7476. foreach (var item in validatorRes.Errors)
  7477. {
  7478. sb.AppendLine(item.ErrorMessage);
  7479. }
  7480. return Ok(JsonView(false, sb.ToString()));
  7481. }
  7482. return Ok(await _visaCommissionRep.Edit(id, _dto));
  7483. }
  7484. /// <summary>
  7485. /// 签证提成录入
  7486. /// Del
  7487. /// </summary>
  7488. /// <param name="id"></param>
  7489. /// <param name="currUserId"></param>
  7490. /// <returns></returns>
  7491. [HttpPost]
  7492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7493. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  7494. {
  7495. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  7496. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  7497. return Ok(await _visaCommissionRep.Del(id, currUserId));
  7498. }
  7499. #endregion
  7500. #region op费用录入
  7501. /// <summary>
  7502. /// 根据diid查询op费用列表
  7503. /// </summary>
  7504. /// <param name="dto"></param>
  7505. /// <returns></returns>
  7506. [HttpPost]
  7507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7508. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  7509. {
  7510. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  7511. if (groupData.Code != 0)
  7512. {
  7513. return Ok(JsonView(false, groupData.Msg));
  7514. }
  7515. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7516. }
  7517. /// <summary>
  7518. /// 根据op费用Id查询单条数据及c表数据
  7519. /// </summary>
  7520. /// <param name="dto"></param>
  7521. /// <returns></returns>
  7522. [HttpPost]
  7523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7524. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  7525. {
  7526. try
  7527. {
  7528. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  7529. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  7530. var data = new
  7531. {
  7532. CarTouristGuideGround = _groupData,
  7533. CreditCardPayment = _creditCardPayment
  7534. };
  7535. return Ok(JsonView(true, "查询成功!", data));
  7536. }
  7537. catch (Exception ex)
  7538. {
  7539. return Ok(JsonView(false, "程序错误!"));
  7540. }
  7541. }
  7542. /// <summary>
  7543. /// op费用删除
  7544. /// </summary>
  7545. /// <param name="dto"></param>
  7546. /// <returns></returns>
  7547. [HttpPost]
  7548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7549. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  7550. {
  7551. try
  7552. {
  7553. _sqlSugar.BeginTran();
  7554. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  7555. if (!res)
  7556. {
  7557. return Ok(JsonView(false, "删除失败"));
  7558. }
  7559. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  7560. {
  7561. IsDel = 1,
  7562. DeleteUserId = dto.DeleteUserId,
  7563. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7564. }).ExecuteCommandAsync();
  7565. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  7566. {
  7567. IsDel = 1,
  7568. DeleteUserId = dto.DeleteUserId,
  7569. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7570. }).ExecuteCommandAsync();
  7571. #region 删除超支相关数据
  7572. //删除导入的超支数据
  7573. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  7574. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  7575. {
  7576. IsDel = 1,
  7577. DeleteUserId = dto.DeleteUserId,
  7578. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7579. }).ExecuteCommand();
  7580. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  7581. {
  7582. IsDel = 1,
  7583. DeleteUserId = dto.DeleteUserId,
  7584. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7585. }).ExecuteCommand();
  7586. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  7587. {
  7588. IsDel = 1,
  7589. DeleteUserId = dto.DeleteUserId,
  7590. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7591. }).ExecuteCommand();
  7592. #endregion
  7593. _sqlSugar.CommitTran();
  7594. return Ok(JsonView(true, "删除成功!"));
  7595. }
  7596. catch (Exception ex)
  7597. {
  7598. _sqlSugar.RollbackTran();
  7599. return Ok(JsonView(false, "程序错误!" + ex.Message));
  7600. }
  7601. }
  7602. /// <summary>
  7603. /// op费用录入操作(Status:1.新增,2.修改)
  7604. /// </summary>
  7605. /// <param name="dto"></param>
  7606. /// <returns></returns>
  7607. [HttpPost]
  7608. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7609. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  7610. {
  7611. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  7612. if (groupData.Code != 0)
  7613. {
  7614. return Ok(JsonView(false, groupData.Msg));
  7615. }
  7616. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7617. }
  7618. /// <summary>
  7619. /// 填写费用详细页面初始化绑定
  7620. /// </summary>
  7621. /// <param name="dto"></param>
  7622. /// <returns></returns>
  7623. [HttpPost]
  7624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7625. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  7626. {
  7627. try
  7628. {
  7629. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  7630. if (groupData.Code != 0)
  7631. {
  7632. return Ok(JsonView(false, groupData.Msg));
  7633. }
  7634. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7635. }
  7636. catch (Exception ex)
  7637. {
  7638. return Ok(JsonView(false, ex.Message));
  7639. }
  7640. }
  7641. /// <summary>
  7642. /// 根据op费用Id查询详细数据
  7643. /// </summary>
  7644. /// <param name="dto"></param>
  7645. /// <returns></returns>
  7646. [HttpPost]
  7647. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7648. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  7649. {
  7650. try
  7651. {
  7652. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  7653. if (groupData.Code != 0)
  7654. {
  7655. return Ok(JsonView(false, groupData.Msg));
  7656. }
  7657. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7658. }
  7659. catch (Exception ex)
  7660. {
  7661. return Ok(JsonView(false, ex.Message));
  7662. }
  7663. }
  7664. /// <summary>
  7665. /// OP费用录入填写详情
  7666. /// </summary>
  7667. /// <param name="dto"></param>
  7668. /// <returns></returns>
  7669. [HttpPost]
  7670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7671. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  7672. {
  7673. try
  7674. {
  7675. #region 参数校验
  7676. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  7677. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  7678. if (di == null) return Ok(JsonView(false, "团组错误!"));
  7679. #endregion
  7680. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  7681. if (groupData.Code != 0)
  7682. {
  7683. return Ok(JsonView(false, groupData.Msg));
  7684. }
  7685. //自动审核
  7686. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  7687. #region 应用推送
  7688. try
  7689. {
  7690. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  7691. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  7692. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  7693. //2024-10-21 新增LZ UID
  7694. var userIds = new List<int>() { 21 };
  7695. string title = $"系统通知";
  7696. var diId = dto.DiId;
  7697. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  7698. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  7699. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  7700. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  7701. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  7702. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  7703. }
  7704. catch (Exception ex)
  7705. {
  7706. }
  7707. #endregion
  7708. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7709. }
  7710. catch (Exception ex)
  7711. {
  7712. return Ok(JsonView(false, ex.Message));
  7713. }
  7714. }
  7715. /// <summary>
  7716. /// 获取三公详细所有城市
  7717. /// </summary>
  7718. /// <returns></returns>
  7719. [HttpGet]
  7720. public IActionResult OpCarCityResult()
  7721. {
  7722. var jw = JsonView(false);
  7723. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  7724. {
  7725. x.Id,
  7726. x.Country,
  7727. x.City,
  7728. }).ToList();
  7729. if (data.Count > 0)
  7730. {
  7731. jw = JsonView(true, "获取成功!", data);
  7732. }
  7733. else
  7734. {
  7735. jw.Msg = "城市数据为空!";
  7736. jw.Data = new string[0];
  7737. }
  7738. return Ok(jw);
  7739. }
  7740. /// <summary>
  7741. /// 导出地接费用明细
  7742. /// </summary>
  7743. /// <param name="dto"></param>
  7744. /// <returns></returns>
  7745. [HttpPost]
  7746. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  7747. {
  7748. var jw = JsonView(false);
  7749. if (dto.Diid < 1)
  7750. {
  7751. jw.Msg = "请输入正确的diid!";
  7752. return Ok(jw);
  7753. }
  7754. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  7755. if (group == null)
  7756. {
  7757. jw.Msg = "未找到团组信息!";
  7758. return Ok(jw);
  7759. }
  7760. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  7761. if (localGuideArr.Count == 0)
  7762. {
  7763. jw.Msg = "该团组暂无地接信息!";
  7764. return Ok(jw);
  7765. }
  7766. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  7767. var overspendSoure = new Dictionary<int, int>
  7768. {
  7769. { 91, 982 }, //车
  7770. { 92 , 1059} ,//导游
  7771. { 994 , 1073}, //翻译
  7772. { 988 , 1074 }, //早餐
  7773. { 93 , 1075 }, //午餐
  7774. { 989 , 1076 }, //晚餐
  7775. };
  7776. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  7777. foreach (var groupArr in localGroup)
  7778. {
  7779. var keyValue = groupArr.Key;
  7780. if (int.TryParse(keyValue, out int cityid))
  7781. {
  7782. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  7783. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  7784. }
  7785. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  7786. foreach (var item in groupArr)
  7787. {
  7788. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  7789. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  7790. new Grp_CarTouristGuideGroundReservationsContentExtend
  7791. {
  7792. Count = a.Count,
  7793. CreateTime = a.CreateTime,
  7794. CreateUserId = a.CreateUserId,
  7795. CTGGRId = a.CTGGRId,
  7796. Currency = a.Currency,
  7797. DatePrice = a.DatePrice,
  7798. DeleteTime = a.DeleteTime,
  7799. DeleteUserId = a.DeleteUserId,
  7800. DiId = a.DiId,
  7801. Id = a.Id,
  7802. IsDel = a.IsDel,
  7803. Price = a.Price,
  7804. PriceContent = a.PriceContent,
  7805. Remark = a.Remark,
  7806. SId = a.SId,
  7807. SidName = b.Name,
  7808. Units = a.Units,
  7809. }
  7810. ).ToList();
  7811. if (content.Count > 0)
  7812. {
  7813. contentArr.Add(content);
  7814. }
  7815. }
  7816. //open excel
  7817. //set excel
  7818. //save excel
  7819. try
  7820. {
  7821. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  7822. IWorkbook workbook;
  7823. if (Path.GetExtension(filePath).ToLower() == ".xls")
  7824. {
  7825. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  7826. }
  7827. else
  7828. {
  7829. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  7830. }
  7831. ISheet sheet = workbook.GetSheetAt(0);
  7832. var rowStartIndex = 2;
  7833. var clounmCount = 10;
  7834. var initStyleRow = sheet.GetRow(2);
  7835. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  7836. //var overspendArrDetail =
  7837. var existsId = new List<CarCompare>();
  7838. var lastElem = arr.Last();
  7839. var thisSid = -1;
  7840. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  7841. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  7842. {
  7843. Name = "未知币种!",
  7844. Remark = "未知币种!",
  7845. };
  7846. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  7847. Action cloneRowFn = () =>
  7848. {
  7849. rowStartIndex++;
  7850. var cloneRow = sheet.CreateRow(rowStartIndex);
  7851. // 复制样式
  7852. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  7853. {
  7854. ICell sourceCell = initStyleRow.GetCell(i);
  7855. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  7856. // 确保单元格存在样式
  7857. if (sourceCell.CellStyle != null)
  7858. {
  7859. targetCell.CellStyle = sourceCell.CellStyle;
  7860. }
  7861. }
  7862. };
  7863. var mergeRow = () =>
  7864. {
  7865. for (int i = 2; i < sheet.LastRowNum; i++)
  7866. {
  7867. var row = sheet.GetRow(i);
  7868. var cellFirst = row.GetCell(0);
  7869. var thisIndex = i + 1;
  7870. while (thisIndex < sheet.LastRowNum)
  7871. {
  7872. var nextRow = sheet.GetRow(thisIndex);
  7873. var nextCellFirst = nextRow.GetCell(0);
  7874. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  7875. {
  7876. thisIndex++;
  7877. }
  7878. else
  7879. {
  7880. break;
  7881. }
  7882. }
  7883. thisIndex--;
  7884. if (thisIndex != i)
  7885. {
  7886. //合并row
  7887. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7888. i, // 起始行索引(0-based)
  7889. thisIndex, // 结束行索引(0-based)
  7890. 0, // 起始列索引(0-based)
  7891. 0 // 结束列索引(0-based)
  7892. );
  7893. sheet.AddMergedRegion(cellRangeAddress);
  7894. i = thisIndex;
  7895. }
  7896. }
  7897. };
  7898. var chaoshiNumber = 0;
  7899. var totalNumber = 0.00M;
  7900. string lastStr = "";
  7901. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  7902. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  7903. {
  7904. b.IsAuditGM,
  7905. x.Id,
  7906. x.Area,
  7907. b.PayPercentage,
  7908. b.PayMoney,
  7909. }).ToList();
  7910. string yesPayment = "", noPayment = "";
  7911. foreach (var item in queryCarArrByCityAndDiid)
  7912. {
  7913. if (item.IsAuditGM == 1)
  7914. {
  7915. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  7916. }
  7917. else
  7918. {
  7919. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  7920. }
  7921. }
  7922. lastStr = yesPayment + noPayment;
  7923. foreach (var item in arr)
  7924. {
  7925. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  7926. {
  7927. if (thisSid != item.SId)
  7928. {
  7929. if (thisSid == -1)
  7930. {
  7931. thisSid = item.SId;
  7932. }
  7933. else
  7934. {
  7935. //合并小计行
  7936. //创建合并区域的实例
  7937. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  7938. rowStartIndex, // 起始行索引(0-based)
  7939. rowStartIndex, // 结束行索引(0-based)
  7940. 0, // 起始列索引(0-based)
  7941. 3 // 结束列索引(0-based)
  7942. );
  7943. sheet.AddMergedRegion(cellRangeAddress);
  7944. var CellStyle = workbook.CreateCellStyle();
  7945. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7946. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  7947. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  7948. for (int i = 0; i <= clounmCount; i++)
  7949. {
  7950. if (i > 6)
  7951. {
  7952. var CellStyle1 = workbook.CreateCellStyle();
  7953. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  7954. IFont Font = workbook.CreateFont(); // 创建字体
  7955. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  7956. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  7957. CellStyle1.SetFont(Font);
  7958. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  7959. }
  7960. else
  7961. {
  7962. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  7963. }
  7964. }
  7965. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  7966. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  7967. //超时合计
  7968. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  7969. //超时数
  7970. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  7971. //超时合计费用
  7972. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  7973. thisSid = item.SId;
  7974. cloneRowFn();
  7975. chaoshiNumber = 0;
  7976. totalNumber = 0;
  7977. }
  7978. }
  7979. IRow row = sheet.GetRow(rowStartIndex);
  7980. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  7981. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  7982. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  7983. if (isOpenOverspendSoure)
  7984. {
  7985. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  7986. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  7987. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  7988. }
  7989. for (int i = 0; i <= clounmCount; i++)
  7990. {
  7991. var cell = row.GetCell(i);
  7992. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  7993. if (cell == null)
  7994. {
  7995. cell = row.CreateCell(i);
  7996. }
  7997. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  7998. fontRed.CloneStyleFrom(cell.CellStyle);
  7999. IFont Font = workbook.CreateFont(); // 创建字体
  8000. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  8001. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  8002. fontRed.SetFont(Font);
  8003. byte[] rgb = new byte[3] { 255, 242, 204 };
  8004. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  8005. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  8006. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  8007. if (workbook is XSSFWorkbook)
  8008. {
  8009. BackgroundColor255_242_204.FillForegroundColor = 0;
  8010. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  8011. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  8012. }
  8013. else
  8014. {
  8015. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  8016. }
  8017. if (i == 1 || i > 6)
  8018. {
  8019. if (i > 6)
  8020. {
  8021. fontRed.FillForegroundColor = 0;
  8022. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  8023. fontRed.FillPattern = FillPattern.SolidForeground;
  8024. }
  8025. cell.CellStyle = fontRed;
  8026. }
  8027. if (i > 2 && i < 7)
  8028. {
  8029. cell.CellStyle = BackgroundColor255_242_204;
  8030. }
  8031. cell.SetCellValue(setCellValue); //写入单元格
  8032. }
  8033. if (overspendSoure.ContainsKey(thisSid))
  8034. {
  8035. var overspendId = overspendSoure[thisSid];
  8036. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  8037. }
  8038. cloneRowFn();
  8039. existsId.Add(new CarCompare
  8040. {
  8041. DataPrice = item.DatePrice.ObjToDate(),
  8042. Sid = item.SId
  8043. });
  8044. }
  8045. if (item.Equals(lastElem))
  8046. {
  8047. //合并小计行
  8048. //创建合并区域的实例
  8049. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  8050. rowStartIndex, // 起始行索引(0-based)
  8051. rowStartIndex, // 结束行索引(0-based)
  8052. 0, // 起始列索引(0-based)
  8053. 3 // 结束列索引(0-based)
  8054. );
  8055. sheet.AddMergedRegion(cellRangeAddress);
  8056. var CellStyle = workbook.CreateCellStyle();
  8057. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8058. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  8059. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  8060. for (int i = 0; i <= clounmCount; i++)
  8061. {
  8062. if (i > 6)
  8063. {
  8064. var CellStyle1 = workbook.CreateCellStyle();
  8065. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  8066. IFont Font = workbook.CreateFont(); // 创建字体
  8067. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  8068. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  8069. CellStyle1.SetFont(Font);
  8070. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  8071. }
  8072. else
  8073. {
  8074. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  8075. }
  8076. }
  8077. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  8078. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  8079. //超时合计
  8080. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  8081. //超时数
  8082. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  8083. //超时合计费用
  8084. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  8085. cloneRowFn();
  8086. // 创建合并区域的实例
  8087. cellRangeAddress = new CellRangeAddress(
  8088. rowStartIndex, // 起始行索引(0-based)
  8089. rowStartIndex, // 结束行索引(0-based)
  8090. 0, // 起始列索引(0-based)
  8091. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  8092. );
  8093. // 添加合并区域
  8094. sheet.AddMergedRegion(cellRangeAddress);
  8095. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  8096. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  8097. }
  8098. }
  8099. mergeRow();
  8100. // 保存修改后的Excel文件到新文件
  8101. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  8102. // new FileStream(newFilePath, FileMode.CreateNew)
  8103. using (var stream = new MemoryStream())
  8104. {
  8105. workbook.Write(stream, true);
  8106. stream.Flush();
  8107. stream.Seek(0, SeekOrigin.Begin);
  8108. MemoryStream memoryStream = new MemoryStream();
  8109. stream.CopyTo(memoryStream);
  8110. memoryStream.Seek(0, SeekOrigin.Begin);
  8111. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  8112. }
  8113. workbook.Close();
  8114. workbook.Dispose();
  8115. }
  8116. catch (Exception ex)
  8117. {
  8118. jw.Msg = "出现异常!" + ex.Message;
  8119. return Ok(jw);
  8120. }
  8121. }
  8122. if (Zips.Count > 0)
  8123. {
  8124. IOOperatorHelper io = new IOOperatorHelper();
  8125. var byts = io.ConvertZipStream(Zips);
  8126. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  8127. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  8128. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  8129. }
  8130. else
  8131. {
  8132. jw.Msg = "暂无生成文件!";
  8133. }
  8134. return Ok(jw);
  8135. }
  8136. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  8137. {
  8138. string outStr = string.Empty;
  8139. switch (i)
  8140. {
  8141. case 0:
  8142. outStr = arr[0].SidName;
  8143. break;
  8144. case 1:
  8145. outStr = arr[0].DataPriceStr;
  8146. break;
  8147. case 2:
  8148. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  8149. break;
  8150. case 4:
  8151. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  8152. break;
  8153. case 7:
  8154. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8155. {
  8156. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  8157. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  8158. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  8159. }
  8160. break;
  8161. case 8:
  8162. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8163. {
  8164. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  8165. }
  8166. break;
  8167. case 9:
  8168. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8169. {
  8170. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  8171. }
  8172. break;
  8173. case 10:
  8174. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  8175. {
  8176. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  8177. }
  8178. break;
  8179. }
  8180. return outStr;
  8181. }
  8182. #region OP行程单
  8183. /// <summary>
  8184. /// OP行程单初始化
  8185. /// </summary>
  8186. /// <param name="dto"></param>
  8187. /// <returns></returns>
  8188. [HttpPost]
  8189. public IActionResult InitOpTravel(InitOpTravelDto dto)
  8190. {
  8191. var jw = JsonView(false);
  8192. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  8193. var group = groupList.First();
  8194. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  8195. if (group == null)
  8196. {
  8197. jw.Msg = "暂无团组!";
  8198. return Ok(jw);
  8199. }
  8200. group = groupList.Find(x => x.Id == diid);
  8201. if (group == null)
  8202. {
  8203. jw.Msg = "请输入正确的团组ID!";
  8204. return Ok(jw);
  8205. }
  8206. string city = string.Empty;
  8207. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  8208. if (blackCode.Count > 0)
  8209. {
  8210. var black = blackCode.First();
  8211. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  8212. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  8213. if (blackSp.Length > 0)
  8214. {
  8215. try
  8216. {
  8217. var cityArrCode = new List<string>(20);
  8218. foreach (var item in blackSp)
  8219. {
  8220. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  8221. var IndexSelect = itemSp[2];
  8222. var cityArrCodeLength = cityArrCode.Count - 1;
  8223. var startCity = IndexSelect.Substring(0, 3);
  8224. if (cityArrCodeLength > 0)
  8225. {
  8226. var arrEndCity = cityArrCode[cityArrCodeLength];
  8227. if (arrEndCity != startCity)
  8228. {
  8229. cityArrCode.Add(startCity.ToUpper());
  8230. }
  8231. }
  8232. else
  8233. {
  8234. cityArrCode.Add(startCity.ToUpper());
  8235. }
  8236. var endCity = IndexSelect.Substring(3, 3);
  8237. cityArrCode.Add(endCity.ToUpper());
  8238. }
  8239. var cityThree = string.Empty;
  8240. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  8241. cityThree = cityThree.TrimEnd(',');
  8242. if (string.IsNullOrWhiteSpace(cityThree))
  8243. {
  8244. throw new
  8245. Exception("error");
  8246. }
  8247. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  8248. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  8249. foreach (var item in cityArrCode)
  8250. {
  8251. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  8252. if (find != null)
  8253. {
  8254. city += find.City + "/";
  8255. }
  8256. else
  8257. {
  8258. city += item + "三字码未收入/";
  8259. }
  8260. }
  8261. city = city.TrimEnd('/');
  8262. }
  8263. catch (Exception e)
  8264. {
  8265. city = "黑屏代码格式不正确!";
  8266. }
  8267. }
  8268. }
  8269. else
  8270. {
  8271. city = "未录入黑屏代码";
  8272. }
  8273. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  8274. {
  8275. Date = x.Date,
  8276. Days = x.Days,
  8277. Diffgroup = x.Diffgroup,
  8278. Diid = x.Diid,
  8279. Traffic_First = x.Traffic_First,
  8280. Traffic_Second = x.Traffic_Second,
  8281. Trip = x.Trip,
  8282. WeekDay = x.WeekDay,
  8283. Id = x.Id
  8284. }).ToList();
  8285. jw.Data = new
  8286. {
  8287. groupList = groupList.Select(x => new
  8288. {
  8289. x.Id,
  8290. x.TeamName,
  8291. x.TourCode
  8292. }).ToList(),
  8293. groupInfo = new
  8294. {
  8295. group.VisitDays,
  8296. group.TourCode,
  8297. group.VisitPNumber,
  8298. group.TeamName,
  8299. city
  8300. },
  8301. OpTravelList
  8302. };
  8303. jw.Code = 200;
  8304. jw.Msg = "操作成功!";
  8305. return Ok(jw);
  8306. }
  8307. /// <summary>
  8308. /// 删除团组行程单
  8309. /// </summary>
  8310. /// <returns></returns>
  8311. [HttpPost]
  8312. public IActionResult DelTravel(DelOpTravelDto dto)
  8313. {
  8314. var jw = JsonView(false);
  8315. if (dto.UserId <= 0 || dto.Diid <= 0)
  8316. {
  8317. jw.Msg = "请输入正确的参数!";
  8318. return Ok(jw);
  8319. }
  8320. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  8321. .SetColumns(x => new Grp_TravelList
  8322. {
  8323. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  8324. DeleteUserId = dto.UserId,
  8325. IsDel = 1,
  8326. }).ExecuteCommand();
  8327. jw = JsonView(true);
  8328. return Ok(jw);
  8329. }
  8330. /// <summary>
  8331. /// 行程单保存
  8332. /// </summary>
  8333. /// <returns></returns>
  8334. [HttpPost]
  8335. public IActionResult TravelSave(TravelSaveDto dto)
  8336. {
  8337. var jw = JsonView(false);
  8338. if (dto.Arr.Count > 0)
  8339. {
  8340. try
  8341. {
  8342. _sqlSugar.BeginTran();
  8343. foreach (var item in dto.Arr)
  8344. {
  8345. if (item.Id == 0)
  8346. {
  8347. throw new Exception("请传入正确的Id");
  8348. }
  8349. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  8350. .SetColumns(x => new Grp_TravelList
  8351. {
  8352. Trip = item.Trip
  8353. }).ExecuteCommand();
  8354. }
  8355. _sqlSugar.CommitTran();
  8356. jw = JsonView(true);
  8357. }
  8358. catch (Exception ex)
  8359. {
  8360. _sqlSugar.RollbackTran();
  8361. jw.Msg = "程序异常!" + ex.Message;
  8362. }
  8363. }
  8364. else
  8365. {
  8366. jw.Msg = "请传入正确的参数!";
  8367. }
  8368. return Ok(jw);
  8369. }
  8370. /// <summary>
  8371. /// 导出行程单
  8372. /// </summary>
  8373. /// <param name="dto"></param>
  8374. /// <returns></returns>
  8375. [HttpPost]
  8376. public IActionResult ExportTravel(ExportTravelDto dto)
  8377. {
  8378. var jw = JsonView(false);
  8379. jw.Data = "";
  8380. int diid = 0;
  8381. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  8382. if (Find == null)
  8383. {
  8384. jw.Msg = "请选择正确的团组!";
  8385. return Ok(jw);
  8386. }
  8387. else
  8388. {
  8389. diid = Find.Id;
  8390. }
  8391. //数据源
  8392. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  8393. DataTable dtBlack = null;
  8394. try
  8395. {
  8396. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  8397. }
  8398. catch (Exception)
  8399. {
  8400. jw.Msg = "机票黑屏代码有误!";
  8401. return Ok(jw);
  8402. }
  8403. string CityStr = string.Empty;
  8404. if (dtBlack.Rows.Count == 0)
  8405. {
  8406. jw.Msg = "机票黑屏代码有误!";
  8407. return Ok(jw);
  8408. }
  8409. else
  8410. {
  8411. foreach (DataRow row in dtBlack.Rows)
  8412. {
  8413. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  8414. {
  8415. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  8416. return Ok(jw);
  8417. }
  8418. }
  8419. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  8420. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  8421. }
  8422. //创建数据源Table
  8423. DataTable dtSource = new DataTable();
  8424. dtSource.Columns.Add("Days", typeof(string));
  8425. dtSource.Columns.Add("Date", typeof(string));
  8426. dtSource.Columns.Add("Week", typeof(string));
  8427. dtSource.Columns.Add("Traffic", typeof(string));
  8428. dtSource.Columns.Add("Trip", typeof(string));
  8429. //获取数据,放到datatable
  8430. foreach (var item in _travelList)
  8431. {
  8432. DataRow dr = dtSource.NewRow();
  8433. dr["Days"] = item.Days;
  8434. dr["Date"] = item.Date;
  8435. dr["Week"] = item.WeekDay;
  8436. dr["Traffic"] = item.Traffic_First
  8437. + "\r\n"
  8438. + item.Traffic_Second;
  8439. dr["Trip"] = item.Trip;
  8440. dtSource.Rows.Add(dr);
  8441. }
  8442. Dictionary<string, string> dic = new Dictionary<string, string>();
  8443. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  8444. dic.Add("City", CityStr);
  8445. dic.Add("Days", Find.VisitDays.ToString());
  8446. dic.Add("DeleCode", Find.TourCode);
  8447. dic.Add("Pnum", Find.VisitPNumber.ToString());
  8448. //模板路径
  8449. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  8450. //载入模板
  8451. Document doc = null;
  8452. DocumentBuilder builder = null;
  8453. try
  8454. {
  8455. //载入模板
  8456. doc = new Document(tempPath);
  8457. builder = new DocumentBuilder(doc);
  8458. }
  8459. catch (Exception)
  8460. {
  8461. jw.Msg = "模板位置不存在!";
  8462. return Ok(jw);
  8463. }
  8464. foreach (var key in dic.Keys)
  8465. {
  8466. Bookmark bookmark = doc.Range.Bookmarks[key];
  8467. if (bookmark != null)
  8468. {
  8469. builder.MoveToBookmark(key);
  8470. builder.Write(dic[key]);
  8471. }
  8472. }
  8473. //获取word里所有表格
  8474. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8475. //获取所填表格的序数
  8476. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8477. try
  8478. {
  8479. //循环赋值
  8480. for (int i = 0; i < dtSource.Rows.Count; i++)
  8481. {
  8482. builder.MoveToCell(0, i + 1, 0, 0);
  8483. builder.Write(dtSource.Rows[i]["Days"].ToString());
  8484. builder.MoveToCell(0, i + 1, 1, 0);
  8485. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  8486. builder.MoveToCell(0, i + 1, 2, 0);
  8487. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  8488. var trip = dtSource.Rows[i]["Trip"].ToString();
  8489. builder.MoveToCell(0, i + 1, 3, 0);
  8490. builder.Write(trip);
  8491. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  8492. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  8493. // 获取特定索引的段落
  8494. Paragraph paragraph = (Paragraph)paragraphs[0];
  8495. Run run = paragraph.Runs[0];
  8496. Aspose.Words.Font font = run.Font;
  8497. font.Name = "黑体";
  8498. //设置双休红色
  8499. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  8500. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  8501. paragraph = (Paragraph)paragraphs[1];
  8502. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  8503. {
  8504. run = paragraph.Runs[0];
  8505. font = run.Font;
  8506. font.Color = Color.Red;
  8507. }
  8508. }
  8509. }
  8510. catch (Exception ex)
  8511. {
  8512. }
  8513. //删除多余行
  8514. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  8515. {
  8516. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  8517. }
  8518. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  8519. if (!Directory.Exists(savePath))
  8520. {
  8521. try
  8522. {
  8523. Directory.CreateDirectory(savePath);
  8524. }
  8525. catch
  8526. {
  8527. }
  8528. }
  8529. string path = savePath + Find.TeamName + "出访日程";
  8530. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  8531. try
  8532. {
  8533. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  8534. string postfix = ".docx";
  8535. if (dto.IsPDF == 1)
  8536. {
  8537. saveFormat = Aspose.Words.SaveFormat.Pdf;
  8538. postfix = ".pdf";
  8539. }
  8540. doc.Save(path + postfix, saveFormat);
  8541. jw = JsonView(true, "导出成功", ftpPath + postfix);
  8542. }
  8543. catch (Exception)
  8544. {
  8545. jw = JsonView(false);
  8546. }
  8547. return Ok(jw);
  8548. }
  8549. /// <summary>
  8550. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  8551. /// </summary>
  8552. /// <param name="num"></param>
  8553. /// <returns></returns>
  8554. string GetNum(string num)
  8555. {
  8556. string str = "";
  8557. switch (num)
  8558. {
  8559. case "1":
  8560. str = "一";
  8561. break;
  8562. case "2":
  8563. str = "二";
  8564. break;
  8565. case "3":
  8566. str = "三";
  8567. break;
  8568. case "4":
  8569. str = "四";
  8570. break;
  8571. case "5":
  8572. str = "五";
  8573. break;
  8574. case "6":
  8575. str = "六";
  8576. break;
  8577. case "7":
  8578. str = "七";
  8579. break;
  8580. case "8":
  8581. str = "八";
  8582. break;
  8583. case "9":
  8584. str = "九";
  8585. break;
  8586. case "10":
  8587. str = "十";
  8588. break;
  8589. case "11":
  8590. str = "十一";
  8591. break;
  8592. case "12":
  8593. str = "十二";
  8594. break;
  8595. case "一":
  8596. str = "1";
  8597. break;
  8598. case "二":
  8599. str = "2";
  8600. break;
  8601. case "三":
  8602. str = "3";
  8603. break;
  8604. case "四":
  8605. str = "4";
  8606. break;
  8607. case "五":
  8608. str = "5";
  8609. break;
  8610. case "六":
  8611. str = "6";
  8612. break;
  8613. case "七":
  8614. str = "7";
  8615. break;
  8616. case "八":
  8617. str = "8";
  8618. break;
  8619. case "九":
  8620. str = "9";
  8621. break;
  8622. case "十":
  8623. str = "10";
  8624. break;
  8625. case "十一":
  8626. str = "11";
  8627. break;
  8628. case "十二":
  8629. str = "12";
  8630. break;
  8631. }
  8632. return str;
  8633. }
  8634. #endregion
  8635. #endregion
  8636. #region 团组成本
  8637. /// <summary>
  8638. /// 团组成本数据初始化
  8639. /// </summary>
  8640. /// <param name="dto"></param>
  8641. /// <returns></returns>
  8642. [HttpPost]
  8643. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  8644. {
  8645. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  8646. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  8647. WHEN COUNT(*) >= 0 THEN 'True'
  8648. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  8649. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  8650. ").ToList(); //团组列表
  8651. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  8652. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  8653. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  8654. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  8655. if (groupinfoValue != null)
  8656. {
  8657. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  8658. var spArr = new string[1] { countryArr };
  8659. if (countryArr.Contains("|"))
  8660. {
  8661. spArr = countryArr.Split("|");
  8662. }
  8663. else if (countryArr.Contains("、"))
  8664. {
  8665. spArr = countryArr.Split("、");
  8666. }
  8667. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  8668. {
  8669. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  8670. if (dbQueryCountry != null)
  8671. {
  8672. visaCountryInfoArr.Add(dbQueryCountry);
  8673. }
  8674. }
  8675. }
  8676. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  8677. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  8678. var create = _GroupCostRepository.
  8679. CreateGroupCostByBlackCode(dto.Diid);
  8680. if (groupCost.Count == 0 && create.Code == 0)
  8681. {
  8682. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  8683. }
  8684. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  8685. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  8686. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  8687. groupCostMap = groupCostMap.Select(x =>
  8688. {
  8689. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  8690. {
  8691. x.Date = dataForamt.ToString("yyyy-MM-dd");
  8692. }
  8693. return x;
  8694. }).ToList();
  8695. //GroupCostParameter.Add(new
  8696. // Grp_GroupCostParameter());
  8697. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  8698. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  8699. return Ok(JsonView(new
  8700. {
  8701. groupList,
  8702. groupInfo,
  8703. groupChecks,
  8704. groupCost = groupCostMap,
  8705. hotelNumber,
  8706. GroupCostParameter = GroupCostParameterMap,
  8707. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  8708. {
  8709. x.VisaCountry,
  8710. x.VisaPrice,
  8711. x.Id,
  8712. }).ToList(),
  8713. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  8714. blackCodeIsTrue = create.Code == 0 ? true : false,
  8715. hotelIsTrue = hotelIsTrue,
  8716. }));
  8717. }
  8718. /// <summary>
  8719. /// 团组成本信息保存
  8720. /// </summary>
  8721. /// <param name="dto"></param>
  8722. /// <returns></returns>
  8723. [HttpPost]
  8724. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  8725. {
  8726. if (dto.Diid <= 0 || dto.Userid <= 0)
  8727. {
  8728. return Ok(JsonView(false));
  8729. }
  8730. JsonView jw = null;
  8731. bool isTrue = false;
  8732. #region 复制团组成本
  8733. //if (dto.Diid == 2581)
  8734. //{
  8735. // dto.Diid = 2599;
  8736. // dto.CheckBoxs.ForEach(x =>
  8737. // {
  8738. // x.Diid = 2599;
  8739. // });
  8740. // dto.GroupCosts.ForEach(x =>
  8741. // {
  8742. // x.Diid = 2599;
  8743. // });
  8744. // dto.CostTypeHotelNumbers.ForEach(x =>
  8745. // {
  8746. // x.Diid = 2599;
  8747. // });
  8748. // dto.GroupCostParameters.ForEach(x =>
  8749. // {
  8750. // x.DiId = 2599;
  8751. // });
  8752. //}
  8753. #endregion
  8754. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  8755. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  8756. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  8757. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  8758. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  8759. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  8760. try
  8761. {
  8762. _sqlSugar.BeginTran();
  8763. isTrue = await _GroupCostRepository.
  8764. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  8765. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  8766. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  8767. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  8768. _sqlSugar.CommitTran();
  8769. jw = JsonView(true, "保存成功!", isTrue);
  8770. }
  8771. catch (Exception)
  8772. {
  8773. _sqlSugar.RollbackTran();
  8774. jw = JsonView(false);
  8775. }
  8776. return Ok(jw);
  8777. }
  8778. /// <summary>
  8779. /// 司兼导数据
  8780. /// </summary>
  8781. /// <param name="dto"></param>
  8782. /// <returns></returns>
  8783. [HttpPost]
  8784. public IActionResult GetCarGuides(CarGuidesDto dto)
  8785. {
  8786. JsonView jw = null;
  8787. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  8788. jw = JsonView(true, "获取成功!", Data);
  8789. return Ok(jw);
  8790. }
  8791. /// <summary>
  8792. /// 导游数据
  8793. /// </summary>
  8794. /// <param name="dto"></param>
  8795. /// <returns></returns>
  8796. [HttpPost]
  8797. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  8798. {
  8799. JsonView jw = null;
  8800. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  8801. // 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
  8802. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  8803. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  8804. jw = JsonView(true, "获取成功!", Data);
  8805. return Ok(jw);
  8806. }
  8807. /// <summary>
  8808. /// 成本车数据
  8809. /// </summary>
  8810. /// <param name="dto"></param>
  8811. /// <returns></returns>
  8812. [HttpPost]
  8813. public IActionResult GetCarInfo(CarGuidesDto dto)
  8814. {
  8815. JsonView jw = null;
  8816. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  8817. jw = JsonView(true, "获取成功!", Data);
  8818. return Ok(jw);
  8819. }
  8820. /// <summary>
  8821. /// 景点数据
  8822. /// </summary>
  8823. /// <param name="dto"></param>
  8824. /// <returns></returns>
  8825. [HttpPost]
  8826. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  8827. {
  8828. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  8829. return Ok(JsonView(true, "获取成功!", Data));
  8830. }
  8831. /// <summary>
  8832. /// 成本通知
  8833. /// </summary>
  8834. /// <param name="dto"></param>
  8835. /// <returns></returns>
  8836. [HttpPost]
  8837. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  8838. {
  8839. if (dto.Diid < 0)
  8840. {
  8841. return Ok(JsonView(false));
  8842. }
  8843. JsonView jw = null;
  8844. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  8845. if (GroupCostParameter != null)
  8846. {
  8847. int IsShare = 0;
  8848. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  8849. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  8850. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  8851. string msg = string.Empty;
  8852. if (isTrue)
  8853. {
  8854. if (IsShare == 0)
  8855. {
  8856. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  8857. }
  8858. else
  8859. {
  8860. #region 企微通知对应岗位用户
  8861. try
  8862. {
  8863. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  8864. }
  8865. catch (Exception ex)
  8866. {
  8867. }
  8868. #endregion
  8869. msg = "通知成功,其他模块操作人员可见此成本信息!";
  8870. }
  8871. jw = JsonView(isTrue, msg, new { IsShare });
  8872. }
  8873. else
  8874. {
  8875. msg = "修改失败!";
  8876. jw = JsonView(isTrue, msg);
  8877. }
  8878. }
  8879. else
  8880. {
  8881. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  8882. }
  8883. return Ok(jw);
  8884. }
  8885. /// <summary>
  8886. /// 导出报价单
  8887. /// </summary>
  8888. /// <param name="dto"></param>
  8889. /// <returns></returns>
  8890. [HttpPost]
  8891. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  8892. {
  8893. if (dto.Diid == 0)
  8894. {
  8895. return Ok(JsonView(false, "请传递团组id"));
  8896. }
  8897. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8898. if (deleInfo.Code != 0)
  8899. {
  8900. return Ok(JsonView(false, "团组信息查询失败!"));
  8901. }
  8902. var di = deleInfo.Data as DelegationInfoWebView;
  8903. if (di != null)
  8904. {
  8905. di.TeamName = di.TeamName.Replace("|", "、");
  8906. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  8907. //文件名
  8908. string strFileName = di.TeamName + "-收款账单.doc";
  8909. //获取模板
  8910. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  8911. //载入模板
  8912. Document doc = new Document(tmppath);
  8913. decimal TotalPrice = 0.00M;
  8914. string itemStr = string.Empty;
  8915. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  8916. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  8917. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  8918. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  8919. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  8920. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  8921. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  8922. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  8923. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  8924. foreach (var cost in groupCostType)
  8925. {
  8926. var List = cost.ToList();
  8927. if (cost.Key == "A")
  8928. {
  8929. foreach (var ListItem in List)
  8930. {
  8931. if (ListItem.number > 0)
  8932. {
  8933. if (ListItem.code.Contains("TBR"))
  8934. {
  8935. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8936. }
  8937. else
  8938. {
  8939. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8940. }
  8941. TotalPrice += (ListItem.number * ListItem.price);
  8942. }
  8943. }
  8944. }
  8945. else
  8946. {
  8947. itemStr = itemStr.Insert(0, "A段\r\n");
  8948. itemStr += "B段\r\n";
  8949. foreach (var ListItem in List)
  8950. {
  8951. if (ListItem.number > 0)
  8952. {
  8953. if (ListItem.code.Contains("TBR"))
  8954. {
  8955. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8956. }
  8957. else
  8958. {
  8959. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  8960. }
  8961. TotalPrice += (ListItem.number * ListItem.price);
  8962. }
  8963. }
  8964. }
  8965. }
  8966. #region 替换Word模板书签内容
  8967. Dictionary<string, string> marks = new Dictionary<string, string>();
  8968. marks.Add("To", di.ClientUnit);//付款方
  8969. marks.Add("ToTel", di.TellPhone);//付款方电话
  8970. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  8971. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  8972. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  8973. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  8974. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  8975. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  8976. marks.Add("PayItemContent", itemStr);//详细信息
  8977. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  8978. #endregion
  8979. ////注
  8980. //if (doc.Range.Bookmarks["Attention"] != null)
  8981. //{
  8982. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  8983. // mark.Text = frList[0].Attention;
  8984. //}
  8985. foreach (var item in marks.Keys)
  8986. {
  8987. if (doc.Range.Bookmarks[item] != null)
  8988. {
  8989. Bookmark mark = doc.Range.Bookmarks[item];
  8990. mark.Text = marks[item];
  8991. }
  8992. }
  8993. byte[] bytes = null;
  8994. using (MemoryStream stream = new MemoryStream())
  8995. {
  8996. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8997. bytes = stream.ToArray();
  8998. }
  8999. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  9000. return Ok(JsonView(true, "", new
  9001. {
  9002. Data = bytes,
  9003. strFileName,
  9004. }));
  9005. }
  9006. else
  9007. {
  9008. return Ok(JsonView(false, "团组信息不存在!"));
  9009. }
  9010. }
  9011. /// <summary>
  9012. /// 导出团组成本
  9013. /// </summary>
  9014. /// <param name="dto"></param>
  9015. /// <returns></returns>
  9016. [HttpPost]
  9017. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  9018. {
  9019. var jw = JsonView(false);
  9020. if (dto.Diid == 0)
  9021. {
  9022. return Ok(JsonView(false, "请传递团组id"));
  9023. }
  9024. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  9025. if (deleInfo.Code != 0)
  9026. {
  9027. return Ok(JsonView(false, "团组信息查询失败!"));
  9028. }
  9029. var di = deleInfo.Data as DelegationInfoWebView;
  9030. if (di == null)
  9031. {
  9032. return Ok(JsonView(false, "团组信息查询失败!"));
  9033. }
  9034. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  9035. WorkbookDesigner designer = new WorkbookDesigner();
  9036. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  9037. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  9038. for (int i = 0; i < List_GC.Count; i++)
  9039. {
  9040. GroupCost_Excel gc = new GroupCost_Excel();
  9041. gc.Id = List_GC[i].Id;
  9042. gc.Diid = List_GC[i].Diid.ToString();
  9043. gc.DAY = List_GC[i].DAY;
  9044. string week = "";
  9045. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  9046. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  9047. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  9048. gc.ITIN = List_GC[i].ITIN;
  9049. gc.CarType = List_GC[i].CarType;
  9050. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  9051. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  9052. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  9053. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  9054. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  9055. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  9056. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  9057. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  9058. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  9059. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  9060. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  9061. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  9062. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  9063. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  9064. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  9065. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  9066. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  9067. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  9068. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  9069. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  9070. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  9071. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  9072. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  9073. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  9074. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  9075. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  9076. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  9077. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  9078. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  9079. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  9080. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  9081. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  9082. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  9083. List_GC1.Add(gc);
  9084. }
  9085. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  9086. dt.TableName = "TB";
  9087. //报表标题等不用dt的值
  9088. designer.SetDataSource("TeamName", dto.title.TeamName);
  9089. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  9090. designer.SetDataSource("Tax", dto.title.Tax);
  9091. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  9092. designer.SetDataSource("Currency", dto.title.Currency);
  9093. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  9094. designer.SetDataSource("Rate", dto.title.Rate);
  9095. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  9096. var Aparams = hotels.Find(x => x.Type == "Default");
  9097. if (Aparams == null)
  9098. {
  9099. return Ok(jw);
  9100. }
  9101. //酒店数量
  9102. var txtSGRNumber = Aparams.SGR.ToString();
  9103. var txtTBRNumber = Aparams.TBR.ToString();
  9104. var txtJSESNumber = Aparams.JSES.ToString();
  9105. var txtSUITENumbe = Aparams.SUITE.ToString();
  9106. if (dto.costType == "B")
  9107. {
  9108. Aparams = hotels.Find(x => x.Type == "A");
  9109. var Bparams = hotels.Find(x => x.Type == "B");
  9110. if (Aparams == null || Bparams == null)
  9111. {
  9112. return Ok(jw);
  9113. }
  9114. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  9115. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  9116. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  9117. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  9118. }
  9119. designer.SetDataSource("SGRNumber", txtSGRNumber);
  9120. designer.SetDataSource("TBRNumber", txtTBRNumber);
  9121. designer.SetDataSource("JSESNumber", txtJSESNumber);
  9122. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  9123. var ws = designer.Workbook.Worksheets[0];
  9124. int Row = List_GC.Count;
  9125. int startIndex = 11;
  9126. int HideRows = 0;
  9127. List<int> hideRowsList = new List<int>();
  9128. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  9129. #region A段left数据
  9130. var left = dto.leftInfo.Find(x => x.Type == "A");
  9131. if (left == null)
  9132. {
  9133. return Ok(jw);
  9134. }
  9135. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  9136. if (leftBindData != null)
  9137. {
  9138. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  9139. designer.SetDataSource("VisaRS", leftBindData.rs);
  9140. designer.SetDataSource("VisaXS", leftBindData.xs);
  9141. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9142. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9143. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9144. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9145. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9146. }
  9147. else
  9148. {
  9149. hideRowsList.Add(Row + startIndex + HideRows);
  9150. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9151. }
  9152. HideRows += 2;
  9153. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  9154. if (leftBindData != null)
  9155. {
  9156. designer.SetDataSource("BXDRCB", leftBindData.cb);
  9157. designer.SetDataSource("BXRS", leftBindData.rs);
  9158. designer.SetDataSource("BXXS", leftBindData.xs);
  9159. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9160. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9161. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9162. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9163. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9164. }
  9165. else
  9166. {
  9167. hideRowsList.Add(Row + startIndex + HideRows);
  9168. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9169. }
  9170. HideRows += 2;
  9171. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  9172. if (leftBindData != null)
  9173. {
  9174. designer.SetDataSource("HSDRCB", leftBindData.cb);
  9175. designer.SetDataSource("HSRS", leftBindData.rs);
  9176. designer.SetDataSource("HSXS", leftBindData.xs);
  9177. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9178. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9179. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9180. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9181. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9182. }
  9183. else
  9184. {
  9185. hideRowsList.Add(Row + startIndex + HideRows);
  9186. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9187. }
  9188. HideRows += 2;
  9189. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  9190. if (leftBindData != null)
  9191. {
  9192. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  9193. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  9194. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  9195. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9196. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9197. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9198. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9199. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9200. }
  9201. else
  9202. {
  9203. hideRowsList.Add(Row + startIndex + HideRows);
  9204. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9205. }
  9206. HideRows += 2;
  9207. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  9208. if (leftBindData != null)
  9209. {
  9210. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  9211. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  9212. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  9213. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9214. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9215. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9216. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9217. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9218. }
  9219. else
  9220. {
  9221. hideRowsList.Add(Row + startIndex + HideRows);
  9222. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9223. }
  9224. HideRows += 2;
  9225. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  9226. if (leftBindData != null)
  9227. {
  9228. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  9229. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  9230. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  9231. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9232. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9233. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9234. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9235. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9236. }
  9237. else
  9238. {
  9239. hideRowsList.Add(Row + startIndex + HideRows);
  9240. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9241. }
  9242. HideRows += 2;
  9243. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  9244. if (leftBindData != null)
  9245. {
  9246. ////TBR
  9247. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  9248. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  9249. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  9250. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9251. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9252. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9253. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9254. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9255. }
  9256. else
  9257. {
  9258. hideRowsList.Add(Row + startIndex + HideRows);
  9259. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9260. }
  9261. HideRows += 2;
  9262. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  9263. if (leftBindData != null)
  9264. {
  9265. ////SGR
  9266. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  9267. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  9268. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  9269. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9270. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9271. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9272. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9273. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9274. }
  9275. else
  9276. {
  9277. hideRowsList.Add(Row + startIndex + HideRows);
  9278. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9279. }
  9280. HideRows += 2;
  9281. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  9282. if (leftBindData != null)
  9283. {
  9284. ////JS/ES
  9285. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  9286. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  9287. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  9288. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9289. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9290. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9291. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9292. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9293. }
  9294. else
  9295. {
  9296. hideRowsList.Add(Row + startIndex + HideRows);
  9297. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9298. }
  9299. HideRows += 2;
  9300. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  9301. if (leftBindData != null)
  9302. {
  9303. ////SUITE
  9304. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  9305. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  9306. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  9307. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9308. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9309. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9310. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9311. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9312. }
  9313. else
  9314. {
  9315. hideRowsList.Add(Row + startIndex + HideRows);
  9316. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9317. }
  9318. HideRows += 2;
  9319. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  9320. if (leftBindData != null)
  9321. {
  9322. designer.SetDataSource("DJDRCB", leftBindData.cb);
  9323. designer.SetDataSource("DJRS", leftBindData.rs);
  9324. designer.SetDataSource("DJXS", leftBindData.xs);
  9325. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9326. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9327. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9328. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9329. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9330. }
  9331. else
  9332. {
  9333. hideRowsList.Add(Row + startIndex + HideRows);
  9334. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9335. }
  9336. HideRows += 2;
  9337. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  9338. if (leftBindData != null)
  9339. {
  9340. designer.SetDataSource("HCPCB", leftBindData.cb);
  9341. designer.SetDataSource("HCPRS", leftBindData.rs);
  9342. designer.SetDataSource("HCPXS", leftBindData.xs);
  9343. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9344. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9345. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9346. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9347. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9348. }
  9349. else
  9350. {
  9351. hideRowsList.Add(Row + startIndex + HideRows);
  9352. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9353. }
  9354. HideRows += 2;
  9355. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  9356. if (leftBindData != null)
  9357. {
  9358. designer.SetDataSource("CPCB", leftBindData.cb);
  9359. designer.SetDataSource("CPRS", leftBindData.rs);
  9360. designer.SetDataSource("CPXS", leftBindData.xs);
  9361. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9362. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9363. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9364. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9365. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9366. }
  9367. else
  9368. {
  9369. hideRowsList.Add(Row + startIndex + HideRows);
  9370. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9371. }
  9372. HideRows += 2;
  9373. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  9374. if (leftBindData != null)
  9375. {
  9376. designer.SetDataSource("GWDRCD", leftBindData.cb);
  9377. designer.SetDataSource("GWRS", leftBindData.rs);
  9378. designer.SetDataSource("GWXS", leftBindData.xs);
  9379. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9380. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9381. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9382. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9383. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9384. }
  9385. else
  9386. {
  9387. hideRowsList.Add(Row + startIndex + HideRows);
  9388. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9389. }
  9390. HideRows += 2;
  9391. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  9392. if (leftBindData != null)
  9393. {
  9394. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  9395. designer.SetDataSource("LYJRS", leftBindData.rs);
  9396. designer.SetDataSource("LYJXS", leftBindData.xs);
  9397. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9398. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9399. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9400. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9401. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9402. }
  9403. else
  9404. {
  9405. hideRowsList.Add(Row + startIndex + HideRows);
  9406. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  9407. }
  9408. #endregion
  9409. #region A段Right信息
  9410. var right = dto.rightInfo.Find(x => x.Type == "A");
  9411. if (right == null)
  9412. {
  9413. return Ok(jw);
  9414. }
  9415. HideRows += 4;
  9416. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  9417. if (rightBindData != null)
  9418. {
  9419. //经济舱 + 双人间 TBR
  9420. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  9421. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  9422. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9423. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  9424. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9425. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9426. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9427. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9428. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9429. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9430. }
  9431. else
  9432. {
  9433. hideRowsList.Add(Row + startIndex + HideRows);
  9434. }
  9435. HideRows += 2;
  9436. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  9437. if (rightBindData != null)
  9438. {
  9439. //经济舱 + 单人间 SGR
  9440. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  9441. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  9442. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9443. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  9444. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9445. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9446. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9447. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9448. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9449. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9450. }
  9451. else
  9452. {
  9453. hideRowsList.Add(Row + startIndex + HideRows);
  9454. }
  9455. HideRows += 2;
  9456. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  9457. if (rightBindData != null)
  9458. {
  9459. //公务舱 + 单人间 SGR
  9460. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  9461. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  9462. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9463. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  9464. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9465. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9466. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9467. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9468. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9469. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9470. }
  9471. else
  9472. {
  9473. hideRowsList.Add(Row + startIndex + HideRows);
  9474. }
  9475. HideRows += 2;
  9476. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  9477. if (rightBindData != null)
  9478. {
  9479. //公务舱 + 小套房 JSES
  9480. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  9481. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  9482. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9483. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  9484. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9485. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9486. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9487. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9488. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9489. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9490. }
  9491. else
  9492. {
  9493. hideRowsList.Add(Row + startIndex + HideRows);
  9494. }
  9495. HideRows += 2;
  9496. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  9497. if (rightBindData != null)
  9498. {
  9499. //公务舱 + 小套房 JSES
  9500. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  9501. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  9502. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9503. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  9504. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9505. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9506. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9507. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9508. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9509. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9510. }
  9511. else
  9512. {
  9513. hideRowsList.Add(Row + startIndex + HideRows);
  9514. }
  9515. HideRows += 2;
  9516. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  9517. if (rightBindData != null)
  9518. {
  9519. //经济舱 + 大套房
  9520. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  9521. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  9522. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9523. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  9524. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9525. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9526. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9527. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9528. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9529. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9530. }
  9531. else
  9532. {
  9533. hideRowsList.Add(Row + startIndex + HideRows);
  9534. }
  9535. HideRows += 2;
  9536. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  9537. if (rightBindData != null)
  9538. {
  9539. //头等舱 + 小套房 JSES
  9540. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  9541. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  9542. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9543. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  9544. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9545. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9546. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9547. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9548. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9549. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9550. }
  9551. else
  9552. {
  9553. hideRowsList.Add(Row + startIndex + HideRows);
  9554. }
  9555. HideRows += 2;
  9556. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  9557. if (rightBindData != null)
  9558. {
  9559. //头等舱 + 大套房
  9560. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  9561. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  9562. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9563. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  9564. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9565. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9566. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9567. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9568. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9569. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9570. }
  9571. else
  9572. {
  9573. hideRowsList.Add(Row + startIndex + HideRows);
  9574. }
  9575. #endregion
  9576. #region B段标题清空
  9577. designer.SetDataSource("CostBDRCB", "");
  9578. designer.SetDataSource("CostBRS", "");
  9579. designer.SetDataSource("CostBXS", "");
  9580. designer.SetDataSource("CostBZCB", "");
  9581. designer.SetDataSource("CostBDRBJ", "");
  9582. designer.SetDataSource("CostBZBJ", "");
  9583. designer.SetDataSource("CostBDRLR", "");
  9584. designer.SetDataSource("CostBZLR", "");
  9585. designer.SetDataSource("CostBDRCBOM", "");
  9586. designer.SetDataSource("CostBRSOM", "");
  9587. designer.SetDataSource("CostBZCBOM", "");
  9588. designer.SetDataSource("CostBDRBJOM", "");
  9589. designer.SetDataSource("CostBZBJOM", "");
  9590. designer.SetDataSource("CostBDRLROM", "");
  9591. designer.SetDataSource("CostBZLROM", "");
  9592. #endregion
  9593. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  9594. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  9595. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  9596. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  9597. designer.SetDataSource("DJName", "地接(CNY)");
  9598. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  9599. designer.SetDataSource("CPName", "地接-船票(CNY)");
  9600. designer.SetDataSource("GWName", "公务(CNY)");
  9601. designer.SetDataSource("YQHName", "邀请函(CNY)");
  9602. designer.SetDataSource("LYJName", "零用金(CNY)");
  9603. designer.SetDataSource("HSName", "核酸检测(CNY)");
  9604. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  9605. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  9606. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  9607. designer.SetDataSource("BXName", "保险(CNY)");
  9608. designer.SetDataSource("VisaName", "签证(CNY)");
  9609. #region B段基本数据
  9610. if (dto.costType == "B")
  9611. {
  9612. left = dto.leftInfo.Find(x => x.Type == "B");
  9613. if (left == null)
  9614. {
  9615. return Ok(jw);
  9616. }
  9617. #region B段left数据
  9618. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  9619. if (leftBindData != null)
  9620. {
  9621. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  9622. designer.SetDataSource("BHSRS", leftBindData.rs);
  9623. designer.SetDataSource("BHSXS", leftBindData.xs);
  9624. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9625. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9626. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9627. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9628. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9629. }
  9630. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  9631. if (leftBindData != null)
  9632. {
  9633. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  9634. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  9635. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  9636. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9637. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9638. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9639. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9640. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9641. }
  9642. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  9643. if (leftBindData != null)
  9644. {
  9645. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  9646. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  9647. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  9648. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9649. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9650. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9651. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9652. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9653. }
  9654. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  9655. if (leftBindData != null)
  9656. {
  9657. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  9658. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  9659. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  9660. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9661. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9662. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9663. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9664. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9665. }
  9666. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  9667. if (leftBindData != null)
  9668. {
  9669. designer.SetDataSource("BHCPCB", leftBindData.cb);
  9670. designer.SetDataSource("BHCPRS", leftBindData.rs);
  9671. designer.SetDataSource("BHCPXS", leftBindData.xs);
  9672. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9673. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9674. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9675. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9676. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9677. }
  9678. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  9679. if (leftBindData != null)
  9680. {
  9681. designer.SetDataSource("BCPCB", leftBindData.cb);
  9682. designer.SetDataSource("BCPRS", leftBindData.rs);
  9683. designer.SetDataSource("BCPXS", leftBindData.xs);
  9684. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9685. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9686. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9687. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9688. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9689. }
  9690. //TBR
  9691. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  9692. if (leftBindData != null)
  9693. {
  9694. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  9695. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  9696. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  9697. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9698. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9699. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9700. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9701. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9702. }
  9703. //SGR
  9704. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  9705. if (leftBindData != null)
  9706. {
  9707. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  9708. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  9709. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  9710. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9711. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9712. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9713. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9714. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9715. }
  9716. //JS/ES
  9717. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  9718. if (leftBindData != null)
  9719. {
  9720. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  9721. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  9722. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  9723. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9724. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9725. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9726. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9727. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9728. }
  9729. //SUITE
  9730. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  9731. if (leftBindData != null)
  9732. {
  9733. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  9734. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  9735. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  9736. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9737. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9738. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9739. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9740. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9741. }
  9742. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  9743. if (leftBindData != null)
  9744. {
  9745. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  9746. designer.SetDataSource("BDJRS", leftBindData.rs);
  9747. designer.SetDataSource("BDJXS", leftBindData.xs);
  9748. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9749. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9750. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9751. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9752. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9753. }
  9754. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  9755. if (leftBindData != null)
  9756. {
  9757. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  9758. designer.SetDataSource("BGWRS", leftBindData.rs);
  9759. designer.SetDataSource("BGWXS", leftBindData.xs);
  9760. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9761. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9762. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9763. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9764. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9765. }
  9766. #region 优化方案
  9767. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  9768. //excelBind.Add("零用金", new {
  9769. //cb="",
  9770. //rs="",
  9771. //xs ="",
  9772. //zcb = "",
  9773. //});
  9774. #endregion
  9775. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  9776. if (leftBindData != null)
  9777. {
  9778. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  9779. designer.SetDataSource("BLYJRS", leftBindData.rs);
  9780. designer.SetDataSource("BLYJXS", leftBindData.xs);
  9781. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  9782. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  9783. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  9784. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  9785. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  9786. }
  9787. #endregion
  9788. #region B段Right信息
  9789. right = dto.rightInfo.Find(x => x.Type == "B");
  9790. if (right == null)
  9791. {
  9792. return Ok(jw);
  9793. }
  9794. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  9795. if (rightBindData != null)
  9796. {
  9797. //经济舱 + 双人间 TBR
  9798. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  9799. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  9800. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9801. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  9802. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9803. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9804. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9805. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9806. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9807. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9808. }
  9809. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  9810. if (rightBindData != null)
  9811. {
  9812. //经济舱 + 单人间 SGR
  9813. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  9814. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  9815. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9816. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  9817. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9818. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9819. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9820. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9821. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9822. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9823. }
  9824. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  9825. if (rightBindData != null)
  9826. {
  9827. //公务舱 + 单人间 SGR
  9828. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  9829. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  9830. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9831. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  9832. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9833. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9834. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9835. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9836. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9837. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9838. }
  9839. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  9840. if (rightBindData != null)
  9841. {
  9842. //公务舱 + 小套房 JSES
  9843. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  9844. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  9845. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9846. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  9847. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9848. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9849. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9850. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9851. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9852. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9853. }
  9854. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  9855. if (rightBindData != null)
  9856. {
  9857. //公务舱 + 小套房 JSES
  9858. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  9859. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  9860. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9861. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  9862. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9863. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9864. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9865. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9866. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9867. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9868. }
  9869. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  9870. if (rightBindData != null)
  9871. {
  9872. //经济舱 + 大套房
  9873. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  9874. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  9875. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9876. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  9877. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9878. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9879. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9880. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9881. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9882. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9883. }
  9884. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  9885. if (rightBindData != null)
  9886. {
  9887. //头等舱 + 小套房 JSES
  9888. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  9889. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  9890. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9891. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  9892. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9893. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9894. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9895. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9896. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9897. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9898. }
  9899. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  9900. if (rightBindData != null)
  9901. {
  9902. //头等舱 + 大套房
  9903. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  9904. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  9905. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  9906. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  9907. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  9908. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  9909. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  9910. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  9911. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  9912. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  9913. }
  9914. #endregion
  9915. #region 标题
  9916. designer.SetDataSource("CostBDRCB", "单人成本");
  9917. designer.SetDataSource("CostBRS", "人数");
  9918. designer.SetDataSource("CostBXS", "系数");
  9919. designer.SetDataSource("CostBZCB", "总成本");
  9920. designer.SetDataSource("CostBDRBJ", "单人报价");
  9921. designer.SetDataSource("CostBZBJ", "总报价");
  9922. designer.SetDataSource("CostBDRLR", "单人利润");
  9923. designer.SetDataSource("CostBZLR", "总利润");
  9924. designer.SetDataSource("CostBDRCBOM", "单人成本");
  9925. designer.SetDataSource("CostBRSOM", "人数");
  9926. designer.SetDataSource("CostBZCBOM", "总成本");
  9927. designer.SetDataSource("CostBDRBJOM", "单人报价");
  9928. designer.SetDataSource("CostBZBJOM", "总报价");
  9929. designer.SetDataSource("CostBDRLROM", "单人利润");
  9930. designer.SetDataSource("CostBZLROM", "总利润");
  9931. #endregion
  9932. }
  9933. #endregion
  9934. designer.SetDataSource("TzZCB2", TzZCB2);
  9935. designer.SetDataSource("TzZBJ2", TzZBJ2);
  9936. designer.SetDataSource("TzZLR2", TzZLR2);
  9937. string[] dataSourceKeys = new string[]
  9938. {
  9939. "VF",
  9940. "TGS",
  9941. "TGOF",
  9942. "TGM",
  9943. "TGA",
  9944. "TGTF",
  9945. "TGEF",
  9946. "CFM",
  9947. "CFOF",
  9948. "B",
  9949. "L",
  9950. "D",
  9951. "TBR",
  9952. "SGR",
  9953. "JSES",
  9954. "Suite",
  9955. "TV",
  9956. "1L",
  9957. "IF",
  9958. "EF",
  9959. "BRF",
  9960. "TE",
  9961. "TGT",
  9962. "DRVT",
  9963. "PC",
  9964. "TLF",
  9965. "ECT"
  9966. };
  9967. foreach (var item in dataSourceKeys)
  9968. {
  9969. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  9970. if (find != null)
  9971. {
  9972. designer.SetDataSource(item, find.text);
  9973. }
  9974. else
  9975. {
  9976. designer.SetDataSource(item, 0);
  9977. }
  9978. }
  9979. designer.SetDataSource(dt);
  9980. //根据数据源处理生成报表内容
  9981. designer.Process();
  9982. designer.Workbook.Worksheets[0].Name = "清单";
  9983. Worksheet sheet = designer.Workbook.Worksheets[0];
  9984. foreach (var Rowindex in hideRowsList)
  9985. {
  9986. ws.Cells.HideRows(Rowindex, 2);
  9987. }
  9988. byte[] bytes = null;
  9989. string strFileName = di.TeamName + "-团组-成本.xls";
  9990. using (MemoryStream stream = new MemoryStream())
  9991. {
  9992. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  9993. bytes = stream.ToArray();
  9994. }
  9995. return Ok(JsonView(true, "", new
  9996. {
  9997. Data = bytes,
  9998. strFileName,
  9999. }));
  10000. }
  10001. /// <summary>
  10002. /// 导出客户报表
  10003. /// </summary>
  10004. /// <returns></returns>
  10005. [HttpPost]
  10006. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  10007. {
  10008. var jw = JsonView(false);
  10009. if (dto.Diid == 0)
  10010. {
  10011. return Ok(JsonView(false, "请传递团组id"));
  10012. }
  10013. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  10014. if (deleInfo.Code != 0)
  10015. {
  10016. return Ok(JsonView(false, "团组信息查询失败!"));
  10017. }
  10018. var di = deleInfo.Data as DelegationInfoWebView;
  10019. if (di == null)
  10020. {
  10021. return Ok(JsonView(false, "团组信息查询失败!"));
  10022. }
  10023. //文件名
  10024. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  10025. //获取模板
  10026. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  10027. //载入模板
  10028. Document doc = new Document(tmppath);
  10029. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  10030. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  10031. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  10032. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  10033. var AParameter = ParameterList.Find(x => x.CostType == "A");
  10034. var BParameter = ParameterList.Find(x => x.CostType == "B");
  10035. if (AParameter == null)
  10036. {
  10037. return Ok(JsonView(false, "系数不存在!"));
  10038. }
  10039. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  10040. , TzAirDesc, TzZCost;
  10041. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  10042. = TzAirDesc = TzZCost = string.Empty;
  10043. TzNumber = AParameter.CostTypenumber.ToString();
  10044. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  10045. CarGuides1 = dto.CarGuides1;
  10046. Meal = dto.Meal;
  10047. SubsidizedMeals = dto.SubsidizedMeals;
  10048. NightRepair = dto.NightRepair;
  10049. AttractionsTickets = dto.AttractionsTickets;
  10050. MiscellaneousFees = dto.MiscellaneousFees;
  10051. ATip = dto.ATip;
  10052. TzHotelDesc = "";
  10053. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  10054. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  10055. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  10056. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  10057. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  10058. TzAirDesc = "";
  10059. TzZCost = dto.TzZCost;
  10060. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  10061. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  10062. var index = 1;
  10063. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  10064. foreach (var item in TzHotelDescArr)
  10065. {
  10066. if (AinfoArr != null)
  10067. {
  10068. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10069. if (Ainfo != null)
  10070. {
  10071. if (int.Parse(Ainfo.rs) <= 0)
  10072. {
  10073. continue;
  10074. }
  10075. var hotelText = string.Empty;
  10076. switch (item)
  10077. {
  10078. case "SGR":
  10079. hotelText = "单人间";
  10080. break;
  10081. case "JSES":
  10082. hotelText = "小套房";
  10083. break;
  10084. case "SUITE":
  10085. hotelText = "套房";
  10086. break;
  10087. case "TBR":
  10088. hotelText = "双人间";
  10089. break;
  10090. }
  10091. if (item != "TBR")
  10092. {
  10093. 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";
  10094. }
  10095. else
  10096. {
  10097. 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";
  10098. }
  10099. index++;
  10100. }
  10101. }
  10102. }
  10103. index = 1;
  10104. foreach (var item in TzAirDescArr)
  10105. {
  10106. if (AinfoArr != null)
  10107. {
  10108. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10109. if (Ainfo != null)
  10110. {
  10111. if (int.Parse(Ainfo.rs) <= 0)
  10112. {
  10113. continue;
  10114. }
  10115. 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";
  10116. index++;
  10117. }
  10118. }
  10119. }
  10120. if (dto.costType == "B")
  10121. {
  10122. if (BParameter == null)
  10123. {
  10124. return Ok(JsonView(false, "B段系数不存在!"));
  10125. }
  10126. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  10127. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  10128. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  10129. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  10130. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  10131. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  10132. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  10133. foreach (var item in TzHotelDescArr)
  10134. {
  10135. if (AinfoArr != null)
  10136. {
  10137. TzHotelDesc += "B段信息 \r\n";
  10138. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10139. if (Ainfo != null)
  10140. {
  10141. if (int.Parse(Ainfo.rs) <= 0)
  10142. {
  10143. continue;
  10144. }
  10145. var hotelText = string.Empty;
  10146. switch (item)
  10147. {
  10148. case "SGR":
  10149. hotelText = "单人间";
  10150. break;
  10151. case "JSES":
  10152. hotelText = "小套房";
  10153. break;
  10154. case "SUITE":
  10155. hotelText = "套房";
  10156. break;
  10157. case "TBR":
  10158. hotelText = "双人间";
  10159. break;
  10160. }
  10161. if (item != "TBR")
  10162. {
  10163. 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";
  10164. }
  10165. else
  10166. {
  10167. 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";
  10168. }
  10169. index++;
  10170. }
  10171. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  10172. }
  10173. }
  10174. index = 1;
  10175. foreach (var item in TzAirDescArr)
  10176. {
  10177. if (AinfoArr != null)
  10178. {
  10179. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  10180. if (Ainfo != null)
  10181. {
  10182. if (int.Parse(Ainfo.rs) <= 0)
  10183. {
  10184. continue;
  10185. }
  10186. 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";
  10187. index++;
  10188. }
  10189. }
  10190. }
  10191. }
  10192. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  10193. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  10194. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  10195. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  10196. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  10197. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  10198. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  10199. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  10200. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  10201. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  10202. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  10203. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  10204. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  10205. DickeyValue.Add("Visa", Visa); // 签证单人报价
  10206. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  10207. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  10208. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  10209. DickeyValue.Add("TzZCost", TzZCost);
  10210. foreach (var key in DickeyValue.Keys)
  10211. {
  10212. if (doc.Range.Bookmarks[key] != null)
  10213. {
  10214. Bookmark mark = doc.Range.Bookmarks[key];
  10215. mark.Text = DickeyValue[key];
  10216. }
  10217. }
  10218. byte[] bytes = null;
  10219. string strFileName = di.TeamName + "-客户报价.doc";
  10220. using (MemoryStream stream = new MemoryStream())
  10221. {
  10222. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  10223. bytes = stream.ToArray();
  10224. }
  10225. return Ok(JsonView(true, "", new
  10226. {
  10227. Data = bytes,
  10228. strFileName,
  10229. }));
  10230. }
  10231. /// <summary>
  10232. /// 团组成本 各模块(酒店,地接,机票)成本提示
  10233. /// </summary>
  10234. /// <param name="dto"></param>
  10235. /// <returns></returns>
  10236. [HttpPost]
  10237. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10238. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  10239. {
  10240. try
  10241. {
  10242. #region 参数验证
  10243. if (dto.DiId < 0)
  10244. {
  10245. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  10246. }
  10247. List<int> cTableIds = new List<int>() {
  10248. 76 ,//酒店预订
  10249. 77 ,//行程
  10250. 79 ,//车/导游地接
  10251. 80 ,//签证
  10252. 81 ,//邀请/公务活
  10253. 82 ,//团组客户保险
  10254. 85 ,//机票预订
  10255. 98 ,//其他款项
  10256. 285 ,//收款退还
  10257. 751 ,//酒店早餐
  10258. 1015 // 超支费用
  10259. };
  10260. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  10261. {
  10262. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  10263. }
  10264. #endregion
  10265. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  10266. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  10267. if (_GroupCostParameters.Count <= 0)
  10268. {
  10269. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  10270. }
  10271. if (_GroupCostParameters[0].IsShare == 0)
  10272. {
  10273. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  10274. }
  10275. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  10276. //处理date为空问题
  10277. if (_GroupCosts.Count > 0)
  10278. {
  10279. for (int i = 0; i < _GroupCosts.Count; i++)
  10280. {
  10281. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  10282. {
  10283. if (i > 0)
  10284. {
  10285. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  10286. }
  10287. }
  10288. }
  10289. }
  10290. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  10291. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  10292. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  10293. string currCode = "";
  10294. #region currCode 验证
  10295. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  10296. if (isInt)
  10297. {
  10298. var currData = currDatas.Find(it => it.Id == intCurrency);
  10299. if (currData != null)
  10300. {
  10301. currCode = currData.Name;
  10302. }
  10303. }
  10304. else
  10305. {
  10306. currCode = _GroupCostParameters[0].Currency.Trim();
  10307. }
  10308. #endregion
  10309. //op,酒店单段模式存储
  10310. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  10311. {
  10312. CurrencyCode = currCode,
  10313. Rate = _GroupCostParameters[0].Rate,
  10314. CostType = _GroupCostParameters[0].CostType,
  10315. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  10316. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  10317. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  10318. };
  10319. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  10320. if (_GroupCostParameters.Count == 2)
  10321. {
  10322. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  10323. }
  10324. foreach (var item in _GroupCostParameters)
  10325. {
  10326. decimal _rate = 1;
  10327. decimal _rate1 = item.Rate;
  10328. decimal _scale = 1;
  10329. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  10330. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  10331. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  10332. //if (userInfo != null)
  10333. //{
  10334. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  10335. // {
  10336. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  10337. // {
  10338. // _scale = 1.00M;
  10339. // }
  10340. // }
  10341. //}
  10342. #endregion
  10343. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  10344. {
  10345. CurrencyCode = currCode,
  10346. Rate = _rate1,
  10347. CostType = item.CostType,
  10348. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  10349. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  10350. CostTypeNumber = item.CostTypenumber
  10351. };
  10352. if (_GroupCostParameters.Count > 1)
  10353. {
  10354. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  10355. }
  10356. else
  10357. {
  10358. modulePromptInfo.CostTypeNumber = item.LYJRS;
  10359. }
  10360. if (dto.CTable == 79)//
  10361. {
  10362. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  10363. modulePromptInfo.TotalCost = item.DJCB;
  10364. }
  10365. List<string> costTypes = new List<string>() { "A", "B" };
  10366. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  10367. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  10368. if (_GroupCostsDuplicates.Count() == 1)
  10369. {
  10370. _GroupCostsTypeData = _GroupCosts;
  10371. }
  10372. else
  10373. {
  10374. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  10375. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  10376. }
  10377. /*
  10378. * 76 酒店预订
  10379. * 77 行程
  10380. * 79 车/导游地接
  10381. * 80 签证
  10382. * 81 邀请/公务活动
  10383. * 82 团组客户保险
  10384. * 85 机票预订
  10385. * 98 其他款项
  10386. * 285 收款退还
  10387. * 751 酒店早餐
  10388. * 1015 超支费用
  10389. */
  10390. switch (dto.CTable)
  10391. {
  10392. case 76: // 酒店预订
  10393. _ModuleSubPromptInfo.AddRange(
  10394. _GroupCostsTypeData.Select(it => new
  10395. {
  10396. it.DAY,
  10397. it.Date,
  10398. it.ACCON,
  10399. it.ITIN,
  10400. it.SGR,
  10401. it.TBR,
  10402. it.JS_ES,
  10403. it.Suite
  10404. })
  10405. );
  10406. break;
  10407. case 79: // 车/导游地接
  10408. _ModuleSubPromptInfo.AddRange(
  10409. _GroupCostsTypeData.Select(it => new
  10410. {
  10411. Date = it.Date, //日期
  10412. CarFee = it.CarCost * _rate * _scale, //车费用
  10413. CarType = it.CarType, //车型
  10414. DriverFee = it.CFS * _rate * _scale, //司机工资
  10415. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  10416. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  10417. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  10418. GuideFee = it.TGS * _rate * _scale, //导游费用
  10419. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  10420. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  10421. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  10422. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  10423. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  10424. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  10425. Breakfast = it.B * _rate * _scale, //早餐费
  10426. Lunch = it.L * _rate * _scale, //午餐费
  10427. Dinner = it.D * _rate * _scale, //晚餐费
  10428. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  10429. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  10430. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  10431. TicketFee = it.EF * _rate * _scale, //门票费
  10432. TicketRemark = it.EFR, //门票费描述
  10433. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  10434. TravelSupplies = it.TE * _rate * _scale, //出行物资
  10435. SpentCash = it.PC * _rate * _scale, //零用金
  10436. LeadersFee = it.TLF * _rate * _scale, //领队费
  10437. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  10438. })
  10439. );
  10440. break;
  10441. case 85: // 机票
  10442. List<dynamic> datas = new List<dynamic>();
  10443. datas.Add(
  10444. new
  10445. {
  10446. AirType = "经济舱",
  10447. AirNum = item.JJCRS,
  10448. AirDRCB = item.JJCCB,
  10449. AirZCB = (item.JJCRS * item.JJCCB)
  10450. }
  10451. );
  10452. datas.Add(
  10453. new
  10454. {
  10455. AirType = "公务舱",
  10456. AirNum = item.GWCRS,
  10457. AirDRCB = item.GWCCB,
  10458. AirZCB = (item.GWCRS * item.GWCCB)
  10459. }
  10460. );
  10461. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  10462. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  10463. modulePromptInfo.Data = new
  10464. {
  10465. airFeeData = datas,
  10466. airInitData = initDatas
  10467. };
  10468. _ModulePromptInfos.Add(modulePromptInfo);
  10469. break;
  10470. default:
  10471. break;
  10472. }
  10473. }
  10474. if (dto.CTable != 85)
  10475. {
  10476. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  10477. _ModulePromptInfos.Add(_ModulePromptInfo);
  10478. }
  10479. _view.ModulePromptInfos = _ModulePromptInfos;
  10480. return Ok(JsonView(true, "操作成功!", _view));
  10481. }
  10482. catch (Exception ex)
  10483. {
  10484. return Ok(JsonView(false, ex.Message));
  10485. }
  10486. }
  10487. /// <summary>
  10488. /// 根据黑屏代码重新生成行程
  10489. /// </summary>
  10490. /// <param name="dto"></param>
  10491. /// <returns></returns>
  10492. [HttpPost]
  10493. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  10494. {
  10495. var jw = JsonView(false);
  10496. var Create = _GroupCostRepository.
  10497. CreateGroupCostByBlackCode(dto.Diid);
  10498. jw.Msg = Create.Msg;
  10499. if (Create.Code == 0)
  10500. {
  10501. jw.Code = 200;
  10502. jw.Data = new
  10503. {
  10504. groupCost = Create.Data,
  10505. blackCodeIsTrue = true
  10506. };
  10507. }
  10508. else
  10509. {
  10510. jw.Code = 400;
  10511. jw.Data = new
  10512. {
  10513. groupCost = Create.Data,
  10514. blackCodeIsTrue = false,
  10515. };
  10516. }
  10517. return Ok(jw);
  10518. }
  10519. /// <summary>
  10520. /// 成本获取OP历史车费用
  10521. /// </summary>
  10522. /// <param name="dto"></param>
  10523. /// <returns></returns>
  10524. [HttpPost]
  10525. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  10526. {
  10527. var jw = JsonView(false);
  10528. try
  10529. {
  10530. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  10531. //获取现有所有车的数据
  10532. if (!dto.Param.IsNullOrWhiteSpace())
  10533. {
  10534. string sql = $@"
  10535. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  10536. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  10537. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  10538. 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
  10539. AND gctggr.ServiceEndTime is not NULL
  10540. ORDER by gctggrc.id DESC
  10541. ";
  10542. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  10543. var numeberResult = await Task.Run(() =>
  10544. {
  10545. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  10546. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  10547. return numberArr;
  10548. });
  10549. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  10550. foreach (var item in numeberResult)
  10551. {
  10552. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  10553. {
  10554. Country = "数据异常!",
  10555. City = string.Empty,
  10556. };
  10557. item.Area = find.Country + " " + find.City;
  10558. }
  10559. dbResult.AddRange(numeberResult);
  10560. if (dto.Param.Contains("、"))
  10561. {
  10562. var sp = dto.Param.Split("、");
  10563. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  10564. .Where(x =>
  10565. {
  10566. return System.Array.Exists(sp, e =>
  10567. {
  10568. bool where = false;
  10569. if (x.Area != null)
  10570. {
  10571. where = x.Area.Contains(e);
  10572. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  10573. {
  10574. return false;
  10575. }
  10576. }
  10577. if (x.PriceName != null && !where)
  10578. {
  10579. where = x.PriceName.Contains(e);
  10580. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  10581. {
  10582. return false;
  10583. }
  10584. }
  10585. return where;
  10586. });
  10587. }).ToList();
  10588. }
  10589. else
  10590. {
  10591. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  10592. .Where(x =>
  10593. {
  10594. bool where = false;
  10595. if (x.Area != null)
  10596. {
  10597. where = x.Area.Contains(dto.Param);
  10598. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  10599. {
  10600. return false;
  10601. }
  10602. }
  10603. if (x.PriceName != null && !where)
  10604. {
  10605. where = x.PriceName.Contains(dto.Param);
  10606. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  10607. {
  10608. return false;
  10609. }
  10610. }
  10611. return where;
  10612. }
  10613. )
  10614. .ToList();
  10615. }
  10616. }
  10617. var view = dbResult.Select(x =>
  10618. {
  10619. decimal dp = 0.00M;
  10620. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  10621. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  10622. if (string.IsNullOrWhiteSpace(x.DatePrice))
  10623. {
  10624. if (startB && endB)
  10625. {
  10626. var timesp = endD.Subtract(startD);
  10627. if ((timesp.Days + 1) != 0)
  10628. {
  10629. dp = x.Price / (timesp.Days + 1);
  10630. }
  10631. }
  10632. }
  10633. else
  10634. {
  10635. dp = x.Price;
  10636. }
  10637. return new
  10638. {
  10639. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  10640. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  10641. x.Area,
  10642. x.id,
  10643. price = x.Price.ToString("F2"),
  10644. x.PriceName,
  10645. x.PriceContent,
  10646. x.TeamName,
  10647. x.DatePrice,
  10648. dayPrice = dp.ToString("F2"),
  10649. };
  10650. }).OrderByDescending(x => x.id).ToList();
  10651. jw = JsonView(true, "获取成功!", view);
  10652. }
  10653. catch (Exception e)
  10654. {
  10655. jw = JsonView(false, e.Message);
  10656. }
  10657. return Ok(jw);
  10658. }
  10659. #endregion
  10660. #region 酒店预订 新 雷怡 2023-12-28 17:45
  10661. /// <summary>
  10662. /// 酒店预订
  10663. /// 酒店费用列表 根据团组Id查询
  10664. /// </summary>
  10665. /// <param name="_dto"></param>
  10666. /// <returns></returns>
  10667. [HttpPost]
  10668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10669. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  10670. {
  10671. #region 参数验证
  10672. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10673. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10674. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10675. #region 团组操作权限验证 76 酒店预定模块
  10676. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10677. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10678. #endregion
  10679. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10680. #region 页面操作权限验证
  10681. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10682. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10683. #endregion
  10684. #endregion
  10685. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  10686. }
  10687. /// <summary>
  10688. /// 酒店预订
  10689. /// 基础数据
  10690. /// </summary>
  10691. /// <param name="_dto"></param>
  10692. /// <returns></returns>
  10693. [HttpPost]
  10694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10695. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  10696. {
  10697. #region 参数验证
  10698. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10699. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10700. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10701. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10702. #region 页面操作权限验证
  10703. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10704. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10705. #endregion
  10706. #region 团组操作权限验证 76 酒店预定模块
  10707. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10708. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10709. #endregion
  10710. #endregion
  10711. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  10712. }
  10713. /// <summary>
  10714. /// 酒店预订
  10715. /// 创建 入住卷号码
  10716. /// </summary>
  10717. /// <param name="_dto"></param>
  10718. /// <returns></returns>
  10719. [HttpPost]
  10720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10721. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  10722. {
  10723. #region 参数验证
  10724. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10725. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10726. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10727. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10728. #region 页面操作权限验证
  10729. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10730. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10731. #endregion
  10732. #region 团组操作权限验证 76 酒店预定模块
  10733. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10734. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10735. #endregion
  10736. #endregion
  10737. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  10738. if (data.Code != 0)
  10739. {
  10740. return Ok(JsonView(false, data.Msg));
  10741. }
  10742. return Ok(JsonView(true, data.Msg, data.Data));
  10743. }
  10744. /// <summary>
  10745. /// 酒店预订
  10746. /// 详情
  10747. /// </summary>
  10748. /// <param name="_dto"></param>
  10749. /// <returns></returns>
  10750. [HttpPost]
  10751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10752. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  10753. {
  10754. #region 参数验证
  10755. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  10756. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10757. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  10758. #region 团组操作权限验证 76 酒店预定模块
  10759. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10760. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10761. #endregion
  10762. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10763. #region 页面操作权限验证
  10764. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10765. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10766. #endregion
  10767. #endregion
  10768. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  10769. }
  10770. /// <summary>
  10771. /// 酒店预订
  10772. /// Add Or Edit
  10773. /// </summary>
  10774. /// <param name="_dto"></param>
  10775. /// <returns></returns>
  10776. [HttpPost]
  10777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10778. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  10779. {
  10780. #region 参数验证
  10781. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10782. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10783. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10784. #region 团组操作权限验证 76 酒店预定模块
  10785. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10786. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10787. #endregion
  10788. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10789. #region 页面操作权限验证
  10790. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10791. if (_dto.Id == 0) // Add
  10792. {
  10793. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10794. }
  10795. else if (_dto.Id > 1) // Edit
  10796. {
  10797. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10798. }
  10799. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  10800. #endregion
  10801. #endregion
  10802. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  10803. if (_view.Code != 200)
  10804. {
  10805. return Ok(_view);
  10806. }
  10807. #region 成本无酒店价格数据进入超支
  10808. _sqlSugar.BeginTran();
  10809. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  10810. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  10811. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  10812. for (int i = 0; i < groupCost.Count; i++)
  10813. {
  10814. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  10815. {
  10816. groupCost[i].Date = groupCost[i - 1].Date;
  10817. }
  10818. }
  10819. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  10820. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  10821. List<Fin_GroupExtraCostDto_OP>();
  10822. if (start_Bool && end_Bool)
  10823. {
  10824. while (start_Time < end_Time)
  10825. {
  10826. foreach (var item in groupCost_Grp)
  10827. {
  10828. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  10829. {
  10830. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  10831. {
  10832. extraCostList.Add(new
  10833. Fin_GroupExtraCostDto_OP
  10834. {
  10835. Area = _dto.AreaId,
  10836. coefficient = 1.5M,
  10837. createUser = _dto.UserId,
  10838. currency = _dto.CardPriceCurrency,
  10839. diId = _dto.DiId,
  10840. ManagerConfirm = 0,
  10841. SupervisorConfirm = 0,
  10842. SYsupervisorConfirm = 0,
  10843. editType = 1,
  10844. PortType = 1,
  10845. price = _dto.CardPrice,
  10846. PriceCount = 1,
  10847. priceType = 1027,
  10848. priceDetailType = 1044,
  10849. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  10850. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  10851. });
  10852. }
  10853. }
  10854. }
  10855. start_Time = start_Time.AddDays(1);
  10856. }
  10857. }
  10858. if (extraCostList.Any())
  10859. {
  10860. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  10861. }
  10862. _sqlSugar.CommitTran();
  10863. #endregion
  10864. #region 应用推送
  10865. try
  10866. {
  10867. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  10868. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  10869. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  10870. var diId = _dto.DiId;
  10871. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10872. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10873. #region 操作记录
  10874. var opInfo = new Crm_TableOperationRecord() {
  10875. TableName = "Grp_HotelReservations",
  10876. PortType = _dto.PortType,
  10877. DataId = hotelId,
  10878. CreateUserId = _dto.UserId
  10879. };
  10880. var opStatus = OperationEnum.NoOperation;
  10881. if (_dto.Id<1) //添加操作
  10882. {
  10883. opInfo.OperationItem = OperationEnum.Add;
  10884. }
  10885. else if (_dto.Id > 0)
  10886. {
  10887. opInfo.OperationItem = OperationEnum.Edit;
  10888. }
  10889. string opRemark = string.Empty;
  10890. if (ccpInfo != null)
  10891. {
  10892. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  10893. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  10894. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  10895. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  10896. }
  10897. opInfo.Remark = opRemark;
  10898. await _tableorRep.AddAsync(opInfo);
  10899. #endregion
  10900. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  10901. //2024-10-21 新增LZ UID
  10902. var userIds = new List<int>() { 21 };
  10903. string title = $"费用审核";
  10904. string content = "";
  10905. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10906. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10907. try
  10908. {
  10909. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10910. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  10911. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  10912. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  10913. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  10914. }
  10915. catch (Exception ex )
  10916. {
  10917. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  10918. }
  10919. }
  10920. catch (Exception ex)
  10921. {
  10922. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  10923. }
  10924. try
  10925. {
  10926. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  10927. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  10928. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  10929. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10930. //自动审核
  10931. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  10932. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  10933. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  10934. //2024-10-21 新增LZ UID
  10935. var userIds = new List<int>() { 21 };
  10936. string title = $"系统通知";
  10937. var diId = _dto.DiId;
  10938. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10939. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10940. string content = "";
  10941. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10942. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10943. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10944. }
  10945. catch (Exception ex)
  10946. {
  10947. }
  10948. #endregion
  10949. return Ok(_view);
  10950. }
  10951. /// <summary>
  10952. /// 酒店自动审核测试
  10953. /// Add Or Edit
  10954. /// </summary>
  10955. /// <param name="_dto"></param>
  10956. /// <returns></returns>
  10957. [HttpPost]
  10958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10959. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  10960. {
  10961. #region 应用推送
  10962. try
  10963. {
  10964. //自动审核
  10965. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  10966. }
  10967. catch (Exception ex)
  10968. {
  10969. return Ok(JsonView(false, "操作失败"));
  10970. }
  10971. #endregion
  10972. return Ok(JsonView(false, "操作成功"));
  10973. }
  10974. /// <summary>
  10975. /// 酒店预订
  10976. /// Del
  10977. /// </summary>
  10978. /// <param name="_dto"></param>
  10979. /// <returns></returns>
  10980. [HttpPost]
  10981. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10982. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  10983. {
  10984. #region 参数验证
  10985. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10986. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10987. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  10988. #region 团组操作权限验证 76 酒店预定模块
  10989. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10990. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  10991. #endregion
  10992. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10993. #region 页面操作权限验证
  10994. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10995. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  10996. #endregion
  10997. #endregion
  10998. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  10999. #region 操作记录
  11000. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  11001. {
  11002. TableName = "Grp_HotelReservations",
  11003. PortType = _dto.PortType,
  11004. OperationItem = OperationEnum.Del,
  11005. DataId = _dto.Id,
  11006. CreateUserId = _dto.UserId
  11007. });
  11008. #endregion
  11009. return Ok(data);
  11010. }
  11011. /// <summary>
  11012. /// 酒店预订
  11013. /// 生成VOUCHER
  11014. /// 2024.05.06 之前版本
  11015. /// </summary>
  11016. /// <param name="_dto"></param>
  11017. /// <returns></returns>
  11018. [HttpPost]
  11019. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11020. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  11021. {
  11022. try
  11023. {
  11024. #region 参数验证
  11025. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11026. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11027. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  11028. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  11029. #region 团组操作权限验证 76 酒店预定模块
  11030. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11031. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  11032. #endregion
  11033. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11034. #region 页面操作权限验证
  11035. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11036. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11037. #endregion
  11038. #endregion
  11039. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  11040. //判断数据是否完整
  11041. if (hr != null)
  11042. {
  11043. if (!string.IsNullOrEmpty(hr.DetermineNo))
  11044. {
  11045. string strFileName = "HotelStatement/";
  11046. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  11047. if (dele != null)
  11048. strFileName += dele.TourCode;
  11049. //载入模板
  11050. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  11051. Document doc = new Document(sss);
  11052. DocumentBuilder builder = new DocumentBuilder(doc);
  11053. #region 替换Word模板书签内容
  11054. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  11055. //入住卷预定号码
  11056. if (doc.Range.Bookmarks["VNO"] != null)
  11057. {
  11058. Bookmark mark = doc.Range.Bookmarks["VNO"];
  11059. mark.Text = hr.CheckNumber;
  11060. }
  11061. //酒店时间
  11062. if (doc.Range.Bookmarks["Date"] != null)
  11063. {
  11064. Bookmark mark = doc.Range.Bookmarks["Date"];
  11065. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  11066. }
  11067. //团号
  11068. if (doc.Range.Bookmarks["TNo"] != null)
  11069. {
  11070. Bookmark mark = doc.Range.Bookmarks["TNo"];
  11071. mark.Text = dele.TourCode;
  11072. }
  11073. //预定号码
  11074. if (doc.Range.Bookmarks["BookingId"] != null)
  11075. {
  11076. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  11077. mark.Text = hr.ReservationsNo;
  11078. }
  11079. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  11080. {
  11081. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  11082. mark.Text = hr.DetermineNo;
  11083. }
  11084. //酒店城市
  11085. if (doc.Range.Bookmarks["City"] != null)
  11086. {
  11087. Bookmark mark = doc.Range.Bookmarks["City"];
  11088. mark.Text = hr.City;
  11089. }
  11090. //酒店名称
  11091. if (doc.Range.Bookmarks["HName"] != null)
  11092. {
  11093. Bookmark mark = doc.Range.Bookmarks["HName"];
  11094. mark.Text = hr.HotelName;
  11095. }
  11096. //酒店地址
  11097. if (doc.Range.Bookmarks["Address"] != null)
  11098. {
  11099. Bookmark mark = doc.Range.Bookmarks["Address"];
  11100. mark.Text = hr.HotelAddress;
  11101. }
  11102. //酒店电话
  11103. if (doc.Range.Bookmarks["Tel"] != null)
  11104. {
  11105. Bookmark mark = doc.Range.Bookmarks["Tel"];
  11106. mark.Text = hr.HotelTel;
  11107. }
  11108. //酒店传真
  11109. if (doc.Range.Bookmarks["Fax"] != null)
  11110. {
  11111. Bookmark mark = doc.Range.Bookmarks["Fax"];
  11112. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  11113. {
  11114. mark.Text = hr.HotelFax;
  11115. }
  11116. }
  11117. //入住时间
  11118. if (doc.Range.Bookmarks["CIn"] != null)
  11119. {
  11120. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  11121. Bookmark mark = doc.Range.Bookmarks["CIn"];
  11122. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  11123. }
  11124. //退房时间
  11125. if (doc.Range.Bookmarks["COut"] != null)
  11126. {
  11127. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  11128. Bookmark mark = doc.Range.Bookmarks["COut"];
  11129. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  11130. }
  11131. //客户名称
  11132. if (doc.Range.Bookmarks["GName"] != null)
  11133. {
  11134. string guestName = "";
  11135. string[] clients = new string[] { };
  11136. if (hr.GuestName.Contains(","))
  11137. {
  11138. clients = hr.GuestName.Split(",");
  11139. }
  11140. else
  11141. {
  11142. clients = new string[] { hr.GuestName };
  11143. }
  11144. List<int> clientIds_int = new List<int>();
  11145. if (clients.Length > 0)
  11146. {
  11147. foreach (var item in clients)
  11148. {
  11149. if (item.IsNumeric())
  11150. {
  11151. clientIds_int.Add(int.Parse(item));
  11152. }
  11153. }
  11154. }
  11155. if (clientIds_int.Count > 0)
  11156. {
  11157. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  11158. foreach (var client in _clientDatas)
  11159. {
  11160. //男
  11161. if (client.Sex == 0) guestName += $"Mr.";
  11162. //女
  11163. else if (client.Sex == 1) guestName += $"Ms.";
  11164. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  11165. {
  11166. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  11167. }
  11168. //guestName += $"{client.Pinyin},";
  11169. }
  11170. if (guestName.Length > 0)
  11171. {
  11172. guestName = guestName.Substring(0, guestName.Length - 1);
  11173. }
  11174. }
  11175. else
  11176. {
  11177. guestName = hr.GuestName;
  11178. }
  11179. Bookmark mark = doc.Range.Bookmarks["GName"];
  11180. mark.Text = guestName;
  11181. }
  11182. //房间介绍
  11183. if (doc.Range.Bookmarks["ROOM"] != null)
  11184. {
  11185. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  11186. mark.Text = hr.RoomExplanation;
  11187. }
  11188. //报价描述
  11189. if (doc.Range.Bookmarks["NOTE"] != null)
  11190. {
  11191. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  11192. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  11193. if (ss != null)
  11194. mark.Text = ss.Name;
  11195. }
  11196. //入住时间
  11197. if (doc.Range.Bookmarks["CheckIn"] != null)
  11198. {
  11199. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  11200. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  11201. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  11202. }
  11203. //退房时间
  11204. if (doc.Range.Bookmarks["CheckOut"] != null)
  11205. {
  11206. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  11207. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  11208. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  11209. }
  11210. //日期
  11211. if (doc.Range.Bookmarks["DT"] != null)
  11212. {
  11213. Bookmark mark = doc.Range.Bookmarks["DT"];
  11214. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  11215. }
  11216. //名称
  11217. if (doc.Range.Bookmarks["VName"] != null)
  11218. {
  11219. Bookmark mark = doc.Range.Bookmarks["VName"];
  11220. mark.Text = hr.HotelName;
  11221. }
  11222. //号码
  11223. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  11224. {
  11225. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  11226. mark.Text = hr.CheckNumber;
  11227. }
  11228. #endregion
  11229. strFileName += "VOUCHER.doc";
  11230. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11231. doc.Save(fileDir);
  11232. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11233. return Ok(JsonView(true, "操作成功!", Url));
  11234. }
  11235. else
  11236. {
  11237. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  11238. }
  11239. }
  11240. else
  11241. {
  11242. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  11243. }
  11244. }
  11245. catch (Exception ex)
  11246. {
  11247. return Ok(JsonView(false, ex.Message));
  11248. }
  11249. }
  11250. /// <summary>
  11251. /// 酒店预订
  11252. /// 生成VOUCHER
  11253. /// 2024.05.06 之后版本
  11254. /// </summary>
  11255. /// <param name="_dto"></param>
  11256. /// <returns></returns>
  11257. [HttpPost]
  11258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11259. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  11260. {
  11261. #region 参数验证
  11262. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11263. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  11264. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11265. #region 团组操作权限验证 76 酒店预定模块
  11266. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11267. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11268. #endregion
  11269. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11270. #region 页面操作权限验证
  11271. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11272. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11273. #endregion
  11274. #endregion
  11275. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  11276. //判断数据是否完整
  11277. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  11278. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  11279. string strFileName = "HotelStatement/";
  11280. string guestNames = ""; //格式Mr.xxx Ms.xxx
  11281. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  11282. #region 数据处理
  11283. List<int> guestIds = new List<int>();
  11284. int index = 0;
  11285. foreach (var item in hrDtas)
  11286. {
  11287. if (item.GuestName.Contains(","))
  11288. {
  11289. string[] guestIdArr = item.GuestName.Split(',');
  11290. foreach (var guestIdStr in guestIdArr)
  11291. {
  11292. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  11293. if (guestBool)
  11294. {
  11295. guestIds.Add(guestId);
  11296. }
  11297. }
  11298. }
  11299. else guestNames += item.GuestName;
  11300. var voucherInfo = new HotelVoucherInfoView()
  11301. {
  11302. HotelName = item.HotelName,
  11303. CheckInDate = item.CheckInDate,
  11304. CheckOutDate = item.CheckOutDate,
  11305. ConfirmationNumber = item.DetermineNo.Trim(),
  11306. RoomType = item.RoomExplanation
  11307. };
  11308. vouchers.Add(voucherInfo);
  11309. }
  11310. if (guestIds.Count > 0)
  11311. {
  11312. guestIds = guestIds.Distinct().ToList();
  11313. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  11314. if (guestDatas.Count > 0)
  11315. {
  11316. guestNames = "";
  11317. foreach (var guest in guestDatas)
  11318. {
  11319. string guestName = "";
  11320. if (guest.Sex == 0) guestName += @"MR.";
  11321. else if (guest.Sex == 1) guestName += @"MS.";
  11322. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  11323. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  11324. guestNames += @$"{guestName.Trim()}、";
  11325. }
  11326. if (guestNames.Length > 0)
  11327. {
  11328. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  11329. }
  11330. }
  11331. }
  11332. #endregion
  11333. //载入模板
  11334. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  11335. Document doc = new Document(sss);
  11336. DocumentBuilder builder = new DocumentBuilder(doc);
  11337. if (doc.Range.Bookmarks["GuestName"] != null)
  11338. {
  11339. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  11340. mark.Text = guestNames;
  11341. }
  11342. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11343. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  11344. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  11345. for (int i = 1; i <= vouchers.Count; i++)
  11346. {
  11347. HotelVoucherInfoView hviv = vouchers[i - 1];
  11348. builder.MoveToCell(0, i, 0, 0);
  11349. builder.Write(hviv.HotelName);
  11350. builder.MoveToCell(0, i, 1, 0);
  11351. builder.Write(hviv.CheckInDate);
  11352. builder.MoveToCell(0, i, 2, 0);
  11353. builder.Write(hviv.CheckOutDate);
  11354. builder.MoveToCell(0, i, 3, 0);
  11355. builder.Write(hviv.RoomType);
  11356. builder.MoveToCell(0, i, 4, 0);
  11357. builder.Write(hviv.ConfirmationNumber);
  11358. }
  11359. //删除多余行
  11360. int currRowIndex = vouchers.Count + 1;
  11361. int delRows = 21 - currRowIndex;
  11362. if (delRows > 0)
  11363. {
  11364. for (int i = 0; i < delRows; i++)
  11365. {
  11366. table.Rows.RemoveAt(currRowIndex);
  11367. //cultivateRowIndex++;
  11368. }
  11369. }
  11370. strFileName += "VOUCHER.docx";
  11371. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11372. doc.Save(fileDir);
  11373. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11374. return Ok(JsonView(true, "操作成功!", Url));
  11375. }
  11376. /// <summary>
  11377. /// 酒店预订
  11378. /// 生成VOUCHER 批量生成
  11379. /// New
  11380. /// </summary>
  11381. /// <param name="_dto"></param>
  11382. /// <returns></returns>
  11383. [HttpPost]
  11384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11385. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  11386. {
  11387. #region 参数验证
  11388. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  11389. if (_dto.PageId < 1) _dto.PageId = 28;
  11390. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  11391. #region 团组操作权限验证 76 酒店预定模块
  11392. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11393. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  11394. #endregion
  11395. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11396. #region 页面操作权限验证
  11397. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11398. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11399. #endregion
  11400. #endregion
  11401. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  11402. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  11403. .OrderBy(x => x.CheckInDate)
  11404. .ToListAsync();
  11405. //判断数据是否完整
  11406. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  11407. string strFileName = "HotelStatement/";
  11408. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  11409. if (dele != null)
  11410. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  11411. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  11412. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  11413. .Where(it => it.IsDel == 0)
  11414. .ToListAsync();
  11415. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  11416. for (int i = 0; i < hrDtas.Count; i++)
  11417. {
  11418. string guestNames = string.Empty;
  11419. List<int> guestIds = new List<int>();
  11420. var item = hrDtas[i];
  11421. //处理客户姓名
  11422. if (item.GuestName.Contains(","))
  11423. {
  11424. string[] guestIdArr = item.GuestName.Split(',');
  11425. foreach (var guestIdStr in guestIdArr)
  11426. if (int.TryParse(guestIdStr, out int guestId))
  11427. guestIds.Add(guestId);
  11428. }
  11429. else
  11430. {
  11431. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  11432. if (guestIdBool)
  11433. {
  11434. guestIds.Add(guestId);
  11435. }
  11436. //NaN
  11437. if (item.GuestName.Contains("NaN"))
  11438. {
  11439. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  11440. }
  11441. }
  11442. if (guestIds.Count > 0)
  11443. {
  11444. guestIds = guestIds.Distinct().ToList();
  11445. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  11446. if (guestDatas1.Count > 0)
  11447. {
  11448. guestNames = "";
  11449. foreach (var guest in guestDatas1)
  11450. {
  11451. string guestName = "";
  11452. if (guest.Sex == 0) guestName += @"MR.";
  11453. else if (guest.Sex == 1) guestName += @"MS.";
  11454. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  11455. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  11456. guestNames += @$"{guestName.Trim()}、";
  11457. }
  11458. if (guestNames.Length > 0)
  11459. {
  11460. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  11461. }
  11462. }
  11463. }
  11464. //if (!string.IsNullOrEmpty(guestNames))
  11465. //{
  11466. hrDtas[i].GuestName = guestNames;
  11467. //}
  11468. }
  11469. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  11470. Document doc = new Document();
  11471. DocumentBuilder builder = new DocumentBuilder(doc);
  11472. try
  11473. {
  11474. builder.MoveToDocumentStart();
  11475. foreach (var item in hrDtas)
  11476. {
  11477. //标题
  11478. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  11479. builder.ParagraphFormat.LineSpacing = 1;
  11480. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11481. builder.ParagraphFormat.Style.Font.Size = 9;
  11482. builder.ParagraphFormat.Style.Font.Bold = true;
  11483. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  11484. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  11485. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  11486. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  11487. builder.ParagraphFormat.LineSpacing = 1;
  11488. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11489. builder.ParagraphFormat.Style.Font.Size = 9;
  11490. builder.ParagraphFormat.Style.Font.Bold = true;
  11491. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  11492. builder.StartTable();
  11493. // 设置边框颜色
  11494. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  11495. //设置边框样式
  11496. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  11497. //表格
  11498. #region 第一行
  11499. builder.InsertCell();
  11500. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11501. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11502. //builder.CellFormat.AllowAutoFit = false;
  11503. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11504. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11505. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11506. builder.CellFormat.WrapText = true; //自动换行
  11507. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11508. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  11509. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11510. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11511. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11512. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11513. builder.Write("TOUR NO:");
  11514. builder.InsertCell();
  11515. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11516. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11517. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11518. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11519. builder.ParagraphFormat.Style.Font.Bold = false;
  11520. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11521. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11522. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11523. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11524. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11525. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11526. builder.Write($"{dele?.TourCode ?? "-"}");
  11527. builder.InsertCell();
  11528. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11529. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11530. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11531. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11532. builder.ParagraphFormat.Style.Font.Bold = false;
  11533. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11534. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11535. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11536. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11537. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11538. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11539. builder.Write($"CITY:");
  11540. builder.InsertCell();
  11541. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11542. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11543. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11544. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11545. builder.ParagraphFormat.Style.Font.Bold = false;
  11546. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11547. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11548. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11549. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11550. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11551. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11552. builder.Write($"{item.City}");
  11553. builder.EndRow();
  11554. #endregion
  11555. #region 第二行
  11556. builder.InsertCell();
  11557. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11558. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11559. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11560. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11561. builder.ParagraphFormat.Style.Font.Bold = false;
  11562. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11563. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11564. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11565. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11566. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11567. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11568. builder.Write("CONFIRMATION NO:");
  11569. builder.InsertCell();
  11570. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11571. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11572. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11573. builder.ParagraphFormat.Style.Font.Bold = false;
  11574. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11575. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11576. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11577. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11578. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11579. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11580. builder.CellFormat.VerticalMerge = CellMerge.None;
  11581. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11582. builder.Write($"{item.DetermineNo}");
  11583. builder.InsertCell();
  11584. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11585. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11586. builder.InsertCell();
  11587. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11588. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11589. builder.EndRow();
  11590. #endregion
  11591. #region 第三行
  11592. builder.InsertCell();
  11593. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11594. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11595. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11596. builder.ParagraphFormat.Style.Font.Bold = false;
  11597. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11598. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11599. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11600. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11601. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11602. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11603. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11604. builder.Write($"HOTEL NAME:");
  11605. builder.InsertCell();
  11606. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11607. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11608. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11609. builder.ParagraphFormat.Style.Font.Bold = false;
  11610. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11611. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11612. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11613. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11614. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11615. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11616. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11617. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11618. builder.Write($"{item.HotelName}");
  11619. builder.InsertCell();
  11620. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11621. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11622. builder.InsertCell();
  11623. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11624. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11625. builder.EndRow();
  11626. #endregion
  11627. #region 第四行
  11628. builder.InsertCell();
  11629. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11630. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11631. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11632. builder.ParagraphFormat.Style.Font.Bold = false;
  11633. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11634. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11635. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11636. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11637. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11638. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11639. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11640. builder.Write($"HOTEL ADDRESS:");
  11641. builder.InsertCell();
  11642. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11643. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11644. builder.ParagraphFormat.Style.Font.Size = 8;
  11645. builder.ParagraphFormat.Style.Font.Bold = false;
  11646. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11647. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11648. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11649. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11650. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11651. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11652. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11653. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11654. builder.Write($"{item.HotelAddress}");
  11655. builder.InsertCell();
  11656. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11657. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11658. builder.InsertCell();
  11659. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11660. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11661. builder.EndRow();
  11662. #endregion
  11663. #region 第五行
  11664. builder.InsertCell();
  11665. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11666. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11667. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11668. builder.ParagraphFormat.Style.Font.Bold = false;
  11669. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11670. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11671. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11672. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11673. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11674. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11675. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11676. builder.Write("TEL:");
  11677. builder.InsertCell();
  11678. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11679. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11680. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11681. builder.ParagraphFormat.Style.Font.Bold = false;
  11682. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11683. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11684. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11685. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11686. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11687. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11688. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11689. builder.Write($"{item.HotelTel}");
  11690. builder.InsertCell();
  11691. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11692. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11693. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11694. builder.ParagraphFormat.Style.Font.Bold = false;
  11695. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11696. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11697. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11698. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11699. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11700. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11701. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11702. builder.Write($"FAX:");
  11703. builder.InsertCell();
  11704. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11705. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11706. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11707. builder.ParagraphFormat.Style.Font.Bold = false;
  11708. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11709. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11710. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11711. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11712. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11713. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11714. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11715. builder.Write($"{item.HotelFax}");
  11716. builder.EndRow();
  11717. #endregion
  11718. #region 第六行
  11719. builder.InsertCell();
  11720. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11721. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11722. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11723. builder.ParagraphFormat.Style.Font.Bold = false;
  11724. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11725. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11726. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11727. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11728. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11729. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11730. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11731. builder.Write("CHECK IN:");
  11732. builder.InsertCell();
  11733. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11734. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11735. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11736. builder.ParagraphFormat.Style.Font.Bold = false;
  11737. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11738. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11739. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11740. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11741. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11742. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11743. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11744. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  11745. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  11746. builder.Write($"{checkInStr}");
  11747. builder.InsertCell();
  11748. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11749. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11750. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11751. builder.ParagraphFormat.Style.Font.Bold = false;
  11752. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11753. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11754. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11755. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11756. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11757. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11758. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11759. builder.Write($"CHECK OUT:");
  11760. builder.InsertCell();
  11761. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11762. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11763. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11764. builder.ParagraphFormat.Style.Font.Bold = false;
  11765. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11766. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11767. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11768. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11769. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11770. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11771. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11772. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  11773. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  11774. builder.Write($"{checkOutStr}");
  11775. builder.EndRow();
  11776. #endregion
  11777. #region 第七行
  11778. builder.InsertCell();
  11779. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11780. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11781. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11782. builder.ParagraphFormat.Style.Font.Bold = false;
  11783. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11784. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11785. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11786. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11787. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11788. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11789. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11790. builder.Write($"GUEST NAME:");
  11791. builder.InsertCell();
  11792. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11793. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11794. builder.ParagraphFormat.Style.Font.Size = 8;
  11795. builder.ParagraphFormat.Style.Font.Bold = false;
  11796. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11797. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11798. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11799. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11800. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11801. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11802. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11803. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11804. builder.Write($"{item.GuestName}");
  11805. builder.InsertCell();
  11806. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11807. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11808. builder.InsertCell();
  11809. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11810. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11811. builder.EndRow();
  11812. #endregion
  11813. #region 第八行
  11814. builder.InsertCell();
  11815. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11816. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11817. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11818. builder.ParagraphFormat.Style.Font.Bold = false;
  11819. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11820. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11821. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11822. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11823. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11824. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11825. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11826. builder.Write($"ROOM TYPE:");
  11827. builder.InsertCell();
  11828. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11829. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11830. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11831. builder.ParagraphFormat.Style.Font.Bold = false;
  11832. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11833. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11834. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11835. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11836. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11837. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11838. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11839. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11840. builder.Write($"{item.RoomExplanation}");
  11841. builder.InsertCell();
  11842. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11843. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11844. builder.InsertCell();
  11845. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11846. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11847. builder.EndRow();
  11848. #endregion
  11849. #region 第九行
  11850. builder.InsertCell();
  11851. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11852. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11853. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11854. builder.ParagraphFormat.Style.Font.Bold = false;
  11855. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11856. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11857. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  11858. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  11859. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  11860. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  11861. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  11862. builder.Write($"NOTE:");
  11863. builder.InsertCell();
  11864. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11865. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  11866. builder.ParagraphFormat.Style.Font.Size = 7.5;
  11867. builder.ParagraphFormat.Style.Font.Bold = false;
  11868. builder.CellFormat.HorizontalMerge = CellMerge.None;
  11869. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  11870. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  11871. builder.CellFormat.HorizontalMerge = CellMerge.First;
  11872. 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.");
  11873. builder.InsertCell();
  11874. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  11875. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11876. builder.InsertCell();
  11877. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  11878. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  11879. builder.EndRow();
  11880. #endregion
  11881. builder.EndTable();
  11882. //换行
  11883. builder.Writeln("");
  11884. builder.Writeln("");
  11885. }
  11886. #region 获取文档中的所有表格 设置文字自适应
  11887. // 获取文档中的所有表格。
  11888. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11889. {
  11890. // 遍历表格中的所有行。
  11891. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11892. {
  11893. foreach (Cell cell in row.Cells)
  11894. {
  11895. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  11896. cellFormat.Width = 0;
  11897. }
  11898. }
  11899. }
  11900. #endregion
  11901. #region 设置页眉
  11902. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  11903. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  11904. if (System.IO.File.Exists(voucherHeaderPath))
  11905. {
  11906. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  11907. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  11908. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  11909. Shape shape = builder.InsertImage(imageBytes);
  11910. // 调整图片位置
  11911. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  11912. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  11913. shape.Top = 50; // 将图片距离页眉上边缘的距离
  11914. shape.Left = 0; // 将图片距离页面左边缘的距离
  11915. shape.Width = 81; // 设置图片宽度
  11916. shape.Height = 36; // 设置图片高度
  11917. }
  11918. //靠右
  11919. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  11920. //// 设置页脚上下边距
  11921. //builder.PageSetup.HeaderDistance = 42;
  11922. // 添加页眉线
  11923. Aspose.Words.Border borderHeader = null;
  11924. try
  11925. {
  11926. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  11927. }
  11928. catch (Exception e)
  11929. {
  11930. // TODO Auto-generated catch block
  11931. //e.printStackTrace();
  11932. }
  11933. borderHeader.Shadow = true;
  11934. borderHeader.DistanceFromText = 2;
  11935. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  11936. #endregion
  11937. }
  11938. catch (Exception ex)
  11939. {
  11940. }
  11941. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  11942. doc.Save(fileDir);
  11943. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  11944. return Ok(JsonView(true, "操作成功!", Url));
  11945. }
  11946. /// <summary>
  11947. /// 酒店预订
  11948. /// 生成 预定成本 Excel
  11949. /// </summary>
  11950. /// <param name="_dto"></param>
  11951. /// <returns></returns>
  11952. [HttpPost]
  11953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11954. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  11955. {
  11956. #region 参数验证
  11957. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  11958. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  11959. if (!vadalitorRes.IsValid)
  11960. {
  11961. var errors = new StringBuilder();
  11962. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  11963. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  11964. }
  11965. #region 团组操作权限验证 76 酒店预定模块
  11966. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  11967. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  11968. #endregion
  11969. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11970. #region 页面操作权限验证
  11971. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  11972. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  11973. #endregion
  11974. #endregion
  11975. decimal _rate = 1.00M;
  11976. string _currency = string.Empty;
  11977. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  11978. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  11979. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  11980. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  11981. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  11982. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  11983. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  11984. if (_GroupCostParameter == null)
  11985. {
  11986. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  11987. bool isIntType = int.TryParse(_currency, out int currId);
  11988. if (isIntType)
  11989. {
  11990. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  11991. }
  11992. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  11993. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  11994. if (currInfo == null)
  11995. {
  11996. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  11997. }
  11998. else _rate = currInfo.Rate;
  11999. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  12000. {
  12001. _rate = _GroupCostParameter.Rate;
  12002. }
  12003. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12004. string strFileName = "HotelStatement/";
  12005. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12006. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  12007. var rateDatas = new List<dynamic>();
  12008. #region 数据处理
  12009. foreach (var item in hrDtas)
  12010. {
  12011. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  12012. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  12013. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  12014. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  12015. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  12016. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  12017. {
  12018. continue;
  12019. }
  12020. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  12021. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  12022. string singleRoomFeeStr = string.Empty,
  12023. doubleRoomFeeStr = string.Empty,
  12024. suiteRoomFeeStr = string.Empty,
  12025. otherRoomFeeStr = string.Empty,
  12026. payMoneyStr = string.Empty,
  12027. cardPriceStr = string.Empty;
  12028. if (roomCurr.Equals("CNY"))
  12029. {
  12030. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  12031. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12032. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12033. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12034. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12035. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  12036. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  12037. }
  12038. else
  12039. {
  12040. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12041. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12042. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12043. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12044. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  12045. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  12046. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12047. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12048. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12049. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  12050. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  12051. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  12052. if (ccpPaymentCurrency.Equals("CNY"))
  12053. {
  12054. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  12055. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  12056. }
  12057. else
  12058. {
  12059. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  12060. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  12061. }
  12062. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  12063. if (hotelcardPriceCurrency.Equals("CNY"))
  12064. {
  12065. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  12066. }
  12067. else
  12068. {
  12069. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  12070. }
  12071. }
  12072. string breakfastPriceStr = string.Empty,
  12073. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  12074. governmentRentStr = string.Empty,
  12075. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  12076. cityTaxStr = string.Empty,
  12077. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  12078. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  12079. if (!string.IsNullOrEmpty(breakfastCurrency1))
  12080. {
  12081. if (breakfastCurrency1.Equals("CNY"))
  12082. {
  12083. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  12084. }
  12085. else
  12086. {
  12087. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  12088. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  12089. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  12090. }
  12091. }
  12092. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  12093. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  12094. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  12095. {
  12096. if (governmentRentCurrency.Equals("CNY"))
  12097. {
  12098. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  12099. }
  12100. else
  12101. {
  12102. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  12103. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  12104. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  12105. }
  12106. }
  12107. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  12108. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  12109. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  12110. {
  12111. if (cityTaxStrCurrency1.Equals("CNY"))
  12112. {
  12113. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  12114. }
  12115. else
  12116. {
  12117. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  12118. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  12119. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  12120. }
  12121. }
  12122. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  12123. int payDId = roomInfo?.PayDId ?? 0;
  12124. pcfds.Add(new HotelReservations_PCFD_View()
  12125. {
  12126. City = item.City,
  12127. HotelName = item.HotelName,
  12128. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  12129. // SingleRoomCount = item.SingleRoomCount,
  12130. SingleRoomPrice = singleRoomFeeStr,
  12131. // DoubleRoomCount = item.DoubleRoomCount,
  12132. DoubleRoomPrice = doubleRoomFeeStr,
  12133. //SuiteRoomCount = item.SuiteRoomCount,
  12134. SuiteRoomPrice = suiteRoomFeeStr,
  12135. OtherRoomPrice = otherRoomFeeStr,
  12136. //OtherRoomCount = item.OtherRoomCount,
  12137. BreakfastPrice = breakfastPriceStr,
  12138. GovernmentRent = governmentRentStr,
  12139. CityTax = cityTaxStr,
  12140. RoomExplanation = item.RoomExplanation,
  12141. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  12142. PayTime = roomInfo?.ConsumptionDate,
  12143. BankNo = roomInfo?.BankNo,
  12144. PayMoney = payMoneyStr,
  12145. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  12146. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  12147. CardPrice = cardPriceStr,
  12148. Remark = ccpInfo.Remark
  12149. });
  12150. }
  12151. #endregion
  12152. //载入模板
  12153. WorkbookDesigner designer = new WorkbookDesigner();
  12154. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  12155. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  12156. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  12157. designer.SetDataSource("TourNo", groupInfo.TourCode);
  12158. var rateDatas1 = rateDatas.Distinct();
  12159. var rateStr = string.Empty;
  12160. foreach (var item in rateDatas1)
  12161. {
  12162. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  12163. }
  12164. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  12165. designer.SetDataSource("Opertor", userInfo.CnName);
  12166. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  12167. dt.TableName = "ViewMyHotelReservations";
  12168. designer.SetDataSource(dt);
  12169. designer.Process();
  12170. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12171. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  12172. designer.Workbook.Save(serverPath);
  12173. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  12174. #region 删除指定行
  12175. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  12176. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  12177. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  12178. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  12179. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  12180. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  12181. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  12182. cssIndex = dt.Columns["CityTax"].Ordinal,
  12183. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  12184. remarkIndex = dt.Columns["Remark"].Ordinal;
  12185. //删除指定列
  12186. foreach (DataRow item in dt.Rows)
  12187. {
  12188. string singleStr = item["SingleRoomPrice"].ToString();
  12189. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  12190. if (containsDigitButNotZero1) singleDel = false;
  12191. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  12192. string doubleStr = item["DoubleRoomPrice"].ToString();
  12193. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12194. if (containsDigitButNotZero2) doubleDel = false;
  12195. string suiteStr = item["SuiteRoomPrice"].ToString();
  12196. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12197. if (containsDigitButNotZero3) suiteDel = false;
  12198. string otherStr = item["OtherRoomPrice"].ToString();
  12199. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  12200. if (containsDigitButNotZero4) otherDel = false;
  12201. string zcStr = item["BreakfastPrice"].ToString();
  12202. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  12203. if (containsDigitButNotZero5) zcDel = false;
  12204. string dsStr = item["GovernmentRent"].ToString();
  12205. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  12206. if (containsDigitButNotZero6) dsDel = false;
  12207. string cssStr = item["CityTax"].ToString();
  12208. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  12209. if (containsDigitButNotZero7) cssDel = false;
  12210. string cpStr = item["ConsumptionPatterns"].ToString();
  12211. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  12212. string remarkStr = item["Remark"].ToString();
  12213. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  12214. }
  12215. DeleteColumn(serverPath, remarkIndex, remarkDel);
  12216. DeleteColumn(serverPath, cpIndex, cpDel);
  12217. DeleteColumn(serverPath, dsIndex, dsDel);
  12218. DeleteColumn(serverPath, cssIndex, cssDel);
  12219. DeleteColumn(serverPath, zcIndex, zcDel);
  12220. DeleteColumn(serverPath, otherIndex, otherDel);
  12221. DeleteColumn(serverPath, suiteIndex, suiteDel);
  12222. DeleteColumn(serverPath, doubleIndex, doubleDel);
  12223. DeleteColumn(serverPath, singleIndex, singleDel);
  12224. #endregion
  12225. //只保留第一个表格
  12226. DeleteSheet(serverPath);
  12227. return Ok(JsonView(true, "操作成功", url = rst));
  12228. }
  12229. else
  12230. {
  12231. _currency = _GroupCostParameter.Currency;
  12232. bool isIntType = int.TryParse(_currency, out int currId);
  12233. if (isIntType)
  12234. {
  12235. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  12236. }
  12237. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  12238. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  12239. if (currInfo == null)
  12240. {
  12241. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  12242. }
  12243. if (!_currency.ToUpper().Equals("CNY"))
  12244. {
  12245. _rate = _GroupCostParameter.Rate;
  12246. }
  12247. _rate = currInfo.Rate;
  12248. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  12249. string strFileName = "HotelStatement/";
  12250. string guestNames = ""; //格式Mr.xxx Ms.xxx
  12251. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  12252. #region 数据处理
  12253. foreach (var item in hrDtas)
  12254. {
  12255. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  12256. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  12257. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  12258. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  12259. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  12260. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  12261. string singleRoomFeeStr = string.Empty,
  12262. doubleRoomFeeStr = string.Empty,
  12263. suiteRoomFeeStr = string.Empty,
  12264. otherRoomFeeStr = string.Empty,
  12265. payMoneyStr = string.Empty,
  12266. cardPriceStr = string.Empty;
  12267. if (roomCurr.Equals(_currency))
  12268. {
  12269. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  12270. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  12271. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  12272. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  12273. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  12274. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  12275. }
  12276. else
  12277. {
  12278. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  12279. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  12280. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  12281. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  12282. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  12283. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  12284. }
  12285. string breakfastPriceStr = string.Empty,
  12286. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  12287. governmentRentStr = string.Empty,
  12288. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  12289. cityTaxStrStr = string.Empty,
  12290. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  12291. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  12292. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  12293. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  12294. int payDId = roomInfo?.PayDId ?? 0;
  12295. pcfds.Add(new HotelReservations_PCFD_View()
  12296. {
  12297. City = item.City,
  12298. HotelName = item.HotelName,
  12299. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  12300. // SingleRoomCount = item.SingleRoomCount,
  12301. SingleRoomPrice = singleRoomFeeStr,
  12302. // DoubleRoomCount = item.DoubleRoomCount,
  12303. DoubleRoomPrice = doubleRoomFeeStr,
  12304. //SuiteRoomCount = item.SuiteRoomCount,
  12305. SuiteRoomPrice = suiteRoomFeeStr,
  12306. OtherRoomPrice = otherRoomFeeStr,
  12307. //OtherRoomCount = item.OtherRoomCount,
  12308. BreakfastPrice = breakfastPriceStr,
  12309. GovernmentRent = governmentRentStr,
  12310. CityTax = cityTaxStrStr,
  12311. RoomExplanation = item.RoomExplanation,
  12312. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  12313. PayTime = roomInfo?.ConsumptionDate,
  12314. BankNo = roomInfo?.BankNo,
  12315. PayMoney = payMoneyStr,
  12316. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  12317. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  12318. CardPrice = cardPriceStr,
  12319. Remark = ccpInfo.Remark
  12320. });
  12321. }
  12322. #endregion
  12323. //载入模板
  12324. WorkbookDesigner designer = new WorkbookDesigner();
  12325. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  12326. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  12327. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  12328. designer.SetDataSource("TourNo", groupInfo.TourCode);
  12329. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  12330. designer.SetDataSource("Opertor", userInfo.CnName);
  12331. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  12332. dt.TableName = "ViewMyHotelReservations";
  12333. designer.SetDataSource(dt);
  12334. designer.Process();
  12335. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12336. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  12337. designer.Workbook.Save(serverPath);
  12338. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  12339. #region 删除指定行
  12340. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  12341. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  12342. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  12343. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  12344. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  12345. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  12346. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  12347. cssIndex = dt.Columns["CityTax"].Ordinal,
  12348. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  12349. remarkIndex = dt.Columns["Remark"].Ordinal;
  12350. //删除指定列
  12351. foreach (DataRow item in dt.Rows)
  12352. {
  12353. string singleStr = item["SingleRoomPrice"].ToString();
  12354. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  12355. if (containsDigitButNotZero1) singleDel = false;
  12356. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  12357. string doubleStr = item["DoubleRoomPrice"].ToString();
  12358. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12359. if (containsDigitButNotZero2) doubleDel = false;
  12360. string suiteStr = item["SuiteRoomPrice"].ToString();
  12361. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  12362. if (containsDigitButNotZero3) suiteDel = false;
  12363. string otherStr = item["OtherRoomPrice"].ToString();
  12364. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  12365. if (containsDigitButNotZero4) otherDel = false;
  12366. string zcStr = item["BreakfastPrice"].ToString();
  12367. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  12368. if (containsDigitButNotZero5) zcDel = false;
  12369. string dsStr = item["GovernmentRent"].ToString();
  12370. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  12371. if (containsDigitButNotZero6) dsDel = false;
  12372. string cssStr = item["CityTax"].ToString();
  12373. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  12374. if (containsDigitButNotZero7) cssDel = false;
  12375. string cpStr = item["ConsumptionPatterns"].ToString();
  12376. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  12377. string remarkStr = item["Remark"].ToString();
  12378. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  12379. }
  12380. DeleteColumn(serverPath, remarkIndex, remarkDel);
  12381. DeleteColumn(serverPath, cpIndex, cpDel);
  12382. DeleteColumn(serverPath, dsIndex, dsDel);
  12383. DeleteColumn(serverPath, cssIndex, cssDel);
  12384. DeleteColumn(serverPath, zcIndex, zcDel);
  12385. DeleteColumn(serverPath, otherIndex, otherDel);
  12386. DeleteColumn(serverPath, suiteIndex, suiteDel);
  12387. DeleteColumn(serverPath, doubleIndex, doubleDel);
  12388. DeleteColumn(serverPath, singleIndex, singleDel);
  12389. #endregion
  12390. //只保留第一个表格
  12391. DeleteSheet(serverPath);
  12392. return Ok(JsonView(true, "操作成功", url = rst));
  12393. }
  12394. return Ok(JsonView(false));
  12395. }
  12396. /// <summary>
  12397. /// 删除指定列
  12398. /// </summary>
  12399. /// <param name="file"></param>
  12400. /// <param name="columnIndex"></param>
  12401. /// <param name="isDel"></param>
  12402. private void DeleteColumn(string file, int columnIndex, bool isDel)
  12403. {
  12404. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  12405. //wb.Save(file);
  12406. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  12407. if (sheet1 != null)
  12408. {
  12409. if (isDel)
  12410. {
  12411. Cells cells = sheet1.Cells;
  12412. cells.DeleteColumn(columnIndex);
  12413. }
  12414. }
  12415. wb.Save(file);
  12416. }
  12417. /// <summary>
  12418. /// 删除sheet
  12419. /// </summary>
  12420. /// <param name="file"></param>
  12421. /// <param name="sheetName"></param>
  12422. private void DeleteSheet(string file, string sheetName = "")
  12423. {
  12424. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  12425. //wb.Save(file);
  12426. List<string> sheets = new List<string>();
  12427. foreach (var item in wb.Worksheets)
  12428. {
  12429. sheets.Add(item.Name);
  12430. }
  12431. if (sheets.Count > 0)
  12432. {
  12433. sheets.RemoveAt(0);//不删除第一个sheet
  12434. foreach (var item in sheets)
  12435. {
  12436. wb.Worksheets.RemoveAt(item);
  12437. }
  12438. }
  12439. wb.Save(file);
  12440. }
  12441. /// <summary>
  12442. /// 酒店预订
  12443. /// 确认单
  12444. /// </summary>
  12445. /// <param name="_dto"></param>
  12446. /// <returns></returns>
  12447. [HttpPost]
  12448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12449. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  12450. {
  12451. try
  12452. {
  12453. #region 参数验证
  12454. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  12455. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  12456. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  12457. #region 团组操作权限验证 76 酒店预定模块
  12458. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  12459. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  12460. #endregion
  12461. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  12462. #region 页面操作权限验证
  12463. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  12464. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  12465. #endregion
  12466. #endregion
  12467. //团组信息
  12468. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  12469. //酒店数据
  12470. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  12471. if (listhoteldata.Count < 0)
  12472. {
  12473. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  12474. }
  12475. //利datatable存储
  12476. DataTable dt = new DataTable();
  12477. dt.Columns.Add("CheckInDate", typeof(string));
  12478. dt.Columns.Add("City", typeof(string));
  12479. dt.Columns.Add("Hotel", typeof(string));
  12480. dt.Columns.Add("Room", typeof(string));
  12481. for (int i = 0; i < listhoteldata.Count; i++)
  12482. {
  12483. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  12484. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  12485. while (dayStart < dayEnd)
  12486. {
  12487. string temp = "";
  12488. DataRow row = dt.NewRow();
  12489. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  12490. row["City"] = listhoteldata[i].City;
  12491. row["Hotel"] = listhoteldata[i].HotelName;
  12492. if (listhoteldata[i].SingleRoomCount > 0)
  12493. {
  12494. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  12495. }
  12496. if (listhoteldata[i].DoubleRoomCount > 0)
  12497. {
  12498. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  12499. }
  12500. if (listhoteldata[i].SuiteRoomCount > 0)
  12501. {
  12502. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  12503. }
  12504. if (listhoteldata[i].OtherRoomCount > 0)
  12505. {
  12506. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  12507. }
  12508. row["Room"] = temp;
  12509. dt.Rows.Add(row);
  12510. dayStart = dayStart.AddDays(1);
  12511. }
  12512. }
  12513. Dictionary<string, string> dic = new Dictionary<string, string>();
  12514. dic.Add("Dele", di.TeamName);
  12515. dic.Add("City", di.VisitCountry);
  12516. //模板路径
  12517. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  12518. //载入模板
  12519. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  12520. DocumentBuilder builder = new DocumentBuilder(doc);
  12521. foreach (var key in dic.Keys)
  12522. {
  12523. builder.MoveToBookmark(key);
  12524. builder.Write(dic[key]);
  12525. }
  12526. //获取word里所有表格
  12527. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12528. //获取所填表格的序数
  12529. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12530. var rowStart = tableOne.Rows[0]; //获取第1行
  12531. //循环赋值
  12532. for (int i = 0; i < dt.Rows.Count; i++)
  12533. {
  12534. builder.MoveToCell(0, i + 1, 0, 0);
  12535. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  12536. builder.MoveToCell(0, i + 1, 1, 0);
  12537. builder.Write(dt.Rows[i]["City"].ToString());
  12538. builder.MoveToCell(0, i + 1, 2, 0);
  12539. builder.Write(dt.Rows[i]["Hotel"].ToString());
  12540. builder.MoveToCell(0, i + 1, 3, 0);
  12541. builder.Write(dt.Rows[i]["Room"].ToString());
  12542. }
  12543. //删除多余行
  12544. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  12545. {
  12546. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  12547. }
  12548. string strFileName = di.TeamName + "酒店确认单.doc";
  12549. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  12550. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  12551. return Ok(JsonView(true, "成功", url));
  12552. }
  12553. catch (Exception ex)
  12554. {
  12555. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  12556. }
  12557. }
  12558. #endregion
  12559. #region 团组状态
  12560. /// <summary>
  12561. /// 团组状态列表 Page
  12562. /// </summary>
  12563. /// <param name="dto">团组列表请求dto</param>
  12564. /// <returns></returns>
  12565. [HttpPost]
  12566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12567. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  12568. {
  12569. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  12570. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  12571. {
  12572. string sqlWhere = string.Empty;
  12573. if (dto.IsSure == 0) //未完成
  12574. {
  12575. sqlWhere += string.Format(@" And IsSure = 0");
  12576. }
  12577. else if (dto.IsSure == 1) //已完成
  12578. {
  12579. sqlWhere += string.Format(@" And IsSure = 1");
  12580. }
  12581. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  12582. {
  12583. string tj = dto.SearchCriteria;
  12584. 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}%')",
  12585. tj, tj, tj, tj, tj);
  12586. }
  12587. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  12588. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  12589. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  12590. From (
  12591. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  12592. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  12593. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  12594. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  12595. From Grp_DelegationInfo gdi
  12596. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  12597. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  12598. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  12599. Where gdi.IsDel = 0 {0}
  12600. ) temp ", sqlWhere);
  12601. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  12602. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  12603. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  12604. }
  12605. else
  12606. {
  12607. return Ok(JsonView(false, "查询失败"));
  12608. }
  12609. }
  12610. /// <summary>
  12611. /// 团组状态
  12612. /// 设置操作完成
  12613. /// </summary>
  12614. /// <param name="dto">团组列表请求dto</param>
  12615. /// <returns></returns>
  12616. [HttpPost]
  12617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12618. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  12619. {
  12620. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  12621. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  12622. {
  12623. Id = dto.Id,
  12624. IsSure = 1
  12625. };
  12626. var result = await _sqlSugar.Updateable(_DelegationInfo)
  12627. .UpdateColumns(it => new { it.IsSure })
  12628. .WhereColumns(it => new { it.Id })
  12629. .ExecuteCommandAsync();
  12630. if (result > 0)
  12631. {
  12632. return Ok(JsonView(true, "操作完成!"));
  12633. }
  12634. return Ok(JsonView(false, "操作失败!"));
  12635. }
  12636. #endregion
  12637. #region 保险费用录入
  12638. /// <summary>
  12639. /// 根据团组Id查询保险费用列表
  12640. /// </summary>
  12641. /// <param name="dto"></param>
  12642. /// <returns></returns>
  12643. [HttpPost]
  12644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12645. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  12646. {
  12647. Result groupData = await _customersRep.CustomersByDiId(dto);
  12648. if (groupData.Code != 0)
  12649. {
  12650. return Ok(JsonView(false, groupData.Msg));
  12651. }
  12652. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12653. }
  12654. /// <summary>
  12655. /// 根据保险费用Id查询保险费用详细
  12656. /// </summary>
  12657. /// <param name="dto"></param>
  12658. /// <returns></returns>
  12659. [HttpPost]
  12660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12661. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  12662. {
  12663. try
  12664. {
  12665. Result groupData = await _customersRep.CustomersById(dto);
  12666. if (groupData.Code != 0)
  12667. {
  12668. return Ok(JsonView(false, groupData.Msg));
  12669. }
  12670. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12671. }
  12672. catch (Exception ex)
  12673. {
  12674. return Ok(JsonView(false, ex.Message));
  12675. }
  12676. }
  12677. /// <summary>
  12678. /// 保险费用录入页面初始化绑定
  12679. /// </summary>
  12680. /// <param name="dto"></param>
  12681. /// <returns></returns>
  12682. [HttpPost]
  12683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12684. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  12685. {
  12686. try
  12687. {
  12688. Result groupData = await _customersRep.CustomersInitialize(dto);
  12689. if (groupData.Code != 0)
  12690. {
  12691. return Ok(JsonView(false, groupData.Msg));
  12692. }
  12693. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12694. }
  12695. catch (Exception ex)
  12696. {
  12697. return Ok(JsonView(false, ex.Message));
  12698. }
  12699. }
  12700. /// <summary>
  12701. /// 保险费用操作(Status:1.新增,2.修改)
  12702. /// </summary>
  12703. /// <param name="dto"></param>
  12704. /// <returns></returns>
  12705. [HttpPost]
  12706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12707. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  12708. {
  12709. Result groupData = await _customersRep.OpCustomers(dto);
  12710. if (groupData.Code != 0)
  12711. {
  12712. return Ok(JsonView(false, groupData.Msg));
  12713. }
  12714. #region 应用推送
  12715. try
  12716. {
  12717. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  12718. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  12719. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  12720. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  12721. //自动审核
  12722. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  12723. //2024-10-21 新增LZ UID
  12724. var userIds = new List<int>() { 21 };
  12725. string title = $"系统通知";
  12726. var diId = dto.DiId;
  12727. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  12728. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  12729. string content = "";
  12730. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12731. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  12732. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  12733. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  12734. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  12735. }
  12736. catch (Exception ex)
  12737. {
  12738. }
  12739. #endregion
  12740. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  12741. }
  12742. /// <summary>
  12743. /// 保险文件上传
  12744. /// </summary>
  12745. /// <param name="file"></param>
  12746. /// <returns></returns>
  12747. [HttpPost]
  12748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12749. public async Task<IActionResult> UploadCus(IFormFile file)
  12750. {
  12751. try
  12752. {
  12753. if (file != null)
  12754. {
  12755. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  12756. //文件名称
  12757. string projectFileName = file.FileName;
  12758. //上传的文件的路径
  12759. string filePath = "";
  12760. if (!Directory.Exists(fileDir))
  12761. {
  12762. Directory.CreateDirectory(fileDir);
  12763. }
  12764. //上传的文件的路径
  12765. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  12766. using (FileStream fs = System.IO.File.Create(filePath))
  12767. {
  12768. file.CopyTo(fs);
  12769. fs.Flush();
  12770. }
  12771. return Ok(JsonView(true, "上传成功!", projectFileName));
  12772. }
  12773. else
  12774. {
  12775. return Ok(JsonView(false, "上传失败!"));
  12776. }
  12777. }
  12778. catch (Exception ex)
  12779. {
  12780. return Ok(JsonView(false, "程序错误!"));
  12781. throw;
  12782. }
  12783. }
  12784. /// <summary>
  12785. /// 保险删除指定文件
  12786. /// </summary>
  12787. /// <param name="dto"></param>
  12788. /// <returns></returns>
  12789. [HttpPost]
  12790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12791. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  12792. {
  12793. try
  12794. {
  12795. string filePath = "";
  12796. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  12797. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  12798. //int id = 0;
  12799. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  12800. // 删除该文件
  12801. try
  12802. {
  12803. System.IO.File.Delete(filePath);
  12804. 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()
  12805. {
  12806. Attachment = "",
  12807. }).ExecuteCommandAsync();
  12808. if (result != 0)
  12809. {
  12810. return Ok(JsonView(true, "成功!"));
  12811. }
  12812. else
  12813. {
  12814. return Ok(JsonView(false, "失败!"));
  12815. }
  12816. }
  12817. catch (Exception)
  12818. {
  12819. 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()
  12820. {
  12821. Attachment = "",
  12822. }).ExecuteCommandAsync();
  12823. if (result != 0)
  12824. {
  12825. return Ok(JsonView(true, "成功!"));
  12826. }
  12827. else
  12828. {
  12829. return Ok(JsonView(false, "失败!"));
  12830. }
  12831. }
  12832. }
  12833. catch (Exception ex)
  12834. {
  12835. return Ok(JsonView(false, "程序错误!"));
  12836. throw;
  12837. }
  12838. }
  12839. /// <summary>
  12840. /// 保险费用操作(删除)
  12841. /// </summary>
  12842. /// <param name="dto"></param>
  12843. /// <returns></returns>
  12844. [HttpPost]
  12845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12846. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  12847. {
  12848. try
  12849. {
  12850. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  12851. if (!res)
  12852. {
  12853. return Ok(JsonView(false, "删除失败"));
  12854. }
  12855. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  12856. {
  12857. IsDel = 1,
  12858. DeleteUserId = dto.DeleteUserId,
  12859. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  12860. }).ExecuteCommandAsync();
  12861. return Ok(JsonView(true, "删除成功!"));
  12862. }
  12863. catch (Exception ex)
  12864. {
  12865. return Ok(JsonView(false, "程序错误!"));
  12866. throw;
  12867. }
  12868. }
  12869. #endregion
  12870. #region 接团客户名单 PageId 104
  12871. /// <summary>
  12872. /// 接团客户名单
  12873. /// 迁移数据(慎用!)
  12874. /// </summary>
  12875. /// <param name="dto"></param>
  12876. /// <returns></returns>
  12877. [HttpPost]
  12878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12879. public async Task<IActionResult> PostTourClientListChange()
  12880. {
  12881. try
  12882. {
  12883. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  12884. //var groupClinetData1
  12885. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  12886. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  12887. int updateCount = 0;
  12888. if (oldOAClientList.Count > 0)
  12889. {
  12890. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  12891. _sqlSugar.BeginTran();
  12892. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  12893. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  12894. foreach (var item in oldOAClientList)
  12895. {
  12896. int comId = 0;
  12897. string format = "yyyy-MM-dd HH:mm:ss";
  12898. string data11 = "1990-01-01 00:00";
  12899. var data1 = IsValidDate(item.OPdate, format);
  12900. if (data1) data11 = item.OPdate;
  12901. //客户公司验证
  12902. if (!string.IsNullOrEmpty(item.Company))
  12903. {
  12904. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  12905. if (clientComInfo == null) // add
  12906. {
  12907. var addInfo = new Crm_CustomerCompany()
  12908. {
  12909. CompanyAbbreviation = "",
  12910. CompanyFullName = item.Company,
  12911. Address = "",
  12912. PostCodes = "",
  12913. LastedOpUserId = item.OPer,
  12914. LastedOpDt = Convert.ToDateTime(data11),
  12915. CreateUserId = item.OPer,
  12916. CreateTime = Convert.ToDateTime(data11),
  12917. IsDel = 0
  12918. };
  12919. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  12920. if (comId1 > 0) comId = comId1;
  12921. }
  12922. else comId = clientComInfo.Id;
  12923. }
  12924. //客户人员验证
  12925. int clientId = 0;
  12926. string name = item.LastName + item.Name;
  12927. if (!string.IsNullOrEmpty(name))
  12928. {
  12929. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  12930. if (clientInfo == null)
  12931. {
  12932. DateTime? dateTime = null;
  12933. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  12934. if (isDt) dateTime = birthDayDt;
  12935. var addInfo1 = new Crm_DeleClient()
  12936. {
  12937. CrmCompanyId = comId,
  12938. DiId = -1,
  12939. LastName = item.LastName,
  12940. FirstName = item.Name,
  12941. OldName = "",
  12942. Pinyin = item.Pinyin,
  12943. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  12944. Marriage = 0,
  12945. Phone = item.Phone,
  12946. Job = item.Job,
  12947. BirthDay = dateTime
  12948. };
  12949. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  12950. if (clientId1 > 0) clientId = clientId1;
  12951. }
  12952. else clientId = clientInfo.Id;
  12953. }
  12954. if (clientId < 1)
  12955. {
  12956. continue;
  12957. }
  12958. int airType = 0;
  12959. if (item.AirType == "超经舱") airType = 459;
  12960. else if (item.AirType == "公务舱") airType = 458;
  12961. else if (item.AirType == "经济舱") airType = 460;
  12962. else if (item.AirType == "其他") airType = 565;
  12963. else if (item.AirType == "头等舱") airType = 457;
  12964. var _TourClientListEntity = new Grp_TourClientList()
  12965. {
  12966. DiId = item.Diid,
  12967. ClientId = clientId,
  12968. CreateUserId = item.OPer,
  12969. CreateTime = Convert.ToDateTime(data11),
  12970. Remark = item.Remark,
  12971. IsDel = item.Isdel,
  12972. ShippingSpaceTypeId = airType,
  12973. ShippingSpaceSpecialNeeds = item.AirRemark,
  12974. HotelSpecialNeeds = item.RoomType
  12975. };
  12976. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  12977. if (_TourClientList > 0)
  12978. {
  12979. updateCount++;
  12980. }
  12981. }
  12982. _sqlSugar.CommitTran();
  12983. }
  12984. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  12985. }
  12986. catch (Exception ex)
  12987. {
  12988. _sqlSugar.RollbackTran();
  12989. return Ok(JsonView(false, ex.Message));
  12990. }
  12991. return Ok(JsonView(true));
  12992. }
  12993. private bool IsValidDate(string dateString, string format)
  12994. {
  12995. DateTime dateValue;
  12996. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  12997. return valid;
  12998. }
  12999. /// <summary>
  13000. /// 接团客户名单
  13001. /// 根据团组Id查询List
  13002. /// </summary>
  13003. /// <param name="dto"></param>
  13004. /// <returns></returns>
  13005. [HttpPost]
  13006. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13007. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  13008. {
  13009. #region 参数验证
  13010. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  13011. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  13012. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  13013. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13014. #region 页面操作权限验证
  13015. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13016. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13017. #endregion
  13018. #endregion
  13019. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  13020. if (viewData.Code != 0)
  13021. {
  13022. return Ok(JsonView(false, viewData.Msg));
  13023. }
  13024. return Ok(JsonView(viewData.Data));
  13025. }
  13026. /// <summary>
  13027. /// 接团客户名单
  13028. /// 基础数据 Init
  13029. /// </summary>
  13030. /// <param name="_dto"></param>
  13031. /// <returns></returns>
  13032. [HttpPost]
  13033. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13034. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  13035. {
  13036. #region 参数验证
  13037. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13038. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13039. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13040. #region 页面操作权限验证
  13041. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13042. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13043. #endregion
  13044. #endregion
  13045. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  13046. }
  13047. /// <summary>
  13048. /// 接团客户名单
  13049. /// 根据 Id查询 Details
  13050. /// </summary>
  13051. /// <param name="_dto"></param>
  13052. /// <returns></returns>
  13053. [HttpPost]
  13054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13055. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  13056. {
  13057. #region 参数验证
  13058. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13059. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13060. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  13061. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13062. #region 页面操作权限验证
  13063. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13064. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13065. #endregion
  13066. #endregion
  13067. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  13068. if (viewData.Code != 0)
  13069. {
  13070. return Ok(JsonView(false, viewData.Msg));
  13071. }
  13072. return Ok(JsonView(viewData.Data));
  13073. }
  13074. /// <summary>
  13075. /// 接团客户名单
  13076. /// Add Or Edit
  13077. /// </summary>
  13078. /// <param name="_dto"></param>
  13079. /// <returns></returns>
  13080. [HttpPost]
  13081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13082. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  13083. {
  13084. #region 参数验证
  13085. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13086. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13087. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  13088. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13089. #region 页面操作权限验证
  13090. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13091. if (_dto.Id == 0) //添加
  13092. {
  13093. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13094. }
  13095. else if (_dto.Id >= 0) //修改
  13096. {
  13097. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  13098. }
  13099. #endregion
  13100. #endregion
  13101. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  13102. if (viewData.Code != 0)
  13103. {
  13104. return Ok(JsonView(false, viewData.Msg));
  13105. }
  13106. return Ok(JsonView(true));
  13107. }
  13108. /// <summary>
  13109. /// 接团客户名单
  13110. /// AddMultiple(添加多个)
  13111. /// </summary>
  13112. /// <param name="_dto"></param>
  13113. /// <returns></returns>
  13114. [HttpPost]
  13115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13116. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  13117. {
  13118. #region 参数验证
  13119. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13120. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13121. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13122. #region 页面操作权限验证
  13123. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13124. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13125. #endregion
  13126. #endregion
  13127. var viewData = await _tourClientListRep._AddMultiple(_dto);
  13128. if (viewData.Code != 0)
  13129. {
  13130. return Ok(JsonView(false, viewData.Msg));
  13131. }
  13132. return Ok(JsonView(true));
  13133. }
  13134. /// <summary>
  13135. /// 接团客户名单
  13136. /// Del
  13137. /// </summary>
  13138. /// <param name="_dto"></param>
  13139. /// <returns></returns>
  13140. [HttpPost]
  13141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13142. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  13143. {
  13144. #region 参数验证
  13145. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13146. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13147. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13148. #region 页面操作权限验证
  13149. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13150. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  13151. #endregion
  13152. #endregion
  13153. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  13154. if (viewData.Code != 0)
  13155. {
  13156. return Ok(JsonView(false, viewData.Msg));
  13157. }
  13158. return Ok(JsonView(true));
  13159. }
  13160. /// <summary>
  13161. /// 接团客户名单
  13162. /// 文件下载 客户名单
  13163. /// </summary>
  13164. /// <param name="_dto"></param>
  13165. /// <returns></returns>
  13166. [HttpPost]
  13167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13168. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  13169. {
  13170. #region 参数验证
  13171. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  13172. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  13173. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  13174. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13175. #region 页面操作权限验证
  13176. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13177. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  13178. #endregion
  13179. #endregion
  13180. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  13181. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  13182. From Grp_TourClientList tcl
  13183. Left Join
  13184. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  13185. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  13186. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  13187. From Crm_DeleClient dc
  13188. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  13189. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  13190. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  13191. Where dc.IsDel = 0) temp
  13192. On temp.DcId =tcl.ClientId
  13193. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  13194. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  13195. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  13196. //载入模板
  13197. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  13198. if (_dto.Language == 1)
  13199. {
  13200. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  13201. }
  13202. //载入模板
  13203. var doc = new Document(tempPath);
  13204. DocumentBuilder builder = new DocumentBuilder(doc);
  13205. //获取word里所有表格
  13206. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  13207. //获取所填表格的序数
  13208. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  13209. var rowStart = tableOne.Rows[0]; //获取第1行
  13210. if (_dto.Language == 0)
  13211. {
  13212. //循环赋值
  13213. for (int i = 0; i < DcList.Count; i++)
  13214. {
  13215. EncryptionProcessor.DecryptProperties(DcList[i]);
  13216. builder.MoveToCell(0, i + 1, 0, 0);
  13217. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  13218. builder.MoveToCell(0, i + 1, 1, 0);
  13219. int sex = DcList[i].Sex;
  13220. string sexStr = string.Empty;
  13221. if (sex == 0) sexStr = "男";
  13222. else if (sex == 1) sexStr = "女";
  13223. else sexStr = "未设置";
  13224. builder.Write(sexStr);
  13225. builder.MoveToCell(0, i + 1, 2, 0);
  13226. string birthDay = DcList[i].BirthDay;
  13227. string birthDayStr = string.Empty;
  13228. if (!string.IsNullOrEmpty(birthDay))
  13229. {
  13230. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  13231. }
  13232. builder.Write(birthDayStr);
  13233. builder.MoveToCell(0, i + 1, 3, 0);
  13234. string company = "";
  13235. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  13236. {
  13237. company = DcList[i].CompanyFullName.ToString();
  13238. }
  13239. builder.Write(company);
  13240. builder.MoveToCell(0, i + 1, 4, 0);
  13241. builder.Write(DcList[i].Job);
  13242. }
  13243. }
  13244. else if (_dto.Language == 1)
  13245. {
  13246. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  13247. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  13248. List<string> transArrayStr = new List<string>();
  13249. string transStrRes1 = "";
  13250. for (int i = 0; i < DcList.Count; i++)
  13251. {
  13252. var dc = DcList[i];
  13253. EncryptionProcessor.DecryptProperties(dc);
  13254. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  13255. if (dc.Job.Equals("暂无")) dc.Job = "-";
  13256. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  13257. if (DcList.Count - 1 == i) transStrRes1 += str1;
  13258. else transStrRes1 += $"{str1}|";
  13259. }
  13260. //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";
  13261. string transStrRes = "";
  13262. if (transStrRes1.Length > 0)
  13263. {
  13264. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  13265. }
  13266. //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
  13267. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  13268. //List<string> transArray = new List<string> { };
  13269. List<TranslateInfo> transArray = new List<TranslateInfo>();
  13270. if (transStrRes.Contains("|"))
  13271. {
  13272. string[] transArray1 = transStrRes.Split('|');
  13273. if (transArray1.Length > 0)
  13274. {
  13275. foreach (var item in transArray1)
  13276. {
  13277. if (item.Contains("&"))
  13278. {
  13279. string[] transArray2 = item.Split('&');
  13280. int index = 0;
  13281. string companyName = "", job = "";
  13282. if (transArray2.Length > 0)
  13283. {
  13284. bool success = int.TryParse(transArray2[0].Trim(), out index);
  13285. if (1 < transArray2.Length) companyName = transArray2[1];
  13286. if (2 < transArray2.Length) job = transArray2[2];
  13287. }
  13288. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  13289. }
  13290. }
  13291. }
  13292. }
  13293. //循环赋值
  13294. for (int i = 0; i < DcList.Count; i++)
  13295. {
  13296. string PYName = "";
  13297. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  13298. {
  13299. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  13300. string PY_First = DcList[i].Pinyin.Split('/')[1];
  13301. PYName = PY_First + " " + PY_Last;
  13302. }
  13303. else
  13304. {
  13305. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  13306. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  13307. PYName = PY_First + " " + PY_Last;
  13308. }
  13309. builder.MoveToCell(0, i + 1, 0, 0);
  13310. builder.Write(PYName);
  13311. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  13312. builder.MoveToCell(0, i + 1, 1, 0);
  13313. builder.Write(sex);
  13314. DateTime birthDt;
  13315. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  13316. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  13317. builder.MoveToCell(0, i + 1, 2, 0);
  13318. builder.Write(birthday);
  13319. string company = string.Empty, job = string.Empty;
  13320. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  13321. if (dcTransInfo != null)
  13322. {
  13323. company = dcTransInfo.CompanyName;
  13324. job = dcTransInfo.Job;
  13325. }
  13326. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  13327. {
  13328. //查询对照表
  13329. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  13330. if (tempCec != null)
  13331. {
  13332. company = tempCec.enName;
  13333. }
  13334. //翻译
  13335. else
  13336. {
  13337. }
  13338. }
  13339. builder.MoveToCell(0, i + 1, 3, 0);
  13340. builder.Write(company);
  13341. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  13342. {
  13343. //查询对照表
  13344. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  13345. if (tempPec != null)
  13346. {
  13347. job = tempPec.enName;
  13348. }
  13349. //翻译
  13350. else
  13351. {
  13352. }
  13353. }
  13354. builder.MoveToCell(0, i + 1, 4, 0);
  13355. builder.Write(job);
  13356. }
  13357. }
  13358. //删除多余行
  13359. while (tableOne.Rows.Count > DcList.Count + 1)
  13360. {
  13361. tableOne.Rows.RemoveAt(DcList.Count + 1);
  13362. }
  13363. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  13364. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  13365. doc.Save(fileDir);
  13366. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  13367. return Ok(JsonView(true, "操作成功!", Url));
  13368. }
  13369. private class TranslateInfo
  13370. {
  13371. public int Index { get; set; }
  13372. public string CompanyName { get; set; }
  13373. public string Job { get; set; }
  13374. }
  13375. #endregion
  13376. #region 团组倒推表
  13377. /// <summary>
  13378. /// 倒推表基础数据
  13379. /// Init
  13380. /// </summary>
  13381. /// <param name="dto"></param>
  13382. /// <returns></returns>
  13383. [HttpPost]
  13384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13385. public async Task<IActionResult> PostInvertedListInit()
  13386. {
  13387. var viewData = await _invertedListRep._Init();
  13388. if (viewData.Code != 0)
  13389. {
  13390. return Ok(JsonView(false, viewData.Msg));
  13391. }
  13392. return Ok(JsonView(viewData.Data));
  13393. }
  13394. /// <summary>
  13395. /// 倒推表
  13396. /// Info
  13397. /// </summary>
  13398. /// <param name="dto"></param>
  13399. /// <returns></returns>
  13400. [HttpPost]
  13401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13402. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  13403. {
  13404. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  13405. if (viewData.Code != 0)
  13406. {
  13407. return Ok(JsonView(false, viewData.Msg));
  13408. }
  13409. return Ok(JsonView(viewData.Data));
  13410. }
  13411. /// <summary>
  13412. /// 倒推表
  13413. /// Create
  13414. /// </summary>
  13415. /// <param name="dto"></param>
  13416. /// <returns></returns>
  13417. [HttpPost]
  13418. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13419. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  13420. {
  13421. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  13422. if (viewData.Code != 0)
  13423. {
  13424. return Ok(JsonView(false, viewData.Msg));
  13425. }
  13426. return Ok(JsonView(viewData.Data));
  13427. }
  13428. /// <summary>
  13429. /// 倒推表
  13430. /// Update
  13431. /// </summary>
  13432. /// <param name="dto"></param>
  13433. /// <returns></returns>
  13434. [HttpPost]
  13435. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13436. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  13437. {
  13438. var viewData = await _invertedListRep._Update(dto);
  13439. if (viewData.Code != 0)
  13440. {
  13441. return Ok(JsonView(false, viewData.Msg));
  13442. }
  13443. return Ok(JsonView(viewData.Data));
  13444. }
  13445. /// <summary>
  13446. /// 倒推表
  13447. /// File Download
  13448. /// </summary>
  13449. /// <param name="dto"></param>
  13450. /// <returns></returns>
  13451. [HttpPost]
  13452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13453. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  13454. {
  13455. var info2 = await _invertedListRep._Info(1, dto.DiId);
  13456. if (info2.Code != 0)
  13457. {
  13458. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  13459. }
  13460. var info1 = info2.Data as InvertedListInfoView;
  13461. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  13462. string teamName = "";
  13463. if (info != null) teamName = info.TeamName;
  13464. //载入模板
  13465. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  13466. DocumentBuilder builder = new DocumentBuilder(doc);
  13467. //利用键值对存放数据
  13468. Dictionary<string, string> dic = new Dictionary<string, string>();
  13469. dic.Add("TeamName", teamName);
  13470. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  13471. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  13472. dic.Add("BPRemark", info1.ApprovalDataRemark);
  13473. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  13474. dic.Add("SQRemark", info1.ApprovalRemark);
  13475. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  13476. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  13477. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  13478. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  13479. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  13480. dic.Add("QZRemark", info1.VisaInformationRemark);
  13481. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  13482. dic.Add("SQQZRemark", info1.SendVisaRemark);
  13483. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  13484. dic.Add("CQRemark", info1.IssueVisaRemark);
  13485. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  13486. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  13487. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  13488. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  13489. #region 填充word模板书签内容
  13490. foreach (var key in dic.Keys)
  13491. {
  13492. builder.MoveToBookmark(key);
  13493. builder.Write(dic[key]);
  13494. }
  13495. #endregion
  13496. var fileDir = AppSettingsHelper.Get("WordBasePath");
  13497. string fileName = $"{teamName}团出行准备流程表.doc";
  13498. string filePath = fileDir + $@"InvertedList/{fileName}";
  13499. doc.Save(filePath);
  13500. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  13501. return Ok(JsonView(true, "操作成功!", Url));
  13502. }
  13503. #endregion
  13504. #region 三公签证费用(签证费、代办费)
  13505. /// <summary>
  13506. /// 三公签证费用(签证费、代办费)
  13507. /// List
  13508. /// </summary>
  13509. /// <returns></returns>
  13510. [HttpPost]
  13511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13512. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  13513. {
  13514. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  13515. if (_view.Code != 0)
  13516. {
  13517. return Ok(JsonView(false, _view.Msg));
  13518. }
  13519. return Ok(JsonView(true, "操作成功!", _view.Data));
  13520. }
  13521. /// <summary>
  13522. /// 三公签证费用(签证费、代办费)
  13523. /// Add Or Update
  13524. /// </summary>
  13525. /// <returns></returns>
  13526. [HttpPost]
  13527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13528. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  13529. {
  13530. var _view = await _visaFeeInfoRep._Update(_dto);
  13531. if (_view.Code != 0)
  13532. {
  13533. return Ok(JsonView(false, _view.Msg));
  13534. }
  13535. return Ok(JsonView(true, _view.Msg));
  13536. }
  13537. #endregion
  13538. #region 酒店询价
  13539. /// <summary>
  13540. /// 酒店询价
  13541. /// Init
  13542. /// </summary>
  13543. /// <param name="dto"></param>
  13544. /// <returns></returns>
  13545. [HttpPost]
  13546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13547. public async Task<IActionResult> PostHotelInquiryInit()
  13548. {
  13549. var res = await _hotelInquiryRep._Init();
  13550. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13551. return Ok(JsonView(true, res.Msg, res.Data));
  13552. }
  13553. /// <summary>
  13554. /// 酒店询价
  13555. /// page Item
  13556. /// </summary>
  13557. /// <param name="_dto"></param>
  13558. /// <returns></returns>
  13559. [HttpPost]
  13560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13561. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  13562. {
  13563. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  13564. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13565. var view = res.Data as PageDataViewBase;
  13566. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  13567. }
  13568. /// <summary>
  13569. /// 酒店询价
  13570. /// info
  13571. /// </summary>
  13572. /// <param name="_dto"></param>
  13573. /// <returns></returns>
  13574. [HttpPost]
  13575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13576. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  13577. {
  13578. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  13579. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13580. return Ok(JsonView(true, res.Msg, res.Data));
  13581. }
  13582. /// <summary>
  13583. /// 酒店询价
  13584. /// Add Or Edit
  13585. /// </summary>
  13586. /// <param name="_dto"></param>
  13587. /// <returns></returns>
  13588. [HttpPost]
  13589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13590. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  13591. {
  13592. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  13593. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13594. return Ok(JsonView(true, res.Msg, res.Data));
  13595. }
  13596. /// <summary>
  13597. /// 酒店询价
  13598. /// Del
  13599. /// </summary>
  13600. /// <param name="_dto"></param>
  13601. /// <returns></returns>
  13602. [HttpPost]
  13603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13604. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  13605. {
  13606. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  13607. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  13608. return Ok(JsonView(true, res.Msg, res.Data));
  13609. }
  13610. #endregion
  13611. #region 下载匹配op行程单
  13612. /// <summary>
  13613. /// 匹配op行程单
  13614. /// Init
  13615. /// </summary>
  13616. /// <param name="dto">团组列表请求dto</param>
  13617. /// <returns></returns>
  13618. [HttpPost]
  13619. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13620. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  13621. {
  13622. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  13623. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13624. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  13625. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  13626. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  13627. .Where(it => it.IsDel == 0)
  13628. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  13629. .OrderByDescending(it => it.CreateUserId)
  13630. .ToList();
  13631. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  13632. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  13633. var diids = groupInfos.Select(it => it.Id).ToList();
  13634. List<string> countrys = new List<string>();
  13635. foreach (var item in country)
  13636. {
  13637. var data = _groupRepository.FormartTeamName(item);
  13638. var dataArray = _groupRepository.GroupSplitCountry(data);
  13639. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  13640. }
  13641. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  13642. List<string> areaArray = new List<string>(); //GetGroupCityLine
  13643. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  13644. foreach (var item in areaItem)
  13645. {
  13646. string areaStr = item.Value;
  13647. if (!string.IsNullOrEmpty(areaStr))
  13648. {
  13649. string[] str1 = areaStr.Split("-");
  13650. if (str1.Length > 0)
  13651. {
  13652. areaArray.AddRange(str1);
  13653. }
  13654. }
  13655. }
  13656. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  13657. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  13658. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  13659. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  13660. .ToList();
  13661. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  13662. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  13663. .Where(it => countriesIds.Contains(it.Id))
  13664. .Select(it => new { it.Id, Name = it.Name_CN })
  13665. .ToList();
  13666. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  13667. .Select(it => it.TeamName).ToList();
  13668. stopwatch.Stop();
  13669. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  13670. }
  13671. ///// <summary>
  13672. ///// 匹配op行程单
  13673. ///// Init 查询区域数据
  13674. ///// </summary>
  13675. ///// <param name="dto">团组列表请求dto</param>
  13676. ///// <returns></returns>
  13677. //[HttpPost]
  13678. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13679. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  13680. //{
  13681. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  13682. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  13683. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  13684. // if (string.IsNullOrEmpty(countriesDataStr))
  13685. // {
  13686. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  13687. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  13688. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  13689. // }
  13690. // else
  13691. // {
  13692. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  13693. // }
  13694. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  13695. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  13696. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  13697. // List<dynamic> childList = new List<dynamic>();
  13698. // int parentId = dto.CountriesId;
  13699. // if (provinceData.Count > 1)
  13700. // {
  13701. // foreach (var item1 in provinceData)
  13702. // {
  13703. // List<dynamic> childList1 = new List<dynamic>();
  13704. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  13705. // foreach (var item2 in citiesData1)
  13706. // {
  13707. // List<dynamic> childList2 = new List<dynamic>();
  13708. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13709. // foreach (var item3 in countiesData1)
  13710. // {
  13711. // childList2.Add(new
  13712. // {
  13713. // id = item3.Id,
  13714. // parentId = item2.Id,
  13715. // level = "district",
  13716. // name = item3.Name_CN,
  13717. // });
  13718. // }
  13719. // childList1.Add(new
  13720. // {
  13721. // id = item2.Id,
  13722. // parentId = item1.Id,
  13723. // level = "city",
  13724. // name = item2.Name_CN,
  13725. // childList = childList2
  13726. // });
  13727. // }
  13728. // childList.Add(new
  13729. // {
  13730. // id = item1.Id,
  13731. // parentId = parentId,
  13732. // level = "province",
  13733. // name = item1.Name_CN,
  13734. // childList = childList1
  13735. // });
  13736. // }
  13737. // //城市
  13738. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  13739. // foreach (var item2 in citiesData2)
  13740. // {
  13741. // List<dynamic> childList22 = new List<dynamic>();
  13742. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13743. // foreach (var item3 in countiesData1)
  13744. // {
  13745. // childList22.Add(new
  13746. // {
  13747. // id = item3.Id,
  13748. // parentId = item2.Id,
  13749. // level = "district",
  13750. // name = item3.Name_CN,
  13751. // });
  13752. // }
  13753. // childList.Add(new
  13754. // {
  13755. // id = item2.Id,
  13756. // parentId = parentId,
  13757. // level = "city",
  13758. // name = item2.Name_CN,
  13759. // childList = childList22
  13760. // });
  13761. // }
  13762. // }
  13763. // else
  13764. // {
  13765. // foreach (var item2 in citiesData)
  13766. // {
  13767. // string cname = item2.Name_CN;
  13768. // List<dynamic> childList1 = new List<dynamic>();
  13769. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  13770. // foreach (var item3 in countiesData1)
  13771. // {
  13772. // childList1.Add(new
  13773. // {
  13774. // Id = item3.Id,
  13775. // parentId = item2.Id,
  13776. // level = "district",
  13777. // name = item3.Name_CN
  13778. // });
  13779. // }
  13780. // childList.Add(new
  13781. // {
  13782. // id = item2.Id,
  13783. // parentId = parentId,
  13784. // level = "city",
  13785. // name = item2.Name_CN,
  13786. // childList = childList1
  13787. // });
  13788. // }
  13789. // }
  13790. // stopwatch.Stop();
  13791. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  13792. //}
  13793. /// <summary>
  13794. /// 匹配op行程单
  13795. /// 接团信息列表 Page
  13796. /// </summary>
  13797. /// <param name="dto">团组列表请求dto</param>
  13798. /// <returns></returns>
  13799. [HttpPost]
  13800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13801. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  13802. {
  13803. var swatch = new Stopwatch();
  13804. swatch.Start();
  13805. #region 参数验证
  13806. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13807. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  13808. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13809. #region 页面操作权限验证
  13810. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  13811. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  13812. #endregion
  13813. #endregion
  13814. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  13815. {
  13816. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  13817. string sqlWhere = "";
  13818. if (!string.IsNullOrEmpty(dto.Country))
  13819. {
  13820. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  13821. }
  13822. if (!string.IsNullOrEmpty(dto.Area))
  13823. {
  13824. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  13825. }
  13826. if (!string.IsNullOrEmpty(dto.TeamName))
  13827. {
  13828. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  13829. }
  13830. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  13831. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  13832. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  13833. swatch.Stop();
  13834. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  13835. }
  13836. else
  13837. {
  13838. return Ok(JsonView(false, "查询失败"));
  13839. }
  13840. }
  13841. /// <summary>
  13842. /// 匹配op行程单
  13843. /// 行程单下载
  13844. /// </summary>
  13845. /// <param name="dto">团组列表请求dto</param>
  13846. /// <returns></returns>
  13847. [HttpPost]
  13848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13849. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  13850. {
  13851. #region 参数验证
  13852. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13853. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  13854. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13855. #region 页面操作权限验证
  13856. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  13857. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  13858. #endregion
  13859. #endregion
  13860. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  13861. {
  13862. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  13863. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  13864. }
  13865. else
  13866. {
  13867. return Ok(JsonView(false, "下载失败!"));
  13868. }
  13869. }
  13870. #endregion
  13871. #region 国家信息 数据 注释
  13872. //[HttpPost]
  13873. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  13874. //{
  13875. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  13876. // foreach (var item in dto)
  13877. // {
  13878. // infos.Add(new Grp_GroupsTaskAssignment()
  13879. // {
  13880. // DIId = item,
  13881. // CTId = 82,
  13882. // UId = 248,
  13883. // IsEnable = 1,
  13884. // CreateUserId = 233,
  13885. // CreateTime = DateTime.Now,
  13886. // IsDel = 0
  13887. // });
  13888. // infos.Add(new Grp_GroupsTaskAssignment()
  13889. // {
  13890. // DIId = item,
  13891. // CTId = 82,
  13892. // UId = 286,
  13893. // IsEnable = 1,
  13894. // CreateUserId = 233,
  13895. // CreateTime = DateTime.Now,
  13896. // IsDel = 0
  13897. // });
  13898. // }
  13899. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  13900. // return Ok("操作成功");
  13901. //}
  13902. //public class paramJsonDto
  13903. //{
  13904. // public List<CountriesInfo> str { get; set; }
  13905. //}
  13906. //[HttpPost]
  13907. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  13908. //{
  13909. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  13910. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  13911. // List<Sys_Cities> cities = new List<Sys_Cities>();
  13912. // List<Sys_Cities> districts = new List<Sys_Cities>();
  13913. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  13914. // _sqlSugar.BeginTran();
  13915. // int countitiesIndex = 0;
  13916. // foreach (var item in dto.str)
  13917. // {
  13918. // dynamic data = item.c;
  13919. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  13920. // if (data != null)
  13921. // {
  13922. // countitiesIndex++;
  13923. // foreach (var item1 in data)
  13924. // {
  13925. // string cnname = item1.cn;
  13926. // string enname = item1.en;
  13927. // Sys_Cities provinceInfo = new Sys_Cities()
  13928. // {
  13929. // CountriesId = countriesId,
  13930. // Name_CN = cnname,
  13931. // Name_EN = enname,
  13932. // ParentId = 0,
  13933. // IsCapital = 1,
  13934. // CreateUserId = 208,
  13935. // CreateTime = DateTime.Now,
  13936. // IsDel = 0
  13937. // };
  13938. // if (item1.lv == "province") //省份
  13939. // {
  13940. // provinceInfo.Level = 1;
  13941. // int provinceId = 0;
  13942. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  13943. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  13944. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  13945. // var data1 = item1.c;
  13946. // foreach (var item2 in data1)
  13947. // {
  13948. // if (item2.lv == "city")
  13949. // {
  13950. // string citycnname = item2.cn;
  13951. // string cityenname = item2.en;
  13952. // Sys_Cities cityInfo = new Sys_Cities()
  13953. // {
  13954. // CountriesId = countriesId,
  13955. // ParentId = provinceId,
  13956. // Level = 2,
  13957. // Name_CN = citycnname,
  13958. // Name_EN = cityenname,
  13959. // IsCapital = 1,
  13960. // CreateUserId = 208,
  13961. // CreateTime = DateTime.Now,
  13962. // IsDel = 0
  13963. // };
  13964. // if (item2.c != null)
  13965. // {
  13966. // int cityId = 0;
  13967. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  13968. // if (citiesInfo != null) cityId = citiesInfo.Id;
  13969. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  13970. // foreach (var item3 in item2.c)
  13971. // {
  13972. // if (item3.lv == "district")
  13973. // {
  13974. // var districtInfo = new Sys_Cities()
  13975. // {
  13976. // CountriesId = countriesId,
  13977. // Name_CN = item3.cn,
  13978. // Name_EN = item3.en,
  13979. // Level = 3,
  13980. // ParentId = cityId,
  13981. // IsCapital = 1,
  13982. // CreateUserId = 208,
  13983. // CreateTime = DateTime.Now,
  13984. // IsDel = 0
  13985. // };
  13986. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  13987. // //{
  13988. // districts.Add(districtInfo);
  13989. // //}
  13990. // }
  13991. // }
  13992. // }
  13993. // else
  13994. // {
  13995. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  13996. // //{
  13997. // cities.Add(cityInfo);
  13998. // //}
  13999. // }
  14000. // }
  14001. // }
  14002. // }
  14003. // else if (item1.lv == "city")//城市
  14004. // {
  14005. // provinceInfo.Level = 2;
  14006. // if (item1.c != null)
  14007. // {
  14008. // int cityId = 0;
  14009. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  14010. // if (citiesInfo != null) cityId = citiesInfo.Id;
  14011. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  14012. // foreach (var item3 in item1.c)
  14013. // {
  14014. // if (item3.lv == "district")
  14015. // {
  14016. // var districtInfo = new Sys_Cities()
  14017. // {
  14018. // CountriesId = countriesId,
  14019. // Name_CN = item3.cn,
  14020. // Name_EN = item3.en,
  14021. // Level = 3,
  14022. // ParentId = cityId,
  14023. // IsCapital = 1,
  14024. // CreateUserId = 208,
  14025. // CreateTime = DateTime.Now,
  14026. // IsDel = 0
  14027. // };
  14028. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  14029. // //{
  14030. // districts.Add(districtInfo);
  14031. // //}
  14032. // }
  14033. // }
  14034. // }
  14035. // else
  14036. // {
  14037. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  14038. // //{
  14039. // cities.Add(provinceInfo);
  14040. // //}
  14041. // }
  14042. // }
  14043. // }
  14044. // }
  14045. // }
  14046. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  14047. // cities = cities.Distinct().ToList();
  14048. // districts = districts.Distinct().ToList();
  14049. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  14050. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  14051. // cities.AddRange(districts);
  14052. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  14053. // //_sqlSugar.RollbackTran();
  14054. // _sqlSugar.CommitTran();
  14055. // return Ok(JsonView(false, "操作成功!"));
  14056. //}
  14057. //[HttpPost]
  14058. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  14059. //{
  14060. // List<CountitiesInfo> infos = dto.MyProperty;
  14061. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  14062. // _sqlSugar.BeginTran();
  14063. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  14064. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  14065. // foreach (var item in infos)
  14066. // {
  14067. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  14068. // if (countryInfo != null)
  14069. // {
  14070. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  14071. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  14072. // if (cityInfo1 != null)
  14073. // {
  14074. // cityInfo1.IsCapital = 0;
  14075. // cityInfos.Add(cityInfo1);
  14076. // }
  14077. // }
  14078. // }
  14079. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  14080. // .UpdateColumns(it => it.IsCapital)
  14081. // .WhereColumns(it => it.Id)
  14082. // .ExecuteCommand();
  14083. // //_sqlSugar.RollbackTran();
  14084. // _sqlSugar.CommitTran();
  14085. // return Ok(JsonView(false, "操作成功!"));
  14086. //}
  14087. //public class CounrtiesDto
  14088. //{
  14089. // public List<CountitiesInfo> MyProperty { get; set; }
  14090. //}
  14091. //public class CountitiesInfo
  14092. //{
  14093. // /// <summary>
  14094. // /// 圣约翰
  14095. // /// </summary>
  14096. // public string capital_name_chinese { get; set; }
  14097. // /// <summary>
  14098. // ///
  14099. // /// </summary>
  14100. // public string capital_name { get; set; }
  14101. // /// <summary>
  14102. // ///
  14103. // /// </summary>
  14104. // public string country_type { get; set; }
  14105. // /// <summary>
  14106. // /// 安提瓜和巴布达
  14107. // /// </summary>
  14108. // public string country_name_chinese { get; set; }
  14109. // /// <summary>
  14110. // /// 安提瓜和巴布达
  14111. // /// </summary>
  14112. // public string country_name_chinese_short { get; set; }
  14113. // /// <summary>
  14114. // /// 安提瓜和巴布达
  14115. // /// </summary>
  14116. // public string country_name_chinese_UN { get; set; }
  14117. // /// <summary>
  14118. // ///
  14119. // /// </summary>
  14120. // public string country_name_english_abbreviation { get; set; }
  14121. // /// <summary>
  14122. // ///
  14123. // /// </summary>
  14124. // public string country_name_english_formal { get; set; }
  14125. // /// <summary>
  14126. // ///
  14127. // /// </summary>
  14128. // public string country_name_english_UN { get; set; }
  14129. // /// <summary>
  14130. // ///
  14131. // /// </summary>
  14132. // public string continent_name { get; set; }
  14133. // /// <summary>
  14134. // ///
  14135. // /// </summary>
  14136. // public string subregion_name { get; set; }
  14137. // /// <summary>
  14138. // ///
  14139. // /// </summary>
  14140. // public string country_code2 { get; set; }
  14141. // /// <summary>
  14142. // ///
  14143. // /// </summary>
  14144. // public string country_code3 { get; set; }
  14145. // /// <summary>
  14146. // ///
  14147. // /// </summary>
  14148. // public string phone_code { get; set; }
  14149. //}
  14150. //public class CountriesInfo : BasicInfo
  14151. //{
  14152. // public List<CitiesInfo> c { get; set; }
  14153. //}
  14154. //public class CitiesInfo : BasicInfo
  14155. //{
  14156. // public List<AreaInfo> c { get; set; }
  14157. //}
  14158. //public class AreaInfo : BasicInfo
  14159. //{
  14160. // public List<AreaInfo> c { get; set; }
  14161. //}
  14162. //public class BasicInfo
  14163. //{
  14164. // public string code { get; set; }
  14165. // public string cn { get; set; }
  14166. // public string lv { get; set; }
  14167. // public string en { get; set; }
  14168. //}
  14169. #endregion
  14170. #region 查看邀请方
  14171. /// <summary>
  14172. /// 查看邀请方
  14173. /// 邀请方信息 Init
  14174. /// </summary>
  14175. /// <param name="dto"></param>
  14176. /// <returns></returns>
  14177. [HttpPost]
  14178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14179. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  14180. {
  14181. string sqlWhere = string.Empty;
  14182. if (!string.IsNullOrEmpty(dto.Search))
  14183. {
  14184. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  14185. }
  14186. string sql = string.Format($@"Select
  14187. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  14188. Id,
  14189. UnitName
  14190. From Res_InvitationOfficialActivityData
  14191. Where IsDel = 0
  14192. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  14193. RefAsync<int> total = 0;
  14194. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14195. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  14196. }
  14197. /// <summary>
  14198. /// 查看邀请方
  14199. /// 国家信息 Init
  14200. /// </summary>
  14201. /// <param name="dto"></param>
  14202. /// <returns></returns>
  14203. [HttpPost]
  14204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14205. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  14206. {
  14207. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  14208. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  14209. var diids = groupInfos.Select(it => it.Id).ToList();
  14210. List<string> countrys = new List<string>();
  14211. foreach (var item in country)
  14212. {
  14213. var data = _groupRepository.FormartTeamName(item);
  14214. var dataArray = _groupRepository.GroupSplitCountry(data);
  14215. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  14216. }
  14217. countrys = countrys.Distinct().ToList();
  14218. for (int i = 0; i < countrys.Count; i++)
  14219. {
  14220. string item = countrys[i];
  14221. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  14222. {
  14223. countrys.Remove(item);
  14224. i--;
  14225. }
  14226. }
  14227. RefAsync<int> total = 0;
  14228. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  14229. .Where(it => countrys.Contains(it.Name_CN))
  14230. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  14231. .Select(it => new { id = it.Id, name = it.Name_CN })
  14232. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14233. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  14234. }
  14235. /// <summary>
  14236. /// 查看邀请方
  14237. /// 城市信息 Init
  14238. /// </summary>
  14239. /// <param name="dto"></param>
  14240. /// <returns></returns>
  14241. [HttpPost]
  14242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14243. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  14244. {
  14245. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  14246. RefAsync<int> total = 0;
  14247. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  14248. .Where(it => it.CountriesId == dto.CountiesId)
  14249. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  14250. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  14251. .Select(it => new { id = it.Id, name = it.Name_CN })
  14252. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14253. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  14254. }
  14255. /// <summary>
  14256. /// 查看邀请方
  14257. /// 团组名称 Init
  14258. /// </summary>
  14259. /// <param name="dto"></param>
  14260. /// <returns></returns>
  14261. [HttpPost]
  14262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14263. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  14264. {
  14265. var watch = new Stopwatch();
  14266. watch.Start();
  14267. RefAsync<int> total = 0;
  14268. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  14269. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  14270. .Where((oa, di) => oa.IsDel == 0)
  14271. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  14272. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  14273. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  14274. .Distinct()
  14275. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14276. watch.Stop();
  14277. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  14278. }
  14279. /// <summary>
  14280. /// 查看邀请方
  14281. /// 团组 & 邀请方信息
  14282. /// </summary>
  14283. /// <param name="dto"></param>
  14284. /// <returns></returns>
  14285. [HttpPost]
  14286. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14287. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  14288. {
  14289. var watch = new Stopwatch();
  14290. watch.Start();
  14291. RefAsync<int> total = 0;
  14292. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  14293. .AS("Grp_DelegationInfo")
  14294. .Includes(x => x.InvitingInfos)
  14295. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  14296. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  14297. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  14298. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  14299. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  14300. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  14301. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  14302. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  14303. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  14304. infos.ForEach(x =>
  14305. {
  14306. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  14307. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  14308. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  14309. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  14310. });
  14311. watch.Stop();
  14312. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  14313. }
  14314. #endregion
  14315. #region 报批行程
  14316. /// <summary>
  14317. /// 报批行程初始化
  14318. /// </summary>
  14319. /// <param name="dto"></param>
  14320. /// <returns></returns>
  14321. [HttpPost]
  14322. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  14323. {
  14324. const int chiNumber = 5;
  14325. var jw = JsonView(false);
  14326. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  14327. var group = groupList.First();
  14328. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  14329. group = groupList.First(x => x.Id == diid);
  14330. if (group == null)
  14331. {
  14332. jw.Msg = "暂无团组!";
  14333. return Ok(jw);
  14334. }
  14335. var data = new
  14336. {
  14337. groupList = groupList.Select(x => new
  14338. {
  14339. x.TeamName,
  14340. x.Id
  14341. }),
  14342. content = new ArrayList(),
  14343. groupInfo = new
  14344. {
  14345. group.VisitDays,
  14346. group.TourCode,
  14347. group.VisitPNumber,
  14348. group.TeamName,
  14349. group.Id,
  14350. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  14351. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  14352. },
  14353. };
  14354. var resultArr = new ArrayList();
  14355. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  14356. if (content.Count == 0)
  14357. {
  14358. var stay = "-";
  14359. var cityPath = "-";
  14360. //添加城市路径以及住宿地
  14361. //黑屏代码数据
  14362. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  14363. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  14364. {
  14365. jw = JsonView(true, "黑屏代码有误!", data);
  14366. return Ok(jw);
  14367. }
  14368. foreach (DataRow row in dtBlack.Rows)
  14369. {
  14370. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14371. {
  14372. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  14373. return Ok(jw);
  14374. }
  14375. }
  14376. //黑屏代码获取时间区间
  14377. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  14378. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  14379. _sqlSugar.BeginTran();
  14380. for (int i = 0; i < timeArr.Count; i++)
  14381. {
  14382. stay = "-";
  14383. cityPath = "-";
  14384. DateTime NewData = DateTime.Parse(timeArr[i]);
  14385. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  14386. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  14387. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  14388. if (tbSelect.Length > 0)
  14389. {
  14390. List<string> threeCodeStr = new List<string>();
  14391. foreach (var item in tbSelect)
  14392. {
  14393. var threeCode = item["Three"].ToString() ?? "";
  14394. if (threeCode.Length == 6)
  14395. {
  14396. var start = threeCode.Substring(0, 3);
  14397. var end = threeCode.Substring(3, 3);
  14398. if (threeCodeStr.Count == 0)
  14399. {
  14400. threeCodeStr.Add(start);
  14401. threeCodeStr.Add(end);
  14402. }
  14403. else
  14404. {
  14405. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  14406. {
  14407. threeCodeStr.Add(end);
  14408. }
  14409. else
  14410. {
  14411. threeCodeStr.Add(start);
  14412. threeCodeStr.Add(end);
  14413. }
  14414. }
  14415. }
  14416. }
  14417. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  14418. var last = threeCodeStr.Last();
  14419. foreach (var item in threeCodeStr)
  14420. {
  14421. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  14422. if (item.Equals(last))
  14423. {
  14424. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  14425. }
  14426. }
  14427. cityPath = cityPath.Trim('-');
  14428. }
  14429. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  14430. appro.Diid = diid ?? -1;
  14431. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  14432. appro.Id = thisId;
  14433. appro.CreateUserId = dto.UserId;
  14434. appro.CreateTime = DateTime.Now;
  14435. content.Add(appro);
  14436. }
  14437. _sqlSugar.CommitTran();
  14438. }
  14439. foreach (var x in content)
  14440. {
  14441. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  14442. if (chiList.Count < chiNumber)
  14443. {
  14444. for (int i = chiList.Count; i < chiNumber; i++)
  14445. {
  14446. chiList.Add(new Grp_ApprovalTravelDetails());
  14447. }
  14448. }
  14449. resultArr.Add(new
  14450. {
  14451. x.Id,
  14452. x.Date,
  14453. x.Diid,
  14454. chiList = chiList.Select(x1 => new
  14455. {
  14456. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  14457. x1.Details,
  14458. x1.ParentId,
  14459. x1.Id
  14460. })
  14461. });
  14462. }
  14463. data = data with
  14464. {
  14465. content = resultArr,
  14466. };
  14467. jw = JsonView(true, "获取成功!", data);
  14468. return Ok(jw);
  14469. }
  14470. /// <summary>
  14471. /// 报批行程删除
  14472. /// </summary>
  14473. /// <param name="dto"></param>
  14474. /// <returns></returns>
  14475. [HttpPost]
  14476. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  14477. {
  14478. var jw = JsonView(false);
  14479. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14480. if (group == null)
  14481. {
  14482. jw.Msg = "团组参数有误!";
  14483. return Ok(jw);
  14484. }
  14485. try
  14486. {
  14487. _sqlSugar.BeginTran();
  14488. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  14489. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  14490. {
  14491. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14492. DeleteUserId = dto.uesrId,
  14493. IsDel = 1
  14494. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  14495. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  14496. {
  14497. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14498. DeleteUserId = dto.uesrId,
  14499. IsDel = 1
  14500. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  14501. _sqlSugar.CommitTran();
  14502. jw = JsonView(true, "删除成功");
  14503. }
  14504. catch (Exception ex)
  14505. {
  14506. jw = JsonView(false, ex.Message);
  14507. }
  14508. return Ok(jw);
  14509. }
  14510. /// <summary>
  14511. /// 报批行程保存
  14512. /// </summary>
  14513. /// <param name="dto"></param>
  14514. /// <returns></returns>
  14515. [HttpPost]
  14516. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  14517. {
  14518. var jw = JsonView(false);
  14519. var Find = dto.Arr.Find(x => x.id == 0);
  14520. if (Find != null)
  14521. {
  14522. jw.Msg = "生成的ID为0!";
  14523. return Ok(jw);
  14524. }
  14525. foreach (var item in dto.Arr)
  14526. {
  14527. foreach (var chi in item.chiList)
  14528. {
  14529. if (chi.parentId == 0)
  14530. {
  14531. chi.parentId = item.id;
  14532. }
  14533. }
  14534. }
  14535. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  14536. _sqlSugar.BeginTran();
  14537. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  14538. {
  14539. var parentIds = dto.Arr.Select(x => x.id).ToList();
  14540. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  14541. {
  14542. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  14543. DeleteUserId = dto.UserId,
  14544. IsDel = 1
  14545. }).ExecuteCommand();
  14546. }
  14547. try
  14548. {
  14549. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  14550. {
  14551. CreateTime = DateTime.Now,
  14552. CreateUserId = dto.UserId,
  14553. Details = x.details,
  14554. ParentId = x.parentId,
  14555. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  14556. Remark = "",
  14557. IsDel = 0
  14558. }).ToList()).ExecuteCommand();
  14559. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  14560. {
  14561. Id = x.id,
  14562. Details = x.details,
  14563. ParentId = x.parentId,
  14564. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  14565. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  14566. {
  14567. Details = x.Details,
  14568. ParentId = x.ParentId,
  14569. Time = x.Time
  14570. }).ExecuteCommand();
  14571. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  14572. {
  14573. Id = x.id,
  14574. Date = x.date,
  14575. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  14576. {
  14577. Date = x.Date
  14578. }).ExecuteCommand();
  14579. _sqlSugar.CommitTran();
  14580. jw = JsonView(true, "保存成功!");
  14581. }
  14582. catch (Exception ex)
  14583. {
  14584. _sqlSugar.RollbackTran();
  14585. jw = JsonView(false, "保存失败!" + ex.Message);
  14586. }
  14587. return Ok(jw);
  14588. }
  14589. /// <summary>
  14590. /// 报批行程生成
  14591. /// </summary>
  14592. /// <param name="dto"></param>
  14593. /// <returns></returns>
  14594. [HttpPost]
  14595. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  14596. {
  14597. var jw = JsonView(false);
  14598. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14599. if (group == null)
  14600. {
  14601. jw.Msg = "暂无该团组!";
  14602. return Ok(jw);
  14603. }
  14604. //黑屏代码数据
  14605. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  14606. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  14607. {
  14608. jw.Msg = "黑屏代码有误!";
  14609. return Ok(jw);
  14610. }
  14611. foreach (DataRow row in dtBlack.Rows)
  14612. {
  14613. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  14614. {
  14615. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  14616. return Ok(jw);
  14617. }
  14618. }
  14619. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  14620. var resultArr = new ArrayList();
  14621. if (officialActivitiesArr.Count == 0)
  14622. {
  14623. jw.Msg = "暂无公务出访信息!";
  14624. return Ok(jw);
  14625. }
  14626. try
  14627. {
  14628. _sqlSugar.BeginTran();
  14629. DeleteApprovalJourney(new
  14630. Domain.Dtos.Groups.DeleteApprovalJourney
  14631. {
  14632. Diid = dto.Diid,
  14633. uesrId = dto.Userid
  14634. });
  14635. var stay = "-";
  14636. var cityPath = "-";
  14637. //添加城市路径以及住宿地
  14638. //黑屏代码获取时间区间
  14639. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  14640. var empty = "【未收入该三字码!请机票同事录入】";
  14641. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  14642. for (int i = 0; i < timeArr.Count; i++)
  14643. {
  14644. stay = "-";
  14645. cityPath = "-";
  14646. var chiarr = new List<Grp_ApprovalTravelDetails>();
  14647. DateTime NewData = DateTime.Parse(timeArr[i]);
  14648. 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();
  14649. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  14650. if (tbSelect.Length > 0)
  14651. {
  14652. List<string> threeCodeStr = new List<string>();
  14653. bool isTrade = false;
  14654. string trip = string.Empty;
  14655. var rowLast = tbSelect.Last();
  14656. var rowFirst = tbSelect.First();
  14657. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  14658. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  14659. var takeOffTime = DateTime.Parse(timeArr[i]);
  14660. var fallToTime = DateTime.Parse(timeArr[i]);
  14661. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  14662. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  14663. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  14664. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  14665. foreach (var item in tbSelect)
  14666. {
  14667. var start = string.Empty;
  14668. var end = string.Empty;
  14669. var threeCode = item["Three"].ToString() ?? "";
  14670. if (threeCode.Length == 6)
  14671. {
  14672. start = threeCode.Substring(0, 3);
  14673. end = threeCode.Substring(3, 3);
  14674. if (threeCodeStr.Count == 0)
  14675. {
  14676. threeCodeStr.Add(start);
  14677. threeCodeStr.Add(end);
  14678. }
  14679. else
  14680. {
  14681. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  14682. {
  14683. threeCodeStr.Add(end);
  14684. }
  14685. else
  14686. {
  14687. threeCodeStr.Add(start);
  14688. threeCodeStr.Add(end);
  14689. }
  14690. }
  14691. }
  14692. //处理机票信息
  14693. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  14694. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  14695. if (start_Object == null)
  14696. {
  14697. start_Object = new Res_ThreeCode()
  14698. {
  14699. AirPort = empty,
  14700. AirPort_En = empty,
  14701. City = empty,
  14702. Country = empty,
  14703. Four = empty,
  14704. Three = empty,
  14705. };
  14706. }
  14707. if (end_Object == null)
  14708. {
  14709. end_Object = new Res_ThreeCode()
  14710. {
  14711. AirPort = empty,
  14712. AirPort_En = empty,
  14713. City = empty,
  14714. Country = empty,
  14715. Four = empty,
  14716. Three = empty,
  14717. };
  14718. }
  14719. //机型判断
  14720. string airModel = item["AirModel"].ToString();
  14721. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  14722. string flightTime = item["FlightTime"].ToString();
  14723. if (flightTime!.Contains(":"))
  14724. {
  14725. flightTime = flightTime.Replace(":", "小时");
  14726. flightTime += "分钟";
  14727. }
  14728. if (flightTime.Contains("H"))
  14729. {
  14730. flightTime = flightTime.Replace("H", "小时");
  14731. }
  14732. if (flightTime.Contains("M"))
  14733. {
  14734. flightTime = flightTime.Replace("M", "分钟");
  14735. }
  14736. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  14737. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  14738. {
  14739. flightTime = flightDataTime.Hour > 0
  14740. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  14741. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  14742. ? flightDataTime.Minute.ToString() + "分钟" : "";
  14743. }
  14744. //航班号
  14745. string flightcode = item["Fliagtcode"].ToString();
  14746. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  14747. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  14748. if (aircompany == null)
  14749. {
  14750. aircompany = new Res_AirCompany
  14751. {
  14752. CnName = hsEmpty,
  14753. EnName = hsEmpty,
  14754. ShortCode = hsEmpty,
  14755. };
  14756. }
  14757. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  14758. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  14759. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  14760. if (isTrade)
  14761. {
  14762. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  14763. }
  14764. else
  14765. {
  14766. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  14767. }
  14768. }
  14769. chiarr.Add(new Grp_ApprovalTravelDetails
  14770. {
  14771. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  14772. CreateTime = DateTime.Now,
  14773. CreateUserId = dto.Userid,
  14774. ParentId = 0,
  14775. Details = trip
  14776. });
  14777. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  14778. var last = threeCodeStr.Last();
  14779. foreach (var item in threeCodeStr)
  14780. {
  14781. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  14782. if (item.Equals(last))
  14783. {
  14784. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  14785. }
  14786. }
  14787. cityPath = cityPath.Trim('-');
  14788. }
  14789. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  14790. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  14791. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  14792. appro.Diid = dto.Diid;
  14793. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  14794. appro.Id = thisId;
  14795. appro.CreateUserId = dto.Userid;
  14796. appro.CreateTime = DateTime.Now;
  14797. foreach (var item in gwinfo)
  14798. {
  14799. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  14800. chi.Details = "拜访" + item.Client;
  14801. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  14802. {
  14803. chi.Details += "," + item.ReqSample;
  14804. }
  14805. chi.ParentId = thisId;
  14806. chi.Time = item.Time;
  14807. chiarr.Add(chi);
  14808. }
  14809. if (chiarr.Count < 5)
  14810. {
  14811. for (int j = chiarr.Count; j < 5; j++)
  14812. {
  14813. chiarr.Add(new
  14814. Grp_ApprovalTravelDetails());
  14815. }
  14816. }
  14817. resultArr.Add(new
  14818. {
  14819. appro.Id,
  14820. appro.Date,
  14821. appro.Diid,
  14822. chiList = chiarr.Select(x1 => new
  14823. {
  14824. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  14825. x1.Details,
  14826. x1.ParentId,
  14827. x1.Id
  14828. })
  14829. });
  14830. }
  14831. _sqlSugar.CommitTran();
  14832. jw = JsonView(true, "生成成功!", resultArr);
  14833. }
  14834. catch (Exception ex)
  14835. {
  14836. jw.Code = 400;
  14837. jw.Msg = "生成失败!" + ex.Message;
  14838. }
  14839. return Ok(jw);
  14840. }
  14841. /// <summary>
  14842. /// 报批行程word导出
  14843. /// </summary>
  14844. /// <param name="dto"></param>
  14845. /// <returns></returns>
  14846. [HttpPost]
  14847. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  14848. {
  14849. var jw = JsonView(false);
  14850. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14851. if (group == null)
  14852. {
  14853. jw.Msg = "暂无该团组!";
  14854. return Ok(jw);
  14855. }
  14856. //模板路径
  14857. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  14858. //载入模板
  14859. Document doc = new Document(tempPath);
  14860. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14861. //获取所填表格的序数
  14862. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  14863. Aspose.Words.Tables.Row titleRowClone = null;
  14864. Aspose.Words.Tables.Row CenterRowClone = null;
  14865. int index = 0;
  14866. int indexChi = 0;
  14867. int SetIndex = 0;
  14868. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  14869. //获取数据,放到datatable
  14870. foreach (var item in ApprovalTravelArr)
  14871. {
  14872. if (index > 0)
  14873. {
  14874. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  14875. tableOne.AppendChild(titleRowClone);
  14876. }
  14877. var textTime = item.Date;
  14878. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  14879. SetCells(tableOne, doc, SetIndex, 0, textTime);
  14880. SetIndex++;
  14881. if (ChiRep.Count > 0)
  14882. {
  14883. foreach (var itemChi in ChiRep)
  14884. {
  14885. var txtTime = itemChi.Time;
  14886. var txtDetail = itemChi.Details;
  14887. if (indexChi > 0)
  14888. {
  14889. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  14890. tableOne.AppendChild(CenterRowClone);
  14891. }
  14892. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  14893. {
  14894. SetCells(tableOne, doc, SetIndex, 0, "");
  14895. SetCells(tableOne, doc, SetIndex, 1, "");
  14896. indexChi++;
  14897. SetIndex++;
  14898. break;
  14899. }
  14900. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  14901. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  14902. indexChi++;
  14903. SetIndex++;
  14904. }
  14905. }
  14906. else
  14907. {
  14908. if (indexChi > 0)
  14909. {
  14910. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  14911. tableOne.AppendChild(CenterRowClone);
  14912. }
  14913. SetCells(tableOne, doc, SetIndex, 0, "");
  14914. SetCells(tableOne, doc, SetIndex, 1, "");
  14915. indexChi++;
  14916. SetIndex++;
  14917. }
  14918. index++;
  14919. }
  14920. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  14921. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  14922. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  14923. jw.Code = 200;
  14924. jw.Msg = "";
  14925. return Ok(jw);
  14926. }
  14927. private string intToString(int numberVal)
  14928. {
  14929. string numberval = numberVal.ToString();
  14930. Dictionary<char, string> Number = new Dictionary<char, string>();
  14931. Number.Add('1', "一");
  14932. Number.Add('2', "二");
  14933. Number.Add('3', "三");
  14934. Number.Add('4', "四");
  14935. Number.Add('5', "五");
  14936. Number.Add('6', "六");
  14937. Number.Add('7', "七");
  14938. Number.Add('8', "八");
  14939. Number.Add('9', "九");
  14940. string stringNumberVal = string.Empty;
  14941. for (int i = 0; i < numberval.Length; i++)
  14942. {
  14943. if (i == 0)
  14944. {
  14945. stringNumberVal += Number[numberval[i]];
  14946. }
  14947. else if (i >= 1)
  14948. {
  14949. if (numberval[i] == '0')
  14950. {
  14951. stringNumberVal = "十";
  14952. }
  14953. else
  14954. {
  14955. stringNumberVal += "十" + Number[numberval[i]];
  14956. }
  14957. }
  14958. }
  14959. return stringNumberVal;
  14960. }
  14961. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  14962. {
  14963. //获取table中的某个单元格,从0开始
  14964. Cell lshCell = table.Rows[rows].Cells[cells];
  14965. //将单元格中段落移除
  14966. foreach (Node item in lshCell.Paragraphs)
  14967. {
  14968. lshCell.Paragraphs.Remove(item);
  14969. }
  14970. if (val.Contains("\r\n"))
  14971. {
  14972. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  14973. foreach (var item in spArr)
  14974. {
  14975. //新建一个段落
  14976. Paragraph p = new Paragraph(doc);
  14977. var r = new Run(doc, item);
  14978. //把设置的值赋给之前新建的段落
  14979. p.AppendChild(r);
  14980. //将此段落加到单元格内
  14981. lshCell.AppendChild(p);
  14982. }
  14983. }
  14984. else
  14985. {
  14986. //新建一个段落
  14987. Paragraph p = new Paragraph(doc);
  14988. var r = new Run(doc, val);
  14989. //把设置的值赋给之前新建的段落
  14990. p.AppendChild(r);
  14991. //将此段落加到单元格内
  14992. lshCell.AppendChild(p);
  14993. }
  14994. }
  14995. [HttpPost]
  14996. public async Task<IActionResult> ServerHttp(string paramStr)
  14997. {
  14998. paramStr = paramStr.TrimEnd('\'');
  14999. paramStr = paramStr.TrimStart('\'');
  15000. JsonView jw = JsonView(false);
  15001. JObject param = JObject.Parse(paramStr);
  15002. if (!param.ContainsKey("url"))
  15003. {
  15004. jw.Msg = "url null";
  15005. return Ok(jw);
  15006. }
  15007. string url = param["url"]!.ToString();
  15008. var methon = "get";
  15009. Dictionary<string, string> headValues = null;
  15010. string bodyStr = string.Empty;
  15011. if (param.ContainsKey("methon"))
  15012. {
  15013. methon = param["methon"]!.ToString().ToLower();
  15014. }
  15015. if (param.ContainsKey("header"))
  15016. {
  15017. var header = param["header"]!.ToString();
  15018. JObject headerJobject = JObject.Parse(header);
  15019. headValues = new Dictionary<string, string>();
  15020. foreach (JProperty item in headerJobject.Properties())
  15021. {
  15022. var value = item.Value.ToString();
  15023. var head = item.Path;
  15024. headValues.Add(head, value);
  15025. }
  15026. }
  15027. HttpClient client = new HttpClient();
  15028. string responseString = string.Empty;
  15029. StringContent content = null;
  15030. if (headValues != null)
  15031. {
  15032. foreach (var item in headValues.Keys)
  15033. {
  15034. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  15035. {
  15036. if (param.ContainsKey("body"))
  15037. {
  15038. bodyStr = param["body"]!.ToString();
  15039. }
  15040. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  15041. }
  15042. else
  15043. {
  15044. client.DefaultRequestHeaders.Add(item, headValues[item]);
  15045. }
  15046. }
  15047. }
  15048. try
  15049. {
  15050. if (methon == "get")
  15051. {
  15052. responseString = await client.GetStringAsync(url);
  15053. }
  15054. else if (methon == "post")
  15055. {
  15056. var request = new HttpRequestMessage(HttpMethod.Post, url)
  15057. {
  15058. Content = content
  15059. };
  15060. var response = await client.SendAsync(request);
  15061. try
  15062. {
  15063. Stream responseStream = await response.Content.ReadAsStreamAsync();
  15064. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  15065. {
  15066. using (StreamReader reader = new StreamReader(gzipStream))
  15067. {
  15068. responseString = await reader.ReadToEndAsync();
  15069. }
  15070. }
  15071. }
  15072. catch (Exception)
  15073. {
  15074. responseString = await response.Content.ReadAsStringAsync();
  15075. }
  15076. }
  15077. else
  15078. {
  15079. responseString = "methon error";
  15080. }
  15081. jw = JsonView(true, "success", responseString);
  15082. }
  15083. catch (Exception ex)
  15084. {
  15085. jw.Msg = "error " + ex.Message;
  15086. jw.Data = ex.StackTrace;
  15087. }
  15088. finally
  15089. {
  15090. client.Dispose();
  15091. }
  15092. return Ok(jw);
  15093. }
  15094. #endregion
  15095. #region 团组接待意见调查
  15096. /// <summary>
  15097. /// 团组接待意见调查 - 信息管理
  15098. /// 基础数据(团组)
  15099. /// </summary>
  15100. /// <param name="dto"></param>
  15101. /// <returns></returns>
  15102. [HttpGet]
  15103. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15104. public async Task<IActionResult> OpinionaireInit()
  15105. {
  15106. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  15107. .Select(x => new
  15108. {
  15109. x.Id,
  15110. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  15111. })
  15112. .OrderByDescending(x => x.Id)
  15113. .ToListAsync();
  15114. return Ok(JsonView(groupData, groupData.Count));
  15115. }
  15116. /// <summary>
  15117. /// 团组接待意见调查 - 信息管理
  15118. /// 列表
  15119. /// </summary>
  15120. /// <param name="groupId"></param>
  15121. /// <returns></returns>
  15122. [HttpGet("{groupId}")]
  15123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15124. public async Task<IActionResult> OpinionaireManageList(int groupId)
  15125. {
  15126. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15127. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  15128. .Select(x => new
  15129. {
  15130. x.Id,
  15131. x.TourGuideName,
  15132. x.CityName,
  15133. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  15134. x.CreateTime
  15135. })
  15136. .OrderBy(x => x.Id)
  15137. .ToListAsync();
  15138. return Ok(JsonView(data));
  15139. }
  15140. /// <summary>
  15141. /// 团组接待意见调查 - 信息管理
  15142. /// 保存
  15143. /// </summary>
  15144. /// <param name="dto"></param>
  15145. /// <returns></returns>
  15146. [HttpPost]
  15147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15148. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  15149. {
  15150. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  15151. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  15152. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15153. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  15154. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  15155. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  15156. _opinionaireRep.BeginTran();
  15157. if (addData != null && addData.Count > 0)
  15158. {
  15159. foreach (var item in addData)
  15160. {
  15161. item.CreateUserId = currUserInfo.UserId;
  15162. item.DiId = dto.DiId;
  15163. }
  15164. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  15165. }
  15166. if (updData != null && updData.Count > 0)
  15167. {
  15168. var upd = await _opinionaireRep._sqlSugar
  15169. .Updateable(updData)
  15170. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  15171. .WhereColumns(x => new { x.Id })
  15172. .ExecuteCommandAsync();
  15173. }
  15174. _opinionaireRep.CommitTran();
  15175. return Ok(JsonView("操作成功!"));
  15176. }
  15177. /// <summary>
  15178. /// 团组接待意见调查 - 信息管理
  15179. /// 删除
  15180. /// </summary>
  15181. /// <param name="id"></param>
  15182. /// <returns></returns>
  15183. [HttpDelete("{id}")]
  15184. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15185. public async Task<IActionResult> OpinionaireManageDel(int id)
  15186. {
  15187. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  15188. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  15189. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  15190. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  15191. if (!del) return Ok(JsonView("操作失败!"));
  15192. return Ok(JsonView("操作成功!"));
  15193. }
  15194. /// <summary>
  15195. /// 团组接待意见调查 - 用户
  15196. /// 列表
  15197. /// </summary>
  15198. /// <param name="id"></param>
  15199. /// <returns></returns>
  15200. [HttpGet("{diId}")]
  15201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15202. public async Task<IActionResult> OpinionaireUserList(int diId)
  15203. {
  15204. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  15205. var sql = string.Format(@"
  15206. SELECT
  15207. o.Id,
  15208. o.DiId,
  15209. di.TeamName AS 'GroupName',
  15210. di.VisitPNumber AS 'PeopleNumber',
  15211. di.ClientName AS 'LeadGroup',
  15212. di.VisitCountry AS 'Travel',
  15213. di.VisitDays AS 'Days',
  15214. o.CityName,
  15215. o.TourGuideName,
  15216. o.Catering,
  15217. o.CateringReason,
  15218. o.Stay,
  15219. o.StayReason,
  15220. o.[Route],
  15221. o.RouteReason,
  15222. o.OfficialActivity,
  15223. o.OfficialActivityReason,
  15224. o.TourGuide,
  15225. o.TourGuideReason,
  15226. o.[Translate],
  15227. o.TranslateReason,
  15228. o.Trip,
  15229. o.TripReason,
  15230. o.ESFileName,
  15231. o.SignatureDate,
  15232. o.Remark
  15233. FROM
  15234. Grp_Opinionaire o
  15235. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  15236. WHERE
  15237. o.IsDel = 0
  15238. AND o.DiId = {0}
  15239. ORDER BY
  15240. o.Id ASC", diId);
  15241. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  15242. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  15243. return Ok(JsonView(data));
  15244. }
  15245. /// <summary>
  15246. /// 团组接待意见调查 - 用户
  15247. /// 保存
  15248. /// </summary>
  15249. /// <param name="id"></param>
  15250. /// <returns></returns>
  15251. [HttpPost]
  15252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15253. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  15254. {
  15255. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  15256. foreach (var item in dto)
  15257. {
  15258. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  15259. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  15260. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  15261. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  15262. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  15263. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  15264. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  15265. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  15266. }
  15267. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  15268. if (!Directory.Exists(filePathBase))
  15269. {
  15270. Directory.CreateDirectory(filePathBase);
  15271. }
  15272. #region 上传文件
  15273. var filePaths = new List<string>();
  15274. foreach (var item in dto)
  15275. {
  15276. var file = item.File;
  15277. // 将文件保存到指定位置
  15278. var filePath = Path.Combine(filePathBase, file.FileName);
  15279. using (var stream = new FileStream(filePath, FileMode.Create))
  15280. {
  15281. await file.CopyToAsync(stream);
  15282. }
  15283. //验证文件是否上传成功
  15284. if (!System.IO.File.Exists(filePath))
  15285. {
  15286. foreach (var filePathStr in filePaths)
  15287. {
  15288. System.IO.File.Delete(filePathStr);
  15289. }
  15290. return Ok(JsonView(false, "文件上传失败!"));
  15291. }
  15292. item.ESFileName = file.FileName;
  15293. }
  15294. #endregion
  15295. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  15296. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  15297. .UpdateColumns(x => new
  15298. {
  15299. x.Catering,
  15300. x.CateringReason,
  15301. x.Stay,
  15302. x.StayReason,
  15303. x.Route,
  15304. x.RouteReason,
  15305. x.OfficialActivity,
  15306. x.OfficialActivityReason,
  15307. x.TourGuide,
  15308. x.TourGuideReason,
  15309. x.Translate,
  15310. x.TranslateReason,
  15311. x.Trip,
  15312. x.TripReason,
  15313. x.ESFileName,
  15314. x.SignatureDate,
  15315. x.Remark
  15316. })
  15317. .WhereColumns(x => new { x.Id })
  15318. .ExecuteCommandAsync();
  15319. if (upd < 1)
  15320. {
  15321. foreach (var filePathStr in filePaths)
  15322. {
  15323. System.IO.File.Delete(filePathStr);
  15324. }
  15325. return Ok(JsonView(false));
  15326. }
  15327. return Ok(JsonView(true));
  15328. }
  15329. #endregion
  15330. // /// <summary>
  15331. // ///
  15332. // /// </summary>
  15333. // /// <param name="_dto"></param>
  15334. // /// <returns></returns>
  15335. // [HttpPost]
  15336. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15337. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  15338. // {
  15339. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  15340. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  15341. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  15342. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  15343. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  15344. // dic_psg.Add("客人", 974);
  15345. // dic_psg.Add("司机", 975);
  15346. // dic_psg.Add("导游", 976);
  15347. // dic_psg.Add("公司内部人员", 977);
  15348. // dic_psg.Add("司机/导游/公司内部人员", 978);
  15349. // foreach (var item in list_visa)
  15350. // {
  15351. // Grp_VisaInfo temp = new Grp_VisaInfo();
  15352. // temp.Id = item.Id;
  15353. // temp.DIId = item.DIId;
  15354. // temp.VisaClient = item.VisaClient;
  15355. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  15356. // temp.VisaCurrency = item.VisaCurrency;
  15357. // temp.IsThird = item.IsThird;
  15358. // if (dic_psg.ContainsKey(item.PassengerType))
  15359. // {
  15360. // temp.PassengerType = dic_psg[item.PassengerType];
  15361. // }
  15362. // else {
  15363. // temp.PassengerType = -1;
  15364. // }
  15365. // temp.VisaNumber = item.VisaNumber;
  15366. // temp.VisaFreeNumber = item.VisaFreeNumber;
  15367. // temp.CreateUserId = item.Operators;
  15368. // DateTime dt_ct;
  15369. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  15370. // if (b_ct)
  15371. // {
  15372. // temp.CreateTime = dt_ct;
  15373. // }
  15374. // else
  15375. // {
  15376. // temp.CreateTime = DateTime.Now;
  15377. // }
  15378. // temp.DeleteTime = "";
  15379. // temp.DeleteUserId = 0;
  15380. // temp.Remark = item.Remark;
  15381. // if (string.IsNullOrEmpty(temp.Remark)) {
  15382. // temp.Remark = "";
  15383. // }
  15384. // temp.IsDel = item.IsDel;
  15385. // temp.VisaDescription = item.VisaAttachment;
  15386. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  15387. //([Id]
  15388. // ,[DIId]
  15389. // ,[VisaClient]
  15390. // ,[VisaPrice]
  15391. // ,[VisaCurrency]
  15392. // ,[IsThird]
  15393. // ,[PassengerType]
  15394. // ,[VisaNumber]
  15395. // ,[VisaFreeNumber]
  15396. // ,[CreateUserId]
  15397. // ,[CreateTime]
  15398. // ,[DeleteTime]
  15399. // ,[DeleteUserId]
  15400. // ,[Remark]
  15401. // ,[IsDel]
  15402. // ,[visaDescription])
  15403. // VALUES
  15404. // ({0},{1},'{2}',{3},{4}
  15405. //,{5},{6},{7},{8},{9}
  15406. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  15407. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  15408. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  15409. //);
  15410. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  15411. // }
  15412. // return Ok(JsonView(true, "操作成功!"));
  15413. // }
  15414. /// <summary>
  15415. /// 123132123
  15416. /// </summary>
  15417. /// <param name="_dto"></param>
  15418. /// <returns></returns>
  15419. [HttpPost]
  15420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15421. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  15422. {
  15423. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  15424. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  15425. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  15426. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  15427. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  15428. dicDetail.Add(789, 1034);
  15429. dicDetail.Add(790, 1035);
  15430. dicDetail.Add(791, 1036);
  15431. dicDetail.Add(792, 1037);
  15432. dicDetail.Add(793, 1038);
  15433. dicDetail.Add(794, 1039);
  15434. dicDetail.Add(795, 1040);
  15435. dicDetail.Add(796, 1041);
  15436. dicDetail.Add(797, 1042);
  15437. dicDetail.Add(798, 1043);
  15438. dicDetail.Add(801, 1044);
  15439. dicDetail.Add(802, 1045);
  15440. dicDetail.Add(803, 1046);
  15441. Dictionary<int, int> dic = new Dictionary<int, int>();
  15442. dic.Add(806, 1027);
  15443. dic.Add(807, 1028);
  15444. dic.Add(808, 1029);
  15445. dic.Add(809, 1030);
  15446. dic.Add(810, 1031);
  15447. dic.Add(811, 1032);
  15448. dic.Add(812, 1033);
  15449. foreach (var item in list_visa)
  15450. {
  15451. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  15452. temp.Coefficient = item.coefficient;
  15453. DateTime dtCrt;
  15454. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  15455. if (b1)
  15456. {
  15457. temp.CreateTime = dtCrt;
  15458. }
  15459. else
  15460. {
  15461. temp.CreateTime = DateTime.Now;
  15462. }
  15463. temp.CreateUserId = item.Operators;
  15464. temp.DeleteTime = "";
  15465. temp.DeleteUserId = 0;
  15466. temp.DiId = int.Parse(item.DIID);
  15467. temp.FilePath = item.FilePath;
  15468. temp.IsDel = item.IsDel;
  15469. temp.Price = item.Price;
  15470. temp.PriceCount = 1;
  15471. temp.PriceCurrency = item.Currency;
  15472. int detailId = 0;
  15473. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  15474. {
  15475. detailId = dicDetail[item.PriceTypeDetail];
  15476. }
  15477. temp.PriceDetailType = detailId;
  15478. temp.PriceDt = DateTime.Now;
  15479. temp.PriceName = item.PriceName;
  15480. temp.PriceSum = item.Price;
  15481. int tid = 0;
  15482. if (dic.ContainsKey(item.PriceType))
  15483. {
  15484. tid = dic[item.PriceType];
  15485. }
  15486. temp.PriceType = tid;
  15487. temp.Remark = item.Remark;
  15488. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  15489. }
  15490. return Ok(JsonView(true, "操作成功!"));
  15491. }
  15492. [HttpPost]
  15493. public IActionResult TimeTest()
  15494. {
  15495. var jw = JsonView(false, "error");
  15496. _sqlSugar.BeginTran();
  15497. try
  15498. {
  15499. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  15500. .Select(x => new Crm_NewClientData
  15501. {
  15502. Id = x.Id,
  15503. Client = x.Client,
  15504. Contact = x.Contact,
  15505. Location = x.Location,
  15506. })
  15507. .ToList();
  15508. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x=>x.Id).ToList();
  15509. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  15510. Stopwatch stopwatch = new Stopwatch();
  15511. // 开始计时
  15512. stopwatch.Start();
  15513. foreach (var item in clientList)
  15514. {
  15515. EncryptionProcessor.DecryptProperties(item);
  15516. }
  15517. stopwatch.Stop();
  15518. jw.Code = 200;
  15519. jw.Data = stopwatch.ElapsedMilliseconds;
  15520. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  15521. }
  15522. catch (Exception ex)
  15523. {
  15524. jw.Code = 400;
  15525. jw.Msg = ex.Message;
  15526. }
  15527. return Ok(jw);
  15528. }
  15529. }
  15530. }